From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8073 invoked by alias); 8 Feb 2016 04:58:11 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37913 Received: (qmail 1169 invoked from network); 8 Feb 2016 04:58:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 From: Eric Cook To: zsh-workers@zsh.org Subject: [PATCH] Completion for gstat, sysrc, gpasswd, (h|)top kpartx tput and zpool improvement Date: Sun, 7 Feb 2016 23:57:59 -0500 Message-Id: <1454907479-4833-1-git-send-email-llua@gmx.com> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:+buzCto/Mcw2Kw8JYJVJ+LICru0mTJ4Kbcli+sWiwhF044LyP7p RlyIYYqZA1V9Sj6EeazV+R2nhdFocqNaVKmR96EJ8G9Nak3PTk4WsG4qSQZx29m+uTlZW30 hUeToPP62w6OXLRR5hzObd88pjABijBzPhLEdWAdtkIxr5Bvv2fzi4cnWPcpdJ8cHao7nla Az92QieHrMDNk5VLeW0vA== X-UI-Out-Filterresults: notjunk:1;V01:K0:DAsvcvm7Mek=:U3Iludbyt6UP25V8JHZ/5y BTcmGlw7PsDn/nSw+BxMmA0KUCI3MuTSB9uTTWj7AwziYvnaWMR5m1jeepuCc4FzdYHyP9wTK Giw8mRSrijUjFStRBT2QnnSvy/kFSujBQfRZdOWyTsZU329+q/C7wWm+p2mUldwh83Khbjb7R nlGruDSJptjx0ngi1VntrRanRSAwC0MPFnVstByQzaPAkIDsozZRcmGls/N/aAZUNWAdpb19e m4uaZqdeWdjPDeAz3ECyqtdWE9oEaqdQLXZIDkH31ZHLYN9kevUghCacihBi8c8BkX6GHDYmP p2tfw1lyCeJO3+uIuPG1dJ53/HjHyGiN1Fq8Fj5Lbb6YOWf/3LYwFwIcwprCMJthLc8IYi2Wv gnQhtgWN4ite6W/lUcCgLVYxKA6JmdhRI1kSR/Xgyidgsv1KqRMgEfNxrVG4ihrvhw6bl0xXm M3Y+vlWFf156KLaSChk0tyc8aUtXqn7+2RsbyhelTrdMeHwMrtCiLvP2vWXypP0MqMRCwK7Kn AeElzoeQl3ZqR5bdGJKwQUsmsZ7mdlgaWsMXERqwyRIqsRnCu6NPPP9IOUJRa3ZWICBeq54EH N/NvknmX7VmaZ0PBPnx+UoOWztSd+u6KH2YNc88nC3FqkNCld60Ikm3i1d2YiNHO6Kxbithdl 6iuKrZbD90bIO9AdGw5ud6PMkBi8nnjt/KJvxouOFfXc13+cKQfb7XOsZMy9YGSzWfJjGG/Ts NYmmN8GLvT2GYv+x6rrRAiZ1fDmWoxcA7d2gP/KZJwLmLkfsLl+/NOFHz6U= --- 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 ++++ 8 files changed, 262 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/Completion/BSD/Command/_gstat b/Completion/BSD/Command/_gstat new file mode 100644 index 0000000..55b7db7 --- /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 0000000..f115273 --- /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%:*}; 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}:" verbose; then + opt=d + else + opt=N + fi + + if ! zstyle -m ":completion:${curcontext}:*" cache-policy '*'; then + zstyle ":completion:${curcontext}:" cache-policy _sysrc_caching_policy + fi + + if _cache_invalid sysrc/rc_conf_vars || + ! _retrieve_cache sysrc/rc_conf_vars; then + + 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 0000000..9b4bede --- /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 0000000..9a6133a --- /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]' \ -- 2.7.0