diff options
Diffstat (limited to 'Completion/Unix/Command/_pgrep')
-rw-r--r-- | Completion/Unix/Command/_pgrep | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index 3b4d082a7..9c3ddf039 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -5,8 +5,6 @@ # (which changed the behaviour of -f and added -a) # - We don't really need to keep pgopts and pkopts separate, but it seems like # it should make things a bit easier to follow -# - @todo We could complete log-in classes given to -c -# - @todo We could complete routing tables given to -T local curcontext="$curcontext" state line ret=1 expl pgopts pkopts no typeset -A opt_args @@ -18,7 +16,7 @@ typeset -a arguments sig_arguments aopts # overridden below arguments=( '-a[include process ancestors in match list]' - '-c+[match only on specified login class]:login class' + '-c+[match only on specified login class]:login class:_login_classes' '(-F --pidfile)'{-F+,--pidfile=}'[match only processes in specified PID file]:PID file:_files' '(-f --full)'{-f,--full}'[match against full command line]' '(-G --group)'{-G+,--group=}'[match only on specified real group IDs]: :_sequence _groups' @@ -32,13 +30,15 @@ arguments=( '(-M)-N+[extract name list from specified system]:system file:_files' '(-o -n --oldest --newest)'{-n,--newest}'[match newest process]' '(-o -n --oldest --newest)'{-o,--oldest}'[match oldest process]' + '(-O --older)'{-O+,--older=}'[select where older than specified age]:age (seconds)' '(-P --parent)'{-P+,--parent=}'[match only on specified parent process IDs]: :->ppid' '(-l)-q[suppress normal output]' + '(-r --runstates)'{-r+,--runstates}'[match runstates]:run state:compadd -S "" D I R S T t W X Z' '-S[search also in system processes (kernel threads)]' '(-s --session)'{-s+,--session=}'[match only on specified process session IDs]: :->sid' # _signals is OK here - we do it differently below '(ss)--signal=[specify signal to send to process]: :_signals -s' - '-T+[match only on specified routing table]:routing table' + '-T+[match only on specified routing table]:routing table:_routing_tables' '(-t --terminal)'{-t+,--terminal=}'[match only on specified controlling terminals]: :_sequence _ttys -do' '(-U --uid)'{-U+,--uid=}'[match only on specified real user IDs]: :_sequence _users' '(-u --euid)'{-u+,--euid=}'[match only on specified effective user IDs]: :_sequence _users' @@ -62,8 +62,8 @@ arguments=( case $OSTYPE in linux*) # Note: We deliberately exclude -v but not --inverse from pkill - pgopts=acdFfGghLlnoPstUuVvwx- - pkopts=ceFfGghLnoPstUuVx- + pgopts=acdFfGghLlnoOPrstUuVvwx- + pkopts=ceFfGghLnoOPstUuVx- arguments=( ${arguments:#((#s)|*\))(\*|)-[acl]*} '(-c --count)'{-c,--count}'[display count of matching processes]' @@ -125,6 +125,10 @@ else fi fi +if [[ $OSTYPE = dragonfly* ]]; then + arguments+=( '(-t)-T[match only processes associated with the current terminal]' ) +fi + arguments+=( $sig_arguments + o '*: :->pname' ) [[ $OSTYPE == linux* ]] || aopts+=( -A '*-' ) @@ -149,7 +153,7 @@ case $state in _pgrep_sequence ppids 'parent process ID' ppid ;; (pgid) - _pgrep_sequence pgids 'process group ID' pgid + _sequence _pgids ;; (projid) _pgrep_sequence project-ids 'project ID' project @@ -163,11 +167,21 @@ case $state in (pname) local ispat="pattern matching " if (( ${+opt_args[-x]} )); then - ispat="" + ispat+="full " fi if (( ${+opt_args[-f]} )); then - _wanted process-args expl $ispat'process command line' \ - compadd ${${(f)"$(_call_program process-args ps -A -o args=)"}% *} + local -a opts=( -lf ) + [[ $OSTYPE == linux* ]] && opts=( -a ) + local -a matches=( ${(f)"$( + _call_program process-args pgrep ${(@q)opts} -- \ + ${(q)${${:-$PREFIX$SUFFIX}:-.\*}} + )"} ) + local -a displ=( "${${matches[@]//:/\:}[@]/ /:}" ) + matches=( "${matches[@]##<-> }" ) + + local desc=$ispat'process command line' + _description process-args expl "$desc" + _describe -t process-args "$desc" displ matches "$@" -U "$expl[@]" else _wanted processes-names expl $ispat'process name' _process_names -a -t fi |