|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21571/root/usr/share/zsh/4.2.6/functions/ |
Upload File : |
#compdef pflags pcred pmap pldd psig pstack pfiles pwdx pstop prun pwait ptree
# If given the `-m <pattern>' option, this tries to complete only pids
# of processes whose command line match the `<pattern>'.
local out pids list expl match desc listargs all nm ret=1
_tags processes || return 1
if [[ "$1" = -m ]]; then
all=()
match="*[[:blank:]]${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*[/[:blank:]]${2}*"
shift 2
elif [[ "$PREFIX$SUFFIX" = ([%-]*|[0-9]#) ]]; then
all=()
match="(*[[:blank:]]|)${PREFIX}[0-9]#${SUFFIX}[[:blank:]]*"
else
all=(-U)
match="*[[:blank:]]*[[/[:blank:]]$PREFIX*$SUFFIX*"
nm="$compstate[nmatches]"
fi
out=( "${(@f)$(_call_program processes ps 2>/dev/null)}" )
desc="$out[1]"
out=( "${(@M)out[2,-1]:#${~match}}" )
if [[ "$desc" = (#i)(|*[[:blank:]])pid(|[[:blank:]]*) ]]; then
pids=( "${(@)${(@M)out#${(l.${#desc[1,(r)(#i)[[:blank:]]pid]}..?.)~:-}[^[:blank:]]#}##*[[:blank:]]}" )
else
pids=( "${(@)${(@M)out##[^0-9]#[0-9]#}##*[[:blank:]]}" )
fi
if zstyle -T ":completion:${curcontext}:processes" verbose; then
list=( "${(@Mr:COLUMNS-1:)out}" )
desc=(-ld list)
else
desc=()
fi
_wanted processes expl 'process ID' \
compadd "$@" "$desc[@]" "$all[@]" -a pids && ret=0
if [[ -n "$all" ]]; then
zstyle -s ":completion:${curcontext}:processes" insert-ids out || out=menu
case "$out" in
menu) compstate[insert]=menu ;;
single) [[ $compstate[nmatches] -ne nm+1 ]] && compstate[insert]= ;;
*) [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] &&
compstate[insert]=menu ;;
esac
fi
return ret