2018-02-10 11:26:35 +00:00
|
|
|
# Helpers
|
2018-02-10 11:14:23 +00:00
|
|
|
function exists { which $1 &> /dev/null }
|
2018-02-10 11:26:35 +00:00
|
|
|
|
|
|
|
# kill process
|
|
|
|
function peco-kill-process() {
|
|
|
|
ps ax -o pid,time,command | peco --query "$LBUFFER" | awk '{print $1}' | xargs kill
|
2018-02-10 11:14:23 +00:00
|
|
|
}
|
2018-02-10 11:26:35 +00:00
|
|
|
alias killp='peco-kill-process'
|
2018-02-10 11:14:23 +00:00
|
|
|
|
2018-02-10 11:26:35 +00:00
|
|
|
# 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
|
|
|
|
}
|
2018-02-10 11:14:23 +00:00
|
|
|
zle -N peco-select-history
|
|
|
|
bindkey '^R' peco-select-history
|