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

host completion in _dput



Hi,
I modified _dput to get host completion.
I send you the diff in case other people find it useful.

arno.



--- /home/arno/debsrc/zsh-4.3.4/Completion/Debian/Command/_dput	2005-11-06 16:04:39.000000000 +0100
+++ zshfunc/_dput	2007-09-07 20:01:49.000000000 +0200
@@ -1,5 +1,18 @@
 #compdef dput
 
+
+ (( $+functions[_dput_hosts] )) ||
+_dput_hosts() {
+    emulate -L zsh
+    setopt extendedglob
+    local -a hosts
+    local match mbegin mend
+    for conff in /etc/dput.cf ~/.dput.cf; do
+        hosts+=(${${(M)"${(f)$(<$conff)}":#\[(*~DEFAULT)\][[:blank:]]#}/\[(#b)(*)\][[:blank:]]#/${match[1]}})
+    done
+    _wanted hosts expl 'hosts' compadd "$@" -a - hosts
+}
+
 _arguments \
   '(-c --config)'{-c,--config}'[specify config file]:config file:_files' \
   '(-d --debug)'{-d,--debug}'[debug mode]' \
@@ -11,4 +24,5 @@
   '(-s --simulate)'{-s,--simulate}'[simulate an upload only]' \
   '(-u --unchecked)'{-u,--unchecked}'[do not check GPG signature on the changes file]' \
   '(-v --version)'{-v,--version}'[show version information]' \
-  '*:changes file:_files -g "*.changes(-.)"'
+  '1: : _alternative "host:host:_dput_hosts" "files:change file:_files -g \*\.changes\(-\.\)"' \
+  '*:file:_files -g "*.changes(-.)"'

Attachment: signature.asc
Description: Digital signature



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