Skip to content
Myr

feat: Allow disabling Ctrl-R binding in shell integration (#4535)

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

Close #4417

authored by Jacobo de Vera · committed by GitHub · parent ab407c4 · Browse files · 5 files+56 added−18 removed
This commit

State

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

Diff stats

5 files+56 added−18 removed

  • other:+56 added−18 removed

5 files+56 added−18 removed

modified:shell/key-bindings.bash+17 added-6 removed
modified:shell/key-bindings.fish+8 added-2 removed
5 unmodified lines
6#7# - $FZF_TMUX_OPTS8# - $FZF_CTRL_T_COMMAND9# - $FZF_CTRL_T_OPTS10# - $FZF_CTRL_R_COMMAND11# - $FZF_CTRL_R_OPTS12# - $FZF_ALT_C_COMMAND13# - $FZF_ALT_C_OPTS14
199 unmodified lines
214215 commandline -f repaint216 end217218 if not set -q FZF_CTRL_R_COMMAND; or test -n "$FZF_CTRL_R_COMMAND"219 if test -n "$FZF_CTRL_R_COMMAND"220 echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2221 end217 bind \cr fzf-history-widget218 bind -M insert \cr fzf-history-widget222 bind \cr fzf-history-widget223 bind -M insert \cr fzf-history-widget224 end225226 if not set -q FZF_CTRL_T_COMMAND; or test -n "$FZF_CTRL_T_COMMAND"227 bind \ct fzf-file-widget228 bind -M insert \ct fzf-file-widget
8 unmodified lines
modified:shell/key-bindings.zsh+10 added-4 removed
5 unmodified lines
6#7# - $FZF_TMUX_OPTS8# - $FZF_CTRL_T_COMMAND9# - $FZF_CTRL_T_OPTS10# - $FZF_CTRL_R_COMMAND11# - $FZF_CTRL_R_OPTS12# - $FZF_ALT_C_COMMAND13# - $FZF_ALT_C_OPTS14
135 unmodified lines
150 fi151 zle reset-prompt152 return $ret153}154if [[ ${FZF_CTRL_R_COMMAND-x} != "" ]]; then155 if [[ -n ${FZF_CTRL_R_COMMAND-} ]]; then156 echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2157 fi153zle -N fzf-history-widget154bindkey -M emacs '^R' fzf-history-widget155bindkey -M vicmd '^R' fzf-history-widget156bindkey -M viins '^R' fzf-history-widget158 zle -N fzf-history-widget159 bindkey -M emacs '^R' fzf-history-widget160 bindkey -M vicmd '^R' fzf-history-widget161 bindkey -M viins '^R' fzf-history-widget162fi163fi164165} always {166 eval $__fzf_key_bindings_options167 'unset' '__fzf_key_bindings_options'
1 unmodified line
modified:CHANGELOG.md+12 added
25 unmodified lines
26| New | Env Var | `FZF_SOCK` | Path to the Unix domain socket fzf is listening on |27| Enhancement | Key | `CTRL-N` | `down` -> `down-match` |28| Enhancement | Key | `CTRL-P` | `up` -> `up-match` |29| Enhancement | Shell | `CTRL-R` binding | Toggle raw mode with `ALT-R` |30| Enhancement | Shell | `CTRL-R` binding | Opt-out with an empty `FZF_CTRL_R_COMMAND` |3132### Introducing "raw" mode3334This version introduces a new "raw" mode (named so because it shows the list
196 unmodified lines
231As described above, `$FZF_RAW` is now exported to child processes in raw mode,232indicating whether the current item is a match (`1`) or not (`0`). It is not233defined when not in raw mode.234235#### `$FZF_CTRL_R_COMMAND`236237You can opt-out `CTRL-R` binding from the shell integration by setting238`FZF_CTRL_R_COMMAND` to an empty string. Setting it to any other value is not239supported and will result in a warning.240241```sh242# Disable the CTRL-R binding from the shell integration243FZF_CTRL_R_COMMAND= eval "$(fzf --bash)"244```245246### Added key support for `--bind`247248Pull request #3996 added support for many additional keys for `--bind` option,249such as `ctrl-backspace`.
2832 unmodified lines
modified:README.md+9 added-6 removed
216 unmodified lines
217> Please refer to the package documentation for more information.218> (e.g. `apt show fzf`)219220> [!TIP]221> You can disable CTRL-T or ALT-C binding by setting `FZF_CTRL_T_COMMAND` or222> `FZF_ALT_C_COMMAND` to an empty string when sourcing the script.223> For example, to disable ALT-C binding:221> You can disable CTRL-T, CTRL-R, or ALT-C bindings by setting the222> corresponding `*_COMMAND` variable to an empty string when sourcing the223> script. For example, to disable CTRL-R and ALT-C:224>225> * bash: `FZF_ALT_C_COMMAND= eval "$(fzf --bash)"`226> * zsh: `FZF_ALT_C_COMMAND= source <(fzf --zsh)`227> * fish: `fzf --fish | FZF_ALT_C_COMMAND= source`225> * bash: `FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= eval "$(fzf --bash)"`226> * zsh: `FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source <(fzf --zsh)`227> * fish: `fzf --fish | FZF_CTRL_R_COMMAND= FZF_ALT_C_COMMAND= source`228>229> Setting the variables after sourcing the script will have no effect.230231### Vim/Neovim plugin
301 unmodified lines
533 --bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'534 --color header:italic535 --header 'Press CTRL-Y to copy command into clipboard'"536 ```537 - Can be disabled by setting `FZF_CTRL_R_COMMAND` to an empty string when538 sourcing the script539 - Custom override via a non-empty `FZF_CTRL_R_COMMAND` is not yet supported and will emit a warning540- `ALT-C` - cd into the selected directory541 - The list is generated using `--walker dir,follow,hidden` option542 - Set `FZF_ALT_C_COMMAND` to override the default command543 - Or you can set `--walker-*` options in `FZF_ALT_C_OPTS`
466 unmodified lines