Add fuzzy history search with fzf

This commit is contained in:
Kenneth Benzie 2024-04-07 19:27:48 +01:00
parent 1bf5d10b74
commit a6d97c1eac

12
zshrc
View File

@ -142,6 +142,18 @@ if [[ `uname` = Linux ]]; then
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
fi
# Fuzzy history search with fzf
function fzf-history-search() {
local selected
selected=`history | sed 's/ *[0-9]* *//' | fzf`
if [[ -n "$selected" ]]; then
BUFFER="$selected"
zle end-of-line
fi
}
zle -N fzf-history-search
bindkey '^R' fzf-history-search
# Enable changing cursor shape based on vi mode
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
# iTerm2 cursor shape escape sequences outside tmux