From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: help with command completion
Date: Wed, 5 Jan 2000 14:42:54 +0100 (MET) [thread overview]
Message-ID: <200001051342.OAA10929@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Shao Zhang's message of Wed, 5 Jan 2000 13:08:29 +1100
[ This one moved to zsh-workers... ]
Shao Zhang wrote:
> lpr -P[TAB] complets to a list a printer name, read from
> /etc/printcap.
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.
Bye
Sven
P.S.: On top of Alexandre's _prcs.
diff -ru ../z.old/Completion/User/.distfiles Completion/User/.distfiles
--- ../z.old/Completion/User/.distfiles Wed Jan 5 14:38:27 2000
+++ Completion/User/.distfiles Wed Jan 5 14:38:30 2000
@@ -2,7 +2,7 @@
.distfiles
_a2ps _archie _bison _bunzip2 _bzip2 _chown _compress _configure _cvs
_dd _dir_list _dirs _dvi _find _flex _gcc _gdb _gprof _groups _gs
- _gunzip _gv _gzip _hosts _ispell _killall _lynx _mailboxes _make _man
+ _gunzip _gv _gzip _hosts _ispell _killall _lp _lynx _mailboxes _make _man
_mh _mount _mutt _my_accounts _netscape _nslookup _other_accounts
_pack _patch _pbm _pdf _perl_basepods _perl_builtin_funcs
_perl_modules _perldoc _ports _prcs _prompt _ps _pspdf _rcs _rlogin _sh
diff -ru ../z.old/Completion/User/_lp Completion/User/_lp
--- ../z.old/Completion/User/_lp Wed Jan 5 14:38:45 2000
+++ Completion/User/_lp Wed Jan 5 14:36:18 2000
@@ -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
diff -ru ../z.old/Completion/User/_ps Completion/User/_ps
--- ../z.old/Completion/User/_ps Tue Jan 4 14:57:55 2000
+++ Completion/User/_ps Wed Jan 5 13:43:06 2000
@@ -1,4 +1,4 @@
-#compdef ps2epsi ps2pdf epsffit extractres fixdlsrps fixfmps fixmacps fixpsditps fixpspps fixscribeps fixtpps fixwfwps fixwpps fixwwps includeres psbook psmerge psnup psresize psselect pstops psmulti pswrap lpr lp
+#compdef ps2epsi ps2pdf epsffit extractres fixdlsrps fixfmps fixmacps fixpsditps fixpspps fixscribeps fixtpps fixwfwps fixwpps fixwwps includeres psbook psmerge psnup psresize psselect pstops psmulti pswrap
local expl
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-01-05 13:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-05 13:42 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-01-05 14:37 Sven Wischnowsky
2000-01-05 5:09 Shao Zhang
2000-01-05 2:08 Shao Zhang
1999-12-21 4:59 Shao Zhang
1999-12-21 9:48 ` Alexandre Duret-Lutz
1999-12-22 0:01 ` Shao Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200001051342.OAA10929@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).