1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-18 15:21:16 +02:00

52114: improve _nice

support -n option, complete only external commands
This commit is contained in:
Jun-ichi Takimoto 2023-09-07 22:37:16 +09:00
parent e3c2af216b
commit d82ea848bf
2 changed files with 23 additions and 9 deletions

View file

@ -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> 2023-09-05 Bart Schaefer <schaefer@zsh.org>
* 52115: Src/Modules/param_private.c, Test/V10private.ztst: permit * 52115: Src/Modules/param_private.c, Test/V10private.ztst: permit

View file

@ -1,14 +1,23 @@
#compdef nice #compdef nice
shift words local -a specs=( '*:: : _normal -p $service' )
(( CURRENT-- ))
if [[ $CURRENT -gt 1 && $words[1] = ([-+](-|)|-n)<-> ]]; then # See if the 1st arg is such as -10 --10 or -+10
shift words if [[ $words[2] = -(-|+|)[0-9]## ]]; then
(( CURRENT -- )) if (( $CURRENT == 2 )); then
elif [[ $CURRENT -gt 2 && $words[1] = -n ]]; then _message 'niceness increment' && return
shift 2 words fi
(( CURRENT -= 2 )) 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 fi
_normal _arguments : $specs