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

View File

@@ -34,8 +34,23 @@ DISABLE_AUTO_TITLE="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse) # Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(brew bundler cake cap gem heroku node nyan osx powder python ruby \ plugins=( \
thor vagrant) brew \
bundler \
cake \
cap \
gem \
heroku \
node \
nyan \
osx \
peco-history \
powder \
python \
ruby \
thor \
vagrant \
)
source "$ZSH/oh-my-zsh.sh" source "$ZSH/oh-my-zsh.sh"
@@ -85,25 +100,3 @@ zle -N zle-line-init
# use ctrl+t to toggle autosuggestions(hopefully this wont be needed as # use ctrl+t to toggle autosuggestions(hopefully this wont be needed as
# zsh-autosuggestions is designed to be unobtrusive) # zsh-autosuggestions is designed to be unobtrusive)
bindkey '^T' autosuggest-toggle bindkey '^T' autosuggest-toggle
#
# 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 percol_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 --query "$LBUFFER")
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N percol_select_history
bindkey '^R' percol_select_history
fi