@@ -111,14 +111,17 @@ fzf-history-widget() {
111
111
# Ensure the module is loaded if not already, and the required features, such
112
112
# as the associative 'history' array, which maps event numbers to full history
113
113
# 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
115
115
# Import commands from other shells if SHARE_HISTORY is enabled, as the
116
116
# '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) ) "
122
125
else
123
126
selected=" $( fc -rl 1 | awk ' { cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
124
127
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