Add killp peco usage
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
5eca93a4c7
commit
e2ce3fef06
1 changed files with 15 additions and 8 deletions
23
.zsh/peco.sh
23
.zsh/peco.sh
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue