From a6d97c1eac8f02669742ec09ad5f2de1e4122fbe Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 7 Apr 2024 19:27:48 +0100 Subject: [PATCH] Add fuzzy history search with fzf --- zshrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zshrc b/zshrc index 2aae63b..39f0ca5 100644 --- a/zshrc +++ b/zshrc @@ -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