diff --git a/utilities/utilities.plugin.zsh b/utilities/utilities.plugin.zsh index 060e4dd..d6f9a65 100644 --- a/utilities/utilities.plugin.zsh +++ b/utilities/utilities.plugin.zsh @@ -148,3 +148,22 @@ fi ls-iommu() { $HOME/.config/zsh/ls-iommu.sh | sort -n } + +# Fuzzy history search with fzf +function .fzf-history-search() { + local selected + selected=$( + cat $HISTFILE | # get entire history + sed 's/ *[0-9]* *//' | # remove cruft + awk '!seen[$0]++' | # remove duplicates + fzf --layout=reverse --tac --cycle --info=hidden \ + --border=rounded --height=50% + ) + if [[ -n "$selected" ]]; then + BUFFER="$selected" + zle end-of-line + fi + zle reset-prompt +} +zle -N .fzf-history-search +bindkey '^R' .fzf-history-search diff --git a/zshrc b/zshrc index bcc1d68..d4d2101 100644 --- a/zshrc +++ b/zshrc @@ -143,25 +143,6 @@ 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=$( - cat $HISTFILE | # get entire history - sed 's/ *[0-9]* *//' | # remove cruft - awk '!seen[$0]++' | # remove duplicates - fzf --layout=reverse --tac --cycle --info=hidden \ - --border=rounded --height=50% - ) - if [[ -n "$selected" ]]; then - BUFFER="$selected" - zle end-of-line - fi - zle reset-prompt -} -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