about summary refs log tree commit diff
path: root/Completion/Builtins/_wait
blob: 17a030dad192fcd1913a5f92e35e1926e01a81a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#compdef wait

# This uses two configuration keys:
#
#  ps_args
#    This can be set to options of the ps(1) command that should be
#    used when invoking it to get the pids to complete.
#
#  ps_listargs
#    This defaults to the value of the `ps_args' key and defines
#    options for the ps command that are to be used when creating
#    the list to display during completion.

local list ret=1 expl

_description expl job
compgen "$expl[@]" -P '%' -j && ret=0
list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*}")
_description expl 'process ID'
compadd "$expl[@]" -ld list - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0

return ret