summaryrefslogtreecommitdiff
path: root/shell/key-bindings.bash
diff options
context:
space:
mode:
authorChristoph Anton Mitterer <mail@christoph.anton.mitterer.name>2023-10-08 18:19:28 +0200
committerGitHub <noreply@github.com>2023-10-09 01:19:28 +0900
commitf103aa4753b435f8f45c5130323effeb75583c15 (patch)
tree05804d2efd4548cd5da28bbcfa8474a30fe11798 /shell/key-bindings.bash
parent884856023ab53fa1eb7f8dbf158aa522daef0ae5 (diff)
downloadfzf-f103aa4753b435f8f45c5130323effeb75583c15.tar.gz
Improve interactiveness checks (#3449)
* [bash] return instead of not executing an if-block, when non-interactive This should keep the code more readable, be less error prone (accidentally doing something outside the if-block and aligns the code with what’s already done for zsh. `0` is returned, because it shall not be considered an error when the script is (accidentally) sourced from a non-interactive shell. If executed as a script (rather than sourced), the results are not specified by POSIX but depend on the shell, with bash giving an error in that case. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> * [shell] exit immediately when called from non-interactive shell The shell execution environment shouldn’t be modified at all, when called from a non-interactive shell. It shall be noted that the current check may become error prone for bash, namely in case there should ever be a differentiation between `i` and `I` in the special variable `-` and bash’s `nocasematch`-shell-option be used. Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Diffstat (limited to 'shell/key-bindings.bash')
-rw-r--r--shell/key-bindings.bash7
1 files changed, 3 insertions, 4 deletions
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash
index 398f66e4..e57f2af8 100644
--- a/shell/key-bindings.bash
+++ b/shell/key-bindings.bash
@@ -11,6 +11,9 @@
# - $FZF_ALT_C_COMMAND
# - $FZF_ALT_C_OPTS
+[[ $- =~ i ]] || return 0
+
+
# Key bindings
# ------------
__fzf_select__() {
@@ -27,8 +30,6 @@ __fzf_select__() {
done
}
-if [[ $- =~ i ]]; then
-
__fzfcmd() {
[[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; } &&
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
@@ -130,5 +131,3 @@ fi
bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'
bind -m vi-command '"\ec": "\C-z\ec\C-z"'
bind -m vi-insert '"\ec": "\C-z\ec\C-z"'
-
-fi