diff options
author | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2023-09-07 22:37:16 +0900 |
---|---|---|
committer | Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> | 2023-09-07 22:37:16 +0900 |
commit | d82ea848bf1350c5f0d668801ff9355ac4e0ad7f (patch) | |
tree | b8511f8ebefe556427618dae07e252edf97b28ae | |
parent | e3c2af216b1f77202ef5240179dabcf4aab66f91 (diff) | |
download | zsh-d82ea848bf1350c5f0d668801ff9355ac4e0ad7f.tar.gz zsh-d82ea848bf1350c5f0d668801ff9355ac4e0ad7f.tar.xz zsh-d82ea848bf1350c5f0d668801ff9355ac4e0ad7f.zip |
52114: improve _nice
support -n option, complete only external commands
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Completion/Unix/Command/_nice | 27 |
2 files changed, 23 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index a4d2dfe2f..0b9ecfce3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-09-07 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 52114: Completion/Unix/Command/_nice: improve _nice (support + -n option, complete only external commands) + 2023-09-05 Bart Schaefer <schaefer@zsh.org> * 52115: Src/Modules/param_private.c, Test/V10private.ztst: permit diff --git a/Completion/Unix/Command/_nice b/Completion/Unix/Command/_nice index 29070697f..b52e5216a 100644 --- a/Completion/Unix/Command/_nice +++ b/Completion/Unix/Command/_nice @@ -1,14 +1,23 @@ #compdef nice -shift words -(( CURRENT-- )) +local -a specs=( '*:: : _normal -p $service' ) -if [[ $CURRENT -gt 1 && $words[1] = ([-+](-|)|-n)<-> ]]; then - shift words - (( CURRENT -- )) -elif [[ $CURRENT -gt 2 && $words[1] = -n ]]; then - shift 2 words - (( CURRENT -= 2 )) +# See if the 1st arg is such as -10 --10 or -+10 +if [[ $words[2] = -(-|+|)[0-9]## ]]; then + if (( $CURRENT == 2 )); then + _message 'niceness increment' && return + fi + compset -n 2 # Ignore the 1st arg +else + if _pick_variant gnu=GNU unix --version; then + specs+=( + '(-)'{-n+,--adjustment=}'[adjust niceness]:niceness increment' + '(* -)--help[display help and exit]' + '(* -)--version[output version information and exit]' + ) + else + specs+=( '-n+[specify increment of niceness]:niceness increment' ) + fi fi -_normal +_arguments : $specs |