diff options
| author | LangLangBart <92653266+LangLangBart@users.noreply.github.com> | 2024-10-31 16:19:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-01 00:19:47 +0900 |
| commit | d938fdc496ccecfe5d747500927b675d31e1835a (patch) | |
| tree | 99bd4981b76d54a249d20fca3159b5ba37140e98 /shell | |
| parent | dcb4c3d84a5bd7985dd70dd7de7a68992693c20c (diff) | |
| download | fzf-d938fdc496ccecfe5d747500927b675d31e1835a.tar.gz | |
fix(zsh): history loading with shared option (#4071)
Fix #4061
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/key-bindings.zsh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh index a4d7055c..9d483921 100644 --- a/shell/key-bindings.zsh +++ b/shell/key-bindings.zsh @@ -108,9 +108,13 @@ fi fzf-history-widget() { local selected setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases noglob nobash_rematch 2> /dev/null - # Ensure the associative history array, which maps event numbers to the full - # history lines, is loaded, and that Perl is installed for multi-line output. - if zmodload -F zsh/parameter p:history 2>/dev/null && (( ${#commands[perl]} )); then + # 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 + # 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") \ |
