1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-10-04 09:51:27 +02:00
zsh/Completion/Builtins/_pids

35 lines
1.0 KiB
Plaintext
Raw Normal View History

1999-11-04 16:44:57 +01:00
#autoload
# If given the `-m <pattern>' option, this tries to complete only pids
# of processes whose command line match the `<pattern>'.
2000-04-01 22:43:43 +02:00
local out list expl match desc listargs args
_tags processes || return 1
1999-11-04 16:44:57 +01:00
if [[ "$1" = -m ]]; then
match="${2}*"
shift 2
fi
zstyle -s ":completion:${curcontext}:processes" command args
2000-04-01 22:43:43 +02:00
out="$(_call processes ps 2>/dev/null)"
1999-11-04 16:44:57 +01:00
2000-04-01 22:43:43 +02:00
if zstyle -T ":completion:${curcontext}:processes" verbose; then
zstyle -s ":completion:${curcontext}:processes-list" command listargs
2000-04-01 22:43:43 +02:00
(( $#listargs )) || listargs=( "$args[@]" )
if [[ "$listargs" = "$args" ]]; then
list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
else
list=("${(@Mr:COLUMNS-1:)${(f@)$(_call processes-list ps 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
2000-04-01 22:43:43 +02:00
fi
desc=(-ld list)
else
desc=()
fi
1999-11-04 16:44:57 +01:00
_wanted processes expl 'process ID' \
2000-04-01 22:43:43 +02:00
compadd "$@" "$desc[@]" - \
${${${(M)${(f)"${out}"}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]#*${~match}}## #}%% *}