Skip to content
Myr

Make it possible to disable `Ctrl+T` / `Alt+C` / completions (#3678)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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)"

authored by Eli Barzilay · committed by GitHub · parent c7ee071 · Browse files · 6 files+60 added−23 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>

Diff stats

6 files+60 added−23 removed

  • tests:+1 added−2 removed
  • other:+59 added−21 removed

6 files+60 added−23 removed

modified:shell/key-bindings.bash+15 added-9 removed
modified:shell/key-bindings.fish+12 added-4 removed
102 unmodified lines
103 echo "fzf"104 end105 end106107 bind \ct fzf-file-widget107 bind \cr fzf-history-widget108 if not set -q FZF_CTRL_T_COMMAND; or test -n "$FZF_CTRL_T_COMMAND"109 bind \ct fzf-file-widget110 end111 if not set -q FZF_ALT_C_COMMAND; or test -n "$FZF_ALT_C_COMMAND"109 bind \ec fzf-cd-widget112 bind \ec fzf-cd-widget113 end114115 if bind -M insert > /dev/null 2>&1112 bind -M insert \ct fzf-file-widget116 bind -M insert \cr fzf-history-widget117 if not set -q FZF_CTRL_T_COMMAND; or test -n "$FZF_CTRL_T_COMMAND"118 bind -M insert \ct fzf-file-widget119 end120 if not set -q FZF_ALT_C_COMMAND; or test -n "$FZF_ALT_C_COMMAND"114 bind -M insert \ec fzf-cd-widget121 bind -M insert \ec fzf-cd-widget122 end123 end124125 function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath, fzf query, and optional -option= prefix'126 set -l commandline (commandline -t)
48 unmodified lines
modified:shell/key-bindings.zsh+12 added-8 removed
60 unmodified lines
61 local ret=$?62 zle reset-prompt63 return $ret64}65zle -N fzf-file-widget66bindkey -M emacs '^T' fzf-file-widget67bindkey -M vicmd '^T' fzf-file-widget68bindkey -M viins '^T' fzf-file-widget65if [[ "${FZF_CTRL_T_COMMAND-x}" != "" ]]; then66 zle -N fzf-file-widget67 bindkey -M emacs '^T' fzf-file-widget68 bindkey -M vicmd '^T' fzf-file-widget69 bindkey -M viins '^T' fzf-file-widget70fi7172# ALT-C - cd into the selected directory73fzf-cd-widget() {74 setopt localoptions pipefail no_aliases 2> /dev/null
9 unmodified lines
84 unset dir # ensure this doesn't end up appearing in prompt expansion85 zle reset-prompt86 return $ret87}86zle -N fzf-cd-widget87bindkey -M emacs '\ec' fzf-cd-widget88bindkey -M vicmd '\ec' fzf-cd-widget89bindkey -M viins '\ec' fzf-cd-widget88if [[ "${FZF_ALT_C_COMMAND-x}" != "" ]]; then89 zle -N fzf-cd-widget90 bindkey -M emacs '\ec' fzf-cd-widget91 bindkey -M vicmd '\ec' fzf-cd-widget92 bindkey -M viins '\ec' fzf-cd-widget93fi9495# CTRL-R - Paste the selected command from history into the command line96fzf-history-widget() {97 local selected num
24 unmodified lines
modified:test/test_go.rb+1 added-2 removed
16 unmodified lines
17 FZF_CTRL_T_COMMAND FZF_CTRL_T_OPTS18 FZF_ALT_C_COMMAND19 FZF_ALT_C_OPTS FZF_CTRL_R_OPTS20 FZF_API_KEY21 fish_history21].freeze22DEFAULT_TIMEOUT = 102324FILE = File.expand_path(__FILE__)
40 unmodified lines
65 end66 end6768 def fish70 UNSETS.map { |v| v + '= ' }.join + ' FZF_DEFAULT_OPTS=--no-scrollbar fish'69 "unset #{UNSETS.join(' ')}; FZF_DEFAULT_OPTS=--no-scrollbar fish_history= fish"70 end71 end72end73
3556 unmodified lines
modified:CHANGELOG.md+16 added
1CHANGELOG2=========340.48.15------6- CTRL-T and ALT-C bindings can be disabled by setting `FZF_CTRL_T_COMMAND` and `FZF_ALT_C_COMMAND` to empty strings respectively when sourcing the script7 ```sh8 # bash9 FZF_CTRL_T_COMMAND= FZF_ALT_C_COMMAND= eval "$(fzf --bash)"1011 # zsh12 FZF_CTRL_T_COMMAND= FZF_ALT_C_COMMAND= eval "$(fzf --zsh)"1314 # fish15 fzf --fish | FZF_CTRL_T_COMMAND= FZF_ALT_C_COMMAND= source16 ```17 - Setting the variables after sourcing the script will have no effect18- Bug fixes19200.48.021------22- Shell integration scripts are now embedded in the fzf binary. This simplifies the distribution, and the users are less likely to have problems caused by using incompatible scripts and binaries.23 - bash
1929 unmodified lines
modified:README.md+4 added
435 unmodified lines
436 --walker-skip .git,node_modules,target437 --preview 'bat -n --color=always {}'438 --bind 'ctrl-/:change-preview-window(down|hidden|)'"439 ```440 - Can be disabled by setting `FZF_CTRL_T_COMMAND` to an empty string when441 sourcing the script442- `CTRL-R` - Paste the selected command from history onto the command-line443 - If you want to see the commands in chronological order, press `CTRL-R`444 again which toggles sorting by relevance445 - Set `FZF_CTRL_R_OPTS` to pass additional options to fzf
17 unmodified lines
463 export FZF_ALT_C_OPTS="464 --walker-skip .git,node_modules,target465 --preview 'tree -C {}'"466 ```467 - Can be disabled by setting `FZF_ALT_C_COMMAND` to an empty string when468 sourcing the script469470If you're on a tmux session, you can start fzf in a tmux split-pane or in471a tmux popup window by setting `FZF_TMUX_OPTS` (e.g. `export FZF_TMUX_OPTS='-p80%,60%'`).472See `fzf-tmux --help` for available options.
416 unmodified lines