nix/config/fish/config.fish
2025-12-02 23:00:51 -06:00

86 lines
2.5 KiB
Fish

set fish_greeting
# Bootstrap Fisher (reads plugins from fish_plugins)
if not functions -q fisher
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source
fisher update
end
function sesh-sessions
set -l session (sesh list -t -c | fzf --height 40% --reverse --border-label ' sesh ' --border --prompt '⚡ ')
commandline -f repaint
if test -z "$session"
return
end
sesh connect $session
end
function sesh-list
set -l session (sesh list --icons | fzf \
--height 40% \
--reverse \
--border-label ' sesh ' \
--border \
--no-sort --ansi --border-label ' sesh ' --prompt '⚡ ' \
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
--bind 'tab:down,btab:up' \
--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list --icons)' \
--bind 'ctrl-t:change-prompt(🪟 )+reload(sesh list -t --icons)' \
--bind 'ctrl-g:change-prompt(⚙️ )+reload(sesh list -c --icons)' \
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z --icons)' \
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \
--preview-window 'right:55%' \
--preview 'sesh preview {}' \
--prompt '⚡ ')
commandline -f repaint
if test -z "$session"
return
end
sesh connect $session
end
function y
set tmp (mktemp -t "yazi-cwd.XXXXXX")
yazi $argv --cwd-file="$tmp"
if read -z cwd <"$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
builtin cd -- "$cwd"
end
rm -f -- "$tmp"
end
###############
# Keybindings #
###############
# emacs + vim
set -g fish_key_bindings fish_hybrid_key_bindings
bind -M default \cx\ce edit_command_buffer
bind -M insert \cx\ce edit_command_buffer
bind -M visual \cx\ce edit_command_buffer
bind -M default \cp up-or-search
bind -M insert \cp up-or-search
bind -M visual \cp up-or-search
bind -M default \cn down-or-search
bind -M insert \cn down-or-search
bind -M visual \cn down-or-search
## Sesh keybindings: keybinding: C-\
if functions -q fish_vi_key_bindings
bind -M default \x1c sesh-list
bind -M insert \x1c sesh-list
else
bind \x1c sesh-list
end
# Keybinding: C-]
if functions -q fish_vi_key_bindings
bind -M default \c] sesh-sessions
bind -M insert \c] sesh-sessions
else
bind \c] sesh-sessions
end
alias vim nvim