mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-04 22:51:42 +02:00
37913: add additional completers and _zpool improvement
This commit is contained in:
parent
6d82ce161a
commit
9cc6ebe7a2
9 changed files with 271 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
|||
2016-02-11 Eric Cook <llua@gmx.com>
|
||||
|
||||
* 37913: Completion/BSD/Command/_gstat,
|
||||
Completion/BSD/Command/_sysrc, Completion/Linux/Command/_gpasswd,
|
||||
Completion/Linux/Command/_htop, Completion/Linux/Command/_kpartx,
|
||||
Completion/Unix/Command/_top, Completion/Unix/Command/_tput,
|
||||
Completion/Unix/Command/_zpool: new completers and improvement
|
||||
for _zpool.
|
||||
|
||||
2016-02-11 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 37946: Src/utils.c: make rm * warnings more informative about
|
||||
|
|
11
Completion/BSD/Command/_gstat
Normal file
11
Completion/BSD/Command/_gstat
Normal file
|
@ -0,0 +1,11 @@
|
|||
#compdef gstat
|
||||
|
||||
_arguments -s -w : \
|
||||
'-a[only display providers that are at least 0.1% busy]' \
|
||||
'-b[batch mode]' \
|
||||
'-c[enable the display geom(4) consumers]' \
|
||||
'-d[enable the display delete operations]' \
|
||||
'-f[filter by regex]:regex' \
|
||||
'-o[enable the display for other operations]' \
|
||||
'-I[display refresh rate]:interval' \
|
||||
'-p[only display physical providers]'
|
77
Completion/BSD/Command/_sysrc
Normal file
77
Completion/BSD/Command/_sysrc
Normal file
|
@ -0,0 +1,77 @@
|
|||
#compdef sysrc
|
||||
_sysrc_caching_policy() {
|
||||
local -a oldp
|
||||
oldp=( "$1"(Nm+1) )
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
|
||||
_sysrc() {
|
||||
_arguments -A '-*' : \
|
||||
'-c[check only, return success if vars are set]' \
|
||||
'-d[print variable(s) description]' \
|
||||
'-D[print default value(s) only]' \
|
||||
'-e[print variables as sh(1) compatible syntax]' \
|
||||
'*-f[operate on specified file(s), not \`rc_conf_files'\'']: : _files' \
|
||||
'-F[print only the last rc.conf(5) file each directive is in]' \
|
||||
'-h[print short usage message]' \
|
||||
'--help[print full usage message]' \
|
||||
'-i[ignore unknown variables]' \
|
||||
'-j[jail to operate within]:jails:_jails' \
|
||||
'-n[print only variable values]' \
|
||||
'-N[print only variable names]' \
|
||||
'-q[quiet mode]' \
|
||||
'-R[specify an alternative root]:alternative root:_files -/' \
|
||||
'-v[verbose mode]' \
|
||||
'--version[print version information]' \
|
||||
'-x[remove specified variables from specified file(s)]' \
|
||||
'*:configuration variable:->confvars' \
|
||||
- set1 \
|
||||
'-a[list all non-default configuration variables]' \
|
||||
- set2 \
|
||||
'-A[list all configuration variables]'
|
||||
|
||||
if [[ $state == confvars ]]; then
|
||||
local k v opt curcontext="${curcontext%:*}:values"; local -a rc_conf_vars
|
||||
if [[ -prefix *=* ]]; then
|
||||
# do you really want to go down this hole?
|
||||
_message -e values value
|
||||
else
|
||||
if zstyle -T ":completion:${curcontext%:*}:values" verbose; then
|
||||
opt=d
|
||||
else
|
||||
opt=N
|
||||
fi
|
||||
|
||||
if ! zstyle -m ":completion:${curcontext%:*}:values" cache-policy '*'; then
|
||||
zstyle ":completion:${curcontext%:*}:values" cache-policy _sysrc_caching_policy
|
||||
fi
|
||||
|
||||
if _cache_invalid sysrc/rc_conf_vars ||
|
||||
! _retrieve_cache sysrc/rc_conf_vars; then
|
||||
|
||||
_call_program sysrc-cmd sysrc -A$opt | while read -r k v; do
|
||||
[[ $k = DEBUG* ]] && continue
|
||||
if [[ -z $v ]]; then
|
||||
rc_conf_vars+=( ${k%:} )
|
||||
else
|
||||
rc_conf_vars+=( "${k%:}[${${v//]/\\]}//:/\\:}]" )
|
||||
fi
|
||||
v=
|
||||
done
|
||||
|
||||
_store_cache sysrc/rc_conf_vars rc_conf_vars
|
||||
fi
|
||||
|
||||
if (( $#rc_conf_vars )); then
|
||||
if [[ $opt == N ]]; then
|
||||
_values -w -C variable ${^rc_conf_vars%%\[*}'::value'
|
||||
else
|
||||
_values -w -C variable ${^rc_conf_vars}'::value'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_sysrc "$@"
|
21
Completion/Linux/Command/_gpasswd
Normal file
21
Completion/Linux/Command/_gpasswd
Normal file
|
@ -0,0 +1,21 @@
|
|||
#compdef gpasswd
|
||||
local curcontext=$curcontext state state_descr line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -w -s \
|
||||
'(-a --add -d --delete)'{-a,--add}'[add user to group]: : _users' \
|
||||
'(-d --delete -a --add)'{-d,--delete}'[remove user from group]: : _users' \
|
||||
'(-h --help)'{-h,--help}'[display help]' \
|
||||
'(-Q --root)'{-Q,--root}'[directory to chroot into]: : _files -/' \
|
||||
'(-r --remove-password)'{-r,--remove-password}'[remove the group password]' \
|
||||
'(-R --restrict)'{-R,--restrict}'[restrict access to GROUP to its members]' \
|
||||
'(-M --members -A --administrators)'{-M,--members}'[set the list of members of GROUP]: :->users' \
|
||||
'(-A --administrators -M --members)'{-A,--administrators}'[set the list of admins for GROUP]: :->users' \
|
||||
'1: : _groups'
|
||||
|
||||
if [[ $state == users ]]; then
|
||||
local -a ignore
|
||||
compset -P '*,'; compset -S ',*'
|
||||
ignore=( ${(s:,:)IPREFIX} ${(s:,:)ISUFFIX} )
|
||||
_users -F ignore -qS ,
|
||||
fi
|
10
Completion/Linux/Command/_htop
Normal file
10
Completion/Linux/Command/_htop
Normal file
|
@ -0,0 +1,10 @@
|
|||
#compdef htop
|
||||
|
||||
_arguments -S : \
|
||||
'(-d --delay)'{-d+,--delay=}'[update frequency]:duration' \
|
||||
'(-C --no-color --no-colour)'{-C,--no-colo{,u}r}'[monochrome mode]' \
|
||||
'(-h --help)'{-h,--help}'[display help]' \
|
||||
'(-p --pid)'{-p+,--pid=}'[show given pids]: : _sequence -n ${$(</proc/sys/kernel/pid_max)\:-32768} _pids' \
|
||||
'(-s --sort-key)'{-s+,--sort-key=}'[sort by key]:key:( ${(f)"$($service --sort-key help)"} )' \
|
||||
'(-u --user)'{-u+,--user=}'[show processes of user]: : _users' \
|
||||
'(-v --version)'{-v,--version}'[print version information]'
|
14
Completion/Linux/Command/_kpartx
Normal file
14
Completion/Linux/Command/_kpartx
Normal file
|
@ -0,0 +1,14 @@
|
|||
#compdef kpartx
|
||||
|
||||
_arguments -s -w : \
|
||||
'-a[add partition mappings]' \
|
||||
'-r[read-only partition mappings]' \
|
||||
'-d[delete partition mappings]' \
|
||||
'-u[update partition mappings]' \
|
||||
'-l[list partition mappings]' \
|
||||
'-p[set device name-partition number delimiter]' \
|
||||
'-f[force creation of mappings]' \
|
||||
'-g[force GUID partition table]' \
|
||||
'-v[Operate verbosely]' \
|
||||
'-s[don'\''t return until the partitions are created]' \
|
||||
'1: : _files'
|
101
Completion/Unix/Command/_top
Normal file
101
Completion/Unix/Command/_top
Normal file
|
@ -0,0 +1,101 @@
|
|||
#compdef top
|
||||
|
||||
local specs fields
|
||||
|
||||
case $OSTYPE in
|
||||
*linux*)
|
||||
fields=(
|
||||
'%CPU:CPU usage' '%MEM:memory usage (res)' 'CGROUPS:control groups'
|
||||
'CODE:code size' 'COMMAND:Commane name/line' 'DATA:data + stack size'
|
||||
'ENVIRON:environment variables' 'Flags:task flags' 'GID:group id'
|
||||
'GROUP:group name' 'NI:nice value' 'P:last used CPU (SMP)'
|
||||
'PGRP:process group id' 'PID:process id' 'PPID:parent pid' 'PR:priority'
|
||||
'RES:resident memory size' 'RUID:real user id' 'RUSER:real uid'
|
||||
'S:process status' 'SHR:shared memory size' 'SID:session id'
|
||||
'SUID:saved uid' 'SUPGIDS:supplementary gids'
|
||||
'SUPGRPS:supplementary group names' 'SUSER:saved username'
|
||||
'SWAP:swapped sized' 'TGID:thread gid' 'TIME:CPU time'
|
||||
'TIME+:CPU time (hundredths)' 'TPGID:TTY gid' 'TTY:controlling TTY'
|
||||
'UID:user id' 'USED:memory in use' 'USER:user name'
|
||||
'VIRT:virtual memory size' 'WCHAN:sleeping in function'
|
||||
'nDRT:dirty pages count' 'nMaj:major page count' 'nMin:minor page count'
|
||||
'nTH:number of threads' 'nsIPC:IPC namespace' 'nsMNT:MNT namespace'
|
||||
'nsNET:NET namespace' 'nsPID:PID namespace' 'nsUSER:USER namespace'
|
||||
'nsUTS:UTS namespace' 'vMj:major page fault count delta'
|
||||
'vMn:minor page fault count delta'
|
||||
)
|
||||
specs=(
|
||||
'(-v -h)-'{h,v}'[show version and usage]'
|
||||
'-b[batch mode]'
|
||||
'-c[command line/program name toggle]'
|
||||
'-d[delay time interval]:interval'
|
||||
'-H[threads mode operation]'
|
||||
'-i[idle process toggle]'
|
||||
'-n[number of iterations]:number of iterations'
|
||||
'-o[override sort field]:fieldname:(( $fields ))'
|
||||
'-O[output field names]'
|
||||
'*-p[monitor pids]: :_pids'
|
||||
'-s[secure mode operation]'
|
||||
'-S[cumulative time toggle]'
|
||||
'(-U)-u[effective user filter mode]: :_users'
|
||||
'(-u)-U[user filter mode]: :_users'
|
||||
'-w[output width override]:number'
|
||||
);;
|
||||
freebsd*)
|
||||
specs=(
|
||||
'-C[CPU display mode]'
|
||||
'-S[show system processes]'
|
||||
'-a[display command names via argv]'
|
||||
'-b[batch mode]'
|
||||
'-H[display individual threads]'
|
||||
'-i[interactive mode]'
|
||||
'-I[do not display idle processes]'
|
||||
'-j[display the jail ID]'
|
||||
'-t[do not display the top process]'
|
||||
'-m+[statistic type]:type:(( cpu\:default io ))'
|
||||
'-n[non-interactive mode]'
|
||||
'-P[per-cpu CPU usage statistics]'
|
||||
'-q[renice top to -20]'
|
||||
'-u[do not translate uid to name]'
|
||||
'-v[write version number]'
|
||||
'-z[no not display system idle process]'
|
||||
'-d+[number of iterations]:count:'
|
||||
'-s+[set delay interval]:interval:'
|
||||
'-o+[sort process display by field]:field:(
|
||||
cpu size res time pri threads total read
|
||||
write fault vcsw ivcsw jid pid
|
||||
)'
|
||||
'-J+[show processes owned by jail]:jail:_jails -0'
|
||||
'-U+[show processes owned by username]: :_users'
|
||||
'1: : _message "top number of processes"'
|
||||
);;
|
||||
openbsd*)
|
||||
specs=(
|
||||
'-1[combine CPU statistic into one line]'
|
||||
'-b[batch mode]'
|
||||
'-C[show command arguments as well and process name]'
|
||||
'-d[number of iterations]:number of iterations'
|
||||
'-g[filter processes by string]:string'
|
||||
'-H[display process threads]'
|
||||
'-I[do not display idle processes]'
|
||||
'-i[interactive mode]'
|
||||
'-n[non-interactive mode]'
|
||||
'-o[sort display by field]:field:(
|
||||
cpu size res time pri pid command
|
||||
)'
|
||||
'-p[filter by pid]: :_pids'
|
||||
'-q[renice top to -20]'
|
||||
'-S[show system processes]'
|
||||
'-s[delay time interval]:interval'
|
||||
'-U[filter processes by user]: :_users -M "L\:|-="'
|
||||
'-u[do not map uid to usernames]'
|
||||
'1: : _message "top number of processes"'
|
||||
);;
|
||||
esac
|
||||
|
||||
if (( $#specs )); then
|
||||
_arguments -s -w : "$specs[@]"
|
||||
return
|
||||
fi
|
||||
|
||||
_normal
|
18
Completion/Unix/Command/_tput
Normal file
18
Completion/Unix/Command/_tput
Normal file
|
@ -0,0 +1,18 @@
|
|||
#compdef tput
|
||||
local -a args
|
||||
|
||||
case $OSTYPE in
|
||||
*linux*)
|
||||
args=(
|
||||
- set1
|
||||
'-S[allows more than one capability per invocation of tput]'
|
||||
- set2
|
||||
'-V[reports the version of ncurses used for tput]'
|
||||
)
|
||||
esac
|
||||
|
||||
_arguments : \
|
||||
$args - set3 \
|
||||
'(-S -V)-T+[terminal type]:terminal type:_terminals' \
|
||||
'1:terminal capabilities:( init reset longname ${(k)terminfo} )' \
|
||||
'*:capability parameters:{ [[ $words[1] != (init|reset|longname) ]] && _message parameter }'
|
|
@ -13,6 +13,10 @@ _zpool() {
|
|||
upgrade history get set split help
|
||||
)
|
||||
|
||||
if [[ $implementation = openzfs ]] && [[ $OSTYPE != solaris* ]]; then
|
||||
subcmds+=(labelclear)
|
||||
fi
|
||||
|
||||
versions=(
|
||||
${${${(M)"${(f)$(_call_program versions zpool upgrade -v)}":#[[:space:]]#<->*}##[[:space:]]}%%[[:space:]]*}
|
||||
)
|
||||
|
@ -164,6 +168,12 @@ _zpool() {
|
|||
'::count:'
|
||||
;;
|
||||
|
||||
(labelclear)
|
||||
_arguments -A "-*" \
|
||||
'-f[treat exported or foreign devices as inactive]' \
|
||||
'*:virtual device:_files'
|
||||
;;
|
||||
|
||||
(status)
|
||||
_arguments -A "-*" \
|
||||
'-l[Display configuration in /dev/chassis location form]' \
|
||||
|
|
Loading…
Reference in a new issue