Use _values instead of _comma_separated
This commit is contained in:
parent
337eb7726a
commit
c99880a2d7
78
src/_ps
78
src/_ps
|
@ -1,18 +1,6 @@
|
||||||
#compdef ps
|
#compdef ps
|
||||||
|
|
||||||
# This works with procps version 3.2.8
|
# This works with procps version 3.2.8
|
||||||
|
|
||||||
# This depends on the _comma_separated function, which should be available from the same
|
|
||||||
# place you got this file. If it isn't then you can uncomment the following lines to define
|
|
||||||
# the function:
|
|
||||||
#
|
|
||||||
# _comma_separated()
|
|
||||||
# {
|
|
||||||
# compset -P '*,'
|
|
||||||
# local -a used vals
|
|
||||||
# used=(${(s:,:)IPREFIX})
|
|
||||||
# _wanted tty expl $1 compadd -S ',' -q -F used "$@[2,-1]"
|
|
||||||
# }
|
|
||||||
|
|
||||||
local context state state_descr line
|
local context state state_descr line
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
@ -34,9 +22,9 @@ _arguments -s -w \
|
||||||
"(--context -F --format -o -O)-f[full format listing]"\
|
"(--context -F --format -o -O)-f[full format listing]"\
|
||||||
"(--context -f --format -o -O)-F[extra full format]"\
|
"(--context -f --format -o -O)-F[extra full format]"\
|
||||||
"(--context -f -F -j -l -o -O)--format[user-defined format]:output format:->format"\
|
"(--context -f -F -j -l -o -O)--format[user-defined format]:output format:->format"\
|
||||||
"$filterexcl-g[by session OR by effective group name]:groups:->groups"\
|
"$filterexcl-g[by session OR by effective group name]:groups:_groups"\
|
||||||
"$filterexcl-G[by real group ID (supports names)]:groups:->rgid"\
|
"$filterexcl-G[by real group ID (supports names)]:groups:->rgid"\
|
||||||
"$filterexcl--group[by session OR by effective group name]:groups:->groups"\
|
"$filterexcl--group[by session OR by effective group name]:groups:_groups"\
|
||||||
"$filterexcl--Group[by real group ID (supports names)]:groups:->rgid"\
|
"$filterexcl--Group[by real group ID (supports names)]:groups:->rgid"\
|
||||||
"-H[show process hierarchy]"\
|
"-H[show process hierarchy]"\
|
||||||
"(--no-heading)--heading[repeat header lines, one per page of output]"\
|
"(--no-heading)--heading[repeat header lines, one per page of output]"\
|
||||||
|
@ -59,10 +47,10 @@ _arguments -s -w \
|
||||||
"$filterexcl-t[by tty]:ttys:->tty"\
|
"$filterexcl-t[by tty]:ttys:->tty"\
|
||||||
"-T[show threads, possibly with SPID column]"\
|
"-T[show threads, possibly with SPID column]"\
|
||||||
"$filterexcl--tty[by tty]:ttys:->tty"\
|
"$filterexcl--tty[by tty]:ttys:->tty"\
|
||||||
"$filterexcl-u[by effective user ID (supports names)]:users:->users"\
|
"$filterexcl-u[by effective user ID (supports names)]:users:_users"\
|
||||||
"$filterexcl-U[by real user ID (supports names)]:users:->users"\
|
"$filterexcl-U[by real user ID (supports names)]:users:_users"\
|
||||||
"$filterexcl--user[by effective user ID (supports names)]:users:->users"\
|
"$filterexcl--user[by effective user ID (supports names)]:users:_users"\
|
||||||
"$filterexcl--User[by real user ID (supports names)]:users:->users"\
|
"$filterexcl--User[by real user ID (supports names)]:users:_users"\
|
||||||
"(--version)-V[print the procps version]"\
|
"(--version)-V[print the procps version]"\
|
||||||
"(-V)--version[print the procps version]"\
|
"(-V)--version[print the procps version]"\
|
||||||
"-w[wide output]"\
|
"-w[wide output]"\
|
||||||
|
@ -72,24 +60,10 @@ _arguments -s -w \
|
||||||
|
|
||||||
case "$state" in
|
case "$state" in
|
||||||
pid)
|
pid)
|
||||||
compset -P '*,'
|
_values -s , 'process id' "${(uonzf)$(ps -A o pid=)}"
|
||||||
local -a used pid
|
|
||||||
used=(${(s:,:)IPREFIX})
|
|
||||||
pid=(${(uon)$(ps -A o pid=)})
|
|
||||||
_wanted pgid expl 'process id' compadd -S ',' -q -F used $pid
|
|
||||||
;;
|
|
||||||
users)
|
|
||||||
_users
|
|
||||||
;;
|
;;
|
||||||
rgid)
|
rgid)
|
||||||
compset -P '*,'
|
_values -s , 'process group id' "${(uonzf)$(ps -A o rgid=)}"
|
||||||
local -a used rgid
|
|
||||||
used=(${(s:,:)IPREFIX})
|
|
||||||
rgid=(${(uon)$(ps -A o rgid=)})
|
|
||||||
_wanted rgid expl 'process group id' compadd -S ',' -q -F used $rgid
|
|
||||||
;;
|
|
||||||
groups)
|
|
||||||
_groups
|
|
||||||
;;
|
;;
|
||||||
pname)
|
pname)
|
||||||
local ispat="pattern matching "
|
local ispat="pattern matching "
|
||||||
|
@ -105,38 +79,24 @@ case "$state" in
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
sid)
|
sid)
|
||||||
compset -P '*,'
|
_values -s , 'session id' "${(uonzf)$(ps -A o sid=)}"
|
||||||
local -a used sid
|
|
||||||
used=(${(s:,:)IPREFIX})
|
|
||||||
sid=(${(uon)$(ps -A o sid=)})
|
|
||||||
_wanted sid expl 'session id' compadd -S ',' -q -F used $sid
|
|
||||||
;;
|
;;
|
||||||
tty)
|
tty)
|
||||||
compset -P '*,'
|
local -a ttys
|
||||||
local -a used ttys
|
|
||||||
used=(${(s:,:)IPREFIX})
|
|
||||||
ttys=( /dev/tty*(N) /dev/pts/*(N) )
|
ttys=( /dev/tty*(N) /dev/pts/*(N) )
|
||||||
_wanted tty expl 'terminal device' compadd -S ',' -q -F used ${ttys#/dev/}
|
_values -s , 'terminal device' ${ttys#/dev/}
|
||||||
;;
|
;;
|
||||||
ppid)
|
ppid)
|
||||||
compset -P '*,'
|
_values -s , 'parent process id' "${(uonzf)$(ps -A o ppid=)}"
|
||||||
local -a used ppid
|
|
||||||
used=(${(s:,:)IPREFIX})
|
|
||||||
ppid=(${(uon)$(ps -A o ppid=)})
|
|
||||||
_wanted ppid expl 'parent process id' compadd -S ',' -q -F used $ppid
|
|
||||||
;;
|
;;
|
||||||
sortspec)
|
sortspec)
|
||||||
compset -P '*,'
|
_values -s , 'format specifier (prefix with - for decreasing order)' "${(uozf)$(ps L|cut -f 1 -d" ")}"
|
||||||
local -a used spec minuspec pluspec allspec
|
|
||||||
used=(${(s:,:)IPREFIX/[-+]/})
|
|
||||||
spec=(${(uo)$(ps L|cut -f 1 -d" ")})
|
|
||||||
_wanted spec expl 'format specifier (prefix with - for decreasing order)' compadd -S ',' -q -F used $spec
|
|
||||||
;;
|
;;
|
||||||
format)
|
format)
|
||||||
compset -P '*,'
|
_values -s , 'format specifier' "${(uozf)$(ps L|cut -f 1 -d" ")}"
|
||||||
local -a used spec
|
|
||||||
used=(${(s:,:)IPREFIX})
|
|
||||||
spec=(${(uo)$(ps L|cut -f 1 -d" ")})
|
|
||||||
_wanted spec expl 'format specifier' compadd -S ',' -q -F used $spec
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:shell-script
|
||||||
|
# End:
|
||||||
|
|
Loading…
Reference in New Issue