diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 2000-01-05 14:14:44 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 2000-01-05 14:14:44 +0000 |
commit | acc2cd6b9e4f39c8a81563d4ae93826aa4a334d8 (patch) | |
tree | 0ad9eeb8667238522f78e1b732ad02c87e407195 | |
parent | 4a7b67c55a0f3a30866dafa6e26faf14ab53941b (diff) | |
download | zsh-acc2cd6b9e4f39c8a81563d4ae93826aa4a334d8.tar.gz zsh-acc2cd6b9e4f39c8a81563d4ae93826aa4a334d8.tar.xz zsh-acc2cd6b9e4f39c8a81563d4ae93826aa4a334d8.zip |
zsh-users/2830
-rw-r--r-- | Completion/User/.distfiles | 2 | ||||
-rw-r--r-- | Completion/User/_lp | 58 | ||||
-rw-r--r-- | Completion/User/_ps | 2 |
3 files changed, 60 insertions, 2 deletions
diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles index c3f78d24d..3e9581878 100644 --- a/Completion/User/.distfiles +++ b/Completion/User/.distfiles @@ -2,7 +2,7 @@ DISTFILES_SRC=' .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 --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 diff --git a/Completion/User/_ps b/Completion/User/_ps index c8d1bd53a..751c1c680 100644 --- a/Completion/User/_ps +++ b/Completion/User/_ps @@ -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 |