Merge pull request #9 from hojerst/master

some improvements (speed, plugin.zsh, fallback if fzf is not installed)
This commit is contained in:
Josh Skidmore
2021-08-30 20:16:57 -04:00
committed by GitHub
2 changed files with 10 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
0=${(%):-%N}
source ${0:A:h}/zsh-fzf-history-search.zsh

View File

@@ -1,13 +1,16 @@
fzf_history_seach() {
# do nothing if fzf is not installed
(( ! $+commands[fzf] )) && return
fzf_history_search() {
setopt extendedglob
candidates=(${(f)"$(history -t '%Y-%m-%d %H:%M:%S' 0| fzf +s +m -x --tac -e -q "$BUFFER")"})
candidates=(${(f)"$(fc -li -1 0 | fzf +s +m -x -e -q "$BUFFER")"})
BUFFER="${candidates[@]/(#m)*/${${(As: :)MATCH}[4,-1]}}"
BUFFER="${BUFFER[@]/(#b)(?)\\n/$match[1]
}"
zle end-of-buffer-or-history
}
autoload fzf_history_seach
zle -N fzf_history_seach
autoload fzf_history_search
zle -N fzf_history_search
bindkey '^r' fzf_history_seach
bindkey '^r' fzf_history_search