Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: New completions
- X-seq: zsh-workers 6709
- From: "Kiddle, Oliver" <KiddleO@xxxxxxxxxx>
- To: "'zsh-workers@xxxxxxxxxxxxxx'" <zsh-workers@xxxxxxxxxxxxxx>
- Subject: PATCH: New completions
- Date: Fri, 18 Jun 1999 10:30:48 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author