Skip to content

Commit 0607227

Browse files
authored
fix(zsh): move 'fc -RI' inside command substitution (#4073)
* fix(zsh): move 'fc -RI' inside command substitution * chore: follow existing option check format
1 parent d938fdc commit 0607227

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

shell/key-bindings.zsh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,17 @@ fzf-history-widget() {
111111
# Ensure the module is loaded if not already, and the required features, such
112112
# as the associative 'history' array, which maps event numbers to full history
113113
# lines, are set. Also, make sure Perl is installed for multi-line output.
114-
if zmodload -F zsh/parameter p:{commands,history,options} 2>/dev/null && (( ${#commands[perl]} )); then
114+
if zmodload -F zsh/parameter p:{commands,history} 2>/dev/null && (( ${#commands[perl]} )); then
115115
# Import commands from other shells if SHARE_HISTORY is enabled, as the
116116
# 'history' array only updates after executing a non-empty command.
117-
[[ "${options[sharehistory]}" == "on" ]] && fc -RI
118-
selected="$(printf '%s\t%s\000' "${(kv)history[@]}" |
119-
perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' |
120-
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") \
121-
FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"
117+
selected="$(
118+
if [[ -o sharehistory ]]; then
119+
fc -RI
120+
fi
121+
printf '%s\t%s\000' "${(kv)history[@]}" |
122+
perl -0 -ne 'if (!$seen{(/^\s*[0-9]+\**\t(.*)/s, $1)}++) { s/\n/\n\t/g; print; }' |
123+
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") \
124+
FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd))"
122125
else
123126
selected="$(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
124127
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") \

0 commit comments

Comments
 (0)