Define an alternative set of bindings (CTRL-G KEY) (#5)

Co-authored-by: Phelipe <39670535+phelipetls@users.noreply.github.com>
main
Junegunn Choi 2 years ago committed by GitHub
parent f72ebd8231
commit c8e146ec1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,6 +28,17 @@ Usage
* <kbd>CTRL-G</kbd><kbd>CTRL-R</kbd> for **R**emotes
* <kbd>CTRL-G</kbd><kbd>CTRL-H</kbd> for commit **H**ashes
* <kbd>CTRL-G</kbd><kbd>CTRL-S</kbd> for **S**tashes
> :warning: You may have issues with these bindings in the following cases:
>
> * <kbd>CTRL-G</kbd><kbd>CTRL-B</kbd> will not work if
> <kbd>CTRL-B</kbd> is used as the tmux prefix
> * <kbd>CTRL-G</kbd><kbd>CTRL-S</kbd> will not work if flow control is enabled,
> <kbd>CTRL-S</kbd> will freeze the terminal instead
> * (`stty -ixoff -ixon` will disable it)
>
> To workaround the problems, you can use
> <kbd>CTRL-G</kbd><kbd>*{key}*</kbd> instead of
> <kbd>CTRL-G</kbd><kbd>CTRL-*{KEY}*</kbd>.
* Inside fzf
* <kbd>TAB</kbd> or <kbd>SHIFT-TAB</kbd> to select multiple objects
* <kbd>CTRL-/</kbd> to change preview window layout

@ -189,13 +189,14 @@ _fzf_git_stashes() {
}
if [[ -n $BASH_VERSION ]]; then
bind '"\er": redraw-current-line'
bind '"\C-g\C-f": "$(_fzf_git_files)\e\C-e\er"'
bind '"\C-g\C-b": "$(_fzf_git_branches)\e\C-e\er"'
bind '"\C-g\C-t": "$(_fzf_git_tags)\e\C-e\er"'
bind '"\C-g\C-h": "$(_fzf_git_hashes)\e\C-e\er"'
bind '"\C-g\C-r": "$(_fzf_git_remotes)\e\C-e\er"'
bind '"\C-g\C-s": "$(_fzf_git_stashes)\e\C-e\er"'
__fzf_git_init() {
bind '"\er": redraw-current-line'
local o
for o in "$@"; do
bind '"\C-g\C-'${o:0:1}'": "$(_fzf_git_'$o')\e\C-e\er"'
bind '"\C-g'${o:0:1}'": "$(_fzf_git_'$o')\e\C-e\er"'
done
}
elif [[ -n $ZSH_VERSION ]]; then
__fzf_git_join() {
local item
@ -206,14 +207,15 @@ elif [[ -n $ZSH_VERSION ]]; then
__fzf_git_init() {
local o
for o in $@; do
for o in "$@"; do
eval "fzf-git-$o-widget() { local result=\$(_fzf_git_$o | __fzf_git_join); zle reset-prompt; LBUFFER+=\$result }"
eval "zle -N fzf-git-$o-widget"
eval "bindkey '^g^${o[1]}' fzf-git-$o-widget"
eval "bindkey '^g${o[1]}' fzf-git-$o-widget"
done
}
__fzf_git_init files branches tags remotes hashes stashes
fi
__fzf_git_init files branches tags remotes hashes stashes
# -----------------------------------------------------------------------------
fi

Loading…
Cancel
Save