From: "Kiddle, Oliver" <KiddleO@logica.com>
To: "'zsh-workers@sunsite.auc.dk'" <zsh-workers@sunsite.auc.dk>
Subject: PATCH: New completions
Date: Fri, 18 Jun 1999 10:30:48 +0100 [thread overview]
Message-ID: <4FBF540FF16FD1119D9600A0C94B2B51F29E90@napier.logica.co.uk> (raw)
First, I've written a new-style completion for chown/chgrp. I've also
patched _x_options to complete hostnames after -display with a ':0' suffix.
The other patch (for _subscript) is a bit messy and can almost certainly be
improved. Basically it completes the index in an array by using -y to
supply a list of each array element. I find it very useful for pulling
single directories out of $manpath, $fpath etc.
Oliver Kiddle
diff -r -c Completion.old/Base/_subscript Completion/Base/_subscript
*** Completion.old/Base/_subscript Tue Apr 13 07:37:36 1999
--- Completion/Base/_subscript Fri Jun 18 09:54:46 1999
***************
*** 1,7 ****
--- 1,16 ----
#compdef -subscript-
+ local list i j
+
if [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then
compgen -S ']' -k "( ${(kP)${compstate[parameter]}} )"
+ elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
+ list=("$(for i in {1..${#${(P)${compstate[parameter]}}}}; do
+ typeset -L 5 j=$i
+ [ "${(P)${compstate[parameter]}[$i]}" ] && \
+ echo "$j ${(P)${compstate[parameter]}[$i]}"
+ done)")
+ compgen -S ']' -y '$list' -s '{1..${#${(P)${compstate[parameter]}}}}'
else
_compalso -math-
fi
diff -r -c Completion.old/User/_chown Completion/User/_chown
*** Completion.old/User/_chown Fri Jun 18 09:58:59 1999
--- Completion/User/_chown Fri Jun 18 09:55:12 1999
***************
*** 0 ****
--- 1,11 ----
+ #compdef chown chgrp
+
+ if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
+ if [[ $words[1] = chgrp ]] || compset -P '*.'; then
+ _groups
+ else
+ compgen -u -S '.' -q
+ fi
+ else
+ _files
+ fi
diff -r -c Completion.old/User/_groups Completion/User/_groups
*** Completion.old/User/_groups Fri Jun 18 10:00:03 1999
--- Completion/User/_groups Fri Jun 18 09:55:12 1999
***************
*** 0 ****
--- 1,6 ----
+ #compdef newgrp
+
+ : ${(A)groups:=${${(s: :)$(</etc/group)}%%:*}}
+ # : ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use NIS
+
+ compadd $groups
diff -r -c Completion.old/User/_x_options Completion/User/_x_options
*** Completion.old/User/_x_options Tue Apr 13 07:37:42 1999
--- Completion/User/_x_options Fri Jun 18 10:15:49 1999
***************
*** 2,5 ****
# A simple pattern completion, just as an example.
! compgen -J options -k '(-display -name -xrm)'
--- 2,9 ----
# A simple pattern completion, just as an example.
! if [ "$words[CURRENT-1]" = "-display" ]; then
! compgen -k hosts -S':0'
! else
! compadd -J options - -display -name -xrm
! fi
next reply other threads:[~1999-06-18 9:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-18 9:30 Kiddle, Oliver [this message]
1999-06-18 12:06 ` Tanaka Akira
1999-06-18 10:01 Sven Wischnowsky
1999-06-18 10:36 Sven Wischnowsky
1999-06-18 12:49 Kiddle, Oliver
1999-06-18 13:04 ` Falk Hueffner
1999-06-18 13:31 ` Tanaka Akira
1999-06-18 13:27 ` Tanaka Akira
2004-01-14 16:58 PATCH: new completions Oliver Kiddle
2004-01-15 7:33 ` Bart Schaefer
2004-01-15 9:41 ` Oliver Kiddle
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=4FBF540FF16FD1119D9600A0C94B2B51F29E90@napier.logica.co.uk \
--to=kiddleo@logica.com \
--cc=zsh-workers@sunsite.auc.dk \
/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).