mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 03:06:40 +00:00
Change peco history script into custom oh-my-zsh plugin
This commit is contained in:
@@ -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
|
||||
@@ -34,8 +34,23 @@ DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
plugins=(brew bundler cake cap gem heroku node nyan osx powder python ruby \
|
||||
thor vagrant)
|
||||
plugins=( \
|
||||
brew \
|
||||
bundler \
|
||||
cake \
|
||||
cap \
|
||||
gem \
|
||||
heroku \
|
||||
node \
|
||||
nyan \
|
||||
osx \
|
||||
peco-history \
|
||||
powder \
|
||||
python \
|
||||
ruby \
|
||||
thor \
|
||||
vagrant \
|
||||
)
|
||||
|
||||
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
|
||||
# zsh-autosuggestions is designed to be unobtrusive)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user