1
0
Fork 0

Add killp peco usage

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-02-10 12:26:35 +01:00
parent 5eca93a4c7
commit e2ce3fef06
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,12 +1,19 @@
# select history
# Helpers
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
}
# kill process
function peco-kill-process() {
ps ax -o pid,time,command | peco --query "$LBUFFER" | awk '{print $1}' | xargs kill
}
alias killp='peco-kill-process'
# select history
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