From 0bf9432bda87af8a3bf38b6cfec09b85c641d99f Mon Sep 17 00:00:00 2001 From: Stefan Hojer Date: Tue, 31 Aug 2021 01:51:11 +0200 Subject: [PATCH] feat: disable plugin if fzf is not installed --- zsh-fzf-history-search.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zsh-fzf-history-search.zsh b/zsh-fzf-history-search.zsh index 5bce856..295e7d9 100644 --- a/zsh-fzf-history-search.zsh +++ b/zsh-fzf-history-search.zsh @@ -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