Skip to content

Instantly share code, notes, and snippets.

@Dimfred
Created June 9, 2023 12:43
Show Gist options
  • Save Dimfred/3dba6288b1835b6a80393b0f1cadded9 to your computer and use it in GitHub Desktop.
Save Dimfred/3dba6288b1835b6a80393b0f1cadded9 to your computer and use it in GitHub Desktop.
zsh fzf reverse search (like bash)
reverse_search() {
sel="$( \
cat ${HOME}/.zsh_history \
| grep -i "$BUFFER" \
| cut -d';' -f2 \
| sort \
| uniq -ui \
| fzf)"
[ -z "$sel" ] && return
BUFFER="$sel"
}
zle -N reverse_search
bindkey '^R' reverse_search
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment