Skip to content

Instantly share code, notes, and snippets.

@iorionda
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save iorionda/e7398d30b7074c54bbeb to your computer and use it in GitHub Desktop.

Select an option

Save iorionda/e7398d30b7074c54bbeb to your computer and use it in GitHub Desktop.
select command from zsh history
################################################################################
# peco
################################################################################
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(history | \
awk '{ $1="";print }' | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment