tmux-dev-env-configuration/dotfiles/.config/fish/conf.d/fzf.fish

107 lines
3.2 KiB
Fish

# From https://github.com/patrickf3139/fzf.fish/blob/main/conf.d/fzf.fish
# Set up the default, mnemonic key bindings unless the user has chosen to customize them
if not set --query fzf_fish_custom_keybindings
# \cf is Ctrl+f
bind \cj '__fzf_search_current_dir'
#bind \cr '__fzf_search_history'
bind \cv '__fzf_search_shell_variables'
# The following two key binding use Alt as an additional modifier key to avoid conflicts
bind \e\cl '__fzf_search_git_log'
bind \e\cs '__fzf_search_git_status'
# set up the same key bindings for insert mode if using fish_vi_key_bindings
if [ "$fish_key_bindings" = 'fish_vi_key_bindings' ]
bind --mode insert \cf '__fzf_search_current_dir'
bind --mode insert \cr '__fzf_search_history'
bind --mode insert \cv '__fzf_search_shell_variables'
bind --mode insert \e\cl '__fzf_search_git_log'
bind --mode insert \e\cs '__fzf_search_git_status'
end
end
# If FZF_DEFAULT_OPTS is not set, then set some sane defaults. This also affects fzf outside of this plugin.
# See https://github.com/junegunn/fzf#environment-variables
if not set --query FZF_DEFAULT_OPTS
# cycle makes scrolling easier
# reverse layout is more familiar as it mimicks the layout of git log, history, and env
# border makes clear where the fzf window ends
# height 75% allows you to view what you were doing and stay in context of your work
# preview-window wrap wraps long lines in the preview window
set --export FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height 75% --preview-window=wrap'
end
# Forgit configuration
set FORGIT_FZF_DEFAULT_OPTS "
$FZF_DEFAULT_OPTS
--ansi
--height='80%'
--bind='alt-k:preview-up,alt-p:preview-up'
--bind='alt-j:preview-down,alt-n:preview-down'
--bind='ctrl-r:toggle-all'
--bind='ctrl-s:toggle-sort'
--bind='?:toggle-preview'
--bind='alt-w:toggle-preview-wrap'
--preview-window='right:60%'
+1
$FORGIT_FZF_DEFAULT_OPTS
"
# register aliases
if test -z "$FORGIT_NO_ALIASES"
if test -n "$forgit_add"
alias $forgit_add 'forgit::add'
else
alias ga 'forgit::add'
end
if test -n "$forgit_reset_head"
alias $forgit_reset_head 'forgit::reset::head'
else
alias grh 'forgit::reset::head'
end
if test -n "$forgit_log"
alias $forgit_log 'forgit::log'
else
alias glo 'forgit::log'
end
if test -n "$forgit_diff"
alias $forgit_diff 'forgit::diff'
else
alias gd 'forgit::diff'
end
if test -n "$forgit_ignore"
alias $forgit_ignore 'forgit::ignore'
else
alias gi 'forgit::ignore'
end
if test -n "$forgit_restore"
alias $forgit_restore 'forgit::checkout_file'
else
alias gcf 'forgit::checkout_file'
end
if test -n "$forgit_clean"
alias $forgit_clean 'forgit::clean'
else
alias gclean 'forgit::clean'
end
if test -n "$forgit_stash_show"
alias $forgit_stash_show 'forgit::stash::show'
else
alias gss 'forgit::stash::show'
end
if test -n "$forgit_cherry_pick"
alias $forgit_cherry_pick 'forgit::cherry::pick'
else
alias gcp 'forgit::cherry::pick'
end
end