_n-kill 814 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #compdef n-kill
  2. local context ret=1
  3. typeset -a list linewords
  4. typeset -aU words wordbits
  5. local line word
  6. integer cygwin=0
  7. local IFS="
  8. "
  9. case "$OSTYPE" in
  10. cygwin*) list=( `command ps -Wa` ); cygwin=1 ;;
  11. *) list=( `command ps -o pid,uid,command -A` ) ;;
  12. esac
  13. shift list
  14. IFS=" "
  15. for line in "${list[@]}"; do
  16. linewords=( $=line )
  17. if [ "$cygwin" = "1" ]; then
  18. linewords=( "${(@)linewords[8,-1]}" )
  19. else
  20. linewords=( "${(@)linewords[3,-1]}" )
  21. fi
  22. for word in "${linewords[@]}"; do
  23. if [ "$cygwin" = "1" ]; then
  24. wordbits=( "${(@s:\:)word}" )
  25. else
  26. wordbits=( "${(@s:/:)word}" )
  27. fi
  28. words+=( "${wordbits[@]}" )
  29. done
  30. done
  31. _wanted bits expl "Processes' name bits" \
  32. compadd "$@" -a - words && ret=0
  33. return "$ret"