Add peco / peco functions

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-02-10 12:14:23 +01:00
parent c9e79a2ca1
commit aa49fc68e1
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 16 additions and 0 deletions

View file

@ -50,5 +50,8 @@ source ${HOME}/.zsh/config-git.zsh
## Load local-config if available
[ -e ${HOME}/.zsh/local-config.zsh ] && source ${HOME}/.zsh/local-config.zsh
## Load peco functions
source ${HOME}/.zsh/peco.sh
## Clean PATH from duplicates
PATH=$(${HOME}/bin/path-dedup.py)

12
.zsh/peco.sh Normal file
View file

@ -0,0 +1,12 @@
# 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

View file

@ -29,6 +29,7 @@ INSTALLS=(
'github.com/Luzifer/slugify'
'github.com/Luzifer/str2hex'
'github.com/Luzifer/worktime'
'github.com/peco/peco/cmd/peco'
)