1#compdef enscript 2 3local curcontext="$curcontext" state line match 4typeset -A opt_args 5local -a libpath 6 7_arguments -C -s -S \ 8 '( -2 --columns)-1' \ 9 '(-1 --columns)-2' \ 10 '(-1 -2 )--columns=:columns:' \ 11 '(--pages)-a+:pages:(even odd)' \ 12 '(-a)--pages=:pages:(even odd)' \ 13 '(--file-align)-A+:align:' \ 14 '(-A)--file-align=:align:' \ 15 '(--header -b -B --no-header --lineprinter -l)'{-b+,--header=}':page header:->formats' \ 16 '(--header -b -B --no-header --lineprinter -l)'{-B,--no-header} \ 17 '(--truncate-lines)-c' \ 18 '(-c)--truncate-lines' \ 19 '(--line-numbers -C)'{-C-,--line-numbers=-}'::start line [1]' \ 20 '(--printer -d )-P+:printer name: _printers' \ 21 '(--printer -P)-d+:printer name: _printers' \ 22 '( -d -P)--printer=:printer name: _printers' \ 23 '*-D+:key\:value:' \ 24 '*--setpagedevice=:key\:value:' \ 25 '(--escapes)-e-:escape character:' \ 26 '(-e)--escapes=-:escape character:' \ 27 '(-E --highlight)'{-E-,--highlight=-}':input language:->inputlang' \ 28 '(--font -f)'{-f+,--font=}':fontname:->fonts' \ 29 '(--header-font -F)'{-F+,--header-font=}':fontname:->fonts' \ 30 '(--print-anyway)-g' \ 31 '(-g)--print-anyway' \ 32 '(--fancy-header)-G' \ 33 '(-G)--fancy-header=:header:->headers' \ 34 '(--no-job-header)-h' \ 35 '(-h)--no-job-header' \ 36 '(--highlight-bars -H)'{-H-,--highlight-bars=-}'::height (lines) [2]' \ 37 '(--indent -i)'{-i+,--indent=}':indent width' \ 38 '(--filter -I)'{-I+,--filter=}':input filter:_cmdstring' \ 39 '(--borders)-j' \ 40 '(-j)--borders' \ 41 '(-k --page-prefeed -K --no-page-prefeed)'{-k,--page-prefeed} \ 42 '!(-k --page-prefeed -K --no-page-prefeed)'{-K,--no-page-prefeed} \ 43 '(--lineprinter -l --lines-per-page -L --header -b -B --no-header)'{-l,--lineprinter} \ 44 '(--lines-per-page -L --lineprinter -l)'{-L+,--lines-per-page=}':lines per page' \ 45 '(--mail)-m' \ 46 '(-m)--mail' \ 47 '(--media)-M+:media name:(A4)' \ 48 '(-M)--media=:media name:(A4)' \ 49 '(--copies -n )-#+:number of copies:' \ 50 '(--copies -#)-n+:number of copies:' \ 51 '( -n -#)--copies=:number of copies:' \ 52 '(--newline)-N+:newline type:((n\:unix r\:mac))' \ 53 '(-N)--newline=:newline type:((n\:unix r\:mac))' \ 54 '(-o -p --output -p)'{-o+,-p+,--output=}':output file:_files' \ 55 '(--missing-characters)-O' \ 56 '(-O)--missing-characters' \ 57 '(--quiet --silent)-q' \ 58 '(-q --silent)--quiet' \ 59 '(-q --quiet)--silent' \ 60 '(-r --landscape -R --portrait)'{-r,--landscape} \ 61 '(-r --landscape -R --portrait)'{-R,--portrait} \ 62 '(--baselineskip -s)'{-s+,--baselineskip=}':baseline skip (PostScript points) [1]' \ 63 '*-S+:key\:value:' \ 64 '*--statusdict=:key\:value:' \ 65 '(--title -t )-J+:banner title:' \ 66 '(--title -J)-t+:banner title:' \ 67 '( -t -J)--title=:banner title:' \ 68 '(--tabsize -T)'{-T+,--tabsize=}':tabsize [8]' \ 69 '(--underlay)-u-:underlay text:' \ 70 '(-u)--underlay=-:underlay text:' \ 71 '(--nup)-U+:pages:(4)' \ 72 '(-U)--nup=:pages:(4)' \ 73 '(--verbose)-v' \ 74 '(-v)--verbose=-:level:' \ 75 '(- *)'{-V,--version} \ 76 '(-w --language)'{-w-,--language=}':output language:(PostScript html overstrike rtf)' \ 77 '(-W --option)'{-W-,--option=}':helper option' \ 78 '(--encoding)-X+:character encoding:(88591 latin1 88592 latin2 88593 latin3 88594 latin4 88595 cyrillic 88597 greek 88599 latin5 885910 latin6 ascii asciifise asciifi asciise asciidkno asciidk asciino ibmpc pc dos mac vms hp8 koi8 ps PS pslatin1 ISOLatin1Encoding)' \ 79 '(-X)--encoding=:character encoding:(88591 latin1 88592 latin2 88593 latin3 88594 latin4 88595 cyrillic 88597 greek 88599 latin5 885910 latin6 ascii asciifise asciifi asciise asciidkno asciidk asciino ibmpc pc dos mac vms hp8 koi8 ps PS pslatin1 ISOLatin1Encoding)' \ 80 '(--no-formfeed)-z' \ 81 '(-z)--no-formfeed' \ 82 '(--pass-through)-Z' \ 83 '(-Z)--pass-through' \ 84 '--color=-:use color:(false true)' \ 85 '--continuous-page-numbers' \ 86 '--download-font=:fontname:' \ 87 '--extended-return-values' \ 88 '--filter-stdin=:stdin name:(-)' \ 89 '--footer=:page footer:->formats' \ 90 '--h-column-height=:horizontal column height:' \ 91 '(- *)--help' \ 92 '(- *)--help-highlight' \ 93 '--highlight-bar-gray=:gray level (0-1):' \ 94 '--list-media' \ 95 '--margins=:left\:right\:top\:bottom:' \ 96 '--mark-wrapped-lines=-:wrapped line style [none]:(none plus box arrow)' \ 97 '--non-printable-format=:rendering of non-printable characters:(caret octal questionmark space)' \ 98 '--nup-columnwise' \ 99 '--nup-xpad=:x-padding [10]' \ 100 '--nup-ypad=:y-padding [10]' \ 101 '--page-label-format=:page label format:(short long)' \ 102 '--ps-level=:PostScript language level:(1 2)' \ 103 '--printer-options=:extra options:' \ 104 '--rotate-even-pages' \ 105 '--slice=:vertical slice number' \ 106 '--style=:highlighting style:(a2ps emacs emacs_verbose ifh msvc)' \ 107 '--swap-even-page-margins' \ 108 '--toc' \ 109 '--word-wrap' \ 110 '--ul-angle=:angle' \ 111 '--ul-font=:fontname [Times-Roman200]:->fonts' \ 112 '--ul-gray=:gray level (0..1) [.8]' \ 113 '--ul-position=:position [+0+0 -0-0]' \ 114 '--ul-style=:style [outline]:(outline filled)' \ 115 '*:filename:_files' && return 0 116 117case "$state" in 118 fonts) 119 if compset -P 1 '*@'; then 120 _message -e size 'pointsize, optionally width/height' 121 else 122 libpath=( {${commands[enscript]:h:h},/usr}/share/enscript/afm/font.map(N) ) 123 _wanted fonts expl font compadd -qS @ - ${${(f)"$(<$libpath[1])"}%% *} 124 fi 125 ;; 126 formats) 127 local -a specs 128 local suf='{' 129 compquote suf 130 if [[ ${PREFIX} = *[%$]D${suf}[^}]# ]]; then 131 _strftime 132 elif [[ ${(Q)PREFIX} = *\$\([^\)]# ]]; then 133 compset -P '*\(' 134 _parameters -g '*export*' -S '\)' 135 elif [[ ${(Q)PREFIX} = *\$ ]]; then 136 specs=( 137 '$:a dollar symbol' 138 '%:current page number' 139 '=:number of pages in the current file' 140 'p:number of pages processed so far' 141 {C,\*}':file modification time (hh:mm:ss)' 142 'n:basename of the input file name' 143 'N:full input file name' 144 'E:file modification date (yy/mm/dd)' 145 'F:file modification date (dd.mm.yyyy)' 146 't:file modification time (12-hour)' 147 'T:file modification time (24-hour)' 148 'v:sequence number of current input file' 149 'V:sequence number of current input file in table of contents format' 150 'W:file modification date (mm/dd/yy)' 151 '\(:environment variable' 152 ) 153 compset -P "*" 154 _describe -t format-specifiers 'format specifier' specs -S '' -- '( D:modification\ date )' -qS $suf 155 elif [[ ${(Q)PREFIX} = *% ]]; then 156 specs=( 157 'c:trailing component of the current working directory' 158 {C,\*}':current time (hh:mm:ss)' 159 'E:current date (yy/mm/dd)' 160 'F:current date (dd.mm.yyyy)' 161 'H:document title' 162 'L:lines in the input file' 163 'm:hostname in short form' 164 'M:hostname in fully qualified form' 165 'n:user login name' 166 'N:user gecos field first component' 167 't:current time (12-hour)' 168 'T:current time (24-hour)' 169 'W:current date (mm/dd/yy)' 170 ) 171 compset -P "*" 172 _describe -t format-specifiers 'format specifier' specs -S '' -- '( D:current\ time )' -qS $suf 173 else 174 compset -P "*" 175 _wanted format-specifiers expl 'format specifier' compadd -S '' % \$ 176 fi 177 ;; 178 headers) 179 libpath=( {${commands[enscript]:h:h},/usr}/share/enscript(N/) ~/.enscript(N/) ) 180 _wanted headers expl header compadd $^libpath/*.hdr(N:r:t) 181 ;; 182 inputlang) 183 if (( ! $+_cache_enscript_languages )); then 184 typeset -ga _cache_enscript_languages 185 _cache_enscript_languages=(${${(f)${(F)${(M)${(f)"$(_call_program languages enscript --help-pretty-print)"}:#(Name|Description):*}}//(#b)Name: ([^ 186]##)( 187Description: ([^ 188]##)|)/$match[1]:$match[3]}%:}) 189 fi 190 _describe -t languages 'input language' _cache_enscript_languages 191 ;; 192esac 193