Completion for ps command
This commit is contained in:
parent
107bdaba20
commit
a0ea8a932e
|
@ -0,0 +1,128 @@
|
|||
#compdef ps
|
||||
|
||||
local context state state_descr line
|
||||
typeset -A opt_args
|
||||
local filterexcl="(-A -a -C -d -e -g -G --group --Group -p --pid --ppid -s --sid -t --tty -u -U --user --User)"
|
||||
|
||||
_arguments -s \
|
||||
"$filterexcl-A[all processes]"\
|
||||
"$filterexcl-a[all w/ tty except session leaders]"\
|
||||
"--cumulative[include some dead child process data (as a sum with the parent)]"\
|
||||
"(-f -F --format -l -o -O)--context[display security context format (for SE Linux)]"\
|
||||
"-c[show different scheduler information]"\
|
||||
"$filterexcl-C[by command name]:processes:->pname"\
|
||||
"(--columns)--cols[set screen width]:width:( )"\
|
||||
"(--cols)--columns[set screen width]:width:( )"\
|
||||
"--deselect[negate selection]"\
|
||||
"$filterexcl-d[all except session leaders]"\
|
||||
"$filterexcl-e[all processes]"\
|
||||
"--forest[ASCII art process tree]"\
|
||||
"(--context -F --format -o -O)-f[full format listing]"\
|
||||
"(--context -f --format -o -O)-F[extra full 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 real group ID (supports names)]:groups:->rgid"\
|
||||
"$filterexcl--group[by session OR by effective group name]:groups:->groups"\
|
||||
"$filterexcl--Group[by real group ID (supports names)]:groups:->rgid"\
|
||||
"-H[show process hierarchy]"\
|
||||
"(--no-heading)--heading[repeat header lines, one per page of output]"\
|
||||
"-j[jobs format]"\
|
||||
"-l[long format. the -y option is often useful with this]"\
|
||||
"-L[show threads, possibly with LWP and NLWP columns]"\
|
||||
"-m[show threads after processes]"\
|
||||
"-M[add a column of security data]"\
|
||||
"-N[negate selection]"\
|
||||
"(--heading --header)--no-heading[omit header lines]"\
|
||||
"(--context -f -F --format -j -l)-o[user-defined format]:output format:->format"\
|
||||
"(--context -f -F --format -j -l)-O[preloaded -o (user-defined with some)]:output format:->format"\
|
||||
"$filterexcl-p[by process ID]:process IDs:->pid"\
|
||||
"$filterexcl--pid[by process ID]:process IDs:->pid"\
|
||||
"$filterexcl--ppid[select by parent process ID]:process IDs:->ppid"\
|
||||
"--rows[set screen height.]:height:( )"\
|
||||
"$filterexcl-s[by session IDs]:sessions:->sid"\
|
||||
"$filterexcl--sid[by session IDs]:sessions:->sid"\
|
||||
"--sort[specify sorting order]:sort specs:->sortspec"\
|
||||
"$filterexcl-t[by tty]:ttys:->tty"\
|
||||
"-T[show threads, possibly with SPID column]"\
|
||||
"$filterexcl--tty[by tty]:ttys:->tty"\
|
||||
"$filterexcl-u[by effective 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 real user ID (supports names)]:users:->users"\
|
||||
"(--version)-V[print the procps version]"\
|
||||
"(-V)--version[print the procps version]"\
|
||||
"-w[wide output]"\
|
||||
"-y[use with -l, do not show flags, show rss in place of addr]"\
|
||||
"1:BSD-style options (complete - to see unix & gnu-style options):((T\:'all processes on this terminal' a\:'all w/ tty, including other users' r\:'only running processes' x\:'processes w/o controlling ttys' t\:'list by tty' j\:'BSD jobs control format' l\:'BSD long format' s\:'signal format' v\:'virtual memory format' u\:'user-oriented format' X\:'register format' L\:'list format codes' S\:'sum info of children into parents' c\:'true command name' n\:'numeric WCHAN & UID' H\:'show threads as if they were processes' U\:'by effective user ID' p\:'by process ID'))"\
|
||||
- debug "--info[print debugging info]"
|
||||
|
||||
case "$state" in
|
||||
pid)
|
||||
compset -P '*,'
|
||||
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)
|
||||
compset -P '*,'
|
||||
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)
|
||||
local ispat="pattern matching "
|
||||
if (( ${+opt_args[-x]} ))
|
||||
then
|
||||
ispat=""
|
||||
fi
|
||||
if (( ${+opt_args[-f]} ))
|
||||
then
|
||||
_wanted pname expl $ispat'process command line' compadd ${(u)${(f)"$(ps -A o cmd=)"}}
|
||||
else
|
||||
_wanted pname expl $ispat'process name' compadd ${(u)${(f)"$(ps -A co cmd=)"}}
|
||||
fi
|
||||
;;
|
||||
sid)
|
||||
compset -P '*,'
|
||||
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)
|
||||
compset -P '*,'
|
||||
local -a used ttys
|
||||
used=(${(s:,:)IPREFIX})
|
||||
ttys=( /dev/tty*(N) /dev/pts/*(N) )
|
||||
_wanted tty expl 'terminal device' compadd -S ',' -q -F used ${ttys#/dev/}
|
||||
;;
|
||||
ppid)
|
||||
compset -P '*,'
|
||||
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)
|
||||
compset -P '*,'
|
||||
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)
|
||||
compset -P '*,'
|
||||
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
|
Loading…
Reference in New Issue