From eec9882d04661b1114e93b6bf6129453fae6f5a1 Mon Sep 17 00:00:00 2001 From: dana Date: Sun, 8 May 2022 01:32:04 -0500 Subject: 50176 (tweaked): Improve htop completion * Correct -v to -V * Make -u argument optional * Enable option stacking * Improve descriptions * Fix broken sort keys with htop 3.x and add new key descriptions * Remove _sequence limit on -p * Add several missing options + Fixed a typo and an erroneous comment in the original patch Thanks to GitHub user xpufx, whose work formed the initial basis of this change (see zsh-users/zsh pull #89) --- ChangeLog | 5 ++++ Completion/Linux/Command/_htop | 66 +++++++++++++++++++++++++++++++++++------- 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index efc9bdb1a..5c617aec3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-05-08 dana + + * 50176 (with xpufx, tweaked): Completion/Linux/Command/_htop: + Improve htop completion + 2022-05-07 Bart Schaefer * 50184: Completion/Base/Utility/_values: fix inclusion of -S diff --git a/Completion/Linux/Command/_htop b/Completion/Linux/Command/_htop index 28c7512bf..e8d2fffb1 100644 --- a/Completion/Linux/Command/_htop +++ b/Completion/Linux/Command/_htop @@ -1,11 +1,55 @@ -#compdef htop - -_arguments -S : \ - '(-d --delay)'{-d+,--delay=}'[update frequency]:duration (tenths of seconds)' \ - '(-C --no-color --no-colour)'{-C,--no-colo{,u}r}'[monochrome mode]' \ - '(-)'{-h,--help}'[display usage information]' \ - \*{-p+,--pid=}'[show given pids]: : _sequence -n ${$(sort-keys' + '(-t --tree)'{-t,--tree}'[show tree view of processes]' + '(-u --user)'{-u+,--user=}'[show only processes of current or specified user]:: : _users' + '(-U --no-unicode)'{-U,--no-unicode}'[disable Unicode]' + '(-)'{-V,--version}'[display version information]' +) + +[[ $OSTYPE == linux* ]] && +(( ! EUID || $+_comp_priv_prefix )) && +_pick_variant libcap=drop-capabilities $OSTYPE --help && +args+=( + '--drop-capabilities=-[drop specified capabilities]::mode [basic]:(( + off\:"do not drop capabilities" + basic\:"drop capabilities not needed for standard functionality (retains kill, renice, etc.)" + strict\:"drop capabilities not needed for core functionality" + ))' +) + +_arguments -s -S : $args && ret=0 + +case $state in + sort-keys) + tmp=( ${(f)"$(_call_program sort-keys $words[1] --sort-key help)"} ) + tmp=( ${tmp/#[[:space:]]##} ) + tmp=( ${tmp//:/\\:} ) + tmp=( ${tmp/[[:space:]]##/:} ) + tmp=( ${tmp/(#m):[A-Z]/${(L)MATCH}} ) + _describe -t sort-keys 'column (key)' tmp && ret=0 + ;; +esac + +return ret -- cgit 1.4.1