feat: disable plugin if fzf is not installed

This commit is contained in:
Stefan Hojer
2021-08-31 01:51:11 +02:00
parent daf2367e9d
commit 0bf9432bda

View File

@@ -1,4 +1,7 @@
fzf_history_seach() {
# do nothing if fzf is not installed
(( ! $+commands[fzf] )) && return
fzf_history_search() {
setopt extendedglob
candidates=(${(f)"$(fc -li -1 0 | fzf +s +m -x -e -q "$BUFFER")"})
BUFFER="${candidates[@]/(#m)*/${${(As: :)MATCH}[4,-1]}}"
@@ -7,7 +10,7 @@ fzf_history_seach() {
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