about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:55:42 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:55:42 +0000
commit68186e49beeb2d58140eeb43407f6760cdfd75bf (patch)
tree43895a8d5754976770388cf14688806633e0a7c4 /Completion
parent4759597e0de9eca42af0139d18d3d71696df694e (diff)
downloadzsh-68186e49beeb2d58140eeb43407f6760cdfd75bf.tar.gz
zsh-68186e49beeb2d58140eeb43407f6760cdfd75bf.tar.xz
zsh-68186e49beeb2d58140eeb43407f6760cdfd75bf.zip
moved from Completion/User/_lp
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_lp52
1 files changed, 52 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp
new file mode 100644
index 000000000..49f9b6cf6
--- /dev/null
+++ b/Completion/Unix/Command/_lp
@@ -0,0 +1,52 @@
+#compdef lp lpr lpq lprm
+
+local expl ret=1 printer list disp strs shown
+
+if compset -P -P || [[ "$words[CURRENT-1]" = -P ]]; then
+  _printers
+else
+  if [[ "$service" = (lpq|lprm) ]]; then
+    if [[ "$words" = *-P* ]]; then
+      printer=(-P "${${words##*-P( |)}%% *}")
+    else
+      printer=()
+    fi
+    list=( ${(M)"${(f@)$(_call_program jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
+
+    if (( $#list )); then
+      _tags users jobs
+
+      while _tags; do
+        if _requested users; then
+          strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
+          if [[ -z "$shown" ]] &&
+             zstyle -T ":completion:${curcontext}:users" verbose; then
+            disp=(-ld list)
+  	  shown=yes
+          else
+  	  disp=()
+          fi
+	  _all_labels users expl user compadd "$disp[@]" -a strs ||
+              _users && ret=0
+        fi
+        if _requested jobs; then
+          strs=( "${(@)${(@)list##[^ 	]##[ 	]##[^ 	]##[ 	]##[^ 	]##[ 	]##}%%[ 	]*}" )
+          if [[ -z "$shown" ]] &&
+             zstyle -T ":completion:${curcontext}:jobs" verbose; then
+            disp=(-ld list)
+  	  shown=yes
+          else
+  	  disp=()
+          fi
+          _all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
+        fi
+        (( ret )) || return 0
+      done
+    else
+      _message 'no print jobs'
+    fi
+    return 1
+  else
+    _ps
+  fi
+fi