This repository has been archived on 2024-06-19. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles-old/dot_oh-my-zsh/plugins/zsh-navigation-tools/_n-kill

41 lines
834 B
Text

#compdef n-kill
local context ret=1
typeset -a list linewords
typeset -aU words wordbits
local line word
integer cygwin=0
local IFS="
"
case "$(uname)" in
CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;;
*) list=( `command ps -o pid,uid,command -A` ) ;;
esac
shift list
IFS=" "
for line in "${list[@]}"; do
linewords=( $=line )
if [ "$cygwin" = "1" ]; then
linewords=( "${(@)linewords[8,-1]}" )
else
linewords=( "${(@)linewords[3,-1]}" )
fi
for word in "${linewords[@]}"; do
if [ "$cygwin" = "1" ]; then
wordbits=( "${(@s:\:)word}" )
else
wordbits=( "${(@s:/:)word}" )
fi
words+=( "${wordbits[@]}" )
done
done
_wanted bits expl "Processes' name bits" \
compadd -M 'm:{a-z}={A-Z}' "$@" -a - words && ret=0
return "$ret"