Skip to content

Instantly share code, notes, and snippets.

@tsub
Created May 2, 2017 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tsub/f4036e067a59b242a161fc3c8a5f01dd to your computer and use it in GitHub Desktop.
Save tsub/f4036e067a59b242a161fc3c8a5f01dd to your computer and use it in GitHub Desktop.
function history-fzf() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(history -n 1 | eval $tac | fzf --query "$LBUFFER")
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N history-fzf
bindkey '^r' history-fzf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment