Skip to content

Instantly share code, notes, and snippets.

@KenshoFujisaki
Last active November 6, 2015 19:10
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 KenshoFujisaki/3588982084e465d13110 to your computer and use it in GitHub Desktop.
Save KenshoFujisaki/3588982084e465d13110 to your computer and use it in GitHub Desktop.
zshで履歴をpeco実行
#------------------------------------------------------------------------------
# 履歴
#------------------------------------------------------------------------------
alias his="fc -l -f 0 | sort -r | peco"
setopt extended_history
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac | uniq"
else
tac="tail -r | uniq"
fi
BUFFER=$(\history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N peco-select-history
bindkey '^R^H' peco-select-history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment