cfg/.zsh/peco.sh
Knut Ahlers aa49fc68e1
Add peco / peco functions
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-02-10 12:16:24 +01:00

13 lines
394 B
Bash

# select history
function exists { which $1 &> /dev/null }
function peco-select-history() {
local tac
exists gtac && tac="gtac" || { exists tac && 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 peco-select-history
bindkey '^R' peco-select-history