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

Re: help with command completion



I wrote:

> [ This one moved to zsh-workers... ]

Ouch. But this time I really did that...

> Here is _lp for lpr, lp, lpq, and lprm. Could definitely be improved,
> but I don't know how (non-)standard the options supported by my lpr
> are.

I'm an idiot.

Bye
 Sven

diff -ru ../z.old/Completion/User/_lp Completion/User/_lp
--- ../z.old/Completion/User/_lp	Wed Jan  5 15:43:57 2000
+++ Completion/User/_lp	Wed Jan  5 15:53:36 2000
@@ -1,6 +1,6 @@
 #compdef lp lpr lpq lprm
 
-local file expl ret=1 list disp strs shown
+local file expl ret=1 printer list disp strs shown
 
 if (( ! $+_lp_cache )); then
    file=( /etc/(printcap|printers.conf)(N) )
@@ -18,7 +18,12 @@
   _wanted printers expl printer && compadd "$expl" - "$_lp_cache[@]"
 else
   if [[ "$words[1]" = (lpq|lprm) ]]; then
-    list=( "${(@M)${(f@)$(lpq)}:#[0-9]*}" )
+    if [[ "$words" = *-P* ]]; then
+      printer=(-P "${${words##*-P( |)}%% *}")
+    else
+      printer=()
+    fi
+    list=( ${(M)"${(f@)$(lpq $printer 2> /dev/null)}":#[0-9]*} )
 
     if (( $#list )); then
       _tags users jobs
diff -ru ../z.old/Doc/Zsh/compsys.yo Doc/Zsh/compsys.yo
--- ../z.old/Doc/Zsh/compsys.yo	Tue Jan  4 14:57:28 2000
+++ Doc/Zsh/compsys.yo	Wed Jan  5 15:45:11 2000
@@ -565,6 +565,9 @@
 item(tt(prefixes))(
 for prefixes (like those of an URL)
 )
+item(tt(printers))(
+for printer names
+)
 item(tt(processes))(
 for process identifiers
 )

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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