summary refs log tree commit diff
path: root/Completion/User
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-01-05 14:14:46 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-01-05 14:14:46 +0000
commitecb3f734a7c5a801bf02e8b694d462c004abce03 (patch)
tree4a4ddd2e87a8237227aa0be2e1f47a4cd3224f28 /Completion/User
parent04dfb080a546b730fd21b892b7247656bd135f48 (diff)
downloadzsh-ecb3f734a7c5a801bf02e8b694d462c004abce03.tar.gz
zsh-ecb3f734a7c5a801bf02e8b694d462c004abce03.tar.xz
zsh-ecb3f734a7c5a801bf02e8b694d462c004abce03.zip
Initial revision
Diffstat (limited to 'Completion/User')
-rw-r--r--Completion/User/_lp58
1 files changed, 58 insertions, 0 deletions
diff --git a/Completion/User/_lp b/Completion/User/_lp
new file mode 100644
index 000000000..f37c62a14
--- /dev/null
+++ b/Completion/User/_lp
@@ -0,0 +1,58 @@
+#compdef lp lpr lpq lprm
+
+local file expl ret=1 list disp strs shown
+
+if (( ! $+_lp_cache )); then
+   file=( /etc/(printcap|printers.conf)(N) )
+
+  if (( $#file )); then
+    _lp_cache=( "${(@)${(@s:|:)${(@)${(@f)$(< $file[1])}:#[    \#]*}%%:*}%%[ 	]*}" )
+  else
+    # Default value. Could probably be improved
+
+    _lp_cache=( lp0 )
+  fi
+fi
+
+if compset -P -P || [[ "$words[CURRENT-1]" = -P ]]; then
+  _wanted printers expl printer && compadd "$expl" - "$_lp_cache[@]"
+else
+  if [[ "$words[1]" = (lpq|lprm) ]]; then
+    list=( "${(@M)${(f@)$(lpq)}:#[0-9]*}" )
+
+    if (( $#list )); then
+      _tags users jobs
+
+      while _tags; do
+        if _requested users expl user; then
+          strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
+          if [[ -z "$shown" ]] &&
+             zstyle -t ":completion:${curcontext}:users" verbose; then
+            disp=(-ld list)
+  	  shown=yes
+          else
+  	  disp=()
+          fi
+          compadd "$expl[@]" "$disp[@]" - "$strs[@]" || _users && ret=0
+        fi
+        if _requested jobs expl job; then
+          strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
+          if [[ -z "$shown" ]] &&
+             zstyle -t ":completion:${curcontext}:jobs" verbose; then
+            disp=(-ld list)
+  	  shown=yes
+          else
+  	  disp=()
+          fi
+          compadd "$expl[@]" "$disp[@]" - "$strs[@]" && ret=0
+        fi
+        (( ret )) || return 0
+      done
+    else
+      _message 'no print jobs'
+    fi
+    return 1
+  else
+    _ps
+  fi
+fi