From 676e108c842bae8044d20290c40b3f9f5144df9f Mon Sep 17 00:00:00 2001 From: wzy <32936898+Freed-Wu@users.noreply.github.com> Date: Thu, 5 Aug 2021 11:34:57 +0800 Subject: [PATCH] Fix #5 --- zsh-fzf-history-search.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zsh-fzf-history-search.zsh b/zsh-fzf-history-search.zsh index 8167033..d80292d 100644 --- a/zsh-fzf-history-search.zsh +++ b/zsh-fzf-history-search.zsh @@ -1,6 +1,8 @@ fzf_history_seach() { - BUFFER=$(history -t '%Y-%m-%d %H:%M:%S' 0 | fzf +s +m -x --tac -e -q "$BUFFER" | awk '{print substr($0, index($0, $4))}') - zle end-of-line + setopt extendedglob + candidates=(${(f)"$(history -t '%Y-%m-%d %H:%M:%S' 0| fzf +s +m -x --tac -e -q "$BUFFER")"}) + print -v BUFFER "${candidates[@]/(#m)*/${${(As: :)MATCH}[4,-1]}}" + zle end-of-buffer-or-history } autoload fzf_history_seach