From 88f4c16755d8fb53e55adec84d60d4aeaf1e7d91 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 17 Mar 2024 03:06:48 -0400 Subject: Make it possible to disable `Ctrl+T` / `Alt+C` / completions (#3678) This makes it possible to skip one of the above key bindings or completions by setting a variable to an empty string. For example, FZF_CTRL_T_COMMAND= FZF_ALT_C_COMMAND= \ eval "$(fzf --zsh)" Co-authored-by: Junegunn Choi --- shell/key-bindings.zsh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'shell/key-bindings.zsh') diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index a3699add..51aa6ea0 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -62,10 +62,12 @@ fzf-file-widget() { zle reset-prompt return $ret } -zle -N fzf-file-widget -bindkey -M emacs '^T' fzf-file-widget -bindkey -M vicmd '^T' fzf-file-widget -bindkey -M viins '^T' fzf-file-widget +if [[ "${FZF_CTRL_T_COMMAND-x}" != "" ]]; then + zle -N fzf-file-widget + bindkey -M emacs '^T' fzf-file-widget + bindkey -M vicmd '^T' fzf-file-widget + bindkey -M viins '^T' fzf-file-widget +fi # ALT-C - cd into the selected directory fzf-cd-widget() { @@ -83,10 +85,12 @@ fzf-cd-widget() { zle reset-prompt return $ret } -zle -N fzf-cd-widget -bindkey -M emacs '\ec' fzf-cd-widget -bindkey -M vicmd '\ec' fzf-cd-widget -bindkey -M viins '\ec' fzf-cd-widget +if [[ "${FZF_ALT_C_COMMAND-x}" != "" ]]; then + zle -N fzf-cd-widget + bindkey -M emacs '\ec' fzf-cd-widget + bindkey -M vicmd '\ec' fzf-cd-widget + bindkey -M viins '\ec' fzf-cd-widget +fi # CTRL-R - Paste the selected command from history into the command line fzf-history-widget() { -- cgit v1.2.3