initial checkin
[zsh-lovers.git] / refcard.tex
1 \documentclass{article}
2 % Needed for multiple column output:
3 \usepackage{multicol}
4 % Used to get a reasonable A4 size:
5 %\usepackage{a4wide}
6 \oddsidemargin 0.05 in
7 \evensidemargin 0.05 in
8 \marginparwidth 0.75 in
9 \voffset -0.6in
10 \hoffset -0.7in
11 \textheight 170 mm
12 \textwidth 280 mm
13
14 % Used for easy swapping to landscape:
15 %\usepackage{portland}
16 % Needed for easy redefinition of running headings/page style:
17 \usepackage{fancyheadings}
18 % Needed for boldsymbol (distinguishes sorts of square brackets):
19 \usepackage{amsmath}
20 %% % Needed for complex if-then-else structures as used in Lentry
21 %% \usepackage{ifthen}
22 %% \usepackage{calc}
23
24 \lhead{Page \rm\thepage}
25 \chead{Zsh Reference Card}
26 \rhead{zsh 3.0}
27 \cfoot{}
28
29 % Make the section command a little more manageable.
30 % This makes it look more like a normal subsection.
31 \makeatletter
32 \renewcommand{\section}{\@startsection
33   {section}%                          % name
34   {1}%                                % level
35   {0mm}%                              % indent
36   {-\baselineskip}%                   % beforeskip
37   {0.1pt}%                 % afterskip
38   {\normalfont\normalsize\scshape}} % style
39 \makeatother
40
41
42 % Command for environment that contains a piece of code.
43 \newcommand{\codelabel}[1]{\mbox{\textsl{#1}}\hfil}
44 \newenvironment{code}%
45 {\begin{list}{}{\renewcommand{\makelabel}{\codelabel}%
46     \setlength{\rightmargin}{0pt}%
47     \setlength{\leftmargin}{1em}}}%
48 {\end{list}}
49
50
51 \newcommand\B[1]{\textbf{#1}}
52 \newcommand\I[1]{\textsl{#1}}
53 \newcommand\T[1]{\texttt{#1}}
54
55 % Left/right square brackets in bold (actual text for syntax
56 % table, optional arguments in commands etc.)
57 \newcommand\Lsq{\ensuremath{\boldsymbol{[}}}
58 \newcommand\Rsq{\ensuremath{\boldsymbol{]}}}
59 % Left/right square brackets (indicates optional in syntax entries)
60 \newcommand\Lop{\ensuremath{[}}
61 \newcommand\Rop{\ensuremath{]}}
62 % Left/right curly brackets
63 \newcommand\Lcu{\ensuremath{\mathbf{\{}}}
64 \newcommand\Rcu{\ensuremath{\mathbf{\}}}}
65 % Left/right parentheses
66 \newcommand\Lpa{\textbf{(}}
67 \newcommand\Rpa{\textbf{)}}
68
69 % Dagger for marking things
70 \newcommand\D{$^\dag$}
71
72 \newlength{\codesep}
73 \setlength{\codesep}{1.5mm}
74
75 \parindent = 0pt
76 \raggedright
77
78 \begin{document}
79
80 % This is a bit simpler than using the portland package,
81 % and works with dvips.
82 \special{landscape}
83 %\landscape
84
85 \pagestyle{fancy}
86
87 \raggedcolumns
88 \setlength{\premulticols}{100pt}
89 %\setlength{\multicolsep}{20pt plus 6pt minus 4pt}
90 \begin{multicols}{3}[\section{Constructs}]
91
92 \I{List} is any sequence of commands separated by \B{;} or
93 \B{newline}, which are always interchangeable.
94 \medskip
95
96 \begin{code}
97 \item \B{if} \I{list}; \B{then} \I{list} \\
98 \Lop\ \B{elif} \I{list}; \B{then} \I{list} \Rop\ \dots \\
99 \Lop\ \B{else} \I{list} \Rop \\
100 \B{fi}
101
102 \item \B{for} \I{name} \Lop\ \B{in} \I{word \dots} \Rop \\
103 \B{do} \I{list} \\
104 \B{done}
105
106 \B{for} \I{name} \B{in} \I{word \dots}; \Lcu\ list \Rcu
107
108 \B{foreach} \I{name} \Lpa \I{word \dots}\Rpa \\
109 \I{list} \\
110 \B{end} \\
111
112 \item \B{while} \I{list}; \B{do} \I{list}; \B{done}
113
114 \B{until} \I{list}; \B{do} \I{list}; \B{done}
115
116 \item \B{repeat} \I{word}; \B{do} \I{list}; \B{done}
117
118 \B{repeat} \I{word} \I{sublist}
119
120 \item \B{case} \I{word} \B{in} \\
121 \Lop\ \I{pattern} \Rpa\ \I{list} ;; \Rop\ \dots \\
122 \B{esac}
123
124 \B{case} \I{word} \Lcu\ \Lop\ \I{pattern} \Rpa\ \I{list} ;; \Rop\ \dots \Rcu
125
126 \item \B{select} \I{name}
127   \Lop\ \B{in} \I{word} \dots \Rop; \B{do} \I{list};
128   done
129
130 \item[Subshell:] \Lpa\ \I{list} \Rpa
131
132 \item[Current shell:] \Lcu\ \I{list} \Rcu
133
134 \item \B{function} \I{word} \Lop\ \Lpa\Rpa\ \Rop\ \dots \Lcu\ \I{list}
135   \Rcu
136
137 \I{word} \dots \Lpa\Rpa\ \Lcu\ list \Rcu
138
139 \I{word} \dots \Lpa\Rpa\ \I{sublist}
140
141 \item \B{time} \Lop\ \I{pipeline} \Rop
142
143 \item[Condition:] \Lsq\Lsq\ \I{exp} \Rsq\Rsq
144 \end{code}
145
146 Other constructs depend on the options \B{NO\_\-SHORT\_\-LOOPS} and
147 \B{CSH\_\-JUNKIE\_\-LOOPS} and should be avoided in scripts.
148
149 \end{multicols}
150
151 %\begin{multicols}{3}[\section{Globbing}]
152 \section{Globbing}
153
154 See also options \B{GLOB}, \B{EXTENDED\_\-GLOB}, \B{KSH\_\-GLOB},
155 \B{NULL\_\-GLOB}, \B{NOMATCH}, \B{SH\_\-GLOB} \B{GLOB\_\-DOTS}. \texttt{X},
156 \texttt{Y}, \dots\ are any pattern. \verb!#! and \verb!##! require grouping
157 of previous characters; those and \verb!~!, \verb!^! require
158 \B{EXTENDED\_\-GLOB}.
159
160 % Due to setting verbatim text, use basic tabbing environment for following.
161 \begin{multicols}{3}
162 \begin{tabbing}
163 \hskip 40pt \= \kill
164 \verb!*!       \>  Any string \\
165 \verb!?!       \>  Any character \\
166 \verb![...]!   \>  Any of the enclosed characters \\
167 \verb![[:X:]]! \>  Character classes where X may be: \\
168 \verb! alnum!  \>  Alphanumeric, \\
169 \verb! alpha!  \>  Alphabetic, \\
170 \verb! blank!  \>  Space or tab, \\
171 \verb! cntrl!  \>  Control character, \\
172 \verb! digit!  \>  Decimal digit, \\
173 \verb! graph!  \>  Printable non-whitespace character, \\
174 \verb! lower!  \>  Lowercase character, \\
175 \verb! print!  \>  Printable character, \\
176 \verb! punct!  \>  Printable, not alnum or space, \\
177 \verb! space!  \>  Whitespace character, \\
178 \verb! upper!  \>  Uppercase character, \\
179 \verb! xdigit! \>  Hexadecimal digit. \\
180                \>  Above use locales, may be combined with \\
181                \>  other characters e.g. \verb![-+[:xdigit:]]! \\
182 \verb![^...]!  \>  Any character except those enclosed \\
183 \verb!<x-y>!   \>  Any number between $x$ and $y$ inclusive: \\
184                \>  both optional, defaults $0$, $\infty$ \\
185 \verb!^X!      \>  Anything not matching \texttt{X} \\
186 \verb!(X|Y)!   \>  Either \texttt{X} or \texttt{Y} \\
187 \verb!X~Y!     \>  Pattern \texttt{X}, but not \texttt{Y} \\
188 \verb!(X|Y~Z)! \>  Either \texttt{X} or (\texttt{Y} but not \texttt{Z}) \\
189 \verb!X#!      \>  Zero or more occurences of \texttt{X} \\
190 \verb!X##!     \>  One or more occurences of \texttt{X} \\
191 \verb!(X)!     \>  Grouping of (part of) pattern. \\
192 \verb!**/!     \>  (As path segment) short for \verb!(*/)!: \\
193                \> match all subdirectories \\
194 \verb!***/!    \>  The same, following symbolic links \\
195 \end{tabbing}
196
197 Globbing flags appear in the form \verb!(#X)! and require the
198 \T{EXTENDED\_GLOB} option.  They may appear in groups.  \verb!X! may be:
199 \begin{tabbing}
200 \hskip 40pt \= \kill
201 \verb!i!       \> Match case insensitively \\
202 \verb!l!       \> Lower case matches upper case \\
203 \verb!I!       \> Case sensitive: cancel \verb!i! and \verb!I! \\
204 \verb!b!       \> Activate backreferences for parentheses. \\
205                \> \verb!$match!, \verb!$mbegin!, \verb!$mend! arrays \\
206                \> give matched string, beginning/end indices \\
207 \verb!B!       \> Deactivate backreferences, negating \verb!b! \\
208 \verb!m!       \> Set \verb!$MATCH!, \verb!$MBEGIN!, \verb!$MEND! for
209                   string \\
210 \verb!M!       \> Deactivate \verb!m!. \\
211 \T{a}\I{num}   \> Allow \I{num} errors in matches (0 to turn off) \\
212 \verb!s!       \> Match only at start of string (use in param expn) \\
213 \verb!e!       \> Match only at end of string \\
214 \end{tabbing}
215
216 Globbing modifiers appear in parentheses after a pattern (usually
217 \I{and}'ed):
218 \begin{tabbing}
219 \hskip 40pt \= \kill
220 \verb!/!       \> directory \\
221 \verb!.!       \> plain file \\
222 \verb!@!       \> symbolic link \\
223 \verb!=!       \> socket \\
224 \verb!p!       \> named pipe (FIFO) \\
225 \verb!*!       \> executable plain file (0100) \\
226 \verb!%!       \> device file (character or block) \\
227 \verb!%b!      \> block special \\
228 \verb!%c!      \> character special \\
229 \verb!r!       \> readable (0400) \\
230 \verb!w!       \> writable (0200) \\
231 \verb!x!       \> executable (0200) \\
232 \verb!A!       \> group-readable (0040) \\
233 \verb!I!       \> group-writable (0020) \\
234 \verb!E!       \> group-executable (0010) \\
235 \verb!R!       \> world-readable (0200) \\
236 \verb!W!       \> world-writable (0200) \\
237 \verb!X!       \> world-executable (0200) \\
238 \verb!s!       \> setuid (04000) \\
239 \verb!S!       \> setgid (02000) \\
240 \verb!t!       \> files with the sticky bit (01000) \\
241 \T{f}\I{spec}  \> chmod-like access permissions \\
242                \> e.g. \verb!f70?! or \verb!f:u+w,go-w:! \\
243 \T{e}\I{str}   \> eval \I{str}, use file (\verb!$REPLY!) if status 0 \\
244                \> or set \verb!$reply! to file array \\
245 \T{d}\I{dev} \> on device number \I{dev} \\
246 \T{l}\Lsq\T{-}$\mid$\T{+}\Rsq\I{ct}
247            \> link count \I{ct} or less (\T{+}) or more (\T{-}) than \I{ct} \\
248 \T{U}          \> owned by current effective uid \\
249 \T{G}          \> owned by current effective gid \\
250 \T{u}\I{uid}   \> owned by uid \I{uid}; may also take forms \\
251                \> \T{.}\I{name}\T{.}, \T{!}\I{name}\T{!}, \dots\ or \\
252                \> \T{(}\I{name}\T{)}, \verb!{!\I{name}\verb!}!, \dots \\
253 \T{g}\I{gid}   \> owned by \I{gid}, as for \T{u}\I{uid}. \\
254 \T{a}\Lsq\T{Mwhm}\Rsq\Lsq\T{-}$\mid$\T{+}\Rsq\I{n} \\
255                \> accessed  (less than, more than) \I{n} days \\
256                \> (months, weeks, hours, minutes) ago \\
257 \T{m}\Lsq\T{Mwhm}\Rsq\Lsq\T{-}$\mid$\T{+}\Rsq\I{n} \\
258                \> modified ditto \\
259 \T{c}\Lsq\T{Mwhm}\Rsq\Lsq\T{-}$\mid$\T{+}\Rsq\I{n} \\
260                \> inode changed ditto \\
261 \T{L}\Lsq\T{kKmMpP}\Rsq\Lsq\T{-}$\mid$\T{+}\Rsq\I{n} \\
262                \> size in bytes (or kb, mb, blocks) $=$ (or $<$, $>$) \I{n} \\
263 \verb!^!       \> negate following qualifiers \\
264 \verb!,!       \> `\I{or}' lists of qualifers together \\
265 \verb!-!       \> toggle following links (off by default) \\
266 \T{M}          \> set \B{MARK\_DIRS}, this pattern only \\
267 \T{T}          \> set \B{LIST\_TYPES}, this pattern only \\
268 \T{N}          \> set \B{NULL\_GLOB}, this pattern only \\
269 \T{D}          \> set \B{GLOB\_DOTS}, this pattern only \\
270 \T{n}          \> set \B{NUMERIC\_GLOB\_SORT}, this pattern only \\
271 \T{o}\Lsq\T{nLlamcd}\Rsq \\
272                \> sort order of resulting files: by name, size, \\
273                \> no. of links, access/modification/inode time, \\
274                \> depth-first order \\
275 \T{o}\Lsq\T{nLlamcd}\Rsq \\
276                \> same but reversed order; \verb!Od! depth-last \\
277 \verb![!\I{beg}\Lsq\verb!,!\I{end}\Rsq\verb!]! \\
278                \> Index of matched file(s) to select \\
279 \verb!:!\dots  \> remainder treated as history \\
280                \> modifiers (each with own \verb!:!)\\
281 \end{tabbing}
282 \end{multicols}
283
284 \section{Options}
285 \D means set by default: these options appear with \T{no} in front in option
286 listings; \verb!+!\I{o} turns single-letter option off (shown in parentheses)
287
288 \begin{multicols}{3}
289 \begin{tabbing}
290 \hskip 1em \= \T{AUTO\_REMOVE\_SLASH} \= \kill
291 \T{ALL\_EXPORT}          \>\> Export all new shell params (-a) \\
292 \T{ALWAYS\_LAST\_PROMPT} \>\> Back to prompt after list \\
293 \T{ALWAYS\_TO\_END}      \>\> End of word after completion \\
294 \T{APPEND\_HISTORY}      \>\> Append history to file \\
295 \T{AUTO\_CD}             \>\> Directory as command does \T{cd} (-J) \\
296 \T{AUTO\_LIST}           \>\> List on ambiguous completion (-9) \\
297 \T{AUTO\_MENU}           \>\> Menu after second \T{TAB} \\
298 \T{AUTO\_NAME\_DIRS}     \>\> Params with paths become names \\
299 \T{AUTO\_PARAM\_KEYS}    \>\> Clever del after param completion \\
300 \T{AUTO\_PARAM\_SLASH}   \>\> \verb!$path<TAB>! $\to$ \verb!$path/! \\
301 \T{AUTO\_PUSHD}          \>\> Make \T{cd} act like \T{pushd} (-N) \\
302 \T{AUTO\_REMOVE\_SLASH}  \>\> Strip slash after completion \\
303 \T{AUTO\_RESUME}         \>\> \T{cmd} can behave like \verb!%cmd! (-W) \\
304 \T{BAD\_PATTERN}\D       \>\> Error on bad glob pattern (+2) \\
305 \T{BANG\_HIST}\D         \>\> Use \verb.!hist. on cmd line (+K) \\
306 \T{BARE\_GLOB\_QUAL}\D   \>\> Use glob quals with just parens \\
307 \T{BASH\_AUTO\_LIST}\D   \>\> List only on second tab \\
308 \T{BEEP}\D               \>\> Beep on errors etc. (+B) \\
309 \T{BG\_NICE}\D           \>\> Lower priority of bg jobs (-6) \\
310 \T{BRACE\_CCL}           \>\> \verb!foo{ab}! $\to$ \verb!fooa foob! \\
311 \T{BSD\_ECHO}            \>\> Builtin \T{echo} works like in BSD \\
312 \T{CDABLE\_VARS}         \>\> \T{cd foo} like \verb!cd ~foo! (-T) \\
313 \T{CHASE\_DOTS}          \>\> Resolve links when \verb!..! in dir \\
314 \T{CHASE\_LINKS}         \>\> Resolve symlinks in directories (-w) \\
315 \T{CHECK\_JOBS}\D        \>\> Report job status at \T{exit} \\
316 \T{CLOBBER}\D            \>\> \verb!>! to existing file needs \verb!>|! (+C) \\
317 \T{COMPLETE\_ALIASES}    \>\> Completion uses unexpanded aliases \\
318 \T{COMPLETE\_IN\_WORD}   \>\> Complete at cursor point in word \\
319 \T{CORRECT}              \>\> Correct command spelling (-0) \\
320 \T{CORRECT\_ALL}         \>\> Correct spelling of all args (-O) \\
321 \T{CSH\_JUNKIE\_HISTORY} \>\> Single \verb.!. is last command \\
322 \T{CSH\_JUNKIE\_LOOPS}   \>\> Lists can be \verb!list; end! \\
323 \T{CSH\_JUNKIE\_QUOTES}  \>\> No unescaped newlines in quotes \\
324 \T{CSH\_NULLCMD}         \>\> Don't use \verb!$NULLCMD!, \verb!$READNULLCMD! \\
325 \T{CSH\_NULL\_GLOB}      \>\> Only one glob must match \\
326 \T{DVORAK}               \>\> Use Dvorak keyboard for spelling \\
327 \T{EQUALS}\D             \>\> Perform \verb!=cmd! expansion \\
328 \T{ERR\_EXIT}            \>\> Exit shell on error (-e) \\
329 \T{EXEC}\D               \>\> Execute commands (+n) \\
330 \T{EXTENDED\_GLOB}       \>\> Use \verb!#!, \verb!~! and \verb!^! in
331    patterns \\
332 \T{EXTENDED\_HISTORY}    \>\> Save timestamp to history file \\
333 \T{FLOW\_CONTROL}\D      \>\> \verb!^S!, \verb!^Q! do flow control \\
334 \T{FUNCTION\_ARGZERO}\D  \>\> Set \verb!$0! on function or source \\
335 \T{GLOB}\D               \>\> Perform globbing (+F) \\
336 \T{GLOBAL\_EXPORT}\D      \>\> \verb!typeset -x! applies globally \\
337 \T{GLOBAL\_RCS}\D         \>\> Use \verb!/etc! startup files \\
338 \T{GLOB\_ASSIGN}         \>\> \verb!scalar=*! globs on right \\
339 \T{GLOB\_COMPLETE}       \>\> Complete globbing with menu \\
340 \T{GLOB\_DOTS}           \>\> Leading dots match wildcards (-4) \\
341 \T{GLOB\_SUBST}          \>\> Text from params can glob \\
342 \T{HASH\_CMDS}\D         \>\> Hash commands when run \\
343 \T{HASH\_DIRS}\D         \>\> Hash directory when cmd runs \\
344 \T{HASH\_LIST\_ALL}\D    \>\> Hash all cmds on completion \\
345 \T{HIST\_ALLOW\_CLOBBER} \>\> Allow clobbering redirects in hist \\
346 \T{HIST\_BEEP}\D         \>\> Beep on bad \verb.!.-history \\
347 \T{HIST\_EXPIRE\_DUPS\_FIRST} \\
348                          \>   Trim duplicate lines to squeeze history \\
349 \T{HIST\_FIND\_NO\_DUPS} \>\> Never show duplicates in history \\
350 \T{HIST\_IGNORE\_ALL\_DUPS} \\
351                          \>   Never save duplicate of existing hist entry \\
352 \T{HIST\_IGNORE\_DUPS}   \>\> No adjacent duplicates in history (-h) \\
353 \T{HIST\_IGNORE\_SPACE}  \>\> `\verb! cmd!' lines not saved (-g) \\
354 \T{HIST\_NO\_FUNCTIONS}  \>\> Don't store function definitions \\
355 \T{HIST\_NO\_STORE}      \>\> No history commands in history \\
356 \T{HIST\_REDUCE\_BLANKS} \>\> Trim excess whitespace in history \\
357 \T{HIST\_SAVE\_NO\_DUPS} \>\> Trim duplicates if saving history \\
358 \T{HIST\_VERIFY}         \>\> Edit after \verb.!. expansion \\
359 \T{HUP}\D                \>\> Send SIGHUP to jobs on exit \\
360 \T{IGNORE\_BRACES}       \>\> No \verb!{!\dots\verb!,!\dots\verb!}!
361    expansion (-I) \\
362 \T{IGNORE\_EOF}          \>\> No exit on first ten eof's (-7) \\
363 \T{INC\_APPEND\_HISTORY} \>\> Save history as it happens \\
364 \T{INTERACTIVE}          \>\> Shell is interactive (not settable) (-i) \\
365 \T{INTERACTIVE\_COMMENTS} \\
366                          \>\> Use comments interactively (-k) \\
367 \T{KSH\_ARRAYS}          \>\> Array syntax more like ksh \\
368 \T{KSH\_AUTOLOAD}        \>\> Emulate ksh function loading \\
369 \T{KSH\_GLOB}            \>\> Emulate ksh patterns, \verb!*(...)! etc. \\
370 \T{KSH\_OPTION\_PRINT}   \>\> Print options like ksh does \\
371 \T{LIST\_AMBIGUOUS}      \>\> Only list ambiguous completions \\
372 \T{LIST\_BEEP}           \>\> Beep on ambiguous completion \\
373 \T{LIST\_PACKED}         \>\> Squeeze completion listings \\
374 \T{LIST\_ROWS\_FIRST}    \>\> List rows first in completion \\
375 \T{LIST\_TYPES}          \>\> File types in completion list (-X) \\
376 \T{LOCAL\_OPTIONS}       \>\> Options set in functions are local \\
377 \T{LOCAL\_TRAPS}         \>\> Reset traps on leaving func \\
378 \T{LOGIN}                \>\> Shell is login (not settable) (-l) \\
379 \T{LONG\_LIST\_JOBS}     \>\> Always use \verb!jobs -l! (-R) \\
380 \T{MAGIC\_EQUAL\_SUBST}  \>\> Any \verb!var=expr! file-expands \T{expr} \\
381 \T{MAIL\_WARNING}        \>\> Warn if mail file accessed (-U) \\
382 \T{MARK\_DIRS}           \>\> Append \verb!/! to globbed directories (-8) \\
383 \T{MENU\_COMPLETE}       \>\> Cycle completions on \T{TAB} (-Y) \\
384 \T{MONITOR}              \>\> Allow job control (-m) \\
385 \T{MULTIOS}\D            \>\> Implicitly tee/cat multiple \verb!<!,
386    \verb!>! \\
387 \T{NOMATCH}\D            \>\> Error on unmatched globs (+3) \\
388 \T{NOTIFY}\D             \>\> Report bg jobs on change (-5) \\
389 \T{NULL\_GLOB}           \>\> Remove unmatched globs (-G) \\
390 \T{NUMERIC\_GLOB\_SORT}  \>\> Numbers sorted in glob \\
391 \T{OCTAL\_ZEROES}        \>\> 0 introduces octal in math expn \\
392 \T{OVER\_STRIKE}         \>\> Editor starts in overstrike mode \\
393 \T{PATH\_DIRS}           \>\> Search path for \verb!dir/cmd! (-Q) \\
394 \T{POSIX\_BUILTINS}      \>\> \T{builtin} command is specialer \\
395 \T{PRINT\_EIGHT\_BIT}    \>\> Show chars with high bit in listings \\
396 \T{PRINT\_EXIT\_VALUE}   \>\> Show non-zero exit status (-1) \\
397 \T{PRIVILEGED}           \>\> Privileged mode: safety first (-p) \\
398 \T{PROMPTT\_BANG}        \>\> \verb.!. is special in prompts \\
399 \T{PROMPT\_CR}\D         \>\> Print CR just before prompt (+V) \\
400 \T{PROMPT\_PERCENT}\D    \>\> Do \verb!%! expansions in prompt \\
401 \T{PROMPT\_SUBST}        \>\> Expand substitutions in prompts \\
402 \T{PUSHD\_IGNORE\_DUPS}  \>\> Only one instance of dir on stack \\
403 \T{PUSHD\_MINUS}         \>\> Swap plus and minus in pushd \\
404 \T{PUSHD\_SILENT}        \>\> Don't print directory stack (-E) \\
405 \T{PUSHD\_TO\_HOME}      \>\> With no args, \T{pushd} goes home (-D) \\
406 \T{RC\_EXPAND\_PARAM}    \>\> \verb!A${array}Z!  $\to$ \verb!Aa1Z Aa2Z!
407    \dots (-P) \\
408 \T{RC\_QUOTES}           \>\> \verb!echo ''''! $\to$ \verb!'! \\
409 \T{RCS}\D                \>\> \verb!.!-files, else just
410    \verb!/etc/zshenv! (+f) \\
411 \T{REC\_EXACT}           \>\> Prefer exact match in completion (-S) \\
412 \T{RESTRICTED}           \>\> Can't cause as much damage \\
413 \T{RM\_STAR\_SILENT}     \>\> No query on \verb!rm *! (-H) \\
414 \T{RM\_STAR\_WAIT}       \>\> Don't believe first RMSTAR reply \\
415 \T{SHARE\_HISTORY}       \>\> Read/write history as it happens \\
416 \T{SH\_FILE\_EXPANSION}  \>\> Perform \verb!~file!, \verb!=cmd! first \\
417 \T{SH\_GLOB}             \>\> Disable \verb!(!, \verb!|!, \verb!)!,
418    \verb!<! in patterns \\
419 \T{SHIN\_STDIN}          \>\> Read commands from stdin (-s) \\
420 \T{SH\_NULLCMD}          \>\> Null commands assume \verb!:! behaviour \\
421 \T{SH\_OPTION\_LETTERS}  \>\> Letter options work like in ksh \\
422 \T{SHORT\_LOOPS}\D       \>\> Short \!verb!for!, \verb!select!, \verb!if!,
423      \verb!function! \\
424 \T{SH\_WORD\_SPLIT}      \>\> Split words like lesser shells do (-y) \\
425 \T{SINGLE\_COMMAND}      \>\> Read a command and exit (-t) \\
426 \T{SINGLE\_LINE\_ZLE}    \>\> Editor only uses one line (-M) \\
427 \T{SUN\_KEYBOARD\_HACK}  \>\> Ignore unmatched trailing \verb!`! (-L) \\
428 \T{UNSET}\D              \>\> Unset parameters cause error (+u) \\
429 \T{VERBOSE}              \>\> Print input lines as read (-v) \\
430 \T{XTRACE}               \>\> Print cmds and args when run (-x) \\
431 \T{ZLE}                  \>\> Use the shell's line editor (-Z) \\
432 \end{tabbing}
433 \end{multicols}
434
435 \begin{multicols}{3}[\section{Parameter expansion}]
436
437 \begin{tabbing}
438 \hskip 20pt \= \kill
439 \verb!$!\I{name} \\
440 \verb!${!\I{name}\verb!}! \\
441                 \> Basic parameter substitution \\
442 \verb!${+!\I{name}\verb!}! \\
443                 \> 1 if \I{name} set, 0 otherwise \\
444 \verb!${!\I{name}\verb!:-!\I{word}\verb!}! \\
445                 \> \verb!$!\I{name} if non-null, else \I{word} \\
446 \verb!${!\I{name}\verb!-!\I{word}\verb!}! \\
447                 \> \verb!$!\I{name} if set, else \I{word} \\
448                 \> (Similar for others with/without colon.) \\
449 \verb!${!\I{name}\verb!:=!\I{word}\verb!}! \\
450                 \> \verb!$!\I{name} if non-null, else use \I{word} \\
451                 \> and set \I{name} to that \\
452 \verb!${!\I{name}\verb!:==!\I{word}\verb!}! \\
453                 \> Unconditional assignment
454 \verb!${!\I{name}\verb!:?!\I{word}\verb!}! \\
455                 \> \verb!$!\I{name} if non-null, else print \I{word}
456                 and exit \\
457 \verb!${!\I{name}\verb!:+!\I{word}\verb!}! \\
458                 \> \I{word} if \verb!$!\I{name} non-null, else nothing \\
459 \verb!${!\I{name}\verb!#!\I{pattern}\verb!}! \\
460 \verb!${!\I{name}\verb!##!\I{pattern}\verb!}! \\
461                 \> \verb!$!\I{name} with shortest (longest)
462                 match of \\
463                 \> \I{pattern} removed from head. Patterns as \\
464                 \> globbing; original parameter unchanged \\
465 \verb!${!\I{name}\verb!%!\I{pattern}\verb!}! \\
466 \verb!${!\I{name}\verb!%%!\I{pattern}\verb!}! \\
467                 \> As for \verb!#!, but remove from tail of match \\
468 \verb!${!\I{name}\verb!/!\I{pattern}\verb!/!\I{repl}\verb!}! \\
469                 \> Substitute longest match of \I{pattern} by \I{repl} \\
470 \verb!${(S)!\I{name}\verb!/!\I{pattern}\verb!/!\I{repl}\verb!}! \\
471                 \> Substitute shortest match \\
472 \verb!${!\I{name}\verb!//!\I{pattern}\verb!/!\I{repl}\verb!}! \\
473                 \> Substitute all non-overlapping longest matches \\
474 \verb!${!\I{name}\verb!/#!\I{pattern}\verb!/!\I{repl}\verb!}! \\
475                 \> Subst if \I{pattern} at start of string \\
476 \verb!${!\I{name}\verb!/%!\I{pattern}\verb!/!\I{repl}\verb!}! \\
477                 \> Subst if \I{pattern} at end of string \\
478 \verb!${!\I{name}\verb!:/!\I{pattern}\verb!/!\I{repl}\verb!}! \\
479                 \> Subst if \I{pattern} matches entire string \\
480 \verb!${#!\I{spec}\verb!}! \\
481                 \> Count length of scalar or words of array \\
482 \verb!${^!\I{spec}\verb!}! \\
483 \verb!${^^!\I{spec}\verb!}! \\
484                 \> Turn on (off) \B{RC\_EXPAND\_PARAM} \\
485 \verb!${=!\I{spec}\verb!}! \\
486 \verb!${==!\I{spec}\verb!}! \\
487                 \> Turn on (off) \B{SH\_WORD\_SPLIT} \\
488 \verb!${~!\I{spec}\verb!}! \\
489 \verb!${~~!\I{spec}\verb!}! \\
490                 \> Turn on (off) \B{GLOB\_SUBST} \\
491 \verb!${!\I{spec}\verb!:!\I{mod}\verb!}! \\
492                 \> Apply history modifier \I{mod} \\
493 \verb!${${name\dots}!\dots\verb!}! \\
494                 \> Perform both sets of modifications on value \\
495                 \> N.B. does not do extra lookup, see \verb!(P)! \\
496 \end{tabbing}
497
498 Flags:  usage \verb!${(o)!\I{name}\verb!}! etc.
499 \begin{tabbing}
500 \hskip 20pt \= \kill
501 \T{A}           \> \verb!${...:=...}! creates array \\
502 \T{AA}          \> \dots creates associative array \\
503 \verb!@!        \> Split into words in double quotes \\
504 \T{e}           \> Use shell expansion on result \\
505 \T{P}           \> Force \verb!$!\I{name} to be re-used as name \\
506 \T{o}           \> sort words in ascending order \\
507 \T{O}           \> sort words in descending order \\
508 \T{i}           \> case-independent with \T{o} or \T{O} \\
509 \T{L}           \> all letters lower case \\
510 \T{U}           \> all letters upper case \\
511 \T{C}           \> capitalise words \\
512 \T{V}           \> make special characters visible \\
513 \T{q}           \> quote result with \verb!\! \\
514 \T{qq}          \> quote result with \verb!'! \\
515 \T{qqq}         \> quote result with \verb!"! \\
516 \T{qqqq}        \\
517                 \> quote result with \verb!$'!\dots\verb!'! \\
518 \T{Q}           \> remove one level of shell quoting \\
519 \verb!%!        \> Expand prompt escapes \\
520 \verb!%%!       \> Expand as prompt with current settings \\
521 \T{X}           \> Report parse errors with quotes, patterns \\
522 \T{c}           \> \verb!${#!\I{name}\verb!}! counts characters \\
523 \T{w}           \> \verb!${#!\I{name}\verb!}! counts words \\
524 \T{W}           \> As \T{w}, but count empty words \\
525 \T{k}           \> With assoc include keys \\
526 \T{v}           \> With assoc include values \\
527 \T{p}           \> Use print escapes in args below \\
528 \T{F}           \> Join words with newlines \\
529 \T{f}           \> Split on newlines \\
530 \T{z}           \> Split using ordinary parsing \\
531 \T{t}           \> Subsituted description, not value \\
532 \end{tabbing}
533
534 Flags with delimiters; use any pair of chars in place of colon, also
535 matched \verb!<>!, \verb!()!, \verb!{}!, \verb![]!
536 \begin{tabbing}
537 \hskip 20pt \= \kill
538 \T{l:}\I{expr}\T{::}\I{string1}\T{::}\I{string2}\T{:} \\
539                 \> Pad words on left to \I{expr} chars using \\
540                 \> \I{string1} repeated (default space), \\
541                 \> \I{string2} appears just once \\
542 \T{r:}\I{expr}\T{::}\I{string1}\T{::}\I{string2}\T{:} \\
543                 \> Ditto padded on right \\
544 \T{j:}\I{string}\T{:} \\
545                 \> Join words using \I{string} \\
546                 \> (occurs before splitting) \\
547 \T{s:}\I{string}\T{:} \\
548                 \> Split words at \I{string}
549 \end{tabbing}
550
551 Flags applying with \verb!${...#...}! or \verb!${...%...}!
552 \begin{tabbing}
553 \hskip 20pt \= \kill
554 \T{S}           \> search substrings too \\
555 \T{I:}\I{expr}\T{:} \\
556                 \> Search/substitute \I{expr\/}th match \\
557 \T{M}           \> Include matched portion \\
558 \T{R}           \> Include unmatched portion (Rest) \\
559 \T{B}           \> Include index of beginning \\
560 \T{E}           \> Include index of end \\
561 \T{N}           \> Include length of match \\
562 \end{tabbing}
563
564 Summary of rules for substitution
565 \begin{tabbing}
566 \hskip 20pt \= \kill
567 1              \> Nested substitution, \verb!${${!\dots\verb!}}! \\
568 2              \> Subscript of parameter by name,
569 \verb!${!\I{name}\verb![!\I{i}\verb!]}! \\
570 3              \> \verb!(P)! flag \\
571 4              \> \verb!"${!\dots\verb!}"! joining \\
572 5              \> Nested subscript, \verb!${${!\dots\verb!}[!\I{i}\verb!]}! \\
573 6              \> \verb!#!, \verb!%!, \verb!/!. \verb!:! modifications \\
574 7              \> \verb!(j)! flag or space joining \\
575 8              \> \verb!(s)!, \verb!(f)!, \verb!(z)! or \verb!=! splitting \\
576 9              \> Shell word splitting (no flags) \\
577 10             \> \verb!(e)! flag \\
578 11             \> \verb!(l)! or \verb!(r)! padding \\
579 \end{tabbing}
580
581 Flags in indexing: usage \verb!$!\I{name}\verb![(i)!\I{index}\verb!]! etc.
582 \begin{tabbing}
583 \hskip 20pt \= \kill
584 \T{e}           \> Backward compatability only \\
585 \T{w}           \> Index by words of scalar \\
586 \T{s:string:} \\
587                 \> Separate words with \T{string} \\
588 \T{p}           \> Use print escapes in following \T{s} \\
589 \T{f}           \> Index by lines: same as \verb!pws:\n:! \\
590 \T{r}           \> Reverse index array/substring/word \\
591                 \> For assocs, match against values \\
592 \T{R}           \> As \T{r}, but last match (all for assocs) \\
593 \T{k}           \> In assoc, keys are patterns; get first \\
594 \T{K}           \> In assoc, keys are patterns; get all \\
595 \T{i}           \> As \T{r}, but return index \\
596                 \> For assocs match against keys \\
597 \T{I}           \> As \T{I}, but last match (all for assocs) \\
598 \verb!n:!\I{expr}\verb!:! \\
599                 \> Use \T{expr}'th first/last match
600 \verb!b:!\I{expr}\verb!:! \\
601                 \> \T{r}, \T{R}, \T{i}, \T{I} start search at \I{expr}th elt.
602 \end{tabbing}
603 \end{multicols}
604
605 \goodbreak
606 \section{History}
607 See also parameters \B{histchars}, \B{HISTFILE}, \B{HISTSIZE},
608 \B{SAVEHIST} and options \B{APPEND\_\-HISTORY},
609 \B{CSH\_\-JUNKIE\_\-HISTORY}, \B{EXTENDED\_\-HISTORY},
610 \B{HIST\_\-ALLOW\_\-CLOBBER}, \B{HIST\_\-IGNORE\_\-DUPS},
611 \B{HIST\_\-IGNORE\_\-SPACE}, \B{HIST\_\-NO\_\-STORE},
612 \B{HIST\_\-VERIFY}, \B{BANG\_\-HIST}, \B{HIST\_\-BEEP},
613 \B{HIST\_\-EXPIRE\_\-DUPS\_\-FIRST}, \B{HIST\_\-FIND\_\_NO\_\-DUPS},
614 \B{HIST\_\-IGNORE\_\-ALL\_\-DUPS}, \B{HIST\_\-NO\_\-FUNCTIONS},
615 \B{HIST\_\-REDUCE\_\-BLANKS}, \B{HIST\_\-SAVE\_\-NO\_\-DUPS},
616 \B{INC\_\-APPEND\_\-HISTORY}, \B{SHARE\_\-HISTORY}.
617
618 \begin{multicols}{3}[\mbox{Events:}]
619 \begin{tabbing}
620 \hskip 60pt \= \kill
621 \verb.!.        \> start history substitution unless after \\
622                 \> space, newline, \verb!=!, \verb!(! \\
623 \verb.!!.       \> immediately previous command \\
624 \verb.!.\I{n}   \> command line \I{n} \\
625 \verb.!-.\I{n}  \> line \I{n} before current \\
626 \verb.!.\I{str} \> last line beginning with \I{str} \\
627 \verb.!.\I{?str}\Lsq\verb.?.\Rsq
628                 \> last line containing \I{str} \\
629 \verb.!#.       \> current command so far \\
630 \verb?!{...}?   \> insulate history reference \\
631 \verb.!".       \> no more expansion this line \\
632 \end{tabbing}
633 \end{multicols}
634
635 \begin{multicols}{3}[\mbox{Words: separated from event by `:'}]
636 \begin{tabbing}
637 \hskip 60pt \= \kill
638 \T{0}           \> first word on line (command) \\
639 \I{n}           \> \I{n\/}th argument of command \\
640 \verb!^!        \> first argument of command \\
641 \verb!$!        \> last argument of command \\
642 \verb!%!        \> word matched by \verb!?s! \\
643 \I{x}\verb!-!\I{y} \> range of words \\
644 \verb!-!\I{y}   \> same as \verb!0-!\I{y} \\
645 \verb!*!        \> all arguments \\
646 \I{x}\verb!*!   \> same as \I{x}\verb!-$! \\
647 \I{x}\verb!-!   \> same but omit word \verb!$! \\
648 \end{tabbing}
649 \end{multicols}
650
651 \begin{multicols}{3}[\mbox{Modifiers: also with globbing and parameters}]
652 \begin{tabbing}
653 \hskip 60pt \= \kill
654 \T{h}           \> (head) strip last path cpt \\
655 \T{r}           \> remove suffix \verb!.!\I{suf} \\
656 \T{e}           \> leave only suffix \I{suf} \\
657 \T{t}           \> (tail) leave only last path cpt \\
658 \verb!&!        \> repeat last substitution \\
659 \T{p}           \> don't execute new command \\
660 \T{q}           \> quote words from further subst \\
661 \T{Q}           \> remove one level of quotes \\
662 \T{x}           \> same but split words at space \\
663 \T{l}           \> all letters lower case \\
664 \T{u}           \> all letters upper case \\
665 \verb!s/!\I{old}\verb!/!\I{new}\Lsq\verb!/!\Rsq \\
666                 \> replace \I{old} by \I{new} (string) \\
667 \T{g}           \> (before s) change every occurrence \\
668 \T{f}           \> repeat till no further change \\
669 \verb!F:!\I{expr}\verb!:! \> same but max \I{expr} changes \\
670 \T{w}           \> (as prefix) apply to each word \\
671 \verb!W:!\I{sep}\verb!:! \> same but separate words on \I{sep} \\
672 \end{tabbing}
673 \end{multicols}
674
675 \begin{multicols}{3}[\section{Parameters}]
676
677 Special parameters: arrays are lower case except \T{status}; those
678 marked\D\ are assignable:
679 \begin{tabbing}
680 \hskip 1em \= USERNAME \= \kill
681 \T{!}             \>\> Last bg PID \\
682 \T{ARGC} \\
683 \verb!#!          \>\> Pos.\ param count \\
684 \verb!$!          \>\> Current PID \\
685 \T{-}             \>\> Shell flags set \\
686 \T{argv}\D \\
687 \verb!*!\D        \>\> Pos.\ params as array \\
688 \verb!@!          \>\> Same as \verb!argv[@]! \\
689 \T{status} \\
690 \T{?}             \>\> Last prog status \\
691 \T{pipestatus}    \>\> Array of statuses for pipeline \\
692 \verb!_!          \>\> Last arg of prev cmd \\
693 \T{CPUTYPE}       \>\> CPU determined at run time \\
694 \T{EGID}\D        \>\> Effective GID \\
695 \T{EUID}\D        \>\> Effective UID \\
696 \T{ERRNO}         \>\> System error no. \\
697 \T{GID}\D         \>\> Current GID \\
698 \T{HOST}          \>\> Current host name \\
699 \T{LINENO}        \>\> Input line no. \\
700 \T{LOGNAME}       \>\> User name \\
701 \T{MACHTYPE}      \>\> Machine type \\
702 \T{OLDPWD}        \>\> Previous working dir. \\
703 \T{OPTARG} \\
704 \T{OPTIND}        \>\> Value, index of last \B{getopts} option \\
705 \T{OSTYPE}        \>\> OS type \\
706 \T{PPID}          \>\> PID of parent proc. \\
707 \T{PWD}           \>\> Current working dir. \\
708 \T{RANDOM}\D      \>\> Random integer: assign to seed. \\
709 \T{SECONDS}\D     \>\> Seconds since start of shell \\
710 \T{SHLVL}         \>\> Incremented for each zsh \\
711 \T{signals}       \>\> Names of signals \\
712 \T{TTY}           \>\> Name of shell terminal \\
713 \T{TTYIDLE}       \>\> Idle time of tty (secs.) or -1 \\
714 \T{UID}\D         \>\> UID \\
715 \T{USERNAME}\D    \>\> username \\
716 \T{VENDOR}        \>\> Machine manufacturer \\
717 \verb!ZSH_NAME!   \>\> Shell invocation name \\
718 \verb!ZSH_VERSION! \>\> ID of zsh version \\
719 \end{tabbing}
720
721 Other parameters used by shell (\D colon-separated path)
722 \begin{tabbing}
723 \hskip 2em \= USERNAME \= \kill
724 \T{ARGV0}         \>\> Export to change \verb!argv[0]! \\
725 \T{BAUD}          \>\> Line speed (zero to ignore) \\
726 \T{cdpath}, \T{CDPATH}\D \>\> Directories search for \B{cd} command \\
727 \T{COUMNS}        \>\> No.\ of columns on terminal \\
728 \T{DIRSTACKSIZE}  \>\> Max size of dir.\ stack \\
729 \T{FCEDIT}        \>\> Default editor for \B{fc} cmd. \\
730 \T{fignore}, \T{FIGNORE}\D \>\>\quad Suffixes ignored for completion \\
731 \T{fpath}, \T{FPATH}\D \>\> Path to search for autoload fns. \\
732 \T{histchars} \>\> three chars: 1) start of history (\verb.!.), \\
733    \>  2) quick history sub (\verb!^!), 3) comment (\verb!#!) \\
734 \T{HISTCHARS}     \>\> same as \T{histchars} \\
735 \T{HISTFILE}      \>\> Where to save shell history \\
736 \T{HISTSIZE}      \>\> Max history lines internally \\
737 \T{HOME}          \>\> Default target for \B{cd} cmd. \\
738 \T{IFS}           \>\> Word seperators for input \\
739 \T{KEYTIMEOUT}    \>\> Time to waits for key in sequence \\
740 \T{LANG}          \>\> General locale setting \\
741 \verb!LC_ALL!     \>\> Overrides \T{LANG} and other \verb!LC_*! \\
742 \verb!LC_COLLATE! \>\> Determines character ordering \\
743 \verb!LC_CTYPE!   \>\> Determines types of characters \\
744 \verb!LC_MESSAGES!\>\> For messages: not used by zsh \\
745 \verb!LC_NUMERIC! \>\> For decimal point, number separator \\
746 \verb!LC_TIME!    \>\> Date and time format \\
747 \T{LINES}         \>\> No.\ of lines on terminal \\
748 \T{LISTMAX}       \>\> No.\ of files to list without asking \\
749 \T{LOGCHECK}      \>\> How often to check \T{watch} (secs.) \\
750 \T{MAIL}          \>\> File to check for mail \\
751 \T{MAILCHECK}     \>\> How often to check \T{MAIL} (secs.) \\
752 \T{mailpath}, \T{MAILPATH}\D \\
753    \> List of files to check for new mail.  Can follow \\
754    \> each with \verb!?'message to print'! \\
755 \T{manpath}, \T{MANPATH}\D \\
756    \> Not used by shell, probably used by \B{man} cmd. \\
757 \T{module\_path}, \T{MODULE\_PATH}\D \\
758    \> Path for dynamic modules; not imported \\
759 \T{NULLCMD}       \>\> Used for redirs.\ with no cmd. \\
760 \T{path}, \T{PATH}\D \>\> Where to search for commands \\
761 \T{POSTEDIT}      \>\> Output when line editor exits \\
762 \T{PROMPT}, \T{prompt} \\
763 \T{PS1}           \>\> Prompt used by editor \\
764 \T{PROMPT2}, \T{PS2} \>\> Continuation prompt \\
765 \T{PROMPT3}, \T{PS3} \>\> Prompt used by \B{select} cmd. \\
766 \T{PROMPT4}  \T{PS4} \>\> Execution trace prompt \\
767 \T{psvar}, \T{PSVAR}\D \>\> Replace \verb!%v! in prompts \\
768 \T{READNULLCMD} \>\> Command used with only input readir. \\
769 \T{REPORTTIME} \>\> Longer commands print usage (secs.) \\
770 \T{RPROMPT} \\
771 \T{RPS1}           \>\> Prompt displayed at right of line \\
772 \T{SAVEHIST}       \>\> Max no.\ of lines in history file \\
773 \T{SPROMPT}        \>\> Prompt used for spelling correction \\
774 \T{STTY}           \>\> Args. to follow \B{stty}, \\
775   \>\> export to run before external cmd.\ \\
776 \T{TERM}           \>\> Type of terminal for editing \\
777 \T{TIMEFMT}        \>\> Format of process time reports \\
778 \T{TMOUT}          \>\> SIGALRM if idle this long (secs.) \\
779 \T{TMPPREFIX}      \>\> Path to temp files (\B{/tmp/zsh}) \\
780 \T{watch}, \T{WATCH}\D \>\> List of users to watch log in/out \\
781               \>\> (also \B{all}, \B{notme}, \verb!%! tty, \verb!@! host) \\
782 \T{WATCHFMT}       \>\> Format of \T{watch} reports \\
783 \T{WORDCHARS}      \>\> Non-alphanumeric characters used \\
784                    \>\> as part of a word by editor \\
785 \T{ZBEEP}          \>\> Sequence to output instead of beeping \\
786 \T{ZDOTDIR}        \>\> Where to find \verb!.zshrc! etc.\ \\
787 \end{tabbing}
788 \end{multicols}
789
790 Prompt escape sequences: those with \D can use integer count \I{n},
791 which must immediately follow \verb!%!.  Default is 1 except for \verb!%_!.
792 \begin{multicols}{3}
793 \begin{tabbing}
794 \hskip 50pt \= \kill
795 \verb!%%!          \> A `\%' \\
796 \verb!%)!          \> A `)' \\
797 \verb!%d! \verb!%/!\D
798                    \> \verb!$PWD! \\
799 \verb!%~!\D        \> \verb!$PWD!, but use \verb!~!-abbrevs \\
800 \verb!%h! \verb.%!.
801                    \> Current history event no. \\
802 \verb!%L!          \> The current value of \verb!$SHLVL! \\
803 \verb!%M!          \> Full hostname \\
804 \verb!%m!\D        \> Host up to \I{n}'th dot \\
805 \verb!%S! \verb!%B! \verb!%U!
806                    \> Start standout, bold, underline \\
807 \verb!%s! \verb!%b! \verb!%u!
808                    \> Stop corresponding mode \\
809 \verb!%t! \verb!%@!
810                    \> Time in 12 hour format \\
811 \verb!%T!          \> Time in 24 hour format  \\
812 \verb!%*!          \> Same with seconds \\
813 \verb!%n!          \> \verb!$USERNAME! \\
814 \verb!%N!          \> Name of script, sourced file, function \\
815 \verb!%i!          \> Line number inside \verb!%N! \\
816 \verb!%w!          \> Date as \verb!day-dd! \\
817 \verb!%W!          \> Date as \verb!mm/dd/yy! \\
818 \verb!%D!          \> Date as \verb!yy-mm-dd! \\
819 \verb!%D{!\I{string}\verb!}! \\
820                    \> Use \T{strftime} to format \I{string} \\
821 \verb!%l!          \> Current tty \\
822 \verb!%?!          \> Return status of last command \\
823 \verb!%_!\D        \> Parser status, \I{n} for max level\\
824 \verb!%E!          \> Clear to end of line \\
825 \verb!%#!          \> \verb!#! if root, else \verb!%! \\
826 \verb!%v!\D        \> \I{n}'th elementt of \verb!$psvar! \\
827 \verb!%{...%}!     \> String which does not move cursor \\
828 \verb!%<string<! \verb!%>string>! \verb!%[<string]! \verb!%[>string]! \\
829                    \> Truncate \T{string} on L or R, \\
830                    \> \I{n} gives max length. \\
831 \verb!%c!\D\ \verb!%.!\D 
832                    \> Component of \verb!$PWD! (deprecated) \\
833 \verb!%C!          \> Same but don't expand \verb!~!'s \\
834 \end{tabbing}
835
836 Codes for ternary expressions in prompts, format
837 \verb!%(!\I{char}\verb!.!\I{true-text}\verb!.!\I{false-text}\verb!)!,
838 integer count \I{n} may proceded or follow `\verb!(!'. Test is true if:
839 \begin{tabbing}
840 \hskip 40pt \= \kill
841 \T{c} \verb!.! \verb!~! \> Tilde'd path has $>=n$ elts \\
842 \verb!/! \T{C}     \> Ditto for absolute path \\
843 \T{t}              \> Current minute is \I{n} \\
844 \T{T}              \> Current hour is \I{n} \\
845 \T{d}              \> Current day of month is \I{n} \\
846 \T{D}              \> Month is \I{n} (Jan${}=0$) \\
847 \T{w}              \> Weekday is \I{n} (Sun${}=0$) \\
848 \verb!?!           \> Last exit status was \I{n} \\
849 \verb!#!           \> Running as uid \I{n} \\
850 \T{g}              \> Running as gid \I{n} \\
851 \T{L}              \> \verb!$SHLVL!${}>=n$ \\
852 \T{S}              \> \verb!$SECONDS!${}>=n$ \\
853 \T{v}              \> \verb!${#psvar}!${}>=n$ \\
854 \verb!_!           \> At least \I{n} shell constructs \\
855 \verb.!.           \> True if shell is priveleged \\
856 \end{tabbing}
857
858 Escape sequences in \verb!$WATCHFMT!:
859 \begin{tabbing}
860 \hskip 50pt \= \kill
861 \verb!%n!          \> Name of user \\
862 \verb!%a!          \> `logged on' or `logged off' \\
863 \verb!%l!          \> User's tty \\
864 \verb!%M!          \> Full remote host name \\
865 \verb!%m!          \> Host to first `.' \\
866 \verb!%S! \verb!%U! \verb!%B!
867                    \> Start standout, underline, boldface \\
868 \verb!%s! \verb!%u! \verb!%b!
869                    \> Stop corresponding mode \\
870 \verb!%t! \verb!%@!
871                    \> Time in 12-hour format \\
872 \verb!%T!          \> Time in 24-hour format \\
873 \verb!%w!          \> Date as \verb!day-dd! \\
874 \verb!%W!          \> Date as \verb!mm/dd/yy! \\
875 \verb!%D!          \> Date as \verb!yy-mm-dd! \\
876 \end{tabbing}
877
878 % end multicols here because at presnt the next bit goes over the page
879 % and looks odd
880 \end{multicols}
881
882 Ternary expressions in \verb!$WATCHFMT!, format
883 \verb!%(!\I{char}\verb!.!\I{true-text}\verb!.!\I{false-text}\verb!)!,
884 can be used with \T{l}, \T{n}, \T{m} or \T{M} (true if non-empty value
885 for corresponding \verb!%!), or \T{a} (true for login, false for
886 logout).
887
888 \begin{multicols}{3}[\section{Conditions}][10cm]
889
890 File tests: followed by a file name
891 \begin{tabbing}
892 \hskip 20pt \= \kill
893 \B{Cond} \\
894                 \> \B{true if file} \\
895 \T{-a}          \> exists \\
896 \T{-b}          \> block special \\
897 \T{-c}          \> character special \\
898 \T{-d}          \> directory \\
899 \T{-e}          \> exists \\
900 \T{-f}          \> plain file \\
901 \T{-g}          \> has setgid bit set \\
902 \T{-h}          \> symbolic link \\
903 \T{-k}          \> has sticky bit set \\
904 \T{-p}          \> FIFO/pipe \\
905 \T{-r}          \> readable \\
906 \T{-s}          \> has size $>0$ \\
907 \T{-u}          \> has setuid bit set \\
908 \T{-w}          \> writeable \\
909 \T{-x}          \> executable/dir.\ readable: \\
910 \T{-L}          \> symbolic link \\
911 \T{-O}          \> owned by UID \\
912 \T{-G}          \> owned by GID \\
913 \T{-S}          \> socket \\
914 \T{-N}          \> access time not newer than mod time \\
915 \end{tabbing}
916
917 Other tests with single argument:
918 \begin{tabbing}
919 \hskip 20pt \= \kill
920 \T{-n}          \> string, length $>0$ \\
921 \T{-o}          \> option, is set \\
922 \T{-t}          \> fd, open to tty \\
923 \T{-z}          \> string, length zero \\
924 \end{tabbing}
925
926 Two argument tests (\Lsq\Lsq \I{a} \T{test} \I{b} \Rsq\Rsq):
927 \begin{tabbing}
928 \hskip 20pt \= \kill
929 \T{-nt}         \> file \I{a} newer than \I{b} \\
930 \T{-ot}         \> file \I{a} older than \I{b} \\
931 \T{-ef}         \> names refer to same file \\
932 \T{=} \\
933 \T{==}          \> \I{string} matches \I{pattern} \\
934 \T{!=}          \> \dots does not match \\
935 \T{<}           \> ASCII before \\
936 \T{>}           \> ASCII after \\
937 \T{-eq}         \> Numbers equal \\
938 \T{-ne}         \> Numbers unequal \\
939 \T{-lt}         \> Numeric $a<b$ \\
940 \T{-gt}         \> Numeric $a>b$ \\
941 \T{-le}         \> Numeric $a\leq b$ \\
942 \T{-ge}         \> Numeric $a\geq b$ \\
943 \end{tabbing}
944
945 Also grouping \Lpa\dots\Rpa, negation \T{!}, and \verb!&&!, or
946 \verb!||!; special handling of \B{/dev/fd}.
947
948 \vfill
949 \end{multicols}
950
951 \end{document}