Last active
August 29, 2015 14:03
-
-
Save quanon/afd7805e1e7c2ec7af49 to your computer and use it in GitHub Desktop.
peco でコマンド履歴を選択する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | \ | |
peco --query "$LBUFFER") | |
CURSOR=$#BUFFER # move cursor | |
zle -R -c # refresh | |
} | |
zle -N peco-select-history | |
bindkey '^R' peco-select-history | |
setopt hist_ignore_all_dups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment