From 9cc6ebe7a2263e6697d497e95335369b06bec11b Mon Sep 17 00:00:00 2001 From: Eric Cook Date: Thu, 11 Feb 2016 22:53:16 -0500 Subject: 37913: add additional completers and _zpool improvement --- ChangeLog | 9 ++++ Completion/BSD/Command/_gstat | 11 +++++ Completion/BSD/Command/_sysrc | 77 +++++++++++++++++++++++++++++ Completion/Linux/Command/_gpasswd | 21 ++++++++ Completion/Linux/Command/_htop | 10 ++++ Completion/Linux/Command/_kpartx | 14 ++++++ Completion/Unix/Command/_top | 101 ++++++++++++++++++++++++++++++++++++++ Completion/Unix/Command/_tput | 18 +++++++ Completion/Unix/Command/_zpool | 10 ++++ 9 files changed, 271 insertions(+) create mode 100644 Completion/BSD/Command/_gstat create mode 100644 Completion/BSD/Command/_sysrc create mode 100644 Completion/Linux/Command/_gpasswd create mode 100644 Completion/Linux/Command/_htop create mode 100644 Completion/Linux/Command/_kpartx create mode 100644 Completion/Unix/Command/_top create mode 100644 Completion/Unix/Command/_tput diff --git a/ChangeLog b/ChangeLog index a6e3514fa..12be11c58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016-02-11 Eric Cook + + * 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 * 37946: Src/utils.c: make rm * warnings more informative about diff --git a/Completion/BSD/Command/_gstat b/Completion/BSD/Command/_gstat new file mode 100644 index 000000000..55b7db74d --- /dev/null +++ b/Completion/BSD/Command/_gstat @@ -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]' diff --git a/Completion/BSD/Command/_sysrc b/Completion/BSD/Command/_sysrc new file mode 100644 index 000000000..d8bc4ef0e --- /dev/null +++ b/Completion/BSD/Command/_sysrc @@ -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 "$@" diff --git a/Completion/Linux/Command/_gpasswd b/Completion/Linux/Command/_gpasswd new file mode 100644 index 000000000..9b4bedec6 --- /dev/null +++ b/Completion/Linux/Command/_gpasswd @@ -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 diff --git a/Completion/Linux/Command/_htop b/Completion/Linux/Command/_htop new file mode 100644 index 000000000..9a6133a86 --- /dev/null +++ b/Completion/Linux/Command/_htop @@ -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 ${$(*}##[[: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]' \ -- cgit 1.4.1