Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] improve _nice



Currently _nice dose not complete any options and
% nice -<TAB>
gives
% nice - <cursor here>
This is for skipping obsolete options such as -10.

With the patch below non-obsolete options are completed in the
above case. User can still specify the obsolete option manually.


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







Messages sorted by: Reverse Date, Date, Thread, Author