mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
20 lines
594 B
Bash
20 lines
594 B
Bash
# 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
|