summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLangLangBart <92653266+LangLangBart@users.noreply.github.com>2024-11-02 02:41:17 +0100
committerGitHub <noreply@github.com>2024-11-02 10:41:17 +0900
commit06072277300e76beb0d4cfea3ff9fd3a86e1d792 (patch)
treece22a27c34e6b692a01d3b285876e671e682eacd
parentd938fdc496ccecfe5d747500927b675d31e1835a (diff)
downloadfzf-06072277300e76beb0d4cfea3ff9fd3a86e1d792.tar.gz
fix(zsh): move 'fc -RI' inside command substitution (#4073)
* fix(zsh): move 'fc -RI' inside command substitution * chore: follow existing option check format
-rw-r--r--shell/key-bindings.zsh15
1 files changed, 9 insertions, 6 deletions
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh
index 9d483921..3015f12d 100644
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -111,14 +111,17 @@ fzf-history-widget() {
# Ensure the module is loaded if not already, and the required features, such
# as the associative 'history' array, which maps event numbers to full history
# lines, are set. Also, make sure Perl is installed for multi-line output.
- if zmodload -F zsh/parameter p:{commands,history,options} 2>/dev/null && (( ${#commands[perl]} )); then
+ if zmodload -F zsh/parameter p:{commands,history} 2>/dev/null && (( ${#commands[perl]} )); then
# Import commands from other shells if SHARE_HISTORY is enabled, as the
# 'history' array only updates after executing a non-empty command.
- [[ "${options[sharehistory]}" == "on" ]] && fc -RI
- selected="$(printf '%s\t%s\000' "${(kv)history[@]}" |
- perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' |
- FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \
- FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"
+ selected="$(
+ if [[ -o sharehistory ]]; then
+ fc -RI
+ fi
+ printf '%s\t%s\000' "${(kv)history[@]}" |
+ perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' |
+ FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m --read0") \
+ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"
else
selected="$(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '\t↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m") \