Skip to content

Instantly share code, notes, and snippets.

@jemiam
Created October 12, 2014 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jemiam/5178426e980c2647502c to your computer and use it in GitHub Desktop.
Save jemiam/5178426e980c2647502c to your computer and use it in GitHub Desktop.
peco-select-history
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
if [ -n "$LBUFFER" ]; then
BUFFER=$(history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
else
BUFFER=$(history -n 1 | \
eval $tac | \
peco)
fi
CURSOR=$#BUFFER
zle clear-screen
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment