diff options
| author | Jacobo de Vera <devel@jacobodevera.com> | 2025-10-11 17:57:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-12 01:57:31 +0900 |
| commit | 0e9026b817696baed3ff48be8ecf2b6352586c7b (patch) | |
| tree | 632a5c18766b602cfc85e3c64f8153af4f6f1a57 /shell/key-bindings.bash | |
| parent | ab407c4645952d09c4bb9b481b178717f0a0578f (diff) | |
| download | fzf-0e9026b817696baed3ff48be8ecf2b6352586c7b.tar.gz | |
feat: Allow disabling Ctrl-R binding in shell integration (#4535)
Close #4417
Diffstat (limited to 'shell/key-bindings.bash')
| -rw-r--r-- | shell/key-bindings.bash | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash index b335e6de..30b776a5 100644 --- a/shell/key-bindings.bash +++ b/shell/key-bindings.bash @@ -7,6 +7,7 @@ # - $FZF_TMUX_OPTS # - $FZF_CTRL_T_COMMAND # - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_COMMAND # - $FZF_CTRL_R_OPTS # - $FZF_ALT_C_COMMAND # - $FZF_ALT_C_OPTS @@ -132,9 +133,14 @@ if ((BASH_VERSINFO[0] < 4)); then fi # CTRL-R - Paste the selected command from history into the command line - bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er"' - bind -m vi-command '"\C-r": "\C-z\C-r\C-z"' - bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"' + if [[ ${FZF_CTRL_R_COMMAND-x} != "" ]]; then + if [[ -n ${FZF_CTRL_R_COMMAND-} ]]; then + echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2 + fi + bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u`__fzf_history__`\e\C-e\er"' + bind -m vi-command '"\C-r": "\C-z\C-r\C-z"' + bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"' + fi else # CTRL-T - Paste the selected file path into the command line if [[ ${FZF_CTRL_T_COMMAND-x} != "" ]]; then @@ -144,9 +150,14 @@ else fi # CTRL-R - Paste the selected command from history into the command line - bind -m emacs-standard -x '"\C-r": __fzf_history__' - bind -m vi-command -x '"\C-r": __fzf_history__' - bind -m vi-insert -x '"\C-r": __fzf_history__' + if [[ ${FZF_CTRL_R_COMMAND-x} != "" ]]; then + if [[ -n ${FZF_CTRL_R_COMMAND-} ]]; then + echo "warning: FZF_CTRL_R_COMMAND is set to a custom command, but custom commands are not yet supported for CTRL-R" >&2 + fi + bind -m emacs-standard -x '"\C-r": __fzf_history__' + bind -m vi-command -x '"\C-r": __fzf_history__' + bind -m vi-insert -x '"\C-r": __fzf_history__' + fi fi # ALT-C - cd into the selected directory |
