Rewrite Zsh completion
authorSteve Youngs <steve@sxemacs.org>
Fri, 14 Feb 2014 03:39:20 +0000 (13:39 +1000)
committerSteve Youngs <steve@sxemacs.org>
Fri, 14 Feb 2014 03:39:20 +0000 (13:39 +1000)
* etc/pkgusr/zsh/_zsh-pkgtools: Rewrite.  User completion is done
on _JUST_ the package users and not all users.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
etc/pkgusr/zsh/_zsh-pkgtools

index ac71782..769106e 100644 (file)
@@ -1,9 +1,27 @@
-#compdef ppkg cpkg dpkg upkg vpkg ipkg gpkg wpkg pkgrepo pkgsu pkgwant xtar vtar
+#compdef cpkg dpkg fpkg gpkg ipkg ppkg upkg vpkg wpkg pkgrepo pkgsu pkgwant vtar xtar
 
-case $service in
-        (cpkg) _command_names -e ;;
-        (?pkg) _wanted file expl 'Pkg User' _users ;;
-        (pkgrepo|pkgsu|pkgwant) _wanted file expl 'Pkg User' _users ;;
-        ([xv]tar) _wanted file expl 'Tarball' _files -g '*.{t{gz,bz{,2},lz,xz},tar.{Z,gz,bz2,lzma,xz}}(-.)' ;;
-esac
+_pkgtools_users()
+{
+    compadd "$@" - $(awk -F: '/^install/ {print $4;}' /etc/group|tr -s , ' ')
+}
 
+_zsh-pkgtools()
+{
+    local curcontext="$curcontext" state line expl
+    typeset -A opt_args
+
+    case $service in
+            (cpkg) _command_names -e ;;
+       (?pkg|pkg*) _arguments -C -s ':Package User:_pkgtools_users' ;;
+         ([xv]tar) _wanted file expl 'Tarball' _files -g \
+             '*.{t{gz,bz{,2},lz,xz},tar.{Z,gz,bz2,lzma,xz}}(-.)' ;;
+    esac
+}
+
+_zsh-pkgtools "$@"
+
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 4
+# sh-basic-offset: 4
+# End: