summaryrefslogtreecommitdiff
path: root/shell/key-bindings.bash
diff options
context:
space:
mode:
authorJacobo de Vera <devel@jacobodevera.com>2025-10-11 17:57:31 +0100
committerGitHub <noreply@github.com>2025-10-12 01:57:31 +0900
commit0e9026b817696baed3ff48be8ecf2b6352586c7b (patch)
tree632a5c18766b602cfc85e3c64f8153af4f6f1a57 /shell/key-bindings.bash
parentab407c4645952d09c4bb9b481b178717f0a0578f (diff)
downloadfzf-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.bash23
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