Merge pull request #9 from hojerst/master
some improvements (speed, plugin.zsh, fallback if fzf is not installed)
This commit is contained in:
2
zsh-fzf-history-search.plugin.zsh
Normal file
2
zsh-fzf-history-search.plugin.zsh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0=${(%):-%N}
|
||||||
|
source ${0:A:h}/zsh-fzf-history-search.zsh
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
fzf_history_seach() {
|
# do nothing if fzf is not installed
|
||||||
|
(( ! $+commands[fzf] )) && return
|
||||||
|
|
||||||
|
fzf_history_search() {
|
||||||
setopt extendedglob
|
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="${candidates[@]/(#m)*/${${(As: :)MATCH}[4,-1]}}"
|
||||||
BUFFER="${BUFFER[@]/(#b)(?)\\n/$match[1]
|
BUFFER="${BUFFER[@]/(#b)(?)\\n/$match[1]
|
||||||
}"
|
}"
|
||||||
zle end-of-buffer-or-history
|
zle end-of-buffer-or-history
|
||||||
}
|
}
|
||||||
|
|
||||||
autoload fzf_history_seach
|
autoload fzf_history_search
|
||||||
zle -N fzf_history_seach
|
zle -N fzf_history_search
|
||||||
|
|
||||||
bindkey '^r' fzf_history_seach
|
bindkey '^r' fzf_history_search
|
||||||
|
|||||||
Reference in New Issue
Block a user