about summary refs log tree commit diff
path: root/Completion/Builtins/_pids
blob: 0ffda900b057bf4b98f8661b6127eb7bbea96493 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#autoload

# If given the `-m <pattern>' option, this tries to complete only pids
# of processes whose command line match the `<pattern>'.

local list expl match

if [[ "$1" = -m ]]; then
  match="${2}*"
  shift 2
fi

_description expl 'process ID'

list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")

compadd "$expl[@]" "$@" -ld list - \
  ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *}