From: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: [PATCH] improve _nice
Date: Mon, 4 Sep 2023 15:32:38 +0900 [thread overview]
Message-ID: <BED23B2A-EF3C-49C4-B85C-D90839A5053D@kba.biglobe.ne.jp> (raw)
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
reply other threads:[~2023-09-04 6:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BED23B2A-EF3C-49C4-B85C-D90839A5053D@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).