Files
zsh-fzf-history-search/zsh-fzf-history-search.zsh
2021-08-31 01:51:11 +02:00

17 lines
412 B
Bash

# 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]}}"
BUFFER="${BUFFER[@]/(#b)(?)\\n/$match[1]
}"
zle end-of-buffer-or-history
}
autoload fzf_history_search
zle -N fzf_history_search
bindkey '^r' fzf_history_search