Change peco history script into custom oh-my-zsh plugin

This commit is contained in:
2014-08-16 15:09:51 +01:00
parent e918219041
commit aa4f90c0a9
2 changed files with 36 additions and 24 deletions

View File

@@ -0,0 +1,19 @@
# History search with peco
#
# Search shell history with peco: https://github.com/peco/peco
# Adapted from: https://github.com/mooz/percol#zsh-history-search
if which peco &> /dev/null; then
function peco_select_history() {
local tac
(which gtac &> /dev/null && tac="gtac") || \
(which tac &> /dev/null && tac="tac") || \
tac="tail -r"
BUFFER=$(fc -l -n 1 | eval $tac | \
peco --layout=bottom-up --query "$LBUFFER")
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N peco_select_history
bindkey '^R' peco_select_history
fi