Skip to content

Instantly share code, notes, and snippets.

@cuongtransc
Created December 22, 2017 02:13
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 cuongtransc/e3631d4ec4367ea593823b3faf4bbc79 to your computer and use it in GitHub Desktop.
Save cuongtransc/e3631d4ec4367ea593823b3faf4bbc79 to your computer and use it in GitHub Desktop.
#
# Download Peco: https://github.com/peco/peco
#
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(\history -n 1 | \
eval $tac | \
awk '!_[$0]++' | \
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