49 lines
1.2 KiB
Bash
49 lines
1.2 KiB
Bash
# shellcheck shell=bash
|
|
# vim: ft=sh
|
|
|
|
# Navi
|
|
if command -v navi > /dev/null 2>&1; then
|
|
zinit snippet https://github.com/denisidoro/navi/blob/master/shell/navi.plugin.zsh
|
|
function magic-ctrl-g {
|
|
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then _navi_widget; fi
|
|
}
|
|
zle -N magic-ctrl-g
|
|
bindkey '^G' magic-ctrl-g
|
|
fi
|
|
|
|
# FZF #{{{
|
|
if command -v fzf > /dev/null 2>&1; then
|
|
function magic-ctrl-f {
|
|
if ! (( $#BUFFER )) && [[ "$CONTEXT" == start ]]; then fzf-file-widget; fi
|
|
}
|
|
zle -N magic-ctrl-f
|
|
bindkey '^F' magic-ctrl-f
|
|
fi
|
|
#}}}
|
|
|
|
ZSH_FZF_PASTE_KEY=enter
|
|
ZSH_FZF_EXEC_KEY=ctrl-r
|
|
fzf-kill-proc-by-list() {
|
|
local cmd=$([ "$UID" != '0' ] && echo "ps -f -u $UID" || echo 'ps -ef')
|
|
local res=$(${=cmd} \
|
|
| FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS}
|
|
--no-sort
|
|
--reverse
|
|
--bind=\"${ZSH_FZF_PASTE_KEY}:execute@echo kill -9 \$(echo {} | awk '{print \$2}')@+abort\"
|
|
--bind=\"${ZSH_FZF_EXEC_KEY}:execute@kill -9 \$(echo {} | awk '{print \$2}')@+abort\"
|
|
" $(__fzfcmd))
|
|
|
|
if [[ -n "$res" ]]; then
|
|
LBUFFER=${LBUFFER}$res
|
|
zle redisplay
|
|
else
|
|
zle reset-prompt
|
|
fi
|
|
}
|
|
|
|
if command -v fzf > /dev/null 2>&1; then
|
|
zle -N fzf-kill-proc-by-list
|
|
bindkey '^Z' fzf-kill-proc-by-list
|
|
fi
|
|
|