diff options
Diffstat (limited to 'Completion/Unix')
-rw-r--r-- | Completion/Unix/Command/_dtruss | 18 | ||||
-rw-r--r-- | Completion/Unix/Type/_process_names | 44 |
2 files changed, 62 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_dtruss b/Completion/Unix/Command/_dtruss new file mode 100644 index 000000000..bd1ae8bc5 --- /dev/null +++ b/Completion/Unix/Command/_dtruss @@ -0,0 +1,18 @@ +#compdef dtruss + +_arguments -s : \ + '-a[print all details]' \ + '-b+[specify dynamic variable buffer size]:buffer size (default 4m)' \ + '-c[print system call counts]' \ + '-d[print relative timestamps]' \ + '-e[print elapsed times]' \ + '-f[follow children as they are forked]' \ + '-l[force printing of pid/lwpid per line]' \ + "-L[don't print pid/lwpid per line]" \ + '(-p :)-n+[examine processes with the specified name]: : _process_names -a' \ + '-o[print on-cpu times]' \ + '-s[print stack backtraces]' \ + '(-n :)-p+[examine process with the specified pid]: : _pids' \ + '-t+[examine only the specified syscall]: : _sys_calls' \ + '1: : _command_names -e' \ + '*:: : _normal' diff --git a/Completion/Unix/Type/_process_names b/Completion/Unix/Type/_process_names new file mode 100644 index 000000000..4f184ccb7 --- /dev/null +++ b/Completion/Unix/Type/_process_names @@ -0,0 +1,44 @@ +#autoload +# +# complete names of running processes +# +# options: +# -a: include all processes (owned by others, no tty, etc.) +# -t: use truncated process names (e.g., those in /proc/PID/stat) +# (only on Linux and BSDs) +# +# this name has been used in _killall and documented in zshcompsys(1) +local tagname='processes-names' +typeset -a expl opts names all truncate + +zparseopts -E -D 'a=all' 't=truncate' +(( $#all )) && opts=( -A ) + +local hyphen='-' +# on Linux, use BSD-style option to include processes on other ttys +[[ $OSTYPE == linux* ]] && hyphen='' + +case $OSTYPE in + (linux*|freebsd*|openbsd*|netbsd*) + if (( $#truncate )); then + if [[ $OSTYPE == netbsd* ]]; then + opts+=(-co args=) + else + opts+=(${hyphen}o comm=) + fi + names=( ${${(f)"$(_call_program $tagname ps $opts 2>/dev/null)"}#-} ) + else + opts+=(${hyphen}o args=) + names=( ${(f)"$(_call_program $tagname ps $opts 2>/dev/null )"} ) + names=( ${${${${${names:#\[*]}%% *}%:}#-}:t} + ${${${(M)names:#\[*]}#\[}%]} ) + fi + ;; + (*) + # ignore -t option + opts+=(-o comm=) + names=( ${${${(f)"$(_call_program $tagname ps $opts 2>/dev/null)"}#-}:t} ) + ;; +esac + +_wanted $tagname expl 'process name' compadd "$@" -F '(ps)' -a - names |