1ZSHALL(1)                   General Commands Manual                  ZSHALL(1)
2
3
4

NAME

6       zshall - the Z shell meta-man page
7

OVERVIEW

9       Because  zsh contains many features, the zsh manual has been split into
10       a number of sections.  This manual page includes all the separate  man‐
11       ual pages in the following order:
12
13       zsh          Zsh overview
14       zshroadmap   Informal introduction to the manual
15       zshmisc      Anything not fitting into the other sections
16       zshexpn      Zsh command and parameter expansion
17       zshparam     Zsh parameters
18       zshoptions   Zsh options
19       zshbuiltins  Zsh built-in functions
20       zshzle       Zsh command line editing
21       zshcompwid   Zsh completion widgets
22       zshcompsys   Zsh completion system
23       zshcompctl   Zsh completion control
24       zshmodules   Zsh loadable modules
25       zshcalsys    Zsh built-in calendar functions
26       zshtcpsys    Zsh built-in TCP functions
27       zshzftpsys   Zsh built-in FTP client
28       zshcontrib   Additional zsh functions and utilities
29

DESCRIPTION

31       Zsh  is a UNIX command interpreter (shell) usable as an interactive lo‐
32       gin shell and as a shell script command  processor.   Of  the  standard
33       shells,  zsh most closely resembles ksh but includes many enhancements.
34       It does not provide compatibility with POSIX or other shells in its de‐
35       fault operating mode:  see the section Compatibility below.
36
37       Zsh has command line editing, builtin spelling correction, programmable
38       command completion, shell functions (with autoloading), a history mech‐
39       anism, and a host of other features.
40

AUTHOR

42       Zsh  was  originally  written by Paul Falstad <pf@zsh.org>.  Zsh is now
43       maintained by the members of the zsh-workers  mailing  list  <zsh-work‐
44       ers@zsh.org>.   The  development  is  currently  coordinated  by  Peter
45       Stephenson <pws@zsh.org>.  The coordinator can be contacted at <coordi‐
46       nator@zsh.org>, but matters relating to the code should generally go to
47       the mailing list.
48

AVAILABILITY

50       Zsh is available from the following HTTP and anonymous FTP site.
51
52       ftp://ftp.zsh.org/pub/
53       https://www.zsh.org/pub/
54       )
55
56       The up-to-date source code is available via Git from Sourceforge.   See
57       https://sourceforge.net/projects/zsh/  for  details.   A summary of in‐
58       structions for the archive can be found at http://zsh.sourceforge.net/.
59

MAILING LISTS

61       Zsh has 3 mailing lists:
62
63       <zsh-announce@zsh.org>
64              Announcements about releases, major changes in the shell and the
65              monthly posting of the Zsh FAQ.  (moderated)
66
67       <zsh-users@zsh.org>
68              User discussions.
69
70       <zsh-workers@zsh.org>
71              Hacking, development, bug reports and patches.
72
73       To subscribe or unsubscribe, send mail to the associated administrative
74       address for the mailing list.
75
76       <zsh-announce-subscribe@zsh.org>
77       <zsh-users-subscribe@zsh.org>
78       <zsh-workers-subscribe@zsh.org>
79       <zsh-announce-unsubscribe@zsh.org>
80       <zsh-users-unsubscribe@zsh.org>
81       <zsh-workers-unsubscribe@zsh.org>
82
83       YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED.  All
84       submissions  to  zsh-announce are automatically forwarded to zsh-users.
85       All submissions to zsh-users are automatically forwarded  to  zsh-work‐
86       ers.
87
88       If  you  have  problems subscribing/unsubscribing to any of the mailing
89       lists, send mail to <listmaster@zsh.org>.  The mailing lists are  main‐
90       tained by Karsten Thygesen <karthy@kom.auc.dk>.
91
92       The  mailing  lists  are archived; the archives can be accessed via the
93       administrative addresses listed above.  There is also a  hypertext  ar‐
94       chive,   maintained   by   Geoff   Wing   <gcw@zsh.org>,  available  at
95       https://www.zsh.org/mla/.
96

THE ZSH FAQ

98       Zsh has a list of Frequently Asked Questions (FAQ), maintained by Peter
99       Stephenson  <pws@zsh.org>.   It  is  regularly  posted to the newsgroup
100       comp.unix.shell and the zsh-announce mailing list.  The latest  version
101       can    be    found   at   any   of   the   Zsh   FTP   sites,   or   at
102       http://www.zsh.org/FAQ/.  The contact address for  FAQ-related  matters
103       is <faqmaster@zsh.org>.
104

THE ZSH WEB PAGE

106       Zsh  has  a web page which is located at https://www.zsh.org/.  This is
107       maintained by Karsten Thygesen <karthy@zsh.org>,  of  SunSITE  Denmark.
108       The contact address for web-related matters is <webmaster@zsh.org>.
109

THE ZSH USERGUIDE

111       A  userguide is currently in preparation.  It is intended to complement
112       the manual, with explanations and hints on issues where the manual  can
113       be cabbalistic, hierographic, or downright mystifying (for example, the
114       word `hierographic' does not exist).  It can be viewed in  its  current
115       state  at  http://zsh.sourceforge.net/Guide/.   At the time of writing,
116       chapters dealing with startup files and their contents and the new com‐
117       pletion system were essentially complete.
118

INVOCATION

120       The following flags are interpreted by the shell when invoked to deter‐
121       mine where the shell will read commands from:
122
123       -c     Take the first argument as a command  to  execute,  rather  than
124              reading  commands  from a script or standard input.  If any fur‐
125              ther arguments are given, the  first  one  is  assigned  to  $0,
126              rather than being used as a positional parameter.
127
128       -i     Force  shell to be interactive.  It is still possible to specify
129              a script to execute.
130
131       -s     Force shell to read commands from the standard input.  If the -s
132              flag is not present and an argument is given, the first argument
133              is taken to be the pathname of a script to execute.
134
135       If there are any remaining arguments after option processing, and  nei‐
136       ther  of the options -c or -s was supplied, the first argument is taken
137       as the file name of a script containing shell commands to be  executed.
138       If  the option PATH_SCRIPT is set, and the file name does not contain a
139       directory path (i.e. there is no `/' in the name),  first  the  current
140       directory  and  then  the  command  path given by the variable PATH are
141       searched for the script.  If the option is not set  or  the  file  name
142       contains a `/' it is used directly.
143
144       After  the  first  one  or  two arguments have been appropriated as de‐
145       scribed above, the remaining arguments are assigned to  the  positional
146       parameters.
147
148       For  further  options,  which  are  common  to  invocation  and the set
149       builtin, see zshoptions(1).
150
151       The long option `--emulate' followed (in a separate word) by an  emula‐
152       tion  mode  may  be passed to the shell.  The emulation modes are those
153       described for the emulate builtin, see zshbuiltins(1).  The `--emulate'
154       option  must  precede any other options (which might otherwise be over‐
155       ridden), but following options are honoured, so may be used  to  modify
156       the  requested emulation mode.  Note that certain extra steps are taken
157       to ensure a smooth emulation when this option is used compared with the
158       emulate  command within the shell: for example, variables that conflict
159       with POSIX usage such as path are not defined within the shell.
160
161       Options may be specified by name using the -o option.  -o acts  like  a
162       single-letter  option, but takes a following string as the option name.
163       For example,
164
165              zsh -x -o shwordsplit scr
166
167       runs the script scr, setting the XTRACE  option  by  the  corresponding
168       letter  `-x'  and  the  SH_WORD_SPLIT  option  by name.  Options may be
169       turned off by name by using +o instead of -o.  -o  can  be  stacked  up
170       with  preceding single-letter options, so for example `-xo shwordsplit'
171       or `-xoshwordsplit' is equivalent to `-x -o shwordsplit'.
172
173       Options may also be specified by name in GNU long option style,  `--op‐
174       tion-name'.   When  this is done, `-' characters in the option name are
175       permitted: they are translated into `_', and thus ignored.  So, for ex‐
176       ample,  `zsh --sh-word-split' invokes zsh with the SH_WORD_SPLIT option
177       turned on.  Like other option syntaxes, options can be  turned  off  by
178       replacing the initial `-' with a `+'; thus `+-sh-word-split' is equiva‐
179       lent to `--no-sh-word-split'.  Unlike other option syntaxes,  GNU-style
180       long  options  cannot be stacked with any other options, so for example
181       `-x-shwordsplit' is an  error,  rather  than  being  treated  like  `-x
182       --shwordsplit'.
183
184       The  special GNU-style option `--version' is handled; it sends to stan‐
185       dard output the shell's version information, then  exits  successfully.
186       `--help' is also handled; it sends to standard output a list of options
187       that can be used when invoking the shell, then exits successfully.
188
189       Option processing may be finished, allowing  following  arguments  that
190       start  with  `-' or `+' to be treated as normal arguments, in two ways.
191       Firstly, a lone `-' (or `+') as an argument by itself ends option  pro‐
192       cessing.  Secondly, a special option `--' (or `+-'), which may be spec‐
193       ified on its own (which is the standard POSIX usage) or may be  stacked
194       with  preceding  options  (so `-x-' is equivalent to `-x --').  Options
195       are not permitted to be stacked after `--' (so `-x-f' is an error), but
196       note  the  GNU-style option form discussed above, where `--shwordsplit'
197       is permitted and does not end option processing.
198
199       Except when the sh/ksh emulation single-letter options are  in  effect,
200       the  option  `-b' (or `+b') ends option processing.  `-b' is like `--',
201       except that further single-letter options can be stacked after the `-b'
202       and will take effect as normal.
203

COMPATIBILITY

205       Zsh  tries to emulate sh or ksh when it is invoked as sh or ksh respec‐
206       tively; more precisely, it looks at the first letter  of  the  name  by
207       which  it  was invoked, excluding any initial `r' (assumed to stand for
208       `restricted'), and if that is `b', `s' or `k' it  will  emulate  sh  or
209       ksh.   Furthermore,  if invoked as su (which happens on certain systems
210       when the shell is executed by the su command), the shell  will  try  to
211       find  an  alternative name from the SHELL environment variable and per‐
212       form emulation based on that.
213
214       In sh and ksh compatibility modes the following parameters are not spe‐
215       cial  and  not  initialized  by the shell: ARGC, argv, cdpath, fignore,
216       fpath, HISTCHARS, mailpath, MANPATH,  manpath,  path,  prompt,  PROMPT,
217       PROMPT2, PROMPT3, PROMPT4, psvar, status, watch.
218
219       The  usual zsh startup/shutdown scripts are not executed.  Login shells
220       source /etc/profile followed by $HOME/.profile.  If the ENV environment
221       variable  is  set  on  invocation,  $ENV  is  sourced after the profile
222       scripts.  The value of ENV is subjected to parameter expansion, command
223       substitution,  and  arithmetic  expansion before being interpreted as a
224       pathname.  Note that the PRIVILEGED option also affects  the  execution
225       of startup files.
226
227       The  following  options  are  set if the shell is invoked as sh or ksh:
228       NO_BAD_PATTERN,   NO_BANG_HIST,   NO_BG_NICE,    NO_EQUALS,    NO_FUNC‐
229       TION_ARGZERO,  GLOB_SUBST,  NO_GLOBAL_EXPORT,  NO_HUP, INTERACTIVE_COM‐
230       MENTS, KSH_ARRAYS, NO_MULTIOS, NO_NOMATCH,  NO_NOTIFY,  POSIX_BUILTINS,
231       NO_PROMPT_PERCENT,  RM_STAR_SILENT,  SH_FILE_EXPANSION, SH_GLOB, SH_OP‐
232       TION_LETTERS,  SH_WORD_SPLIT.   Additionally  the  BSD_ECHO   and   IG‐
233       NORE_BRACES options are set if zsh is invoked as sh.  Also, the KSH_OP‐
234       TION_PRINT,   LOCAL_OPTIONS,   PROMPT_BANG,   PROMPT_SUBST   and   SIN‐
235       GLE_LINE_ZLE options are set if zsh is invoked as ksh.
236

RESTRICTED SHELL

238       When  the  basename  of  the command used to invoke zsh starts with the
239       letter `r' or the `-r' command line option is supplied  at  invocation,
240       the  shell  becomes  restricted.   Emulation  mode  is determined after
241       stripping the letter `r' from the invocation name.  The  following  are
242       disabled in restricted mode:
243
244       •      changing directories with the cd builtin
245
246       •      changing  or  unsetting the EGID, EUID, GID, HISTFILE, HISTSIZE,
247              IFS,  LD_AOUT_LIBRARY_PATH,  LD_AOUT_PRELOAD,   LD_LIBRARY_PATH,
248              LD_PRELOAD, MODULE_PATH, module_path, PATH, path, SHELL, UID and
249              USERNAME parameters
250
251       •      specifying command names containing /
252
253       •      specifying command pathnames using hash
254
255       •      redirecting output to files
256
257       •      using the exec builtin command to replace the shell with another
258              command
259
260       •      using jobs -Z to overwrite the shell process' argument and envi‐
261              ronment space
262
263       •      using the ARGV0 parameter to override argv[0] for external  com‐
264              mands
265
266       •      turning off restricted mode with set +r or unsetopt RESTRICTED
267
268       These  restrictions  are  enforced  after processing the startup files.
269       The startup files should set up PATH to point to a  directory  of  com‐
270       mands  which can be safely invoked in the restricted environment.  They
271       may also add further restrictions by disabling selected builtins.
272
273       Restricted mode can also be activated  any  time  by  setting  the  RE‐
274       STRICTED  option.   This  immediately  enables all the restrictions de‐
275       scribed above even if the shell still has  not  processed  all  startup
276       files.
277
278       A  shell  Restricted Mode is an outdated way to restrict what users may
279       do:  modern systems have better, safer and more reliable ways  to  con‐
280       fine user actions, such as chroot jails, containers and zones.
281
282       A  restricted shell is very difficult to implement safely.  The feature
283       may be removed in a future version of zsh.
284
285       It is important to realise that the  restrictions  only  apply  to  the
286       shell,  not  to  the commands it runs (except for some shell builtins).
287       While a restricted shell can only run the restricted list  of  commands
288       accessible  via  the  predefined  `PATH'  variable, it does not prevent
289       those commands from running any other command.
290
291       As an example, if `env' is among the list of allowed commands, then  it
292       allows the user to run any command as `env' is not a shell builtin com‐
293       mand and can run arbitrary executables.
294
295       So when implementing a restricted shell framework it is important to be
296       fully  aware  of  what actions each of the allowed commands or features
297       (which may be regarded as modules) can perform.
298
299       Many commands can have their behaviour affected  by  environment  vari‐
300       ables.  Except for the few listed above, zsh does not restrict the set‐
301       ting of environment variables.
302
303       If a `perl', `python', `bash', or  other  general  purpose  interpreted
304       script it treated as a restricted command, the user can work around the
305       restriction by  setting  specially  crafted  `PERL5LIB',  `PYTHONPATH',
306       `BASHENV' (etc.) environment variables. On GNU systems, any command can
307       be made to run arbitrary code when performing character set  conversion
308       (including  zsh itself) by setting a `GCONV_PATH' environment variable.
309       Those are only a few examples.
310
311       Bear in mind that, contrary to some other shells, `readonly' is  not  a
312       security  feature  in  zsh as it can be undone and so cannot be used to
313       mitigate the above.
314
315       A restricted shell only works if the allowed commands are few and care‐
316       fully  written  so  as not to grant more access to users than intended.
317       It is also important to restrict what zsh module the user may  load  as
318       some  of them, such as `zsh/system', `zsh/mapfile' and `zsh/files', al‐
319       low bypassing most of the restrictions.
320

STARTUP/SHUTDOWN FILES

322       Commands are first read from /etc/zshenv; this  cannot  be  overridden.
323       Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the
324       former affects all startup files, while the second only affects  global
325       startup  files  (those  shown here with an path starting with a /).  If
326       one of the options is  unset  at  any  point,  any  subsequent  startup
327       file(s)  of the corresponding type will not be read.  It is also possi‐
328       ble for a file in  $ZDOTDIR  to  re-enable  GLOBAL_RCS.  Both  RCS  and
329       GLOBAL_RCS are set by default.
330
331       Commands  are then read from $ZDOTDIR/.zshenv.  If the shell is a login
332       shell, commands are read from /etc/zprofile  and  then  $ZDOTDIR/.zpro‐
333       file.   Then,  if  the  shell  is  interactive,  commands are read from
334       /etc/zshrc and then $ZDOTDIR/.zshrc.  Finally, if the shell is a  login
335       shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
336
337       When a login shell exits, the files $ZDOTDIR/.zlogout and then /etc/zl‐
338       ogout are read.  This happens with either an explicit exit via the exit
339       or logout commands, or an implicit exit by reading end-of-file from the
340       terminal.  However, if the shell terminates  due  to  exec'ing  another
341       process, the logout files are not read.  These are also affected by the
342       RCS and GLOBAL_RCS options.  Note also that the RCS option affects  the
343       saving  of history files, i.e. if RCS is unset when the shell exits, no
344       history file will be saved.
345
346       If ZDOTDIR is unset, HOME is used instead.  Files listed above as being
347       in /etc may be in another directory, depending on the installation.
348
349       As /etc/zshenv is run for all instances of zsh, it is important that it
350       be kept as small as possible.  In particular, it is a good idea to  put
351       code  that does not need to be run for every single shell behind a test
352       of the form `if [[ -o rcs ]]; then ...' so that it will not be executed
353       when zsh is invoked with the `-f' option.
354
355       Any  of  these files may be pre-compiled with the zcompile builtin com‐
356       mand (see zshbuiltins(1)).  If a compiled file exists  (named  for  the
357       original  file plus the .zwc extension) and it is newer than the origi‐
358       nal file, the compiled file will be used instead.
359
360
361
362ZSHROADMAP(1)               General Commands Manual              ZSHROADMAP(1)
363
364
365

NAME

367       zshroadmap - informal introduction to the zsh manual  The  Zsh  Manual,
368       like the shell itself, is large and often complicated.  This section of
369       the manual provides some pointers to areas of the shell that are likely
370       to  be  of particular interest to new users, and indicates where in the
371       rest of the manual the documentation is to be found.
372

WHEN THE SHELL STARTS

374       When it starts, the shell reads commands from various files.  These can
375       be  created  or  edited  to  customize  the  shell.   See  the  section
376       Startup/Shutdown Files in zsh(1).
377
378       If no personal initialization files exist for the current user, a func‐
379       tion  is  run  to help you change some of the most common settings.  It
380       won't appear if your administrator has disabled the zsh/newuser module.
381       The  function  is  designed  to be self-explanatory.  You can run it by
382       hand with `autoload -Uz zsh-newuser-install;  zsh-newuser-install  -f'.
383       See also the section User Configuration Functions in zshcontrib(1).
384

INTERACTIVE USE

386       Interaction with the shell uses the builtin Zsh Line Editor, ZLE.  This
387       is described in detail in zshzle(1).
388
389       The first decision a user must make is whether to use the Emacs  or  Vi
390       editing  mode  as  the  keys  for  editing are substantially different.
391       Emacs editing mode is probably more natural for beginners  and  can  be
392       selected explicitly with the command bindkey -e.
393
394       A  history mechanism for retrieving previously typed lines (most simply
395       with the Up or Down arrow keys) is available; note that,  unlike  other
396       shells,  zsh  will not save these lines when the shell exits unless you
397       set appropriate variables, and the number of history lines retained  by
398       default  is  quite  small (30 lines).  See the description of the shell
399       variables (referred to in the documentation  as  parameters)  HISTFILE,
400       HISTSIZE  and  SAVEHIST  in zshparam(1).  Note that it's currently only
401       possible to read and write files saving history when the shell  is  in‐
402       teractive, i.e. it does not work from scripts.
403
404       The shell now supports the UTF-8 character set (and also others if sup‐
405       ported by the operating system).  This is  (mostly)  handled  transpar‐
406       ently  by the shell, but the degree of support in terminal emulators is
407       variable.   There  is  some  discussion  of  this  in  the  shell  FAQ,
408       http://www.zsh.org/FAQ/.  Note in particular that for combining charac‐
409       ters to be handled the option COMBINING_CHARS needs to be set.  Because
410       the shell is now more sensitive to the definition of the character set,
411       note that if you are upgrading from an older version of the  shell  you
412       should ensure that the appropriate variable, either LANG (to affect all
413       aspects of the shell's operation) or LC_CTYPE (to affect only the  han‐
414       dling  of character sets) is set to an appropriate value.  This is true
415       even if you are using a single-byte character set including  extensions
416       of  ASCII  such  as  ISO-8859-1 or ISO-8859-15.  See the description of
417       LC_CTYPE in zshparam(1).
418
419   Completion
420       Completion is a feature present in many shells. It allows the  user  to
421       type only a part (usually the prefix) of a word and have the shell fill
422       in the rest.  The completion system in zsh is programmable.  For  exam‐
423       ple,  the  shell can be set to complete email addresses in arguments to
424       the mail command from your ~/.abook/addressbook; usernames,  hostnames,
425       and  even  remote  paths in arguments to scp, and so on.  Anything that
426       can be written in or glued together with zsh can be the source of  what
427       the line editor offers as possible completions.
428
429       Zsh  has  two  completion systems, an old, so called compctl completion
430       (named after the builtin command that serves as its complete  and  only
431       user  interface),  and  a new one, referred to as compsys, organized as
432       library of builtin and user-defined functions.  The two systems  differ
433       in  their  interface  for  specifying the completion behavior.  The new
434       system is more customizable and is supplied with completions  for  many
435       commonly used commands; it is therefore to be preferred.
436
437       The completion system must be enabled explicitly when the shell starts.
438       For more information see zshcompsys(1).
439
440   Extending the line editor
441       Apart from completion, the line editor is highly extensible by means of
442       shell  functions.   Some  useful functions are provided with the shell;
443       they provide facilities such as:
444
445       insert-composed-char
446              composing characters not found on the keyboard
447
448       match-words-by-style
449              configuring what the line editor considers a word when moving or
450              deleting by word
451
452       history-beginning-search-backward-end, etc.
453              alternative ways of searching the shell history
454
455       replace-string, replace-pattern
456              functions for replacing strings or patterns globally in the com‐
457              mand line
458
459       edit-command-line
460              edit the command line with an external editor.
461
462       See the section `ZLE Functions' in zshcontrib(1)  for  descriptions  of
463       these.
464

OPTIONS

466       The  shell  has  a  large number of options for changing its behaviour.
467       These cover all aspects of the shell; browsing the  full  documentation
468       is  the only good way to become acquainted with the many possibilities.
469       See zshoptions(1).
470

PATTERN MATCHING

472       The shell has a rich set of  patterns  which  are  available  for  file
473       matching  (described  in the documentation as `filename generation' and
474       also known for historical reasons as `globbing') and for use when  pro‐
475       gramming.   These are described in the section `Filename Generation' in
476       zshexpn(1).
477
478       Of particular interest are the following patterns that are not commonly
479       supported by other systems of pattern matching:
480
481       **     for matching over multiple directories
482
483       |      for matching either of two alternatives
484
485       ~, ^   the  ability  to  exclude  patterns  from  matching when the EX‐
486              TENDED_GLOB option is set
487
488       (...)  glob qualifiers, included in parentheses at the end of the  pat‐
489              tern, which select files by type (such as directories) or attri‐
490              bute (such as size).
491

GENERAL COMMENTS ON SYNTAX

493       Although the syntax of zsh is in ways similar to the  Korn  shell,  and
494       therefore  more  remotely to the original UNIX shell, the Bourne shell,
495       its default behaviour does not entirely  correspond  to  those  shells.
496       General  shell  syntax  is introduced in the section `Shell Grammar' in
497       zshmisc(1).
498
499       One commonly encountered difference is that variables substituted  onto
500       the  command line are not split into words.  See the description of the
501       shell option SH_WORD_SPLIT in the section `Parameter Expansion' in zsh‐
502       expn(1).  In zsh, you can either explicitly request the splitting (e.g.
503       ${=foo}) or use an array when you want a variable  to  expand  to  more
504       than one word.  See the section `Array Parameters' in zshparam(1).
505

PROGRAMMING

507       The  most  convenient  way of adding enhancements to the shell is typi‐
508       cally by writing a shell function  and  arranging  for  it  to  be  au‐
509       toloaded.   Functions  are described in the section `Functions' in zsh‐
510       misc(1).  Users changing from the C shell and its relatives should  no‐
511       tice  that  aliases are less used in zsh as they don't perform argument
512       substitution, only simple text replacement.
513
514       A few general functions, other than those for the line editor described
515       above,  are provided with the shell and are described in zshcontrib(1).
516       Features include:
517
518       promptinit
519              a prompt theme system for changing prompts easily, see the  sec‐
520              tion `Prompt Themes'
521
522
523       zsh-mime-setup
524              a  MIME-handling  system  which dispatches commands according to
525              the suffix of a file as done by graphical file managers
526
527       zcalc  a calculator
528
529       zargs  a version of xargs that makes the find command redundant
530
531       zmv    a command for renaming files by means of shell patterns.
532
533
534
535ZSHMISC(1)                  General Commands Manual                 ZSHMISC(1)
536
537
538

NAME

540       zshmisc - everything and then some
541

SIMPLE COMMANDS & PIPELINES

543       A simple command is a sequence of optional parameter  assignments  fol‐
544       lowed  by  blank-separated  words,  with  optional  redirections inter‐
545       spersed.  For a description of assignment, see the  beginning  of  zsh‐
546       param(1).
547
548       The  first word is the command to be executed, and the remaining words,
549       if any, are arguments to the command.  If a command name is given,  the
550       parameter  assignments modify the environment of the command when it is
551       executed.  The value of a simple command is its  exit  status,  or  128
552       plus the signal number if terminated by a signal.  For example,
553
554              echo foo
555
556       is a simple command with arguments.
557
558       A  pipeline  is  either  a simple command, or a sequence of two or more
559       simple commands where each command is separated from the next by `|' or
560       `|&'.   Where commands are separated by `|', the standard output of the
561       first command is connected to the standard input of the next.  `|&'  is
562       shorthand for `2>&1 |', which connects both the standard output and the
563       standard error of the command to the standard input of the  next.   The
564       value  of a pipeline is the value of the last command, unless the pipe‐
565       line is preceded by `!' in which case the value is the logical  inverse
566       of the value of the last command.  For example,
567
568              echo foo | sed 's/foo/bar/'
569
570       is  a  pipeline,  where  the output (`foo' plus a newline) of the first
571       command will be passed to the input of the second.
572
573       If a pipeline is preceded by `coproc', it is executed as a coprocess; a
574       two-way pipe is established between it and the parent shell.  The shell
575       can read from or write to the coprocess by means of the `>&p' and `<&p'
576       redirection  operators  or  with  `print -p' and `read -p'.  A pipeline
577       cannot be preceded by both `coproc' and `!'.  If job control is active,
578       the coprocess can be treated in other than input and output as an ordi‐
579       nary background job.
580
581       A sublist is either a single pipeline, or a sequence  of  two  or  more
582       pipelines separated by `&&' or `||'.  If two pipelines are separated by
583       `&&', the second pipeline is executed only if the first  succeeds  (re‐
584       turns a zero status).  If two pipelines are separated by `||', the sec‐
585       ond is executed only if the first fails  (returns  a  nonzero  status).
586       Both  operators  have  equal  precedence and are left associative.  The
587       value of the sublist is the value of the last pipeline  executed.   For
588       example,
589
590              dmesg | grep panic && print yes
591
592       is a sublist consisting of two pipelines, the second just a simple com‐
593       mand which will be executed if and only if the grep command  returns  a
594       zero  status.   If it does not, the value of the sublist is that return
595       status, else it is the status returned by the print  (almost  certainly
596       zero).
597
598       A list is a sequence of zero or more sublists, in which each sublist is
599       terminated by `;', `&', `&|', `&!', or a newline.  This terminator  may
600       optionally  be  omitted from the last sublist in the list when the list
601       appears as a complex command inside `(...)' or `{...}'.  When a sublist
602       is  terminated  by `;' or newline, the shell waits for it to finish be‐
603       fore executing the next sublist.  If a sublist is terminated by a  `&',
604       `&|',  or `&!', the shell executes the last pipeline in it in the back‐
605       ground, and does not wait for it to finish (note  the  difference  from
606       other  shells  which  execute  the whole sublist in the background).  A
607       backgrounded pipeline returns a status of zero.
608
609       More generally, a list can be seen as a set of any shell commands what‐
610       soever,  including the complex commands below; this is implied wherever
611       the word `list' appears in later descriptions.  For example,  the  com‐
612       mands in a shell function form a special sort of list.
613

PRECOMMAND MODIFIERS

615       A  simple  command may be preceded by a precommand modifier, which will
616       alter how the  command  is  interpreted.   These  modifiers  are  shell
617       builtin  commands  with  the exception of nocorrect which is a reserved
618       word.
619
620       -      The command is executed with a  `-'  prepended  to  its  argv[0]
621              string.
622
623       builtin
624              The  command  word is taken to be the name of a builtin command,
625              rather than a shell function or external command.
626
627       command [ -pvV ]
628              The command word is taken to be the name of an external command,
629              rather than a shell function or builtin.   If the POSIX_BUILTINS
630              option is set, builtins will also be executed but  certain  spe‐
631              cial properties of them are suppressed. The -p flag causes a de‐
632              fault path to be searched instead of that in $path. With the  -v
633              flag, command is similar to whence and with -V, it is equivalent
634              to whence -v.
635
636       exec [ -cl ] [ -a argv0 ]
637              The following command together with  any  arguments  is  run  in
638              place of the current process, rather than as a sub-process.  The
639              shell does not fork and is replaced.  The shell does not  invoke
640              TRAPEXIT,  nor  does  it  source zlogout files.  The options are
641              provided for compatibility with other shells.
642
643              The -c option clears the environment.
644
645              The -l option is equivalent to the  -  precommand  modifier,  to
646              treat  the  replacement command as a login shell; the command is
647              executed with a - prepended to its argv[0]  string.   This  flag
648              has no effect if used together with the -a option.
649
650              The  -a  option is used to specify explicitly the argv[0] string
651              (the name of the command as seen by the process  itself)  to  be
652              used  by  the  replacement command and is directly equivalent to
653              setting a value for the ARGV0 environment variable.
654
655       nocorrect
656              Spelling correction is not done on any of the words.  This  must
657              appear  before  any  other  precommand modifier, as it is inter‐
658              preted immediately, before any parsing is done.  It has  no  ef‐
659              fect in non-interactive shells.
660
661       noglob Filename  generation  (globbing)  is not performed on any of the
662              words.
663

COMPLEX COMMANDS

665       A complex command in zsh is one of the following:
666
667       if list then list [ elif list then list ] ... [ else list ] fi
668              The if list is executed, and if it returns a zero  exit  status,
669              the then list is executed.  Otherwise, the elif list is executed
670              and if its status is zero, the then list is executed.   If  each
671              elif list returns nonzero status, the else list is executed.
672
673       for name ... [ in word ... ] term do list done
674              Expand  the list of words, and set the parameter name to each of
675              them in turn, executing list each time.  If  the  `in  word'  is
676              omitted, use the positional parameters instead of the words.
677
678              The  term  consists  of one or more newline or ; which terminate
679              the words, and are optional when the `in word' is omitted.
680
681              More than one parameter name  can  appear  before  the  list  of
682              words.  If N names are given, then on each execution of the loop
683              the next N words are assigned to the  corresponding  parameters.
684              If  there are more names than remaining words, the remaining pa‐
685              rameters are each set to the empty  string.   Execution  of  the
686              loop ends when there is no remaining word to assign to the first
687              name.  It is only possible for in to appear as the first name in
688              the  list,  else  it  will  be treated as marking the end of the
689              list.
690
691       for (( [expr1] ; [expr2] ; [expr3] )) do list done
692              The arithmetic expression expr1 is evaluated first (see the sec‐
693              tion  `Arithmetic Evaluation').  The arithmetic expression expr2
694              is repeatedly evaluated until it  evaluates  to  zero  and  when
695              non-zero,  list  is executed and the arithmetic expression expr3
696              evaluated.  If any expression is omitted, then it behaves as  if
697              it evaluated to 1.
698
699       while list do list done
700              Execute  the  do  list  as long as the while list returns a zero
701              exit status.
702
703       until list do list done
704              Execute the do list as long as until list returns a nonzero exit
705              status.
706
707       repeat word do list done
708              word  is expanded and treated as an arithmetic expression, which
709              must evaluate to a number n.  list is then executed n times.
710
711              The repeat syntax is disabled by default when the  shell  starts
712              in  a  mode emulating another shell.  It can be enabled with the
713              command `enable -r repeat'
714
715       case word in [ [(] pattern [ | pattern ] ... ) list  (;;|;&|;|)  ]  ...
716       esac
717              Execute  the list associated with the first pattern that matches
718              word, if any.  The form of the patterns is the same as that used
719              for filename generation.  See the section `Filename Generation'.
720
721              Note  further  that, unless the SH_GLOB option is set, the whole
722              pattern with alternatives is treated by the shell as  equivalent
723              to  a group of patterns within parentheses, although white space
724              may appear about the parentheses and the vertical bar  and  will
725              be  stripped  from the pattern at those points.  White space may
726              appear elsewhere in the pattern; this is not stripped.   If  the
727              SH_GLOB option is set, so that an opening parenthesis can be un‐
728              ambiguously treated as part of the case syntax,  the  expression
729              is  parsed  into  separate words and these are treated as strict
730              alternatives (as in other shells).
731
732              If the list that is executed is terminated with ;&  rather  than
733              ;;,  the following list is also executed.  The rule for the ter‐
734              minator of the following list ;;, ;& or ;| is applied unless the
735              esac is reached.
736
737              If  the  list  that  is executed is terminated with ;| the shell
738              continues to scan the patterns looking for the next match,  exe‐
739              cuting  the  corresponding  list,  and applying the rule for the
740              corresponding terminator ;;, ;& or ;|.  Note that  word  is  not
741              re-expanded;  all  applicable  patterns are tested with the same
742              word.
743
744       select name [ in word ... term ] do list done
745              where term is one or more newline or ; to terminate  the  words.
746              Print  the  set  of words, each preceded by a number.  If the in
747              word is omitted, use the  positional  parameters.   The  PROMPT3
748              prompt is printed and a line is read from the line editor if the
749              shell is interactive and that is active, or else standard input.
750              If  this line consists of the number of one of the listed words,
751              then the parameter name is set to the word corresponding to this
752              number.   If  this  line is empty, the selection list is printed
753              again.  Otherwise, the value of the parameter  name  is  set  to
754              null.   The  contents  of  the  line read from standard input is
755              saved in the parameter REPLY.  list is executed for each  selec‐
756              tion until a break or end-of-file is encountered.
757
758       ( list )
759              Execute  list  in a subshell.  Traps set by the trap builtin are
760              reset to their default values while executing list.
761
762       { list }
763              Execute list.
764
765       { try-list } always { always-list }
766              First execute try-list.  Regardless of errors, or break or  con‐
767              tinue commands encountered within try-list, execute always-list.
768              Execution then continues from the result  of  the  execution  of
769              try-list;  in  other words, any error, or break or continue com‐
770              mand is treated in the normal way, as if  always-list  were  not
771              present.   The  two  chunks  of code are referred to as the `try
772              block' and the `always block'.
773
774              Optional newlines or semicolons may  appear  after  the  always;
775              note,  however,  that  they may not appear between the preceding
776              closing brace and the always.
777
778              An `error' in this context is a condition such as a syntax error
779              which  causes  the shell to abort execution of the current func‐
780              tion, script, or list.   Syntax  errors  encountered  while  the
781              shell is parsing the code do not cause the always-list to be ex‐
782              ecuted.  For example, an erroneously  constructed  if  block  in
783              try-list  would cause the shell to abort during parsing, so that
784              always-list would not be executed, while an erroneous  substitu‐
785              tion  such as ${*foo*} would cause a run-time error, after which
786              always-list would be executed.
787
788              An error condition can be tested and reset with the special  in‐
789              teger  variable  TRY_BLOCK_ERROR.   Outside  an  always-list the
790              value is irrelevant, but it is initialised to  -1.   Inside  al‐
791              ways-list,  the value is 1 if an error occurred in the try-list,
792              else 0.  If TRY_BLOCK_ERROR is set to 0 during the  always-list,
793              the  error  condition caused by the try-list is reset, and shell
794              execution continues normally after the end of always-list.   Al‐
795              tering  the value during the try-list is not useful (unless this
796              forms part of an enclosing always block).
797
798              Regardless of TRY_BLOCK_ERROR, after the end of always-list  the
799              normal  shell  status  $?  is  the value returned from try-list.
800              This  will  be  non-zero  if  there  was  an  error,   even   if
801              TRY_BLOCK_ERROR was set to zero.
802
803              The  following  executes  the given code, ignoring any errors it
804              causes.  This is an alternative to the usual convention of  pro‐
805              tecting code by executing it in a subshell.
806
807                     {
808                         # code which may cause an error
809                       } always {
810                         # This code is executed regardless of the error.
811                         (( TRY_BLOCK_ERROR = 0 ))
812                     }
813                     # The error condition has been reset.
814
815              When  a  try block occurs outside of any function, a return or a
816              exit encountered in try-list does not cause the execution of al‐
817              ways-list.   Instead, the shell exits immediately after any EXIT
818              trap has been executed.  Otherwise, a return command encountered
819              in  try-list  will cause the execution of always-list, just like
820              break and continue.
821
822       function word ... [ () ] [ term ] { list }
823       word ... () [ term ] { list }
824       word ... () [ term ] command
825              where term is one or more newline or ;.  Define a function which
826              is  referenced  by  any one of word.  Normally, only one word is
827              provided; multiple words are usually  only  useful  for  setting
828              traps.   The  body of the function is the list between the { and
829              }.  See the section `Functions'.
830
831              If the option  SH_GLOB  is  set  for  compatibility  with  other
832              shells,  then  whitespace  may appear between the left and right
833              parentheses when there is a single word;  otherwise, the  paren‐
834              theses  will  be  treated  as forming a globbing pattern in that
835              case.
836
837              In any of the forms above, a redirection may appear outside  the
838              function body, for example
839
840                     func() { ... } 2>&1
841
842              The redirection is stored with the function and applied whenever
843              the function is executed.  Any variables in the redirection  are
844              expanded  at the point the function is executed, but outside the
845              function scope.
846
847       time [ pipeline ]
848              The pipeline is executed, and timing statistics are reported  on
849              the  standard error in the form specified by the TIMEFMT parame‐
850              ter.  If pipeline is omitted, print statistics about  the  shell
851              process and its children.
852
853       [[ exp ]]
854              Evaluates  the conditional expression exp and return a zero exit
855              status if it is true.  See the section `Conditional Expressions'
856              for a description of exp.
857

ALTERNATE FORMS FOR COMPLEX COMMANDS

859       Many  of  zsh's  complex  commands  have  alternate  forms.   These are
860       non-standard and are likely not to be obvious even  to  seasoned  shell
861       programmers; they should not be used anywhere that portability of shell
862       code is a concern.
863
864       The short versions below only work if sublist is of the form `{ list }'
865       or  if the SHORT_LOOPS option is set.  For the if, while and until com‐
866       mands, in both these cases the test part of the loop must also be suit‐
867       ably  delimited, such as by `[[ ... ]]' or `(( ... ))', else the end of
868       the test will not be recognized.  For the for, repeat, case and  select
869       commands  no  such special form for the arguments is necessary, but the
870       other condition (the special form of sublist or use of the  SHORT_LOOPS
871       option) still applies.
872
873       if list { list } [ elif list { list } ] ... [ else { list } ]
874              An alternate form of if.  The rules mean that
875
876                     if [[ -o ignorebraces ]] {
877                       print yes
878                     }
879
880              works, but
881
882                     if true {  # Does not work!
883                       print yes
884                     }
885
886              does not, since the test is not suitably delimited.
887
888       if list sublist
889              A  short  form of the alternate if.  The same limitations on the
890              form of list apply as for the previous form.
891
892       for name ... ( word ... ) sublist
893              A short form of for.
894
895       for name ... [ in word ... ] term sublist
896              where term is at least one newline or ;.  Another short form  of
897              for.
898
899       for (( [expr1] ; [expr2] ; [expr3] )) sublist
900              A short form of the arithmetic for command.
901
902       foreach name ... ( word ... ) list end
903              Another form of for.
904
905       while list { list }
906              An  alternative form of while.  Note the limitations on the form
907              of list mentioned above.
908
909       until list { list }
910              An alternative form of until.  Note the limitations on the  form
911              of list mentioned above.
912
913       repeat word sublist
914              This is a short form of repeat.
915
916       case word { [ [(] pattern [ | pattern ] ... ) list (;;|;&|;|) ] ... }
917              An alternative form of case.
918
919       select name [ in word ... term ] sublist
920              where  term  is  at least one newline or ;.  A short form of se‐
921              lect.
922
923       function word ... [ () ] [ term ] sublist
924              This is a short form of function.
925

RESERVED WORDS

927       The following words are recognized as reserved words when used  as  the
928       first word of a command unless quoted or disabled using disable -r:
929
930       do  done  esac then elif else fi for case if while function repeat time
931       until select coproc nocorrect foreach end ! [[ { } declare export float
932       integer local readonly typeset
933
934       Additionally,  `}'  is  recognized  in  any position if neither the IG‐
935       NORE_BRACES option nor the IGNORE_CLOSE_BRACES option is set.
936

ERRORS

938       Certain errors are treated as fatal by the  shell:  in  an  interactive
939       shell,  they  cause  control  to  return  to the command line, and in a
940       non-interactive shell they cause the shell to  be  aborted.   In  older
941       versions  of  zsh,  a  non-interactive shell running a script would not
942       abort completely, but would resume execution at the next command to  be
943       read  from the script, skipping the remainder of any functions or shell
944       constructs such as loops or conditions; this somewhat illogical  behav‐
945       iour can be recovered by setting the option CONTINUE_ON_ERROR.
946
947       Fatal errors found in non-interactive shells include:
948
949       •      Failure to parse shell options passed when invoking the shell
950
951       •      Failure to change options with the set builtin
952
953       •      Parse errors of all sorts, including failures to parse mathemat‐
954              ical expressions
955
956       •      Failures to set or modify variable behaviour with  typeset,  lo‐
957              cal, declare, export, integer, float
958
959       •      Execution  of  incorrectly  positioned  loop  control structures
960              (continue, break)
961
962       •      Attempts to use regular expression with  no  regular  expression
963              module available
964
965       •      Disallowed operations when the RESTRICTED options is set
966
967       •      Failure to create a pipe needed for a pipeline
968
969       •      Failure to create a multio
970
971       •      Failure to autoload a module needed for a declared shell feature
972
973       •      Errors creating command or process substitutions
974
975       •      Syntax errors in glob qualifiers
976
977       •      File  generation  errors where not caught by the option BAD_PAT‐
978              TERN
979
980       •      All bad patterns used for matching within case statements
981
982       •      File generation failures where not caused by NO_MATCH or similar
983              options
984
985       •      All  file generation errors where the pattern was used to create
986              a multio
987
988       •      Memory errors where detected by the shell
989
990       •      Invalid subscripts to shell variables
991
992       •      Attempts to assign read-only variables
993
994       •      Logical errors with variables such as assignment  to  the  wrong
995              type
996
997       •      Use of invalid variable names
998
999       •      Errors in variable substitution syntax
1000
1001       •      Failure to convert characters in $'...' expressions
1002
1003       If  the POSIX_BUILTINS option is set, more errors associated with shell
1004       builtin commands are treated as fatal, as specified by the POSIX  stan‐
1005       dard.
1006

COMMENTS

1008       In  non-interactive  shells, or in interactive shells with the INTERAC‐
1009       TIVE_COMMENTS option set, a word beginning with the third character  of
1010       the  histchars  parameter (`#' by default) causes that word and all the
1011       following characters up to a newline to be ignored.
1012

ALIASING

1014       Every eligible word in the shell input is checked to see if there is an
1015       alias  defined  for it.  If so, it is replaced by the text of the alias
1016       if it is in command position (if it could be the first word of a simple
1017       command), or if the alias is global.  If the replacement text ends with
1018       a space, the next word in the shell input is always eligible  for  pur‐
1019       poses of alias expansion.  An alias is defined using the alias builtin;
1020       global aliases may be defined using the -g option to that builtin.
1021
1022       A word is defined as:
1023
1024       •      Any plain string or glob pattern
1025
1026       •      Any quoted string, using  any  quoting  method  (note  that  the
1027              quotes  must be part of the alias definition for this to be eli‐
1028              gible)
1029
1030       •      Any parameter reference or command substitution
1031
1032       •      Any series of the foregoing, concatenated without whitespace  or
1033              other tokens between them
1034
1035       •      Any reserved word (case, do, else, etc.)
1036
1037       •      With global aliasing, any command separator, any redirection op‐
1038              erator, and `(' or `)' when not part of a glob pattern
1039
1040       Alias expansion is done on the shell input before any  other  expansion
1041       except  history  expansion.   Therefore, if an alias is defined for the
1042       word foo, alias expansion may be avoided by quoting part of  the  word,
1043       e.g.  \foo.   Any  form  of quoting works, although there is nothing to
1044       prevent an alias being defined for the quoted  form  such  as  \foo  as
1045       well.
1046
1047       When POSIX_ALIASES is set, only plain unquoted strings are eligible for
1048       aliasing.  The alias builtin does not reject  ineligible  aliases,  but
1049       they are not expanded.
1050
1051       For  use  with completion, which would remove an initial backslash fol‐
1052       lowed by a character that isn't special, it may be more  convenient  to
1053       quote  the  word by starting with a single quote, i.e. 'foo; completion
1054       will automatically add the trailing single quote.
1055
1056   Alias difficulties
1057       Although aliases can be used in ways that bend normal shell syntax, not
1058       every string of non-white-space characters can be used as an alias.
1059
1060       Any  set  of characters not listed as a word above is not a word, hence
1061       no attempt is made to expand it as an alias, no matter how  it  is  de‐
1062       fined  (i.e. via the builtin or the special parameter aliases described
1063       in the section THE ZSH/PARAMETER MODULE in zshmodules(1)).  However, as
1064       noted in the case of POSIX_ALIASES above, the shell does not attempt to
1065       deduce whether the string corresponds to a word at the time  the  alias
1066       is created.
1067
1068       For  example,  an  expression containing an = at the start of a command
1069       line is an assignment and cannot be expanded as an alias; a lone  =  is
1070       not  an assignment but can only be set as an alias using the parameter,
1071       as otherwise the = is taken part of the syntax of the builtin command.
1072
1073       It is not presently possible to alias the `(('  token  that  introduces
1074       arithmetic expressions, because until a full statement has been parsed,
1075       it cannot be distinguished from two consecutive `(' tokens  introducing
1076       nested  subshells.   Also,  if  a  separator such as && is aliased, \&&
1077       turns into the two tokens \& and &, each of which may have been aliased
1078       separately.  Similarly for \<<, \>|, etc.
1079
1080       There is a commonly encountered problem with aliases illustrated by the
1081       following code:
1082
1083              alias echobar='echo bar'; echobar
1084
1085       This prints a message that the command  echobar  could  not  be  found.
1086       This happens because aliases are expanded when the code is read in; the
1087       entire line is read in one go, so that when echobar is executed  it  is
1088       too late to expand the newly defined alias.  This is often a problem in
1089       shell scripts, functions, and code executed with `source' or `.'.  Con‐
1090       sequently,  use  of  functions  rather  than  aliases is recommended in
1091       non-interactive code.
1092
1093       Note also the unhelpful interaction of  aliases  and  function  defini‐
1094       tions:
1095
1096              alias func='noglob func'
1097              func() {
1098                  echo Do something with $*
1099              }
1100
1101       Because  aliases  are expanded in function definitions, this causes the
1102       following command to be executed:
1103
1104              noglob func() {
1105                  echo Do something with $*
1106              }
1107
1108       which defines noglob as well as func as functions with the body  given.
1109       To  avoid this, either quote the name func or use the alternative func‐
1110       tion definition form `function func'.  Ensuring the  alias  is  defined
1111       after  the function works but is problematic if the code fragment might
1112       be re-executed.
1113

QUOTING

1115       A character may be quoted (that is, made to stand for itself)  by  pre‐
1116       ceding it with a `\'.  `\' followed by a newline is ignored.
1117
1118       A string enclosed between `$'' and `'' is processed the same way as the
1119       string arguments of the print builtin, and the resulting string is con‐
1120       sidered to be entirely quoted.  A literal `'' character can be included
1121       in the string by using the `\'' escape.
1122
1123       All characters enclosed between a pair of single quotes  ('')  that  is
1124       not  preceded by a `$' are quoted.  A single quote cannot appear within
1125       single quotes unless the option RC_QUOTES is set, in which case a  pair
1126       of single quotes are turned into a single quote.  For example,
1127
1128              print ''''
1129
1130       outputs  nothing  apart from a newline if RC_QUOTES is not set, but one
1131       single quote if it is set.
1132
1133       Inside double quotes (""), parameter and  command  substitution  occur,
1134       and `\' quotes the characters `\', ``', `"', `$', and the first charac‐
1135       ter of $histchars (default `!').
1136

REDIRECTION

1138       If a command is followed by & and job control is not active,  then  the
1139       default  standard  input  for  the command is the empty file /dev/null.
1140       Otherwise, the environment for the execution of a command contains  the
1141       file  descriptors  of  the  invoking  shell as modified by input/output
1142       specifications.
1143
1144       The following may appear anywhere in a simple command or may precede or
1145       follow  a  complex  command.   Expansion occurs before word or digit is
1146       used except as noted below.  If the result of substitution on word pro‐
1147       duces  more  than  one  filename,  redirection occurs for each separate
1148       filename in turn.
1149
1150       < word Open file word for reading as standard input.  It is an error to
1151              open a file in this fashion if it does not exist.
1152
1153       <> word
1154              Open  file  word  for reading and writing as standard input.  If
1155              the file does not exist then it is created.
1156
1157       > word Open file word for writing as standard output.  If the file does
1158              not exist then it is created.  If the file exists, and the CLOB‐
1159              BER option is unset, this causes  an  error;  otherwise,  it  is
1160              truncated to zero length.
1161
1162       >| word
1163       >! word
1164              Same  as  >, except that the file is truncated to zero length if
1165              it exists, regardless of CLOBBER.
1166
1167       >> word
1168              Open file word for writing in append mode  as  standard  output.
1169              If  the  file  does not exist, and the CLOBBER and APPEND_CREATE
1170              options are both unset, this causes  an  error;  otherwise,  the
1171              file is created.
1172
1173       >>| word
1174       >>! word
1175              Same  as  >>, except that the file is created if it does not ex‐
1176              ist, regardless of CLOBBER and APPEND_CREATE.
1177
1178       <<[-] word
1179              The shell input is read up to a line that is the same  as  word,
1180              or to an end-of-file.  No parameter expansion, command substitu‐
1181              tion or filename generation is performed on word.  The resulting
1182              document, called a here-document, becomes the standard input.
1183
1184              If  any character of word is quoted with single or double quotes
1185              or a `\', no interpretation is placed upon the characters of the
1186              document.  Otherwise, parameter and command substitution occurs,
1187              `\' followed by a newline is removed, and `\' must  be  used  to
1188              quote  the  characters  `\', `$', ``' and the first character of
1189              word.
1190
1191              Note that word itself does not undergo shell  expansion.   Back‐
1192              quotes  in word do not have their usual effect; instead they be‐
1193              have similarly to double  quotes,  except  that  the  backquotes
1194              themselves  are  passed through unchanged.  (This information is
1195              given for completeness and it is not recommended that backquotes
1196              be  used.)  Quotes in the form $'...' have their standard effect
1197              of expanding backslashed references to special characters.
1198
1199              If <<- is used, then all leading tabs are stripped from word and
1200              from the document.
1201
1202       <<< word
1203              Perform  shell expansion on word and pass the result to standard
1204              input.  This is known as a here-string.  Compare the use of word
1205              in  here-documents  above, where word does not undergo shell ex‐
1206              pansion.
1207
1208       <& number
1209       >& number
1210              The standard input/output is  duplicated  from  file  descriptor
1211              number (see dup2(2)).
1212
1213       <& -
1214       >& -   Close the standard input/output.
1215
1216       <& p
1217       >& p   The  input/output from/to the coprocess is moved to the standard
1218              input/output.
1219
1220       >& word
1221       &> word
1222              (Except where `>& word' matches one of the above syntaxes;  `&>'
1223              can  always  be  used  to avoid this ambiguity.)  Redirects both
1224              standard output and standard error (file descriptor  2)  in  the
1225              manner  of  `> word'.  Note that this does not have the same ef‐
1226              fect as `> word 2>&1' in the presence of multios (see  the  sec‐
1227              tion below).
1228
1229       >&| word
1230       >&! word
1231       &>| word
1232       &>! word
1233              Redirects both standard output and standard error (file descrip‐
1234              tor 2) in the manner of `>| word'.
1235
1236       >>& word
1237       &>> word
1238              Redirects both standard output and standard error (file descrip‐
1239              tor 2) in the manner of `>> word'.
1240
1241       >>&| word
1242       >>&! word
1243       &>>| word
1244       &>>! word
1245              Redirects both standard output and standard error (file descrip‐
1246              tor 2) in the manner of `>>| word'.
1247
1248       If one of the above is preceded by a digit, then  the  file  descriptor
1249       referred  to is that specified by the digit instead of the default 0 or
1250       1.  The order in which redirections are specified is significant.   The
1251       shell  evaluates  each  redirection  in  terms of the (file descriptor,
1252       file) association at the time of evaluation.  For example:
1253
1254              ... 1>fname 2>&1
1255
1256       first associates file descriptor 1 with file fname.  It then associates
1257       file descriptor 2 with the file associated with file descriptor 1 (that
1258       is, fname).  If the order of redirections were reversed, file  descrip‐
1259       tor 2 would be associated with the terminal (assuming file descriptor 1
1260       had been) and then file descriptor 1  would  be  associated  with  file
1261       fname.
1262
1263       The  `|&' command separator described in Simple Commands & Pipelines in
1264       zshmisc(1) is a shorthand for `2>&1 |'.
1265
1266       The various forms of process substitution, `<(list)', and `=(list)' for
1267       input  and `>(list)' for output, are often used together with redirect‐
1268       ion.  For example, if word in an output  redirection  is  of  the  form
1269       `>(list)'  then the output is piped to the command represented by list.
1270       See Process Substitution in zshexpn(1).
1271

OPENING FILE DESCRIPTORS USING PARAMETERS

1273       When the shell is parsing arguments to a command, and the shell  option
1274       IGNORE_BRACES  is  not set, a different form of redirection is allowed:
1275       instead of a digit before the operator there is a valid  shell  identi‐
1276       fier  enclosed  in  braces.   The shell will open a new file descriptor
1277       that is guaranteed to be at least 10 and set the parameter named by the
1278       identifier to the file descriptor opened.  No whitespace is allowed be‐
1279       tween the closing brace and the redirection character.  For example:
1280
1281              ... {myfd}>&1
1282
1283       This opens a new file descriptor that is a duplicate of file descriptor
1284       1  and  sets  the  parameter myfd to the number of the file descriptor,
1285       which will be at least 10.  The new file descriptor can be  written  to
1286       using  the  syntax  >&$myfd.   The file descriptor remains open in sub‐
1287       shells and forked external executables.
1288
1289       The syntax {varid}>&-, for example {myfd}>&-, may be used  to  close  a
1290       file  descriptor opened in this fashion.  Note that the parameter given
1291       by varid must previously be set to a file descriptor in this case.
1292
1293       It is an error to open or close a file descriptor in this fashion  when
1294       the  parameter  is  readonly.   However,  it is not an error to read or
1295       write a file descriptor using <&$param or >&$param if  param  is  read‐
1296       only.
1297
1298       If  the option CLOBBER is unset, it is an error to open a file descrip‐
1299       tor using a parameter that is already set to an  open  file  descriptor
1300       previously allocated by this mechanism.  Unsetting the parameter before
1301       using it for allocating a file descriptor avoids the error.
1302
1303       Note that this mechanism merely allocates or closes a file  descriptor;
1304       it does not perform any redirections from or to it.  It is usually con‐
1305       venient to allocate a file descriptor prior to use as  an  argument  to
1306       exec.   The  syntax  does not in any case work when used around complex
1307       commands such as parenthesised subshells or loops,  where  the  opening
1308       brace  is  interpreted  as part of a command list to be executed in the
1309       current shell.
1310
1311       The following shows a typical sequence of allocation, use, and  closing
1312       of a file descriptor:
1313
1314              integer myfd
1315              exec {myfd}>~/logs/mylogfile.txt
1316              print This is a log message. >&$myfd
1317              exec {myfd}>&-
1318
1319       Note  that  the expansion of the variable in the expression >&$myfd oc‐
1320       curs at the point the redirection is opened.  This is after the  expan‐
1321       sion of command arguments and after any redirections to the left on the
1322       command line have been processed.
1323

MULTIOS

1325       If the user tries to open a file descriptor for writing more than once,
1326       the  shell opens the file descriptor as a pipe to a process that copies
1327       its input to all the specified outputs, similar to  tee,  provided  the
1328       MULTIOS option is set, as it is by default.  Thus:
1329
1330              date >foo >bar
1331
1332       writes  the date to two files, named `foo' and `bar'.  Note that a pipe
1333       is an implicit redirection; thus
1334
1335              date >foo | cat
1336
1337       writes the date to the file `foo', and also pipes it to cat.
1338
1339       Note that the shell opens all the  files  to  be  used  in  the  multio
1340       process immediately, not at the point they are about to be written.
1341
1342       Note also that redirections are always expanded in order.  This happens
1343       regardless of the setting of the MULTIOS option, but with the option in
1344       effect  there  are additional consequences. For example, the meaning of
1345       the expression >&1 will change after a previous redirection:
1346
1347              date >&1 >output
1348
1349       In the case above, the >&1 refers to the standard output at  the  start
1350       of  the  line; the result is similar to the tee command.  However, con‐
1351       sider:
1352
1353              date >output >&1
1354
1355       As redirections are evaluated in order, when the >&1 is encountered the
1356       standard  output is set to the file output and another copy of the out‐
1357       put is therefore sent to that file.  This is unlikely to be what is in‐
1358       tended.
1359
1360       If  the MULTIOS option is set, the word after a redirection operator is
1361       also subjected to filename generation (globbing).  Thus
1362
1363              : > *
1364
1365       will truncate all files in the current directory, assuming  there's  at
1366       least  one.  (Without the MULTIOS option, it would create an empty file
1367       called `*'.)  Similarly, you can do
1368
1369              echo exit 0 >> *.sh
1370
1371       If the user tries to open a file descriptor for reading more than once,
1372       the  shell opens the file descriptor as a pipe to a process that copies
1373       all the specified inputs to its output in the order specified, provided
1374       the MULTIOS option is set.  It should be noted that each file is opened
1375       immediately, not at the point where it is about to be read: this behav‐
1376       iour differs from cat, so if strictly standard behaviour is needed, cat
1377       should be used instead.
1378
1379       Thus
1380
1381              sort <foo <fubar
1382
1383       or even
1384
1385              sort <f{oo,ubar}
1386
1387       is equivalent to `cat foo fubar | sort'.
1388
1389       Expansion of the redirection argument occurs at the point the redirect‐
1390       ion  is  opened,  at the point described above for the expansion of the
1391       variable in >&$myfd.
1392
1393       Note that a pipe is an implicit redirection; thus
1394
1395              cat bar | sort <foo
1396
1397       is equivalent to `cat bar foo | sort' (note the order of the inputs).
1398
1399       If the MULTIOS option is unset, each redirection replaces the  previous
1400       redirection for that file descriptor.  However, all files redirected to
1401       are actually opened, so
1402
1403              echo Hello > bar > baz
1404
1405       when MULTIOS is unset will  truncate  `bar',  and  write  `Hello'  into
1406       `baz'.
1407
1408       There  is  a  problem  when an output multio is attached to an external
1409       program.  A simple example shows this:
1410
1411              cat file >file1 >file2
1412              cat file1 file2
1413
1414       Here, it is possible that the second `cat' will not  display  the  full
1415       contents  of  file1  and  file2 (i.e. the original contents of file re‐
1416       peated twice).
1417
1418       The reason for this is that the  multios  are  spawned  after  the  cat
1419       process  is  forked from the parent shell, so the parent shell does not
1420       wait for the multios to finish writing data.  This means the command as
1421       shown  can  exit  before  file1 and file2 are completely written.  As a
1422       workaround, it is possible to run the cat process as part of a  job  in
1423       the current shell:
1424
1425              { cat file } >file >file2
1426
1427       Here, the {...} job will pause to wait for both files to be written.
1428

REDIRECTIONS WITH NO COMMAND

1430       When a simple command consists of one or more redirection operators and
1431       zero or more parameter assignments, but no command name, zsh can behave
1432       in several ways.
1433
1434       If  the  parameter NULLCMD is not set or the option CSH_NULLCMD is set,
1435       an error is caused.  This is the csh behavior and CSH_NULLCMD is set by
1436       default when emulating csh.
1437
1438       If  the option SH_NULLCMD is set, the builtin `:' is inserted as a com‐
1439       mand with the given redirections.  This is the default  when  emulating
1440       sh or ksh.
1441
1442       Otherwise, if the parameter NULLCMD is set, its value will be used as a
1443       command with the given redirections.  If both NULLCMD  and  READNULLCMD
1444       are  set,  then the value of the latter will be used instead of that of
1445       the former when the redirection is an input.  The default  for  NULLCMD
1446       is `cat' and for READNULLCMD is `more'. Thus
1447
1448              < file
1449
1450       shows the contents of file on standard output, with paging if that is a
1451       terminal.  NULLCMD and READNULLCMD may refer to shell functions.
1452

COMMAND EXECUTION

1454       If a command name contains no slashes, the shell attempts to locate it.
1455       If  there exists a shell function by that name, the function is invoked
1456       as described in the section  `Functions'.   If  there  exists  a  shell
1457       builtin by that name, the builtin is invoked.
1458
1459       Otherwise,  the  shell  searches  each element of $path for a directory
1460       containing an executable file by that name.  If the  search  is  unsuc‐
1461       cessful,  the  shell prints an error message and returns a nonzero exit
1462       status.
1463
1464       If execution fails because the file is not in  executable  format,  and
1465       the  file  is  not  a  directory,  it  is assumed to be a shell script.
1466       /bin/sh is spawned to execute it.  If the program is a  file  beginning
1467       with `#!', the remainder of the first line specifies an interpreter for
1468       the program.  The shell will execute the specified interpreter on oper‐
1469       ating systems that do not handle this executable format in the kernel.
1470
1471       If  no  external command is found but a function command_not_found_han‐
1472       dler exists the shell executes this function with all command line  ar‐
1473       guments.   The  return status of the function becomes the status of the
1474       command.  If the function wishes to mimic the behaviour  of  the  shell
1475       when the command is not found, it should print the message `command not
1476       found: cmd' to standard error and return status  127.   Note  that  the
1477       handler  is  executed  in a subshell forked to execute an external com‐
1478       mand, hence changes to directories, shell parameters, etc. have no  ef‐
1479       fect on the main shell.
1480

FUNCTIONS

1482       Shell functions are defined with the function reserved word or the spe‐
1483       cial syntax `funcname ()'.  Shell functions are read in and stored  in‐
1484       ternally.   Alias  names are resolved when the function is read.  Func‐
1485       tions are executed like commands with the  arguments  passed  as  posi‐
1486       tional parameters.  (See the section `Command Execution'.)
1487
1488       Functions execute in the same process as the caller and share all files
1489       and present working directory with the caller.  A trap on EXIT set  in‐
1490       side  a  function is executed after the function completes in the envi‐
1491       ronment of the caller.
1492
1493       The return builtin is used to return from function calls.
1494
1495       Function identifiers can be listed with the functions  builtin.   Func‐
1496       tions can be undefined with the unfunction builtin.
1497

AUTOLOADING FUNCTIONS

1499       A  function  can  be marked as undefined using the autoload builtin (or
1500       `functions -u' or `typeset -fu').  Such a function has no  body.   When
1501       the  function  is first executed, the shell searches for its definition
1502       using the elements of the fpath variable.  Thus to define functions for
1503       autoloading, a typical sequence is:
1504
1505              fpath=(~/myfuncs $fpath)
1506              autoload myfunc1 myfunc2 ...
1507
1508       The  usual alias expansion during reading will be suppressed if the au‐
1509       toload builtin or its equivalent is given the option -U. This is recom‐
1510       mended  for  the  use  of functions supplied with the zsh distribution.
1511       Note that for functions precompiled with the zcompile  builtin  command
1512       the flag -U must be provided when the .zwc file is created, as the cor‐
1513       responding information is compiled into the latter.
1514
1515       For each element in fpath, the shell looks for  three  possible  files,
1516       the newest of which is used to load the definition for the function:
1517
1518       element.zwc
1519              A  file  created with the zcompile builtin command, which is ex‐
1520              pected to contain the definitions for all functions in  the  di‐
1521              rectory  named  element.  The file is treated in the same manner
1522              as a directory containing files for functions  and  is  searched
1523              for  the  definition of the function.   If the definition is not
1524              found, the search for a definition proceeds with the  other  two
1525              possibilities described below.
1526
1527              If element already includes a .zwc extension (i.e. the extension
1528              was explicitly given by the user), element is searched  for  the
1529              definition  of the function without comparing its age to that of
1530              other files; in fact, there does not need to  be  any  directory
1531              named  element  without  the  suffix.  Thus including an element
1532              such as `/usr/local/funcs.zwc' in fpath will speed up the search
1533              for  functions,  with  the  disadvantage that functions included
1534              must be explicitly recompiled by hand before the  shell  notices
1535              any changes.
1536
1537       element/function.zwc
1538              A  file  created with zcompile, which is expected to contain the
1539              definition for function.  It may include other function  defini‐
1540              tions as well, but those are neither loaded nor executed; a file
1541              found in this way is searched only for the definition  of  func‐
1542              tion.
1543
1544       element/function
1545              A file of zsh command text, taken to be the definition for func‐
1546              tion.
1547
1548       In summary, the order of searching is, first, in the parents of  direc‐
1549       tories  in  fpath for the newer of either a compiled directory or a di‐
1550       rectory in fpath; second, if more than one of these contains a  defini‐
1551       tion for the function that is sought, the leftmost in the fpath is cho‐
1552       sen; and third, within a directory, the  newer  of  either  a  compiled
1553       function or an ordinary function definition is used.
1554
1555       If  the  KSH_AUTOLOAD option is set, or the file contains only a simple
1556       definition of the function, the file's contents will be executed.  This
1557       will  normally  define  the  function in question, but may also perform
1558       initialization, which is executed in the context of the function execu‐
1559       tion, and may therefore define local parameters.  It is an error if the
1560       function is not defined by loading the file.
1561
1562       Otherwise, the function body (with no surrounding  `funcname()  {...}')
1563       is taken to be the complete contents of the file.  This form allows the
1564       file to be used directly as an executable shell script.  If  processing
1565       of  the file results in the function being re-defined, the function it‐
1566       self is not re-executed.  To force the shell to perform  initialization
1567       and then call the function defined, the file should contain initializa‐
1568       tion code (which will be executed then discarded) in addition to a com‐
1569       plete  function definition (which will be retained for subsequent calls
1570       to the function), and a call to the shell function, including any argu‐
1571       ments, at the end.
1572
1573       For example, suppose the autoload file func contains
1574
1575              func() { print This is func; }
1576              print func is initialized
1577
1578       then  `func;  func' with KSH_AUTOLOAD set will produce both messages on
1579       the first call, but only the message `This is func' on the  second  and
1580       subsequent  calls.   Without KSH_AUTOLOAD set, it will produce the ini‐
1581       tialization message on the first call, and the  other  message  on  the
1582       second and subsequent calls.
1583
1584       It  is  also  possible  to  create a function that is not marked as au‐
1585       toloaded, but which loads its own definition by searching fpath, by us‐
1586       ing  `autoload -X' within a shell function.  For example, the following
1587       are equivalent:
1588
1589              myfunc() {
1590                autoload -X
1591              }
1592              myfunc args...
1593
1594       and
1595
1596              unfunction myfunc   # if myfunc was defined
1597              autoload myfunc
1598              myfunc args...
1599
1600       In fact, the functions command outputs `builtin  autoload  -X'  as  the
1601       body of an autoloaded function.  This is done so that
1602
1603              eval "$(functions)"
1604
1605       produces  a reasonable result.  A true autoloaded function can be iden‐
1606       tified by the presence of the comment `# undefined' in  the  body,  be‐
1607       cause all comments are discarded from defined functions.
1608
1609       To load the definition of an autoloaded function myfunc without execut‐
1610       ing myfunc, use:
1611
1612              autoload +X myfunc
1613

ANONYMOUS FUNCTIONS

1615       If no name is given for a function, it is `anonymous'  and  is  handled
1616       specially.  Either form of function definition may be used: a `()' with
1617       no preceding name, or a `function' with an immediately  following  open
1618       brace.  The function is executed immediately at the point of definition
1619       and is not stored  for  future  use.   The  function  name  is  set  to
1620       `(anon)'.
1621
1622       Arguments to the function may be specified as words following the clos‐
1623       ing brace defining the function, hence if there are none  no  arguments
1624       (other than $0) are set.  This is a difference from the way other func‐
1625       tions are parsed: normal function definitions may be followed  by  cer‐
1626       tain  keywords  such  as `else' or `fi', which will be treated as argu‐
1627       ments to anonymous functions, so that a newline or semicolon is  needed
1628       to force keyword interpretation.
1629
1630       Note also that the argument list of any enclosing script or function is
1631       hidden (as would be the case for any  other  function  called  at  this
1632       point).
1633
1634       Redirections  may be applied to the anonymous function in the same man‐
1635       ner as to a current-shell structure enclosed in braces.  The  main  use
1636       of anonymous functions is to provide a scope for local variables.  This
1637       is particularly convenient in start-up files as these  do  not  provide
1638       their own local variable scope.
1639
1640       For example,
1641
1642              variable=outside
1643              function {
1644                local variable=inside
1645                print "I am $variable with arguments $*"
1646              } this and that
1647              print "I am $variable"
1648
1649       outputs the following:
1650
1651              I am inside with arguments this and that
1652              I am outside
1653
1654       Note  that  function definitions with arguments that expand to nothing,
1655       for example `name=; function $name { ... }', are not treated as  anony‐
1656       mous  functions.   Instead, they are treated as normal function defini‐
1657       tions where the definition is silently discarded.
1658

SPECIAL FUNCTIONS

1660       Certain functions, if defined, have special meaning to the shell.
1661
1662   Hook Functions
1663       For the functions below, it is possible to define an array that has the
1664       same  name  as the function with `_functions' appended.  Any element in
1665       such an array is taken as the name of a function to execute; it is exe‐
1666       cuted  in  the  same  context  and with the same arguments as the basic
1667       function.  For example, if $chpwd_functions is an array containing  the
1668       values `mychpwd', `chpwd_save_dirstack', then the shell attempts to ex‐
1669       ecute the functions `chpwd', `mychpwd'  and  `chpwd_save_dirstack',  in
1670       that  order.   Any function that does not exist is silently ignored.  A
1671       function found by this mechanism is referred to elsewhere  as  a  `hook
1672       function'.  An error in any function causes subsequent functions not to
1673       be run.  Note further that an error in a precmd hook causes an  immedi‐
1674       ately  following periodic function not to run (though it may run at the
1675       next opportunity).
1676
1677       chpwd  Executed whenever the current working directory is changed.
1678
1679       periodic
1680              If the parameter PERIOD is set, this function is executed  every
1681              $PERIOD  seconds,  just  before a prompt.  Note that if multiple
1682              functions are defined using the  array  periodic_functions  only
1683              one  period is applied to the complete set of functions, and the
1684              scheduled time is not reset if the list of functions is altered.
1685              Hence the set of functions is always called together.
1686
1687       precmd Executed before each prompt.  Note that precommand functions are
1688              not re-executed simply because the command line is  redrawn,  as
1689              happens,  for  example, when a notification about an exiting job
1690              is displayed.
1691
1692       preexec
1693              Executed just after a command has been read and is about  to  be
1694              executed.   If  the  history  mechanism is active (regardless of
1695              whether the line was discarded from  the  history  buffer),  the
1696              string that the user typed is passed as the first argument, oth‐
1697              erwise it is an empty string.  The actual command that  will  be
1698              executed (including expanded aliases) is passed in two different
1699              forms: the second argument is a single-line,  size-limited  ver‐
1700              sion  of  the command (with things like function bodies elided);
1701              the third argument contains the full text  that  is  being  exe‐
1702              cuted.
1703
1704       zshaddhistory
1705              Executed  when  a  history line has been read interactively, but
1706              before it is executed.  The sole argument is the  complete  his‐
1707              tory  line  (so  that  any  terminating  newline  will  still be
1708              present).
1709
1710              If any of the hook functions returns status 1 (or  any  non-zero
1711              value  other  than  2,  though this is not guaranteed for future
1712              versions of the shell) the history line will not be  saved,  al‐
1713              though  it  lingers  in  the history until the next line is exe‐
1714              cuted, allowing you to reuse or edit it immediately.
1715
1716              If any of the hook functions returns status 2 the  history  line
1717              will  be  saved on the internal history list, but not written to
1718              the history file.  In case of a  conflict,  the  first  non-zero
1719              status value is taken.
1720
1721              A  hook function may call `fc -p ...' to switch the history con‐
1722              text so that the history is saved in a different file  from  the
1723              that  in  the  global  HISTFILE parameter.  This is handled spe‐
1724              cially: the history context is automatically restored after  the
1725              processing of the history line is finished.
1726
1727              The  following  example  function  works with one of the options
1728              INC_APPEND_HISTORY or SHARE_HISTORY set, in order that the  line
1729              is written out immediately after the history entry is added.  It
1730              first adds the history line to the normal history with the  new‐
1731              line  stripped, which is usually the correct behaviour.  Then it
1732              switches the history context so that the line will be written to
1733              a history file in the current directory.
1734
1735                     zshaddhistory() {
1736                       print -sr -- ${1%%$'\n'}
1737                       fc -p .zsh_local_history
1738                     }
1739
1740       zshexit
1741              Executed at the point where the main shell is about to exit nor‐
1742              mally.  This is not called by exiting subshells,  nor  when  the
1743              exec  precommand  modifier  is  used before an external command.
1744              Also, unlike TRAPEXIT, it is not called when functions exit.
1745
1746   Trap Functions
1747       The functions below are treated specially but do not have corresponding
1748       hook arrays.
1749
1750       TRAPNAL
1751              If defined and non-null, this function will be executed whenever
1752              the shell catches a signal SIGNAL, where NAL is a signal name as
1753              specified  for  the  kill  builtin.   The  signal number will be
1754              passed as the first parameter to the function.
1755
1756              If a function of this form is defined and null,  the  shell  and
1757              processes spawned by it will ignore SIGNAL.
1758
1759              The return status from the function is handled specially.  If it
1760              is zero, the signal is assumed to have been handled, and  execu‐
1761              tion  continues  normally.   Otherwise, the shell will behave as
1762              interrupted except that the return status of  the  trap  is  re‐
1763              tained.
1764
1765              Programs  terminated  by  uncaught  signals typically return the
1766              status 128 plus the signal number.  Hence the  following  causes
1767              the  handler for SIGINT to print a message, then mimic the usual
1768              effect of the signal.
1769
1770                     TRAPINT() {
1771                       print "Caught SIGINT, aborting."
1772                       return $(( 128 + $1 ))
1773                     }
1774
1775              The functions TRAPZERR, TRAPDEBUG and TRAPEXIT  are  never  exe‐
1776              cuted inside other traps.
1777
1778       TRAPDEBUG
1779              If the option DEBUG_BEFORE_CMD is set (as it is by default), ex‐
1780              ecuted before each command; otherwise executed after  each  com‐
1781              mand.  See the description of the trap builtin in zshbuiltins(1)
1782              for details of additional features provided in debug traps.
1783
1784       TRAPEXIT
1785              Executed when the shell exits, or when the current function  ex‐
1786              its  if defined inside a function.  The value of $? at the start
1787              of execution is the exit status of the shell or the return  sta‐
1788              tus of the function exiting.
1789
1790       TRAPZERR
1791              Executed  whenever  a  command has a non-zero exit status.  How‐
1792              ever, the function is not executed if the command occurred in  a
1793              sublist  followed  by  `&&' or `||'; only the final command in a
1794              sublist of this type causes the trap to be executed.  The  func‐
1795              tion TRAPERR acts the same as TRAPZERR on systems where there is
1796              no SIGERR (this is the usual case).
1797
1798       The functions beginning `TRAP' may alternatively be  defined  with  the
1799       trap  builtin:   this  may be preferable for some uses.  Setting a trap
1800       with one form removes any trap of the other form for the  same  signal;
1801       removing  a  trap in either form removes all traps for the same signal.
1802       The forms
1803
1804              TRAPNAL() {
1805               # code
1806              }
1807
1808       ('function traps') and
1809
1810              trap '
1811               # code
1812              ' NAL
1813
1814       ('list traps') are equivalent in most ways, the  exceptions  being  the
1815       following:
1816
1817       •      Function  traps have all the properties of normal functions, ap‐
1818              pearing in the list of functions and being called with their own
1819              function  context  rather  than  the  context where the trap was
1820              triggered.
1821
1822       •      The return status from function traps is special, whereas a  re‐
1823              turn  from  a list trap causes the surrounding context to return
1824              with the given status.
1825
1826       •      Function traps are not reset  within  subshells,  in  accordance
1827              with  zsh  behaviour;  list  traps are reset, in accordance with
1828              POSIX behaviour.
1829

JOBS

1831       If the MONITOR option is set, an interactive  shell  associates  a  job
1832       with  each  pipeline.  It keeps a table of current jobs, printed by the
1833       jobs command, and assigns them small integer numbers.  When  a  job  is
1834       started  asynchronously  with  `&', the shell prints a line to standard
1835       error which looks like:
1836
1837              [1] 1234
1838
1839       indicating that the job which was started asynchronously was job number
1840       1 and had one (top-level) process, whose process ID was 1234.
1841
1842       If  a  job  is  started with `&|' or `&!', then that job is immediately
1843       disowned.  After startup, it does not have a place in  the  job  table,
1844       and is not subject to the job control features described here.
1845
1846       If  you are running a job and wish to do something else you may hit the
1847       key ^Z (control-Z) which sends a TSTP signal to the current job:   this
1848       key  may  be redefined by the susp option of the external stty command.
1849       The shell will then normally indicate  that  the  job  has  been  `sus‐
1850       pended',  and  print another prompt.  You can then manipulate the state
1851       of this job, putting it in the background with the bg command,  or  run
1852       some  other  commands  and  then eventually bring the job back into the
1853       foreground with the foreground command fg.  A ^Z takes  effect  immedi‐
1854       ately  and is like an interrupt in that pending output and unread input
1855       are discarded when it is typed.
1856
1857       A job being run in the background will suspend if it tries to read from
1858       the terminal.
1859
1860       Note  that  if  the  job running in the foreground is a shell function,
1861       then suspending it will have the effect of causing the shell  to  fork.
1862       This  is  necessary  to  separate the function's state from that of the
1863       parent shell performing the job control, so that the latter can  return
1864       to  the  command  line prompt.  As a result, even if fg is used to con‐
1865       tinue the job the function will no longer be part of the parent  shell,
1866       and any variables set by the function will not be visible in the parent
1867       shell.  Thus the behaviour is different from the case where  the  func‐
1868       tion  was  never suspended.  Zsh is different from many other shells in
1869       this regard.
1870
1871       One additional side effect is that use of disown with a job created  by
1872       suspending  shell  code in this fashion is delayed: the job can only be
1873       disowned once any process started from the parent shell has terminated.
1874       At that point, the disowned job disappears silently from the job list.
1875
1876       The  same  behaviour  is  found when the shell is executing code as the
1877       right hand side of a pipeline or any complex shell  construct  such  as
1878       if, for, etc., in order that the entire block of code can be managed as
1879       a single job.  Background jobs are normally allowed to produce  output,
1880       but  this  can be disabled by giving the command `stty tostop'.  If you
1881       set this tty option, then background jobs will suspend when they try to
1882       produce output like they do when they try to read input.
1883
1884       When  a  command  is  suspended and continued later with the fg or wait
1885       builtins, zsh restores tty modes that were in effect when it  was  sus‐
1886       pended.   This (intentionally) does not apply if the command is contin‐
1887       ued via `kill -CONT', nor when it is continued with bg.
1888
1889       There are several ways to refer to jobs in the shell.  A job can be re‐
1890       ferred  to by the process ID of any process of the job or by one of the
1891       following:
1892
1893       %number
1894              The job with the given number.
1895       %string
1896              The last job whose command line begins with string.
1897       %?string
1898              The last job whose command line contains string.
1899       %%     Current job.
1900       %+     Equivalent to `%%'.
1901       %-     Previous job.
1902
1903       The shell learns immediately whenever a process changes state.  It nor‐
1904       mally  informs  you  whenever  a job becomes blocked so that no further
1905       progress is possible.  If the NOTIFY option is not set, it waits  until
1906       just before it prints a prompt before it informs you.  All such notifi‐
1907       cations are sent directly to the terminal, not to the  standard  output
1908       or standard error.
1909
1910       When  the  monitor mode is on, each background job that completes trig‐
1911       gers any trap set for CHLD.
1912
1913       When you try to leave the shell while jobs are  running  or  suspended,
1914       you  will  be warned that `You have suspended (running) jobs'.  You may
1915       use the jobs command to see what they are.  If you do this  or  immedi‐
1916       ately try to exit again, the shell will not warn you a second time; the
1917       suspended jobs will be terminated, and the running jobs will be sent  a
1918       SIGHUP signal, if the HUP option is set.
1919
1920       To  avoid  having  the shell terminate the running jobs, either use the
1921       nohup command (see nohup(1)) or the disown builtin.
1922

SIGNALS

1924       The INT and QUIT signals for an invoked command are ignored if the com‐
1925       mand  is  followed  by  `&'  and the MONITOR option is not active.  The
1926       shell itself always ignores the QUIT signal.  Otherwise,  signals  have
1927       the  values inherited by the shell from its parent (but see the TRAPNAL
1928       special functions in the section `Functions').
1929
1930       Certain jobs are run asynchronously by the shell other than  those  ex‐
1931       plicitly  put  into the background; even in cases where the shell would
1932       usually wait for such jobs, an explicit exit command or exit due to the
1933       option ERR_EXIT will cause the shell to exit without waiting.  Examples
1934       of such asynchronous jobs are process  substitution,  see  the  section
1935       PROCESS  SUBSTITUTION  in  the  zshexpn(1) manual page, and the handler
1936       processes for multios, see the section MULTIOS in the zshmisc(1) manual
1937       page.
1938

ARITHMETIC EVALUATION

1940       The shell can perform integer and floating point arithmetic, either us‐
1941       ing the builtin let, or via a substitution of the form  $((...)).   For
1942       integers,  the  shell is usually compiled to use 8-byte precision where
1943       this is available, otherwise precision is 4 bytes.  This can be tested,
1944       for example, by giving the command `print - $(( 12345678901 ))'; if the
1945       number appears unchanged, the precision is at least 8 bytes.   Floating
1946       point  arithmetic  always  uses  the `double' type with whatever corre‐
1947       sponding precision is provided by the compiler and the library.
1948
1949       The let builtin command takes arithmetic expressions as arguments; each
1950       is  evaluated  separately.   Since many of the arithmetic operators, as
1951       well as spaces, require quoting, an alternative form is  provided:  for
1952       any command which begins with a `((', all the characters until a match‐
1953       ing `))' are treated as a quoted expression  and  arithmetic  expansion
1954       performed  as  for  an  argument  of let.  More precisely, `((...))' is
1955       equivalent to `let "..."'.  The return status is 0  if  the  arithmetic
1956       value of the expression is non-zero, 1 if it is zero, and 2 if an error
1957       occurred.
1958
1959       For example, the following statement
1960
1961              (( val = 2 + 1 ))
1962
1963       is equivalent to
1964
1965              let "val = 2 + 1"
1966
1967       both assigning the value 3 to the shell variable val  and  returning  a
1968       zero status.
1969
1970       Integers can be in bases other than 10.  A leading `0x' or `0X' denotes
1971       hexadecimal and a leading `0b' or `0B' binary.  Integers may also be of
1972       the  form  `base#n',  where  base  is  a decimal number between two and
1973       thirty-six representing the arithmetic base and n is a number  in  that
1974       base  (for example, `16#ff' is 255 in hexadecimal).  The base# may also
1975       be omitted, in which case base 10 is used.  For backwards compatibility
1976       the form `[base]n' is also accepted.
1977
1978       An  integer expression or a base given in the form `base#n' may contain
1979       underscores (`_') after the leading digit for  visual  guidance;  these
1980       are  ignored  in  computation.   Examples  are 1_000_000 or 0xffff_ffff
1981       which are equivalent to 1000000 and 0xffffffff respectively.
1982
1983       It is also possible to specify a base to be used for output in the form
1984       `[#base]',  for  example  `[#16]'.  This is used when outputting arith‐
1985       metical substitutions or when assigning to scalar  parameters,  but  an
1986       explicitly  defined integer or floating point parameter will not be af‐
1987       fected.  If an integer variable is implicitly defined by an  arithmetic
1988       expression,  any  base  specified  in this way will be set as the vari‐
1989       able's output arithmetic base as if the option `-i base' to the typeset
1990       builtin  had been used.  The expression has no precedence and if it oc‐
1991       curs more than once in a mathematical expression, the last  encountered
1992       is used.  For clarity it is recommended that it appear at the beginning
1993       of an expression.  As an example:
1994
1995              typeset -i 16 y
1996              print $(( [#8] x = 32, y = 32 ))
1997              print $x $y
1998
1999       outputs first `8#40', the rightmost value in the given output base, and
2000       then  `8#40 16#20', because y has been explicitly declared to have out‐
2001       put base 16, while x (assuming it does not already exist) is implicitly
2002       typed  by  the arithmetic evaluation, where it acquires the output base
2003       8.
2004
2005       The base may be replaced or followed by an underscore, which may itself
2006       be  followed  by  a  positive  integer (if it is missing the value 3 is
2007       used).  This indicates that underscores should  be  inserted  into  the
2008       output  string,  grouping the number for visual clarity.  The following
2009       integer specifies the number of digits to group together.  For example:
2010
2011              setopt cbases
2012              print $(( [#16_4] 65536 ** 2 ))
2013
2014       outputs `0x1_0000_0000'.
2015
2016       The feature can be used with floating point numbers, in which case  the
2017       base must be omitted; grouping is away from the decimal point.  For ex‐
2018       ample,
2019
2020              zmodload zsh/mathfunc
2021              print $(( [#_] sqrt(1e7) ))
2022
2023       outputs `3_162.277_660_168_379_5' (the number of decimal  places  shown
2024       may vary).
2025
2026       If  the  C_BASES  option  is set, hexadecimal numbers are output in the
2027       standard C format, for example `0xFF' instead of the usual `16#FF'.  If
2028       the  option OCTAL_ZEROES is also set (it is not by default), octal num‐
2029       bers will be treated similarly and hence appear  as  `077'  instead  of
2030       `8#77'.   This  option  has no effect on the output of bases other than
2031       hexadecimal and octal, and these formats are always understood  on  in‐
2032       put.
2033
2034       When  an output base is specified using the `[#base]' syntax, an appro‐
2035       priate base prefix will be output if necessary, so that the value  out‐
2036       put  is  valid  syntax  for  input.   If  the # is doubled, for example
2037       `[##16]', then no base prefix is output.
2038
2039       Floating point constants are recognized by the presence  of  a  decimal
2040       point  or an exponent.  The decimal point may be the first character of
2041       the constant, but the exponent character e or E may not, as it will  be
2042       taken  for  a  parameter name.  All numeric parts (before and after the
2043       decimal point and in the exponent) may contain  underscores  after  the
2044       leading digit for visual guidance; these are ignored in computation.
2045
2046       An  arithmetic expression uses nearly the same syntax and associativity
2047       of expressions as in C.
2048
2049       In the native mode of operation, the following operators are  supported
2050       (listed in decreasing order of precedence):
2051
2052       + - ! ~ ++ --
2053              unary plus/minus, logical NOT, complement, {pre,post}{in,de}cre‐
2054              ment
2055       << >>  bitwise shift left, right
2056       &      bitwise AND
2057       ^      bitwise XOR
2058       |      bitwise OR
2059       **     exponentiation
2060       * / %  multiplication, division, modulus (remainder)
2061       + -    addition, subtraction
2062       < > <= >=
2063              comparison
2064       == !=  equality and inequality
2065       &&     logical AND
2066       || ^^  logical OR, XOR
2067       ? :    ternary operator
2068       = += -= *= /= %= &= ^= |= <<= >>= &&= ||= ^^= **=
2069              assignment
2070       ,      comma operator
2071
2072       The operators `&&', `||', `&&=', and `||='  are  short-circuiting,  and
2073       only  one of the latter two expressions in a ternary operator is evalu‐
2074       ated.  Note the precedence of the bitwise AND, OR, and XOR operators.
2075
2076       With the option C_PRECEDENCES the precedences (but no other properties)
2077       of the operators are altered to be the same as those in most other lan‐
2078       guages that support the relevant operators:
2079
2080       + - ! ~ ++ --
2081              unary plus/minus, logical NOT, complement, {pre,post}{in,de}cre‐
2082              ment
2083       **     exponentiation
2084       * / %  multiplication, division, modulus (remainder)
2085       + -    addition, subtraction
2086       << >>  bitwise shift left, right
2087       < > <= >=
2088              comparison
2089       == !=  equality and inequality
2090       &      bitwise AND
2091       ^      bitwise XOR
2092       |      bitwise OR
2093       &&     logical AND
2094       ^^     logical XOR
2095       ||     logical OR
2096       ? :    ternary operator
2097       = += -= *= /= %= &= ^= |= <<= >>= &&= ||= ^^= **=
2098              assignment
2099       ,      comma operator
2100
2101       Note  the  precedence  of exponentiation in both cases is below that of
2102       unary operators, hence `-3**2' evaluates as `9', not `-9'.  Use  paren‐
2103       theses  where  necessary:  `-(3**2)'.   This  is for compatibility with
2104       other shells.
2105
2106       Mathematical functions can be  called  with  the  syntax  `func(args)',
2107       where  the  function  decides  if  the  args  is  used as a string or a
2108       comma-separated list of arithmetic expressions. The shell currently de‐
2109       fines no mathematical functions by default, but the module zsh/mathfunc
2110       may be loaded with the zmodload builtin to  provide  standard  floating
2111       point mathematical functions.
2112
2113       An  expression of the form `##x' where x is any character sequence such
2114       as `a', `^A', or `\M-\C-x' gives the value of this character and an ex‐
2115       pression  of the form `#name' gives the value of the first character of
2116       the contents of the parameter name.  Character values are according  to
2117       the  character  set used in the current locale; for multibyte character
2118       handling the option MULTIBYTE must be set.  Note that this form is dif‐
2119       ferent from `$#name', a standard parameter substitution which gives the
2120       length of the parameter name.  `#\' is accepted instead  of  `##',  but
2121       its use is deprecated.
2122
2123       Named  parameters  and  subscripted  arrays  can  be referenced by name
2124       within an arithmetic expression without using the  parameter  expansion
2125       syntax.  For example,
2126
2127              ((val2 = val1 * 2))
2128
2129       assigns twice the value of $val1 to the parameter named val2.
2130
2131       An  internal  integer representation of a named parameter can be speci‐
2132       fied with the integer builtin.  Arithmetic evaluation is  performed  on
2133       the  value  of each assignment to a named parameter declared integer in
2134       this manner.  Assigning a floating point number to an  integer  results
2135       in rounding towards zero.
2136
2137       Likewise,  floating  point  numbers  can  be  declared  with  the float
2138       builtin; there are two types, differing only in their output format, as
2139       described  for  the typeset builtin.  The output format can be bypassed
2140       by using arithmetic substitution instead of the parameter substitution,
2141       i.e.  `${float}'  uses  the  defined  format,  but  `$((float))' uses a
2142       generic floating point format.
2143
2144       Promotion of integer to floating point values is performed where neces‐
2145       sary.   In  addition,  if  any operator which requires an integer (`&',
2146       `|', `^', `<<', `>>' and their equivalents with assignment) is given  a
2147       floating  point  argument, it will be silently rounded towards zero ex‐
2148       cept for `~' which rounds down.
2149
2150       Users should beware that, in common with many  other  programming  lan‐
2151       guages  but not software designed for calculation, the evaluation of an
2152       expression in zsh is taken a term at a time and promotion  of  integers
2153       to  floating point does not occur in terms only containing integers.  A
2154       typical result of this is that a division such as 6/8 is truncated,  in
2155       this being rounded towards 0.  The FORCE_FLOAT shell option can be used
2156       in scripts or functions where floating  point  evaluation  is  required
2157       throughout.
2158
2159       Scalar variables can hold integer or floating point values at different
2160       times; there is no memory of the numeric type in this case.
2161
2162       If a variable is first assigned in a numeric context without previously
2163       being declared, it will be implicitly typed as integer or float and re‐
2164       tain that type either until the type is explicitly changed or until the
2165       end of the scope.  This can have unforeseen consequences.  For example,
2166       in the loop
2167
2168              for (( f = 0; f < 1; f += 0.1 )); do
2169              # use $f
2170              done
2171
2172       if f has not already been declared, the first assignment will cause  it
2173       to  be created as an integer, and consequently the operation `f += 0.1'
2174       will always cause the result to be truncated to zero, so that the  loop
2175       will  fail.  A simple fix would be to turn the initialization into `f =
2176       0.0'.  It is therefore best to declare numeric variables with  explicit
2177       types.
2178

CONDITIONAL EXPRESSIONS

2180       A  conditional  expression is used with the [[ compound command to test
2181       attributes of files and to compare strings.   Each  expression  can  be
2182       constructed  from  one or more of the following unary or binary expres‐
2183       sions:
2184
2185       -a file
2186              true if file exists.
2187
2188       -b file
2189              true if file exists and is a block special file.
2190
2191       -c file
2192              true if file exists and is a character special file.
2193
2194       -d file
2195              true if file exists and is a directory.
2196
2197       -e file
2198              true if file exists.
2199
2200       -f file
2201              true if file exists and is a regular file.
2202
2203       -g file
2204              true if file exists and has its setgid bit set.
2205
2206       -h file
2207              true if file exists and is a symbolic link.
2208
2209       -k file
2210              true if file exists and has its sticky bit set.
2211
2212       -n string
2213              true if length of string is non-zero.
2214
2215       -o option
2216              true if option named option is on.  option may be a single char‐
2217              acter,  in  which  case it is a single letter option name.  (See
2218              the section `Specifying Options'.)
2219
2220              When no option named option exists, and the  POSIX_BUILTINS  op‐
2221              tion  hasn't  been set, return 3 with a warning.  If that option
2222              is set, return 1 with no warning.
2223
2224       -p file
2225              true if file exists and is a FIFO special file (named pipe).
2226
2227       -r file
2228              true if file exists and is readable by current process.
2229
2230       -s file
2231              true if file exists and has size greater than zero.
2232
2233       -t fd  true if file descriptor number fd is open and associated with  a
2234              terminal device.  (note: fd is not optional)
2235
2236       -u file
2237              true if file exists and has its setuid bit set.
2238
2239       -v varname
2240              true if shell variable varname is set.
2241
2242       -w file
2243              true if file exists and is writable by current process.
2244
2245       -x file
2246              true  if  file  exists and is executable by current process.  If
2247              file exists and is a directory, then  the  current  process  has
2248              permission to search in the directory.
2249
2250       -z string
2251              true if length of string is zero.
2252
2253       -L file
2254              true if file exists and is a symbolic link.
2255
2256       -O file
2257              true  if  file  exists  and is owned by the effective user ID of
2258              this process.
2259
2260       -G file
2261              true if file exists and its group matches the effective group ID
2262              of this process.
2263
2264       -S file
2265              true if file exists and is a socket.
2266
2267       -N file
2268              true  if  file  exists and its access time is not newer than its
2269              modification time.
2270
2271       file1 -nt file2
2272              true if file1 exists and is newer than file2.
2273
2274       file1 -ot file2
2275              true if file1 exists and is older than file2.
2276
2277       file1 -ef file2
2278              true if file1 and file2 exist and refer to the same file.
2279
2280       string = pattern
2281       string == pattern
2282              true if string matches  pattern.   The  two  forms  are  exactly
2283              equivalent.   The  `=' form is the traditional shell syntax (and
2284              hence the only one generally used with the test and [ builtins);
2285              the  `=='  form  provides compatibility with other sorts of com‐
2286              puter language.
2287
2288       string != pattern
2289              true if string does not match pattern.
2290
2291       string =~ regexp
2292              true if string matches the regular expression  regexp.   If  the
2293              option  RE_MATCH_PCRE  is set regexp is tested as a PCRE regular
2294              expression using the zsh/pcre module, else it  is  tested  as  a
2295              POSIX  extended  regular  expression using the zsh/regex module.
2296              Upon successful match, some variables will be updated; no  vari‐
2297              ables are changed if the matching fails.
2298
2299              If the option BASH_REMATCH is not set the scalar parameter MATCH
2300              is set to the substring that matched the pattern and the integer
2301              parameters  MBEGIN  and  MEND to the index of the start and end,
2302              respectively, of the match in string, such  that  if  string  is
2303              contained in variable var the expression `${var[$MBEGIN,$MEND]}'
2304              is identical to `$MATCH'.  The setting of the option  KSH_ARRAYS
2305              is  respected.   Likewise,  the  array  match is set to the sub‐
2306              strings that matched parenthesised subexpressions and the arrays
2307              mbegin  and  mend to the indices of the start and end positions,
2308              respectively, of the substrings within string.  The  arrays  are
2309              not  set if there were no parenthesised subexpressions.  For ex‐
2310              ample, if the string `a short string'  is  matched  against  the
2311              regular  expression `s(...)t', then (assuming the option KSH_AR‐
2312              RAYS is not set) MATCH, MBEGIN and MEND are `short',  3  and  7,
2313              respectively,  while match, mbegin and mend are single entry ar‐
2314              rays containing the strings `hor', `4' and `6', respectively.
2315
2316              If the option BASH_REMATCH is set the array BASH_REMATCH is  set
2317              to  the  substring that matched the pattern followed by the sub‐
2318              strings that matched  parenthesised  subexpressions  within  the
2319              pattern.
2320
2321       string1 < string2
2322              true  if  string1  comes  before string2 based on ASCII value of
2323              their characters.
2324
2325       string1 > string2
2326              true if string1 comes after string2  based  on  ASCII  value  of
2327              their characters.
2328
2329       exp1 -eq exp2
2330              true if exp1 is numerically equal to exp2.  Note that for purely
2331              numeric comparisons use of the ((...)) builtin described in  the
2332              section  `ARITHMETIC  EVALUATION' is more convenient than condi‐
2333              tional expressions.
2334
2335       exp1 -ne exp2
2336              true if exp1 is numerically not equal to exp2.
2337
2338       exp1 -lt exp2
2339              true if exp1 is numerically less than exp2.
2340
2341       exp1 -gt exp2
2342              true if exp1 is numerically greater than exp2.
2343
2344       exp1 -le exp2
2345              true if exp1 is numerically less than or equal to exp2.
2346
2347       exp1 -ge exp2
2348              true if exp1 is numerically greater than or equal to exp2.
2349
2350       ( exp )
2351              true if exp is true.
2352
2353       ! exp  true if exp is false.
2354
2355       exp1 && exp2
2356              true if exp1 and exp2 are both true.
2357
2358       exp1 || exp2
2359              true if either exp1 or exp2 is true.
2360
2361       For compatibility, if there is a single argument that is not  syntacti‐
2362       cally  significant, typically a variable, the condition is treated as a
2363       test for whether the expression expands as a string of non-zero length.
2364       In  other words, [[ $var ]] is the same as [[ -n $var ]].  It is recom‐
2365       mended that the second, explicit, form be used where possible.
2366
2367       Normal shell expansion is performed on the file, string and pattern ar‐
2368       guments, but the result of each expansion is constrained to be a single
2369       word, similar to the effect of double quotes.
2370
2371       Filename generation is not performed on any form of argument to  condi‐
2372       tions.  However, it can be forced in any case where normal shell expan‐
2373       sion is valid and when the option EXTENDED_GLOB is in effect  by  using
2374       an  explicit  glob qualifier of the form (#q) at the end of the string.
2375       A normal glob qualifier expression may appear between the `q'  and  the
2376       closing  parenthesis;  if none appears the expression has no effect be‐
2377       yond causing filename generation.  The results of  filename  generation
2378       are joined together to form a single word, as with the results of other
2379       forms of expansion.
2380
2381       This special use of filename generation is only available with  the  [[
2382       syntax.   If the condition occurs within the [ or test builtin commands
2383       then globbing occurs instead as part of normal command  line  expansion
2384       before the condition is evaluated.  In this case it may generate multi‐
2385       ple words which are likely to confuse the syntax of the test command.
2386
2387       For example,
2388
2389              [[ -n file*(#qN) ]]
2390
2391       produces status zero if and only if there is at least one file  in  the
2392       current directory beginning with the string `file'.  The globbing qual‐
2393       ifier N ensures that the expression is empty if there  is  no  matching
2394       file.
2395
2396       Pattern  metacharacters  are active for the pattern arguments; the pat‐
2397       terns are the same as those used  for  filename  generation,  see  zsh‐
2398       expn(1), but there is no special behaviour of `/' nor initial dots, and
2399       no glob qualifiers are allowed.
2400
2401       In each of the above expressions, if file is of the  form  `/dev/fd/n',
2402       where n is an integer, then the test applied to the open file whose de‐
2403       scriptor number is n, even if the underlying system  does  not  support
2404       the /dev/fd directory.
2405
2406       In  the  forms which do numeric comparison, the expressions exp undergo
2407       arithmetic expansion as if they were enclosed in $((...)).
2408
2409       For example, the following:
2410
2411              [[ ( -f foo || -f bar ) && $report = y* ]] && print File exists.
2412
2413       tests if either file foo or file bar exists, and if so, if the value of
2414       the  parameter  report  begins  with  `y'; if the complete condition is
2415       true, the message `File exists.' is printed.
2416

EXPANSION OF PROMPT SEQUENCES

2418       Prompt sequences undergo a special form of expansion.  This type of ex‐
2419       pansion is also available using the -P option to the print builtin.
2420
2421       If the PROMPT_SUBST option is set, the prompt string is first subjected
2422       to parameter expansion, command substitution and arithmetic  expansion.
2423       See zshexpn(1).
2424
2425       Certain escape sequences may be recognised in the prompt string.
2426
2427       If  the  PROMPT_BANG  option is set, a `!' in the prompt is replaced by
2428       the current history event number.  A literal `!'  may  then  be  repre‐
2429       sented as `!!'.
2430
2431       If  the  PROMPT_PERCENT  option  is  set, certain escape sequences that
2432       start with `%' are expanded.  Many escapes are  followed  by  a  single
2433       character,  although  some  of  these take an optional integer argument
2434       that should appear between the `%' and the next character  of  the  se‐
2435       quence.   More  complicated  escape  sequences are available to provide
2436       conditional expansion.
2437

SIMPLE PROMPT ESCAPES

2439   Special characters
2440       %%     A `%'.
2441
2442       %)     A `)'.
2443
2444   Login information
2445       %l     The line (tty) the user is logged in on, without `/dev/' prefix.
2446              If the name starts with `/dev/tty', that prefix is stripped.
2447
2448       %M     The full machine hostname.
2449
2450       %m     The hostname up to the first `.'.  An integer may follow the `%'
2451              to specify how many components  of  the  hostname  are  desired.
2452              With a negative integer, trailing components of the hostname are
2453              shown.
2454
2455       %n     $USERNAME.
2456
2457       %y     The line (tty) the user is logged in on, without `/dev/' prefix.
2458              This does not treat `/dev/tty' names specially.
2459
2460   Shell state
2461       %#     A  `#'  if  the  shell is running with privileges, a `%' if not.
2462              Equivalent to `%(!.#.%%)'.  The definition of `privileged',  for
2463              these  purposes,  is  that either the effective user ID is zero,
2464              or, if POSIX.1e capabilities are supported, that  at  least  one
2465              capability  is raised in either the Effective or Inheritable ca‐
2466              pability vectors.
2467
2468       %?     The return status of the last command executed just  before  the
2469              prompt.
2470
2471       %_     The  status  of the parser, i.e. the shell constructs (like `if'
2472              and `for') that have been started on the command line. If  given
2473              an  integer  number  that  many strings will be printed; zero or
2474              negative or no integer means print as many as there  are.   This
2475              is most useful in prompts PS2 for continuation lines and PS4 for
2476              debugging with the XTRACE option; in the  latter  case  it  will
2477              also work non-interactively.
2478
2479       %^     The  status  of  the parser in reverse. This is the same as `%_'
2480              other than the order of strings.  It is often used in RPS2.
2481
2482       %d
2483       %/     Current working directory.  If an integer follows  the  `%',  it
2484              specifies a number of trailing components of the current working
2485              directory to show; zero means the whole path.  A negative  inte‐
2486              ger  specifies leading components, i.e. %-1d specifies the first
2487              component.
2488
2489       %~     As %d and %/, but if the current working directory  starts  with
2490              $HOME,  that part is replaced by a `~'. Furthermore, if it has a
2491              named directory as its prefix, that part is replaced  by  a  `~'
2492              followed by the name of the directory, but only if the result is
2493              shorter than the full path; see Dynamic and Static named  direc‐
2494              tories in zshexpn(1).
2495
2496       %e     Evaluation depth of the current sourced file, shell function, or
2497              eval.  This is incremented or decremented every time  the  value
2498              of  %N  is  set  or  reverted to a previous value, respectively.
2499              This is most useful for debugging as part of $PS4.
2500
2501       %h
2502       %!     Current history event number.
2503
2504       %i     The line number currently being executed in the script,  sourced
2505              file,  or  shell  function given by %N.  This is most useful for
2506              debugging as part of $PS4.
2507
2508       %I     The line number currently being executed in the file  %x.   This
2509              is similar to %i, but the line number is always a line number in
2510              the file where the code was defined, even if the code is a shell
2511              function.
2512
2513       %j     The number of jobs.
2514
2515       %L     The current value of $SHLVL.
2516
2517       %N     The name of the script, sourced file, or shell function that zsh
2518              is currently executing, whichever was started most recently.  If
2519              there is none, this is equivalent to the parameter $0.  An inte‐
2520              ger may follow the `%' to specify a number of trailing path com‐
2521              ponents  to  show; zero means the full path.  A negative integer
2522              specifies leading components.
2523
2524       %x     The name of the file containing the source code currently  being
2525              executed.  This behaves as %N except that function and eval com‐
2526              mand names are not shown, instead the file where they  were  de‐
2527              fined.
2528
2529       %c
2530       %.
2531       %C     Trailing component of the current working directory.  An integer
2532              may follow the `%' to get more than one component.  Unless  `%C'
2533              is used, tilde contraction is performed first.  These are depre‐
2534              cated as %c and %C are equivalent to %1~ and %1/,  respectively,
2535              while explicit positive integers have the same effect as for the
2536              latter two sequences.
2537
2538   Date and time
2539       %D     The date in yy-mm-dd format.
2540
2541       %T     Current time of day, in 24-hour format.
2542
2543       %t
2544       %@     Current time of day, in 12-hour, am/pm format.
2545
2546       %*     Current time of day in 24-hour format, with seconds.
2547
2548       %w     The date in day-dd format.
2549
2550       %W     The date in mm/dd/yy format.
2551
2552       %D{string}
2553              string is formatted using  the  strftime  function.   See  strf‐
2554              time(3)  for  more details.  Various zsh extensions provide num‐
2555              bers with no leading zero or space if the  number  is  a  single
2556              digit:
2557
2558              %f     a day of the month
2559              %K     the hour of the day on the 24-hour clock
2560              %L     the hour of the day on the 12-hour clock
2561
2562              In  addition, if the system supports the POSIX gettimeofday sys‐
2563              tem call, %. provides decimal fractions of a  second  since  the
2564              epoch  with leading zeroes.  By default three decimal places are
2565              provided, but a number of digits up to 9 may be given  following
2566              the %; hence %6.  outputs microseconds, and %9. outputs nanosec‐
2567              onds.  (The latter requires  a  nanosecond-precision  clock_get‐
2568              time; systems lacking this will return a value multiplied by the
2569              appropriate power of 10.)  A typical example of this is the for‐
2570              mat `%D{%H:%M:%S.%.}'.
2571
2572              The GNU extension %N is handled as a synonym for %9..
2573
2574              Additionally, the GNU extension that a `-' between the % and the
2575              format character causes a leading zero or space to  be  stripped
2576              is handled directly by the shell for the format characters d, f,
2577              H, k, l, m, M, S and y; any other format characters are provided
2578              to the system's strftime(3) with any leading `-' present, so the
2579              handling is system dependent.  Further GNU (or other) extensions
2580              are  also  passed to strftime(3) and may work if the system sup‐
2581              ports them.
2582
2583   Visual effects
2584       %B (%b)
2585              Start (stop) boldface mode.
2586
2587       %E     Clear to end of line.
2588
2589       %U (%u)
2590              Start (stop) underline mode.
2591
2592       %S (%s)
2593              Start (stop) standout mode.
2594
2595       %F (%f)
2596              Start (stop) using a different foreground colour,  if  supported
2597              by  the  terminal.  The colour may be specified two ways: either
2598              as a numeric argument, as normal, or by  a  sequence  in  braces
2599              following  the  %F, for example %F{red}.  In the latter case the
2600              values allowed are as described for the fg zle_highlight  attri‐
2601              bute;  see Character Highlighting in zshzle(1).  This means that
2602              numeric colours are allowed in the second format also.
2603
2604       %K (%k)
2605              Start (stop) using a different bacKground colour.  The syntax is
2606              identical to that for %F and %f.
2607
2608       %{...%}
2609              Include  a  string  as  a  literal  escape sequence.  The string
2610              within the braces should not change the cursor position.   Brace
2611              pairs can nest.
2612
2613              A  positive  numeric argument between the % and the { is treated
2614              as described for %G below.
2615
2616       %G     Within a %{...%} sequence, include a `glitch': that  is,  assume
2617              that  a  single  character width will be output.  This is useful
2618              when outputting characters that otherwise  cannot  be  correctly
2619              handled  by  the  shell,  such as the alternate character set on
2620              some terminals.  The characters  in  question  can  be  included
2621              within  a  %{...%} sequence together with the appropriate number
2622              of %G sequences to indicate the correct width.  An  integer  be‐
2623              tween  the  `%'  and  `G' indicates a character width other than
2624              one.  Hence %{seq%2G%} outputs seq and assumes it takes  up  the
2625              width of two standard characters.
2626
2627              Multiple uses of %G accumulate in the obvious fashion; the posi‐
2628              tion of the %G is unimportant.  Negative integers are  not  han‐
2629              dled.
2630
2631              Note  that  when  prompt truncation is in use it is advisable to
2632              divide up output into  single  characters  within  each  %{...%}
2633              group so that the correct truncation point can be found.
2634

CONDITIONAL SUBSTRINGS IN PROMPTS

2636       %v     The  value  of  the  first element of the psvar array parameter.
2637              Following the `%' with an integer gives that element of the  ar‐
2638              ray.  Negative integers count from the end of the array.
2639
2640       %(x.true-text.false-text)
2641              Specifies  a  ternary expression.  The character following the x
2642              is arbitrary; the same character is used to  separate  the  text
2643              for  the  `true'  result from that for the `false' result.  This
2644              separator may not appear in the true-text, except as part  of  a
2645              %-escape  sequence.  A `)' may appear in the false-text as `%)'.
2646              true-text and false-text may both contain arbitrarily-nested es‐
2647              cape sequences, including further ternary expressions.
2648
2649              The  left  parenthesis may be preceded or followed by a positive
2650              integer n, which defaults to zero.  A negative integer  will  be
2651              multiplied by -1, except as noted below for `l'.  The test char‐
2652              acter x may be any of the following:
2653
2654              !      True if the shell is running with privileges.
2655              #      True if the effective uid of the current process is n.
2656              ?      True if the exit status of the last command was n.
2657              _      True if at least n shell constructs were started.
2658              C
2659              /      True if the current absolute path has at least n elements
2660                     relative  to  the root directory, hence / is counted as 0
2661                     elements.
2662              c
2663              .
2664              ~      True if the current path, with prefix replacement, has at
2665                     least  n elements relative to the root directory, hence /
2666                     is counted as 0 elements.
2667              D      True if the month is equal to n (January = 0).
2668              d      True if the day of the month is equal to n.
2669              e      True if the evaluation depth is at least n.
2670              g      True if the effective gid of the current process is n.
2671              j      True if the number of jobs is at least n.
2672              L      True if the SHLVL parameter is at least n.
2673              l      True if at least n characters have already  been  printed
2674                     on  the  current  line.   When  n is negative, true if at
2675                     least abs(n) characters remain before the opposite margin
2676                     (thus the left margin for RPROMPT).
2677              S      True if the SECONDS parameter is at least n.
2678              T      True if the time in hours is equal to n.
2679              t      True if the time in minutes is equal to n.
2680              v      True if the array psvar has at least n elements.
2681              V      True  if  element  n  of  the  array  psvar  is  set  and
2682                     non-empty.
2683              w      True if the day of the week is equal to n (Sunday = 0).
2684
2685       %<string<
2686       %>string>
2687       %[xstring]
2688              Specifies truncation behaviour for the remainder of  the  prompt
2689              string.    The   third,   deprecated,   form  is  equivalent  to
2690              `%xstringx', i.e. x may be `<' or `>'.  The string will be  dis‐
2691              played  in  place  of  the truncated portion of any string; note
2692              this does not undergo prompt expansion.
2693
2694              The numeric argument, which in the third form may appear immedi‐
2695              ately  after  the `[', specifies the maximum permitted length of
2696              the various strings that can be displayed in the prompt.  In the
2697              first two forms, this numeric argument may be negative, in which
2698              case the truncation length is determined by subtracting the  ab‐
2699              solute  value of the numeric argument from the number of charac‐
2700              ter positions remaining on the current prompt line.  If this re‐
2701              sults  in  a zero or negative length, a length of 1 is used.  In
2702              other words, a negative argument arranges that after  truncation
2703              at  least n characters remain before the right margin (left mar‐
2704              gin for RPROMPT).
2705
2706              The forms with `<' truncate at the left of the string,  and  the
2707              forms  with  `>' truncate at the right of the string.  For exam‐
2708              ple, if  the  current  directory  is  `/home/pike',  the  prompt
2709              `%8<..<%/'  will expand to `..e/pike'.  In this string, the ter‐
2710              minating character (`<', `>' or `]'), or in fact any  character,
2711              may be quoted by a preceding `\'; note when using print -P, how‐
2712              ever, that this must be doubled as the string is also subject to
2713              standard  print  processing,  in addition to any backslashes re‐
2714              moved by a double quoted string:  the worst  case  is  therefore
2715              `print -P "%<\\\\<<..."'.
2716
2717              If the string is longer than the specified truncation length, it
2718              will appear in full, completely replacing the truncated string.
2719
2720              The part of the prompt string to be truncated runs to the end of
2721              the  string,  or  to  the end of the next enclosing group of the
2722              `%(' construct, or to the next  truncation  encountered  at  the
2723              same  grouping  level  (i.e. truncations inside a `%(' are sepa‐
2724              rate), which ever comes first.  In particular, a truncation with
2725              argument  zero  (e.g.,  `%<<') marks the end of the range of the
2726              string to be truncated while turning off truncation  from  there
2727              on.  For  example,  the  prompt  `%10<...<%~%<<%# ' will print a
2728              truncated representation of the current directory, followed by a
2729              `%'  or  `#', followed by a space.  Without the `%<<', those two
2730              characters would be included in  the  string  to  be  truncated.
2731              Note  that `%-0<<' is not equivalent to `%<<' but specifies that
2732              the prompt is truncated at the right margin.
2733
2734              Truncation applies only  within  each  individual  line  of  the
2735              prompt,  as delimited by embedded newlines (if any).  If the to‐
2736              tal length of any line of the prompt after truncation is greater
2737              than the terminal width, or if the part to be truncated contains
2738              embedded newlines, truncation  behavior  is  undefined  and  may
2739              change    in    a    future   version   of   the   shell.    Use
2740              `%-n(l.true-text.false-text)' to remove parts of the prompt when
2741              the available space is less than n.
2742
2743
2744
2745ZSHEXPN(1)                  General Commands Manual                 ZSHEXPN(1)
2746
2747
2748

NAME

2750       zshexpn - zsh expansion and substitution
2751

DESCRIPTION

2753       The  following types of expansions are performed in the indicated order
2754       in five steps:
2755
2756       History Expansion
2757              This is performed only in interactive shells.
2758
2759       Alias Expansion
2760              Aliases are expanded immediately  before  the  command  line  is
2761              parsed as explained under Aliasing in zshmisc(1).
2762
2763       Process Substitution
2764       Parameter Expansion
2765       Command Substitution
2766       Arithmetic Expansion
2767       Brace Expansion
2768              These  five are performed in left-to-right fashion.  On each ar‐
2769              gument, any of the five steps that are needed are performed  one
2770              after the other.  Hence, for example, all the parts of parameter
2771              expansion are completed before command substitution is  started.
2772              After  these expansions, all unquoted occurrences of the charac‐
2773              ters `\',`'' and `"' are removed.
2774
2775       Filename Expansion
2776              If the SH_FILE_EXPANSION option is set, the order  of  expansion
2777              is  modified  for  compatibility  with sh and ksh.  In that case
2778              filename expansion is performed immediately after  alias  expan‐
2779              sion, preceding the set of five expansions mentioned above.
2780
2781       Filename Generation
2782              This expansion, commonly referred to as globbing, is always done
2783              last.
2784
2785       The following sections explain the types of expansion in detail.
2786

HISTORY EXPANSION

2788       History expansion allows you to use words from previous  command  lines
2789       in  the  command line you are typing.  This simplifies spelling correc‐
2790       tions and the repetition of complicated commands or arguments.
2791
2792       Immediately before execution, each command  is  saved  in  the  history
2793       list,  the  size of which is controlled by the HISTSIZE parameter.  The
2794       one most recent command is always retained in  any  case.   Each  saved
2795       command in the history list is called a history event and is assigned a
2796       number, beginning with 1 (one) when the shell starts up.   The  history
2797       number  that  you  may  see in your prompt (see EXPANSION OF PROMPT SE‐
2798       QUENCES in zshmisc(1)) is the number that is to be assigned to the next
2799       command.
2800
2801   Overview
2802       A  history  expansion  begins with the first character of the histchars
2803       parameter, which is `!' by default, and may occur anywhere on the  com‐
2804       mand line, including inside double quotes (but not inside single quotes
2805       '...' or C-style quotes $'...' nor when escaped with a backslash).
2806
2807       The first character is followed by an optional  event  designator  (see
2808       the  section  `Event Designators') and then an optional word designator
2809       (the section `Word Designators'); if neither of  these  designators  is
2810       present, no history expansion occurs.
2811
2812       Input  lines  containing  history expansions are echoed after being ex‐
2813       panded, but before any other expansions take place and before the  com‐
2814       mand  is  executed.   It  is this expanded form that is recorded as the
2815       history event for later references.
2816
2817       History expansions do not nest.
2818
2819       By default, a history reference with no event designator refers to  the
2820       same  event as any preceding history reference on that command line; if
2821       it is the only history reference in a command, it refers to the  previ‐
2822       ous  command.   However,  if the option CSH_JUNKIE_HISTORY is set, then
2823       every history reference with no event specification  always  refers  to
2824       the previous command.
2825
2826       For  example,  `!' is the event designator for the previous command, so
2827       `!!:1' always refers to the first word of  the  previous  command,  and
2828       `!!$'  always  refers  to  the last word of the previous command.  With
2829       CSH_JUNKIE_HISTORY set, then `!:1' and `!$' function in the same manner
2830       as  `!!:1'  and `!!$', respectively.  Conversely, if CSH_JUNKIE_HISTORY
2831       is unset, then `!:1' and `!$' refer to the first and  last  words,  re‐
2832       spectively,  of  the same event referenced by the nearest other history
2833       reference preceding them on the current command line, or to the  previ‐
2834       ous command if there is no preceding reference.
2835
2836       The  character  sequence  `^foo^bar'  (where `^' is actually the second
2837       character of the histchars parameter) repeats the last command, replac‐
2838       ing  the string foo with bar.  More precisely, the sequence `^foo^bar^'
2839       is synonymous with `!!:s^foo^bar^', hence other modifiers (see the sec‐
2840       tion   `Modifiers')   may   follow   the  final  `^'.   In  particular,
2841       `^foo^bar^:G' performs a global substitution.
2842
2843       If the shell encounters the character sequence `!"' in the  input,  the
2844       history  mechanism  is temporarily disabled until the current list (see
2845       zshmisc(1)) is fully parsed.  The `!"' is removed from the  input,  and
2846       any subsequent `!' characters have no special significance.
2847
2848       A  less convenient but more comprehensible form of command history sup‐
2849       port is provided by the fc builtin.
2850
2851   Event Designators
2852       An event designator is a reference to a command-line entry in the  his‐
2853       tory  list.   In  the list below, remember that the initial `!' in each
2854       item may be changed to another character by setting the  histchars  pa‐
2855       rameter.
2856
2857       !      Start a history expansion, except when followed by a blank, new‐
2858              line, `=' or `('.  If followed immediately by a word  designator
2859              (see  the section `Word Designators'), this forms a history ref‐
2860              erence with no event designator (see the section `Overview').
2861
2862       !!     Refer to the previous command.  By itself,  this  expansion  re‐
2863              peats the previous command.
2864
2865       !n     Refer to command-line n.
2866
2867       !-n    Refer to the current command-line minus n.
2868
2869       !str   Refer to the most recent command starting with str.
2870
2871       !?str[?]
2872              Refer  to  the most recent command containing str.  The trailing
2873              `?' is necessary if this reference is to be followed by a  modi‐
2874              fier  or  followed by any text that is not to be considered part
2875              of str.
2876
2877       !#     Refer to the current command line typed in so far.  The line  is
2878              treated  as if it were complete up to and including the word be‐
2879              fore the one with the `!#' reference.
2880
2881       !{...} Insulate a history reference from adjacent characters (if neces‐
2882              sary).
2883
2884   Word Designators
2885       A word designator indicates which word or words of a given command line
2886       are to be included in a history reference.  A `:' usually separates the
2887       event  specification  from the word designator.  It may be omitted only
2888       if the word designator begins with a `^', `$', `*', `-' or  `%'.   Word
2889       designators include:
2890
2891       0      The first input word (command).
2892       n      The nth argument.
2893       ^      The first argument.  That is, 1.
2894       $      The last argument.
2895       %      The word matched by (the most recent) ?str search.
2896       x-y    A range of words; x defaults to 0.
2897       *      All the arguments, or a null value if there are none.
2898       x*     Abbreviates `x-$'.
2899       x-     Like `x*' but omitting word $.
2900
2901       Note  that  a  `%' word designator works only when used in one of `!%',
2902       `!:%' or `!?str?:%', and only when used after a !? expansion  (possibly
2903       in  an  earlier  command).  Anything else results in an error, although
2904       the error may not be the most obvious one.
2905
2906   Modifiers
2907       After the optional word designator, you can add a sequence  of  one  or
2908       more  of  the following modifiers, each preceded by a `:'.  These modi‐
2909       fiers also work on the result of filename generation and parameter  ex‐
2910       pansion, except where noted.
2911
2912       a      Turn  a  file  name into an absolute path:  prepends the current
2913              directory, if necessary; remove `.' path  segments;  and  remove
2914              `..'  path  segments  and  the segments that immediately precede
2915              them.
2916
2917              This transformation is agnostic about what is in the filesystem,
2918              i.e.  is  on  the logical, not the physical directory.  It takes
2919              place in the same manner as when changing directories when  nei‐
2920              ther of the options CHASE_DOTS or CHASE_LINKS is set.  For exam‐
2921              ple, `/before/here/../after'  is  always  transformed  to  `/be‐
2922              fore/after', regardless of whether `/before/here' exists or what
2923              kind of object (dir, file, symlink, etc.) it is.
2924
2925       A      Turn a file name into an absolute path as the `a' modifier does,
2926              and  then  pass the result through the realpath(3) library func‐
2927              tion to resolve symbolic links.
2928
2929              Note: on systems that do not have a  realpath(3)  library  func‐
2930              tion,  symbolic  links are not resolved, so on those systems `a'
2931              and `A' are equivalent.
2932
2933              Note: foo:A and realpath(foo) are different on some inputs.  For
2934              realpath(foo) semantics, see the `P` modifier.
2935
2936       c      Resolve  a  command  name into an absolute path by searching the
2937              command path given by the PATH variable.  This does not work for
2938              commands  containing  directory parts.  Note also that this does
2939              not usually work as a glob qualifier unless a file of  the  same
2940              name is found in the current directory.
2941
2942       e      Remove  all but the part of the filename extension following the
2943              `.'; see the definition of the filename  extension  in  the  de‐
2944              scription  of the r modifier below.  Note that according to that
2945              definition the result will be empty if the string  ends  with  a
2946              `.'.
2947
2948       h [ digits ]
2949              Remove a trailing pathname component, shortening the path by one
2950              directory level: this is the `head' of the pathname.  This works
2951              like  `dirname'.  If the h is followed immediately (with no spa‐
2952              ces or other separator) by any number of decimal digits, and the
2953              value  of the resulting number is non-zero, that number of lead‐
2954              ing components is preserved instead of the final component being
2955              removed.   In an absolute path the leading `/' is the first com‐
2956              ponent, so,  for  example,  if  var=/my/path/to/something,  then
2957              ${var:h3}  substitutes  /my/path.   Consecutive `/'s are treated
2958              the same as a single `/'.  In parameter substitution, digits may
2959              only  be used if the expression is in braces, so for example the
2960              short form substitution $var:h2 is treated as ${var:h}2, not  as
2961              ${var:h2}.   No restriction applies to the use of digits in his‐
2962              tory substitution or globbing qualifiers.   If  more  components
2963              are  requested  than are present, the entire path is substituted
2964              (so this does not trigger a `failed modifier' error  in  history
2965              expansion).
2966
2967       l      Convert the words to all lowercase.
2968
2969       p      Print  the  new  command but do not execute it.  Only works with
2970              history expansion.
2971
2972       P      Turn a file name into an absolute path, like  realpath(3).   The
2973              resulting  path will be absolute, have neither `.' nor `..' com‐
2974              ponents, and refer to the same  directory  entry  as  the  input
2975              filename.
2976
2977              Unlike realpath(3), non-existent trailing components are permit‐
2978              ted and preserved.
2979
2980       q      Quote the substituted  words,  escaping  further  substitutions.
2981              Works with history expansion and parameter expansion, though for
2982              parameters it is only useful if the  resulting  text  is  to  be
2983              re-evaluated such as by eval.
2984
2985       Q      Remove one level of quotes from the substituted words.
2986
2987       r      Remove a filename extension leaving the root name.  Strings with
2988              no filename extension are not altered.  A filename extension  is
2989              a `.' followed by any number of characters (including zero) that
2990              are neither `.' nor `/' and that continue  to  the  end  of  the
2991              string.  For example, the extension of `foo.orig.c' is `.c', and
2992              `dir.c/foo' has no extension.
2993
2994       s/l/r[/]
2995              Substitute r for l as described below.  The substitution is done
2996              only  for  the  first string that matches l.  For arrays and for
2997              filename generation, this applies to each word of  the  expanded
2998              text.  See below for further notes on substitutions.
2999
3000              The  forms  `gs/l/r' and `s/l/r/:G' perform global substitution,
3001              i.e. substitute every occurrence of r for l.  Note that the g or
3002              :G must appear in exactly the position shown.
3003
3004              See further notes on this form of substitution below.
3005
3006       &      Repeat the previous s substitution.  Like s, may be preceded im‐
3007              mediately by a g.  In parameter expansion the & must appear  in‐
3008              side braces, and in filename generation it must be quoted with a
3009              backslash.
3010
3011       t [ digits ]
3012              Remove all leading pathname components, leaving the final compo‐
3013              nent  (tail).  This works like `basename'.  Any trailing slashes
3014              are first removed.  Decimal  digits  are  handled  as  described
3015              above  for  (h), but in this case that number of trailing compo‐
3016              nents is preserved instead of the default 1; 0  is  treated  the
3017              same as 1.
3018
3019       u      Convert the words to all uppercase.
3020
3021       x      Like  q, but break into words at whitespace.  Does not work with
3022              parameter expansion.
3023
3024       The s/l/r/ substitution works as follows.   By  default  the  left-hand
3025       side  of  substitutions  are  not patterns, but character strings.  Any
3026       character can be used as the delimiter in place of  `/'.   A  backslash
3027       quotes   the   delimiter   character.    The   character  `&',  in  the
3028       right-hand-side r, is replaced by the text from the  left-hand-side  l.
3029       The  `&'  can  be  quoted with a backslash.  A null l uses the previous
3030       string either from the previous l or from the contextual scan string  s
3031       from  `!?s'.  You can omit the rightmost delimiter if a newline immedi‐
3032       ately follows r; the rightmost `?' in a context scan can  similarly  be
3033       omitted.  Note the same record of the last l and r is maintained across
3034       all forms of expansion.
3035
3036       Note that if a `&' is used within glob qualifiers an extra backslash is
3037       needed as a & is a special character in this case.
3038
3039       Also  note that the order of expansions affects the interpretation of l
3040       and r.  When used in a history expansion, which occurs before any other
3041       expansions, l and r are treated as literal strings (except as explained
3042       for HIST_SUBST_PATTERN below).  When used in parameter  expansion,  the
3043       replacement of r into the parameter's value is done first, and then any
3044       additional process, parameter, command, arithmetic, or brace references
3045       are applied, which may evaluate those substitutions and expansions more
3046       than once if l appears more than once in the starting value.  When used
3047       in a glob qualifier, any substitutions or expansions are performed once
3048       at the time the qualifier is parsed, even before  the  `:s'  expression
3049       itself is divided into l and r sides.
3050
3051       If  the  option HIST_SUBST_PATTERN is set, l is treated as a pattern of
3052       the usual form described in  the  section  FILENAME  GENERATION  below.
3053       This can be used in all the places where modifiers are available; note,
3054       however, that in globbing qualifiers parameter substitution has already
3055       taken  place,  so parameters in the replacement string should be quoted
3056       to ensure they are replaced at the correct time.  Note also  that  com‐
3057       plicated  patterns  used  in  globbing qualifiers may need the extended
3058       glob qualifier notation (#q:s/.../.../) in order for the shell to  rec‐
3059       ognize the expression as a glob qualifier.  Further, note that bad pat‐
3060       terns in the substitution are not subject to the NO_BAD_PATTERN  option
3061       so will cause an error.
3062
3063       When  HIST_SUBST_PATTERN  is set, l may start with a # to indicate that
3064       the pattern must match at the start of the string  to  be  substituted,
3065       and a % may appear at the start or after an # to indicate that the pat‐
3066       tern must match at the end of the string to be substituted.  The % or #
3067       may be quoted with two backslashes.
3068
3069       For  example,  the following piece of filename generation code with the
3070       EXTENDED_GLOB option:
3071
3072              print -r -- *.c(#q:s/#%(#b)s(*).c/'S${match[1]}.C'/)
3073
3074       takes the expansion of *.c and  applies  the  glob  qualifiers  in  the
3075       (#q...)  expression, which consists of a substitution modifier anchored
3076       to the start and end of each word (#%).  This turns  on  backreferences
3077       ((#b)), so that the parenthesised subexpression is available in the re‐
3078       placement string as ${match[1]}.  The replacement string is  quoted  so
3079       that the parameter is not substituted before the start of filename gen‐
3080       eration.
3081
3082       The following f, F, w and W modifiers work only with  parameter  expan‐
3083       sion and filename generation.  They are listed here to provide a single
3084       point of reference for all modifiers.
3085
3086       f      Repeats the immediately (without a colon) following modifier un‐
3087              til the resulting word doesn't change any more.
3088
3089       F:expr:
3090              Like  f,  but repeats only n times if the expression expr evalu‐
3091              ates to n.  Any character can be used instead  of  the  `:';  if
3092              `(',  `[',  or `{' is used as the opening delimiter, the closing
3093              delimiter should be ')', `]', or `}', respectively.
3094
3095       w      Makes the immediately following modifier work on  each  word  in
3096              the string.
3097
3098       W:sep: Like  w  but  words are considered to be the parts of the string
3099              that are separated by sep. Any character can be used instead  of
3100              the `:'; opening parentheses are handled specially, see above.
3101

PROCESS SUBSTITUTION

3103       Each  part  of  a  command  argument  that  takes  the  form `<(list)',
3104       `>(list)' or `=(list)' is subject to process substitution.  The expres‐
3105       sion  may be preceded or followed by other strings except that, to pre‐
3106       vent clashes with commonly occurring strings  and  patterns,  the  last
3107       form  must  occur at the start of a command argument, and the forms are
3108       only expanded when  first  parsing  command  or  assignment  arguments.
3109       Process  substitutions  may be used following redirection operators; in
3110       this case, the substitution must appear with no trailing string.
3111
3112       Note that `<<(list)' is not a special syntax; it is  equivalent  to  `<
3113       <(list)', redirecting standard input from the result of process substi‐
3114       tution.  Hence all the following  documentation  applies.   The  second
3115       form (with the space) is recommended for clarity.
3116
3117       In the case of the < or > forms, the shell runs the commands in list as
3118       a subprocess of the job executing the shell command line.  If the  sys‐
3119       tem supports the /dev/fd mechanism, the command argument is the name of
3120       the device file corresponding to a file descriptor; otherwise,  if  the
3121       system  supports  named  pipes  (FIFOs), the command argument will be a
3122       named pipe.  If the form with > is selected then writing on  this  spe‐
3123       cial  file  will  provide  input for list.  If < is used, then the file
3124       passed as an argument will be connected  to  the  output  of  the  list
3125       process.  For example,
3126
3127              paste <(cut -f1 file1) <(cut -f3 file2) |
3128              tee >(process1) >(process2) >/dev/null
3129
3130       cuts fields 1 and 3 from the files file1 and file2 respectively, pastes
3131       the results together, and  sends  it  to  the  processes  process1  and
3132       process2.
3133
3134       If  =(...)  is used instead of <(...), then the file passed as an argu‐
3135       ment will be the name of a temporary file containing the output of  the
3136       list  process.   This  may  be used instead of the < form for a program
3137       that expects to lseek (see lseek(2)) on the input file.
3138
3139       There is an optimisation for substitutions of the form =(<<<arg), where
3140       arg is a single-word argument to the here-string redirection <<<.  This
3141       form produces a file name containing the value of arg after any substi‐
3142       tutions  have been performed.  This is handled entirely within the cur‐
3143       rent shell.  This is  effectively  the  reverse  of  the  special  form
3144       $(<arg) which treats arg as a file name and replaces it with the file's
3145       contents.
3146
3147       The = form is useful as both the /dev/fd and the named pipe implementa‐
3148       tion of <(...) have drawbacks.  In the former case, some programmes may
3149       automatically close the file descriptor in  question  before  examining
3150       the file on the command line, particularly if this is necessary for se‐
3151       curity reasons such as when the programme is running  setuid.   In  the
3152       second case, if the programme does not actually open the file, the sub‐
3153       shell attempting to read from or write to the pipe will (in  a  typical
3154       implementation,  different  operating systems may have different behav‐
3155       iour) block for ever and have to be killed explicitly.  In both  cases,
3156       the  shell actually supplies the information using a pipe, so that pro‐
3157       grammes that expect to lseek (see lseek(2)) on the file will not work.
3158
3159       Also note that the previous example can be  more  compactly  and  effi‐
3160       ciently written (provided the MULTIOS option is set) as:
3161
3162              paste <(cut -f1 file1) <(cut -f3 file2) \
3163              > >(process1) > >(process2)
3164
3165       The  shell  uses  pipes  instead  of  FIFOs to implement the latter two
3166       process substitutions in the above example.
3167
3168       There is an additional problem with >(process); when this  is  attached
3169       to  an  external command, the parent shell does not wait for process to
3170       finish and hence an immediately following command cannot  rely  on  the
3171       results  being  complete.  The problem and solution are the same as de‐
3172       scribed in the section MULTIOS in zshmisc(1).  Hence  in  a  simplified
3173       version of the example above:
3174
3175              paste <(cut -f1 file1) <(cut -f3 file2) > >(process)
3176
3177       (note that no MULTIOS are involved), process will be run asynchronously
3178       as far as the parent shell is concerned.  The workaround is:
3179
3180              { paste <(cut -f1 file1) <(cut -f3 file2) } > >(process)
3181
3182       The extra processes here are spawned from the parent shell  which  will
3183       wait for their completion.
3184
3185       Another problem arises any time a job with a substitution that requires
3186       a temporary file is disowned by the shell,  including  the  case  where
3187       `&!' or `&|' appears at the end of a command containing a substitution.
3188       In that case the temporary file will not be cleaned up as the shell  no
3189       longer  has  any memory of the job.  A workaround is to use a subshell,
3190       for example,
3191
3192              (mycmd =(myoutput)) &!
3193
3194       as the forked subshell will wait for the command to finish then  remove
3195       the temporary file.
3196
3197       A  general  workaround  to ensure a process substitution endures for an
3198       appropriate length of time is to pass it as a parameter to an anonymous
3199       shell  function  (a  piece  of  shell code that is run immediately with
3200       function scope).  For example, this code:
3201
3202              () {
3203                 print File $1:
3204                 cat $1
3205              } =(print This be the verse)
3206
3207       outputs something resembling the following
3208
3209              File /tmp/zsh6nU0kS:
3210              This be the verse
3211
3212       The temporary file created by the process substitution will be  deleted
3213       when the function exits.
3214

PARAMETER EXPANSION

3216       The  character `$' is used to introduce parameter expansions.  See zsh‐
3217       param(1) for a description of parameters, including arrays, associative
3218       arrays, and subscript notation to access individual array elements.
3219
3220       Note  in  particular the fact that words of unquoted parameters are not
3221       automatically split on whitespace unless the  option  SH_WORD_SPLIT  is
3222       set;  see references to this option below for more details.  This is an
3223       important difference from other shells.  However, as in  other  shells,
3224       null words are elided from unquoted parameters' expansions.
3225
3226       With default options, after the assignments:
3227
3228              array=("first word" "" "third word")
3229              scalar="only word"
3230
3231       then  $array  substitutes two words, `first word' and `third word', and
3232       $scalar substitutes a single word `only word'.  Note that  second  ele‐
3233       ment of array was elided.  Scalar parameters can be elided too if their
3234       value is null (empty).  To  avoid  elision,  use  quoting  as  follows:
3235       "$scalar"  for  scalars  and "${array[@]}" or "${(@)array}" for arrays.
3236       (The last two forms are equivalent.)
3237
3238       Parameter expansions can involve flags, as  in  `${(@kv)aliases}',  and
3239       other  operators,  such as `${PREFIX:-"/usr/local"}'.  Parameter expan‐
3240       sions can also be nested.  These topics will be introduced below.   The
3241       full rules are complicated and are noted at the end.
3242
3243       In  the  expansions discussed below that require a pattern, the form of
3244       the pattern is the same as that used for filename generation;  see  the
3245       section  `Filename  Generation'.   Note that these patterns, along with
3246       the replacement text of any substitutions, are  themselves  subject  to
3247       parameter  expansion,  command  substitution, and arithmetic expansion.
3248       In addition to the following operations, the colon modifiers  described
3249       in  the  section  `Modifiers' in the section `History Expansion' can be
3250       applied:  for example, ${i:s/foo/bar/} performs string substitution  on
3251       the expansion of parameter $i.
3252
3253       In  the  following descriptions, `word' refers to a single word substi‐
3254       tuted on the command line, not necessarily a space delimited word.
3255
3256       ${name}
3257              The value, if any, of the parameter name  is  substituted.   The
3258              braces are required if the expansion is to be followed by a let‐
3259              ter, digit, or underscore that is not to be interpreted as  part
3260              of  name.   In  addition, more complicated forms of substitution
3261              usually require the braces to be present; exceptions, which only
3262              apply  if  the  option  KSH_ARRAYS is not set, are a single sub‐
3263              script or any colon modifiers appearing after the name,  or  any
3264              of the characters `^', `=', `~', `#' or `+' appearing before the
3265              name, all of which work with or without braces.
3266
3267              If name is an array parameter, and the KSH_ARRAYS option is  not
3268              set,  then the value of each element of name is substituted, one
3269              element per word.  Otherwise, the expansion results in one  word
3270              only;  with  KSH_ARRAYS,  this is the first element of an array.
3271              No  field  splitting  is  done  on   the   result   unless   the
3272              SH_WORD_SPLIT   option  is  set.   See  also  the  flags  =  and
3273              s:string:.
3274
3275       ${+name}
3276              If name is the name of a set parameter `1' is substituted,  oth‐
3277              erwise `0' is substituted.
3278
3279       ${name-word}
3280       ${name:-word}
3281              If  name is set, or in the second form is non-null, then substi‐
3282              tute its value; otherwise substitute word.  In the  second  form
3283              name may be omitted, in which case word is always substituted.
3284
3285       ${name+word}
3286       ${name:+word}
3287              If  name is set, or in the second form is non-null, then substi‐
3288              tute word; otherwise substitute nothing.
3289
3290       ${name=word}
3291       ${name:=word}
3292       ${name::=word}
3293              In the first form, if name is unset then set it to word; in  the
3294              second  form,  if name is unset or null then set it to word; and
3295              in the third form, unconditionally set name  to  word.   In  all
3296              forms, the value of the parameter is then substituted.
3297
3298       ${name?word}
3299       ${name:?word}
3300              In the first form, if name is set, or in the second form if name
3301              is both set and non-null, then substitute its value;  otherwise,
3302              print  word and exit from the shell.  Interactive shells instead
3303              return to the prompt.  If word is omitted, then a standard  mes‐
3304              sage is printed.
3305
3306       In  any of the above expressions that test a variable and substitute an
3307       alternate word, note that you can use standard  shell  quoting  in  the
3308       word   value   to  selectively  override  the  splitting  done  by  the
3309       SH_WORD_SPLIT option and the = flag, but not splitting by the s:string:
3310       flag.
3311
3312       In  the  following expressions, when name is an array and the substitu‐
3313       tion is not quoted, or if the `(@)' flag or the name[@] syntax is used,
3314       matching and replacement is performed on each array element separately.
3315
3316       ${name#pattern}
3317       ${name##pattern}
3318              If  the pattern matches the beginning of the value of name, then
3319              substitute the value of name with the matched  portion  deleted;
3320              otherwise,  just  substitute  the  value  of name.  In the first
3321              form, the smallest matching pattern is preferred; in the  second
3322              form, the largest matching pattern is preferred.
3323
3324       ${name%pattern}
3325       ${name%%pattern}
3326              If  the  pattern matches the end of the value of name, then sub‐
3327              stitute the value of name with the matched portion deleted; oth‐
3328              erwise,  just  substitute the value of name.  In the first form,
3329              the smallest matching pattern is preferred; in the second  form,
3330              the largest matching pattern is preferred.
3331
3332       ${name:#pattern}
3333              If  the  pattern  matches the value of name, then substitute the
3334              empty string; otherwise, just substitute the value of name.   If
3335              name  is  an  array the matching array elements are removed (use
3336              the `(M)' flag to remove the non-matched elements).
3337
3338       ${name:|arrayname}
3339              If arrayname is the name (N.B., not contents) of an array  vari‐
3340              able,  then any elements contained in arrayname are removed from
3341              the substitution of name.  If the substitution is scalar, either
3342              because  name  is a scalar variable or the expression is quoted,
3343              the elements of arrayname are instead tested against the  entire
3344              expression.
3345
3346       ${name:*arrayname}
3347              Similar  to  the  preceding  substitution,  but  in the opposite
3348              sense, so that entries present in both the original substitution
3349              and as elements of arrayname are retained and others removed.
3350
3351       ${name:^arrayname}
3352       ${name:^^arrayname}
3353              Zips  two arrays, such that the output array is twice as long as
3354              the shortest (longest for `:^^') of name and arrayname, with the
3355              elements  alternatingly being picked from them. For `:^', if one
3356              of the input arrays is longer, the output will stop when the end
3357              of the shorter array is reached.  Thus,
3358
3359                     a=(1 2 3 4); b=(a b); print ${a:^b}
3360
3361              will  output  `1  a 2 b'.  For `:^^', then the input is repeated
3362              until all of the longer array has been used  up  and  the  above
3363              will output `1 a 2 b 3 a 4 b'.
3364
3365              Either  or  both inputs may be a scalar, they will be treated as
3366              an array of length 1 with the scalar as the only element. If ei‐
3367              ther array is empty, the other array is output with no extra el‐
3368              ements inserted.
3369
3370              Currently the following code will output `a b' and  `1'  as  two
3371              separate  elements,  which  can  be unexpected. The second print
3372              provides a workaround which should continue to work if  this  is
3373              changed.
3374
3375                     a=(a b); b=(1 2); print -l "${a:^b}"; print -l "${${a:^b}}"
3376
3377       ${name:offset}
3378       ${name:offset:length}
3379              This  syntax  gives effects similar to parameter subscripting in
3380              the form $name[start,end], but is compatible with other  shells;
3381              note  that  both  offset  and length are interpreted differently
3382              from the components of a subscript.
3383
3384              If offset is non-negative, then if the variable name is a scalar
3385              substitute  the  contents  starting  offset  characters from the
3386              first character of the string, and if name is an  array  substi‐
3387              tute  elements  starting offset elements from the first element.
3388              If length is given, substitute that many characters or elements,
3389              otherwise the entire rest of the scalar or array.
3390
3391              A positive offset is always treated as the offset of a character
3392              or element in name from the first character or  element  of  the
3393              array  (this  is  different from native zsh subscript notation).
3394              Hence 0 refers to the first character or element  regardless  of
3395              the setting of the option KSH_ARRAYS.
3396
3397              A negative offset counts backwards from the end of the scalar or
3398              array, so that -1 corresponds to the last character or  element,
3399              and so on.
3400
3401              When positive, length counts from the offset position toward the
3402              end of the scalar or array.  When negative, length  counts  back
3403              from  the  end.  If this results in a position smaller than off‐
3404              set, a diagnostic is printed and nothing is substituted.
3405
3406              The option MULTIBYTE is obeyed, i.e. the offset and length count
3407              multibyte characters where appropriate.
3408
3409              offset and length undergo the same set of shell substitutions as
3410              for scalar assignment; in addition, they  are  then  subject  to
3411              arithmetic evaluation.  Hence, for example
3412
3413                     print ${foo:3}
3414                     print ${foo: 1 + 2}
3415                     print ${foo:$(( 1 + 2))}
3416                     print ${foo:$(echo 1 + 2)}
3417
3418              all  have the same effect, extracting the string starting at the
3419              fourth character of $foo if the substitution would otherwise re‐
3420              turn  a  scalar,  or the array starting at the fourth element if
3421              $foo would return an array.  Note that with the  option  KSH_AR‐
3422              RAYS  $foo always returns a scalar (regardless of the use of the
3423              offset syntax) and a form such as ${foo[*]:3} is required to ex‐
3424              tract elements of an array named foo.
3425
3426              If  offset  is  negative, the - may not appear immediately after
3427              the : as this indicates the ${name:-word} form of  substitution.
3428              Instead,  a  space  may  be inserted before the -.  Furthermore,
3429              neither offset nor length may begin with an alphabetic character
3430              or  & as these are used to indicate history-style modifiers.  To
3431              substitute a value from a variable, the recommended approach  is
3432              to  precede it with a $ as this signifies the intention (parame‐
3433              ter substitution can easily be rendered unreadable); however, as
3434              arithmetic  substitution  is  performed,  the  expression ${var:
3435              offs} does work, retrieving the offset from $offs.
3436
3437              For further compatibility with other shells there is  a  special
3438              case  for  array offset 0.  This usually accesses the first ele‐
3439              ment of the array.  However, if the substitution refers  to  the
3440              positional parameter array, e.g. $@ or $*, then offset 0 instead
3441              refers to $0, offset 1 refers to $1, and so on.  In other words,
3442              the  positional  parameter  array  is  effectively  extended  by
3443              prepending $0.  Hence ${*:0:1} substitutes $0 and ${*:1:1}  sub‐
3444              stitutes $1.
3445
3446       ${name/pattern/repl}
3447       ${name//pattern/repl}
3448       ${name:/pattern/repl}
3449              Replace  the  longest possible match of pattern in the expansion
3450              of parameter name by string repl.  The first form replaces  just
3451              the  first  occurrence, the second form all occurrences, and the
3452              third form replaces only if pattern matches the  entire  string.
3453              Both pattern and repl are subject to double-quoted substitution,
3454              so that expressions like ${name/$opat/$npat} will work, but obey
3455              the  usual rule that pattern characters in $opat are not treated
3456              specially unless either the option GLOB_SUBST is set,  or  $opat
3457              is instead substituted as ${~opat}.
3458
3459              The pattern may begin with a `#', in which case the pattern must
3460              match at the start of the string, or `%', in which case it  must
3461              match  at  the end of the string, or `#%' in which case the pat‐
3462              tern must match the entire string.  The repl  may  be  an  empty
3463              string,  in  which  case  the final `/' may also be omitted.  To
3464              quote the final `/' in other cases it should be  preceded  by  a
3465              single backslash; this is not necessary if the `/' occurs inside
3466              a substituted parameter.  Note also that the `#',  `%'  and  `#%
3467              are  not  active  if  they occur inside a substituted parameter,
3468              even at the start.
3469
3470              If, after quoting rules apply, ${name} expands to an array,  the
3471              replacements  act  on  each element individually.  Note also the
3472              effect of the I and S parameter expansion flags below;  however,
3473              the flags M, R, B, E and N are not useful.
3474
3475              For example,
3476
3477                     foo="twinkle twinkle little star" sub="t*e" rep="spy"
3478                     print ${foo//${~sub}/$rep}
3479                     print ${(S)foo//${~sub}/$rep}
3480
3481              Here, the `~' ensures that the text of $sub is treated as a pat‐
3482              tern rather than a plain string.  In the first case, the longest
3483              match for t*e is substituted and the result is `spy star', while
3484              in the second case, the shortest matches are taken and  the  re‐
3485              sult is `spy spy lispy star'.
3486
3487       ${#spec}
3488              If spec is one of the above substitutions, substitute the length
3489              in characters of the result instead of the  result  itself.   If
3490              spec  is  an array expression, substitute the number of elements
3491              of the result.  This has the side-effect that joining is skipped
3492              even  in quoted forms, which may affect other sub-expressions in
3493              spec.  Note that `^', `=', and `~', below, must  appear  to  the
3494              left of `#' when these forms are combined.
3495
3496              If the option POSIX_IDENTIFIERS is not set, and spec is a simple
3497              name, then the braces are optional; this is true even  for  spe‐
3498              cial  parameters  so  e.g.  $#-  and  $#* take the length of the
3499              string $- and the array $* respectively.   If  POSIX_IDENTIFIERS
3500              is set, then braces are required for the # to be treated in this
3501              fashion.
3502
3503       ${^spec}
3504              Turn on the RC_EXPAND_PARAM option for the evaluation  of  spec;
3505              if  the  `^'  is doubled, turn it off.  When this option is set,
3506              array expansions of the form foo${xx}bar, where the parameter xx
3507              is  set  to  (a  b  c),  are  substituted  with `fooabar foobbar
3508              foocbar' instead of the default `fooa b  cbar'.   Note  that  an
3509              empty array will therefore cause all arguments to be removed.
3510
3511              Internally, each such expansion is converted into the equivalent
3512              list   for   brace    expansion.     E.g.,    ${^var}    becomes
3513              {$var[1],$var[2],...}, and is processed as described in the sec‐
3514              tion `Brace Expansion' below: note, however, the expansion  hap‐
3515              pens  immediately,  with  any explicit brace expansion happening
3516              later.  If word splitting is also  in  effect  the  $var[N]  may
3517              themselves be split into different list elements.
3518
3519       ${=spec}
3520              Perform  word splitting using the rules for SH_WORD_SPLIT during
3521              the evaluation of spec, but regardless of whether the  parameter
3522              appears  in  double  quotes; if the `=' is doubled, turn it off.
3523              This forces parameter expansions to be split into separate words
3524              before  substitution, using IFS as a delimiter.  This is done by
3525              default in most other shells.
3526
3527              Note that splitting is applied to word in the  assignment  forms
3528              of  spec  before  the assignment to name is performed.  This af‐
3529              fects the result of array assignments with the A flag.
3530
3531       ${~spec}
3532              Turn on the GLOB_SUBST option for the evaluation of spec; if the
3533              `~'  is  doubled,  turn  it  off.   When this option is set, the
3534              string resulting from the expansion will  be  interpreted  as  a
3535              pattern anywhere that is possible, such as in filename expansion
3536              and filename generation and pattern-matching contexts  like  the
3537              right hand side of the `=' and `!=' operators in conditions.
3538
3539              In  nested  substitutions, note that the effect of the ~ applies
3540              to the result of the current level of substitution.  A surround‐
3541              ing  pattern  operation on the result may cancel it.  Hence, for
3542              example, if the parameter foo is set to  *,  ${~foo//\*/*.c}  is
3543              substituted  by  the pattern *.c, which may be expanded by file‐
3544              name  generation,  but  ${${~foo}//\*/*.c}  substitutes  to  the
3545              string *.c, which will not be further expanded.
3546
3547       If  a ${...} type parameter expression or a $(...) type command substi‐
3548       tution is used in place of name above, it is expanded first and the re‐
3549       sult  is  used as if it were the value of name.  Thus it is possible to
3550       perform nested operations:  ${${foo#head}%tail} substitutes  the  value
3551       of  $foo  with both `head' and `tail' deleted.  The form with $(...) is
3552       often useful in combination with the flags described next; see the  ex‐
3553       amples  below.  Each name or nested ${...} in a parameter expansion may
3554       also be followed by a subscript expression as described in Array Param‐
3555       eters in zshparam(1).
3556
3557       Note  that double quotes may appear around nested expressions, in which
3558       case  only  the  part  inside  is  treated  as  quoted;  for   example,
3559       ${(f)"$(foo)"} quotes the result of $(foo), but the flag `(f)' (see be‐
3560       low) is applied using the rules for unquoted expansions.  Note  further
3561       that  quotes  are  themselves  nested  in this context; for example, in
3562       "${(@f)"$(foo)"}", there are two sets of quotes,  one  surrounding  the
3563       whole  expression,  the other (redundant) surrounding the $(foo) as be‐
3564       fore.
3565
3566   Parameter Expansion Flags
3567       If the opening brace is directly followed by  an  opening  parenthesis,
3568       the  string  up  to the matching closing parenthesis will be taken as a
3569       list of flags.  In cases where repeating a flag is meaningful, the rep‐
3570       etitions need not be consecutive; for example, `(q%q%q)' means the same
3571       thing as the more readable `(%%qqq)'.  The  following  flags  are  sup‐
3572       ported:
3573
3574       #      Evaluate  the  resulting words as numeric expressions and output
3575              the characters corresponding to  the  resulting  integer.   Note
3576              that  this  form  is entirely distinct from use of the # without
3577              parentheses.
3578
3579              If the MULTIBYTE option is set and the number  is  greater  than
3580              127  (i.e.  not  an  ASCII character) it is treated as a Unicode
3581              character.
3582
3583       %      Expand all % escapes in the resulting words in the same  way  as
3584              in prompts (see EXPANSION OF PROMPT SEQUENCES in zshmisc(1)). If
3585              this flag is given twice, full prompt expansion is done  on  the
3586              resulting words, depending on the setting of the PROMPT_PERCENT,
3587              PROMPT_SUBST and PROMPT_BANG options.
3588
3589       @      In double quotes, array elements are put  into  separate  words.
3590              E.g.,   `"${(@)foo}"'   is   equivalent   to  `"${foo[@]}"'  and
3591              `"${(@)foo[1,2]}"' is the same as `"$foo[1]"  "$foo[2]"'.   This
3592              is  distinct  from field splitting by the f, s or z flags, which
3593              still applies within each array element.
3594
3595       A      Convert the substitution into an array expression,  even  if  it
3596              otherwise  would be scalar.  This has lower precedence than sub‐
3597              scripting, so one level of nested expansion is required in order
3598              that  subscripts apply to array elements.  Thus ${${(A)name}[1]}
3599              yields the full value of name when name is scalar.
3600
3601              This assigns an array parameter with `${...=...}', `${...:=...}'
3602              or  `${...::=...}'.   If this flag is repeated (as in `AA'), as‐
3603              signs an associative array parameter.  Assignment is made before
3604              sorting  or padding; if field splitting is active, the word part
3605              is split before assignment.  The name part may be a  subscripted
3606              range  for ordinary arrays; when assigning an associative array,
3607              the word part must be converted to an array, for example by  us‐
3608              ing `${(AA)=name=...}' to activate field splitting.
3609
3610              Surrounding  context  such  as  additional nesting or use of the
3611              value in a scalar assignment may cause the array  to  be  joined
3612              back into a single string again.
3613
3614       a      Sort  in  array  index order; when combined with `O' sort in re‐
3615              verse array index order.  Note that `a' is therefore  equivalent
3616              to  the default but `Oa' is useful for obtaining an array's ele‐
3617              ments in reverse order.
3618
3619       b      Quote with backslashes only characters that are special to  pat‐
3620              tern  matching. This is useful when the contents of the variable
3621              are to be tested using GLOB_SUBST, including the ${~...} switch.
3622
3623              Quoting using one of the q family of flags  does  not  work  for
3624              this  purpose  since  quotes  are  not stripped from non-pattern
3625              characters by GLOB_SUBST.  In other words,
3626
3627                     pattern=${(q)str}
3628                     [[ $str = ${~pattern} ]]
3629
3630              works if $str is `a*b' but not if it is `a b', whereas
3631
3632                     pattern=${(b)str}
3633                     [[ $str = ${~pattern} ]]
3634
3635              is always true for any possible value of $str.
3636
3637       c      With ${#name}, count the total number of characters in an array,
3638              as  if  the elements were concatenated with spaces between them.
3639              This is not a true join of the array, so other expressions  used
3640              with  this  flag may have an effect on the elements of the array
3641              before it is counted.
3642
3643       C      Capitalize the resulting words.  `Words' in this case refers  to
3644              sequences  of  alphanumeric characters separated by non-alphanu‐
3645              merics, not to words that result from field splitting.
3646
3647       D      Assume the string or array elements contain directories and  at‐
3648              tempt to substitute the leading part of these by names.  The re‐
3649              mainder of the path (the whole of it if the leading part was not
3650              substituted) is then quoted so that the whole string can be used
3651              as a shell argument.  This is the reverse of  `~'  substitution:
3652              see the section FILENAME EXPANSION below.
3653
3654       e      Perform  single  word  shell expansions, namely parameter expan‐
3655              sion, command substitution and arithmetic expansion, on the  re‐
3656              sult.  Such  expansions can be nested but too deep recursion may
3657              have unpredictable effects.
3658
3659       f      Split the result of the expansion at newlines. This is a  short‐
3660              hand for `ps:\n:'.
3661
3662       F      Join  the words of arrays together using newline as a separator.
3663              This is a shorthand for `pj:\n:'.
3664
3665       g:opts:
3666              Process escape sequences like the echo builtin when  no  options
3667              are  given (g::).  With the o option, octal escapes don't take a
3668              leading zero.  With the c option, sequences like `^X'  are  also
3669              processed.   With the e option, processes `\M-t' and similar se‐
3670              quences like the print builtin.  With both of the o  and  e  op‐
3671              tions,  behaves  like  the  print builtin except that in none of
3672              these modes is `\c' interpreted.
3673
3674       i      Sort case-insensitively.  May be combined with `n' or `O'.
3675
3676       k      If name refers to an associative array, substitute the keys (el‐
3677              ement  names) rather than the values of the elements.  Used with
3678              subscripts (including ordinary arrays), force indices or keys to
3679              be  substituted  even  if  the  subscript form refers to values.
3680              However, this flag may not be combined  with  subscript  ranges.
3681              With  the KSH_ARRAYS option a subscript `[*]' or `[@]' is needed
3682              to operate on the whole array, as usual.
3683
3684       L      Convert all letters in the result to lower case.
3685
3686       n      Sort decimal integers numerically; if the first differing  char‐
3687              acters  of  two test strings are not digits, sorting is lexical.
3688              Integers with more initial zeroes are sorted before  those  with
3689              fewer  or  none.   Hence  the  array `foo1 foo02 foo2 foo3 foo20
3690              foo23' is sorted into the order shown.  May be combined with `i'
3691              or `O'.
3692
3693       o      Sort  the resulting words in ascending order; if this appears on
3694              its own the sorting is lexical and  case-sensitive  (unless  the
3695              locale renders it case-insensitive).  Sorting in ascending order
3696              is the default for other forms of sorting, so this is ignored if
3697              combined with `a', `i' or `n'.
3698
3699       O      Sort  the  resulting words in descending order; `O' without `a',
3700              `i' or `n' sorts in reverse lexical order.  May be combined with
3701              `a', `i' or `n' to reverse the order of sorting.
3702
3703       P      This forces the value of the parameter name to be interpreted as
3704              a further parameter name, whose value will be used where  appro‐
3705              priate.   Note  that flags set with one of the typeset family of
3706              commands (in particular case transformations) are not applied to
3707              the value of name used in this fashion.
3708
3709              If used with a nested parameter or command substitution, the re‐
3710              sult of that will be taken as a parameter name in the same  way.
3711              For  example,  if  you have `foo=bar' and `bar=baz', the strings
3712              ${(P)foo}, ${(P)${foo}}, and ${(P)$(echo bar)} will be  expanded
3713              to `baz'.
3714
3715              Likewise, if the reference is itself nested, the expression with
3716              the flag is treated as if it were directly replaced by  the  pa‐
3717              rameter  name.   It is an error if this nested substitution pro‐
3718              duces an array  with  more  than  one  word.   For  example,  if
3719              `name=assoc'  where the parameter assoc is an associative array,
3720              then `${${(P)name}[elt]}' refers to the element of the  associa‐
3721              tive subscripted `elt'.
3722
3723       q      Quote  characters that are special to the shell in the resulting
3724              words with backslashes; unprintable or  invalid  characters  are
3725              quoted  using  the  $'\NNN'  form, with separate quotes for each
3726              octet.
3727
3728              If this flag is given twice, the resulting words are  quoted  in
3729              single  quotes  and  if  it  is given three times, the words are
3730              quoted in double quotes; in these forms no special  handling  of
3731              unprintable  or invalid characters is attempted.  If the flag is
3732              given four times, the words are quoted in single quotes preceded
3733              by  a  $.  Note that in all three of these forms quoting is done
3734              unconditionally, even if this does not change the  way  the  re‐
3735              sulting string would be interpreted by the shell.
3736
3737              If a q- is given (only a single q may appear), a minimal form of
3738              single quoting is used that only quotes the string if needed  to
3739              protect  special characters.  Typically this form gives the most
3740              readable output.
3741
3742              If a q+ is given, an extended form of minimal  quoting  is  used
3743              that  causes unprintable characters to be rendered using $'...'.
3744              This quoting is similar to that used by the output of values  by
3745              the typeset family of commands.
3746
3747       Q      Remove one level of quotes from the resulting words.
3748
3749       t      Use  a  string  describing  the  type of the parameter where the
3750              value of the parameter would usually appear.  This  string  con‐
3751              sists  of keywords separated by hyphens (`-'). The first keyword
3752              in the string  describes  the  main  type,  it  can  be  one  of
3753              `scalar',  `array',  `integer',  `float'  or  `association'. The
3754              other keywords describe the type in more detail:
3755
3756              local  for local parameters
3757
3758              left   for left justified parameters
3759
3760              right_blanks
3761                     for right justified parameters with leading blanks
3762
3763              right_zeros
3764                     for right justified parameters with leading zeros
3765
3766              lower  for parameters whose value is converted to all lower case
3767                     when it is expanded
3768
3769              upper  for parameters whose value is converted to all upper case
3770                     when it is expanded
3771
3772              readonly
3773                     for readonly parameters
3774
3775              tag    for tagged parameters
3776
3777              export for exported parameters
3778
3779              unique for arrays which keep only the first occurrence of dupli‐
3780                     cated values
3781
3782              hide   for parameters with the `hide' flag
3783
3784              hideval
3785                     for parameters with the `hideval' flag
3786
3787              special
3788                     for special parameters defined by the shell
3789
3790       u      Expand only the first occurrence of each unique word.
3791
3792       U      Convert all letters in the result to upper case.
3793
3794       v      Used  with k, substitute (as two consecutive words) both the key
3795              and the value of each associative array element.  Used with sub‐
3796              scripts,  force  values  to be substituted even if the subscript
3797              form refers to indices or keys.
3798
3799       V      Make any special characters in the resulting words visible.
3800
3801       w      With ${#name}, count words in arrays or strings; the s flag  may
3802              be used to set a word delimiter.
3803
3804       W      Similar  to  w  with the difference that empty words between re‐
3805              peated delimiters are also counted.
3806
3807       X      With this flag, parsing errors occurring with the  Q,  e  and  #
3808              flags  or  the  pattern matching forms such as `${name#pattern}'
3809              are reported.  Without the flag, errors are silently ignored.
3810
3811       z      Split the result of the expansion into words using shell parsing
3812              to  find  the words, i.e. taking into account any quoting in the
3813              value.  Comments are  not  treated  specially  but  as  ordinary
3814              strings, similar to interactive shells with the INTERACTIVE_COM‐
3815              MENTS option unset (however, see the Z flag  below  for  related
3816              options)
3817
3818              Note  that  this  is  done  very late, even later than the `(s)'
3819              flag. So to access single words in the result use nested  expan‐
3820              sions as in `${${(z)foo}[2]}'. Likewise, to remove the quotes in
3821              the resulting words use `${(Q)${(z)foo}}'.
3822
3823       0      Split the result of the expansion on  null  bytes.   This  is  a
3824              shorthand for `ps:\0:'.
3825
3826       The following flags (except p) are followed by one or more arguments as
3827       shown.  Any character, or the matching pairs `(...)', `{...}', `[...]',
3828       or  `<...>',  may  be  used in place of a colon as delimiters, but note
3829       that when a flag takes more than one argument, a matched pair of delim‐
3830       iters must surround each argument.
3831
3832       p      Recognize  the  same  escape  sequences  as the print builtin in
3833              string arguments to any of the flags described below that follow
3834              this argument.
3835
3836              Alternatively,  with  this option string arguments may be in the
3837              form $var in which case the value of  the  variable  is  substi‐
3838              tuted.   Note  this form is strict; the string argument does not
3839              undergo general parameter expansion.
3840
3841              For example,
3842
3843                     sep=:
3844                     val=a:b:c
3845                     print ${(ps.$sep.)val}
3846
3847              splits the variable on a :.
3848
3849       ~      Strings inserted into the expansion by any of  the  flags  below
3850              are to be treated as patterns.  This applies to the string argu‐
3851              ments of flags that follow ~ within the same set of parentheses.
3852              Compare with ~ outside parentheses, which forces the entire sub‐
3853              stituted string to be treated as a pattern.  Hence, for example,
3854
3855                     [[ "?" = ${(~j.|.)array} ]]
3856
3857              treats `|' as a pattern and succeeds if and only if $array  con‐
3858              tains  the  string  `?' as an element.  The ~ may be repeated to
3859              toggle the behaviour; its effect only lasts to the  end  of  the
3860              parenthesised group.
3861
3862       j:string:
3863              Join  the  words of arrays together using string as a separator.
3864              Note that this occurs before field splitting  by  the  s:string:
3865              flag or the SH_WORD_SPLIT option.
3866
3867       l:expr::string1::string2:
3868              Pad  the  resulting  words on the left.  Each word will be trun‐
3869              cated if required and placed in a field expr characters wide.
3870
3871              The arguments :string1: and :string2: are optional; neither, the
3872              first, or both may be given.  Note that the same pairs of delim‐
3873              iters must be used for each of the three arguments.   The  space
3874              to  the  left will be filled with string1 (concatenated as often
3875              as needed) or spaces if string1 is not given.  If  both  string1
3876              and  string2 are given, string2 is inserted once directly to the
3877              left of each word, truncated if  necessary,  before  string1  is
3878              used to produce any remaining padding.
3879
3880              If either of string1 or string2 is present but empty, i.e. there
3881              are two delimiters together at that point, the  first  character
3882              of $IFS is used instead.
3883
3884              If  the  MULTIBYTE  option  is in effect, the flag m may also be
3885              given, in which case widths will be used for the calculation  of
3886              padding;  otherwise  individual multibyte characters are treated
3887              as occupying one unit of width.
3888
3889              If the MULTIBYTE option is not  in  effect,  each  byte  in  the
3890              string is treated as occupying one unit of width.
3891
3892              Control  characters are always assumed to be one unit wide; this
3893              allows the mechanism to be used for  generating  repetitions  of
3894              control characters.
3895
3896       m      Only  useful together with one of the flags l or r or with the #
3897              length operator when the MULTIBYTE option is in effect.  Use the
3898              character  width  reported by the system in calculating how much
3899              of the string it occupies or the overall length of  the  string.
3900              Most printable characters have a width of one unit, however cer‐
3901              tain Asian character sets and certain special effects use  wider
3902              characters; combining characters have zero width.  Non-printable
3903              characters are arbitrarily counted as zero width; how they would
3904              actually be displayed will vary.
3905
3906              If  the  m  is repeated, the character either counts zero (if it
3907              has zero width), else one.  For printable character strings this
3908              has  the  effect of counting the number of glyphs (visibly sepa‐
3909              rate characters), except for the case where combining characters
3910              themselves have non-zero width (true in certain alphabets).
3911
3912       r:expr::string1::string2:
3913              As  l, but pad the words on the right and insert string2 immedi‐
3914              ately to the right of the string to be padded.
3915
3916              Left and right padding may be used together.  In this  case  the
3917              strategy  is  to  apply  left padding to the first half width of
3918              each of the resulting words, and right  padding  to  the  second
3919              half.   If  the string to be padded has odd width the extra pad‐
3920              ding is applied on the left.
3921
3922       s:string:
3923              Force field splitting at the  separator  string.   Note  that  a
3924              string  of  two  or  more characters means that all of them must
3925              match in sequence; this differs from the  treatment  of  two  or
3926              more  characters  in the IFS parameter.  See also the = flag and
3927              the SH_WORD_SPLIT option.  An empty string may also be given  in
3928              which case every character will be a separate element.
3929
3930              For historical reasons, the usual behaviour that empty array el‐
3931              ements are retained inside double quotes is disabled for  arrays
3932              generated by splitting; hence the following:
3933
3934                     line="one::three"
3935                     print -l "${(s.:.)line}"
3936
3937              produces  two  lines  of output for one and three and elides the
3938              empty field.  To override this behaviour, supply the `(@)'  flag
3939              as well, i.e.  "${(@s.:.)line}".
3940
3941       Z:opts:
3942              As z but takes a combination of option letters between a follow‐
3943              ing pair of delimiter characters.  With no options the effect is
3944              identical to z.  (Z+c+) causes comments to be parsed as a string
3945              and retained; any field in the resulting array beginning with an
3946              unquoted comment character is a comment.  (Z+C+) causes comments
3947              to be parsed and removed.  The rule for  comments  is  standard:
3948              anything  between  a  word  starting with the third character of
3949              $HISTCHARS, default #, up to the  next  newline  is  a  comment.
3950              (Z+n+) causes unquoted newlines to be treated as ordinary white‐
3951              space, else they are treated as if they are  shell  code  delim‐
3952              iters  and converted to semicolons.  Options are combined within
3953              the same set of delimiters, e.g. (Z+Cn+).
3954
3955       _:flags:
3956              The underscore (_) flag is reserved for future use.  As of  this
3957              revision of zsh, there are no valid flags; anything following an
3958              underscore, other than an empty pair of delimiters,  is  treated
3959              as an error, and the flag itself has no effect.
3960
3961       The  following  flags  are meaningful with the ${...#...} or ${...%...}
3962       forms.  The S and I flags may also be used with the ${.../...} forms.
3963
3964       S      With # or ##, search for the match that starts  closest  to  the
3965              start  of  the string (a `substring match'). Of all matches at a
3966              particular position, # selects the shortest and ## the longest:
3967
3968                     % str="aXbXc"
3969                     % echo ${(S)str#X*}
3970                     abXc
3971                     % echo ${(S)str##X*}
3972                     a
3973                     %
3974
3975              With % or %%, search for the match that starts  closest  to  the
3976              end of the string:
3977
3978                     % str="aXbXc"
3979                     % echo ${(S)str%X*}
3980                     aXbc
3981                     % echo ${(S)str%%X*}
3982                     aXb
3983                     %
3984
3985              (Note that % and %% don't search for the match that ends closest
3986              to the end of the string, as one might expect.)
3987
3988              With  substitution  via  ${.../...}  or  ${...//...},  specifies
3989              non-greedy matching, i.e. that the shortest instead of the long‐
3990              est match should be replaced:
3991
3992                     % str="abab"
3993                     % echo ${str/*b/_}
3994                     _
3995                     % echo ${(S)str/*b/_}
3996                     _ab
3997                     %
3998
3999       I:expr:
4000              Search the exprth match (where  expr  evaluates  to  a  number).
4001              This only applies when searching for substrings, either with the
4002              S flag, or with ${.../...} (only the  exprth  match  is  substi‐
4003              tuted)  or  ${...//...} (all matches from the exprth on are sub‐
4004              stituted).  The default is to take the first match.
4005
4006              The exprth match is counted such that there  is  either  one  or
4007              zero matches from each starting position in the string, although
4008              for global substitution matches  overlapping  previous  replace‐
4009              ments  are  ignored.  With the ${...%...} and ${...%%...} forms,
4010              the starting position for the match moves backwards from the end
4011              as the index increases, while with the other forms it moves for‐
4012              ward from the start.
4013
4014              Hence with the string
4015                     which switch is the right switch for Ipswich?
4016              substitutions of the form ${(SI:N:)string#w*ch} as  N  increases
4017              from  1  will  match  and  remove  `which', `witch', `witch' and
4018              `wich'; the form using `##' will match and remove `which  switch
4019              is the right switch for Ipswich', `witch is the right switch for
4020              Ipswich', `witch for Ipswich' and `wich'.  The  form  using  `%'
4021              will  remove  the same matches as for `#', but in reverse order,
4022              and the form using `%%' will remove the same matches as for `##'
4023              in reverse order.
4024
4025       B      Include the index of the beginning of the match in the result.
4026
4027       E      Include the index one character past the end of the match in the
4028              result (note this is inconsistent with other uses  of  parameter
4029              index).
4030
4031       M      Include the matched portion in the result.
4032
4033       N      Include the length of the match in the result.
4034
4035       R      Include the unmatched portion in the result (the Rest).
4036
4037   Rules
4038       Here  is  a  summary  of  the rules for substitution; this assumes that
4039       braces are present around the substitution, i.e. ${...}.  Some particu‐
4040       lar  examples are given below.  Note that the Zsh Development Group ac‐
4041       cepts no responsibility for any brain damage which may occur during the
4042       reading of the following rules.
4043
4044       1. Nested substitution
4045              If  multiple  nested  ${...}  forms are present, substitution is
4046              performed from the inside outwards.  At each level, the  substi‐
4047              tution takes account of whether the current value is a scalar or
4048              an array, whether the whole substitution is  in  double  quotes,
4049              and  what  flags  are supplied to the current level of substitu‐
4050              tion, just as if the nested  substitution  were  the  outermost.
4051              The  flags are not propagated up to enclosing substitutions; the
4052              nested substitution will return either a scalar or an  array  as
4053              determined by the flags, possibly adjusted for quoting.  All the
4054              following steps take place where applicable  at  all  levels  of
4055              substitution.
4056
4057              Note  that,  unless the `(P)' flag is present, the flags and any
4058              subscripts apply directly to the value of the  nested  substitu‐
4059              tion;  for  example, the expansion ${${foo}} behaves exactly the
4060              same as ${foo}.  When the `(P)' flag is present in a nested sub‐
4061              stitution, the other substitution rules are applied to the value
4062              before it is interpreted as a name, so ${${(P)foo}}  may  differ
4063              from ${(P)foo}.
4064
4065              At  each nested level of substitution, the substituted words un‐
4066              dergo all forms of single-word substitution (i.e.  not  filename
4067              generation),  including  command substitution, arithmetic expan‐
4068              sion and filename expansion (i.e. leading ~ and =).   Thus,  for
4069              example,  ${${:-=cat}:h}  expands to the directory where the cat
4070              program resides.  (Explanation: the internal substitution has no
4071              parameter  but  a default value =cat, which is expanded by file‐
4072              name expansion to a full path; the outer substitution  then  ap‐
4073              plies the modifier :h and takes the directory part of the path.)
4074
4075       2. Internal parameter flags
4076              Any  parameter  flags  set  by one of the typeset family of com‐
4077              mands, in particular the -L, -R, -Z, -u and -l options for  pad‐
4078              ding  and  capitalization, are applied directly to the parameter
4079              value.  Note these flags are options to the command, e.g. `type‐
4080              set  -Z'; they are not the same as the flags used within parame‐
4081              ter substitutions.
4082
4083              At the outermost level of substitution, the `(P)' flag (rule 4.)
4084              ignores  these  transformations and uses the unmodified value of
4085              the parameter as the name to be replaced.  This is  usually  the
4086              desired  behavior  because  padding may make the value syntacti‐
4087              cally illegal as a parameter name, but if capitalization changes
4088              are desired, use the ${${(P)foo}} form (rule 25.).
4089
4090       3. Parameter subscripting
4091              If the value is a raw parameter reference with a subscript, such
4092              as ${var[3]}, the effect of subscripting is applied directly  to
4093              the  parameter.   Subscripts are evaluated left to right; subse‐
4094              quent subscripts apply to the scalar or array value  yielded  by
4095              the  previous  subscript.  Thus if var is an array, ${var[1][2]}
4096              is the second character of the first word, but ${var[2,4][2]} is
4097              the entire third word (the second word of the range of words two
4098              through four of the original array).  Any number  of  subscripts
4099              may  appear.   Flags such as `(k)' and `(v)' which alter the re‐
4100              sult of subscripting are applied.
4101
4102       4. Parameter name replacement
4103              At the outermost level of nesting only, the `(P)'  flag  is  ap‐
4104              plied.   This treats the value so far as a parameter name (which
4105              may include a subscript expression) and replaces that  with  the
4106              corresponding value.  This replacement occurs later if the `(P)'
4107              flag appears in a nested substitution.
4108
4109              If the value so far names a parameter that  has  internal  flags
4110              (rule 2.), those internal flags are applied to the new value af‐
4111              ter replacement.
4112
4113       5. Double-quoted joining
4114              If the value after this process is an array, and  the  substitu‐
4115              tion  appears  in double quotes, and neither an `(@)' flag nor a
4116              `#' length operator is present at the current level, then  words
4117              of  the value are joined with the first character of the parame‐
4118              ter $IFS, by default a space, between each word (single word ar‐
4119              rays  are  not modified).  If the `(j)' flag is present, that is
4120              used for joining instead of $IFS.
4121
4122       6. Nested subscripting
4123              Any remaining subscripts (i.e. of  a  nested  substitution)  are
4124              evaluated  at this point, based on whether the value is an array
4125              or a scalar.  As with 3., multiple subscripts can appear.   Note
4126              that  ${foo[2,4][2]} is thus equivalent to ${${foo[2,4]}[2]} and
4127              also to "${${(@)foo[2,4]}[2]}" (the nested substitution  returns
4128              an  array  in  both  cases), but not to "${${foo[2,4]}[2]}" (the
4129              nested substitution returns a scalar because of the quotes).
4130
4131       7. Modifiers
4132              Any modifiers, as specified by a trailing `#', `%', `/'  (possi‐
4133              bly  doubled)  or  by a set of modifiers of the form `:...' (see
4134              the section `Modifiers' in the section `History Expansion'), are
4135              applied to the words of the value at this level.
4136
4137       8. Character evaluation
4138              Any  `(#)' flag is applied, evaluating the result so far numeri‐
4139              cally as a character.
4140
4141       9. Length
4142              Any initial `#' modifier, i.e. in the form ${#var}, is  used  to
4143              evaluate the length of the expression so far.
4144
4145       10. Forced joining
4146              If  the  `(j)'  flag is present, or no `(j)' flag is present but
4147              the string is to be split as given by rule 11., and joining  did
4148              not take place at rule 5., any words in the value are joined to‐
4149              gether using the given string or the first character of $IFS  if
4150              none.  Note that the `(F)' flag implicitly supplies a string for
4151              joining in this manner.
4152
4153       11. Simple word splitting
4154              If one of the `(s)' or `(f)' flags are present, or the `=' spec‐
4155              ifier  was  present  (e.g. ${=var}), the word is split on occur‐
4156              rences of the specified string, or (for = with  neither  of  the
4157              two flags present) any of the characters in $IFS.
4158
4159              If  no `(s)', `(f)' or `=' was given, but the word is not quoted
4160              and the option SH_WORD_SPLIT is set, the word is split on occur‐
4161              rences  of  any of the characters in $IFS.  Note this step, too,
4162              takes place at all levels of a nested substitution.
4163
4164       12. Case modification
4165              Any case modification from one of  the  flags  `(L)',  `(U)'  or
4166              `(C)' is applied.
4167
4168       13. Escape sequence replacement
4169              First  any  replacements from the `(g)' flag are performed, then
4170              any prompt-style formatting from the `(%)' family  of  flags  is
4171              applied.
4172
4173       14. Quote application
4174              Any quoting or unquoting using `(q)' and `(Q)' and related flags
4175              is applied.
4176
4177       15. Directory naming
4178              Any directory name substitution using `(D)' flag is applied.
4179
4180       16. Visibility enhancement
4181              Any modifications to make characters  visible  using  the  `(V)'
4182              flag are applied.
4183
4184       17. Lexical word splitting
4185              If  the  '(z)'  flag  or  one  of the forms of the '(Z)' flag is
4186              present, the word is split as if it were a shell  command  line,
4187              so that quotation marks and other metacharacters are used to de‐
4188              cide what constitutes a word.  Note this form  of  splitting  is
4189              entirely  distinct  from that described by rule 11.: it does not
4190              use $IFS, and does not cause forced joining.
4191
4192       18. Uniqueness
4193              If the result is an array and the `(u)' flag was present, dupli‐
4194              cate elements are removed from the array.
4195
4196       19. Ordering
4197              If  the  result  is still an array and one of the `(o)' or `(O)'
4198              flags was present, the array is reordered.
4199
4200       20. RC_EXPAND_PARAM
4201              At this point the decision is made whether any  resulting  array
4202              elements  are to be combined element by element with surrounding
4203              text, as given by either the RC_EXPAND_PARAM option or  the  `^'
4204              flag.
4205
4206       21. Re-evaluation
4207              Any  `(e)' flag is applied to the value, forcing it to be re-ex‐
4208              amined for new parameter substitutions, but also for command and
4209              arithmetic substitutions.
4210
4211       22. Padding
4212              Any padding of the value by the `(l.fill.)' or `(r.fill.)' flags
4213              is applied.
4214
4215       23. Semantic joining
4216              In contexts where expansion semantics requires a single word  to
4217              result,  all  words are rejoined with the first character of IFS
4218              between.  So in `${(P)${(f)lines}}' the  value  of  ${lines}  is
4219              split  at  newlines,  but  then  must be joined again before the
4220              `(P)' flag can be applied.
4221
4222              If a single word is not required, this rule is skipped.
4223
4224       24. Empty argument removal
4225              If the substitution does not appear in double  quotes,  any  re‐
4226              sulting  zero-length  argument, whether from a scalar or an ele‐
4227              ment of an array, is elided from the list of arguments  inserted
4228              into the command line.
4229
4230              Strictly speaking, the removal happens later as the same happens
4231              with other forms of substitution; the point to note here is sim‐
4232              ply that it occurs after any of the above parameter operations.
4233
4234       25. Nested parameter name replacement
4235              If  the  `(P)'  flag is present and rule 4. has not applied, the
4236              value so far is treated as a parameter name (which may include a
4237              subscript expression) and replaced with the corresponding value,
4238              with internal flags (rule 2.) applied to the new value.
4239
4240   Examples
4241       The flag f is useful to split  a  double-quoted  substitution  line  by
4242       line.   For  example, ${(f)"$(<file)"} substitutes the contents of file
4243       divided so that each line is an element of the resulting  array.   Com‐
4244       pare  this with the effect of $(<file) alone, which divides the file up
4245       by words, or the same inside double quotes, which makes the entire con‐
4246       tent of the file a single string.
4247
4248       The  following  illustrates  the rules for nested parameter expansions.
4249       Suppose that $foo contains the array (bar baz):
4250
4251       "${(@)${foo}[1]}"
4252              This produces the  result  b.   First,  the  inner  substitution
4253              "${foo}",  which  has  no array (@) flag, produces a single word
4254              result "bar baz".  The outer substitution "${(@)...[1]}" detects
4255              that this is a scalar, so that (despite the `(@)' flag) the sub‐
4256              script picks the first character.
4257
4258       "${${(@)foo}[1]}"
4259              This produces the result `bar'.  In this case, the inner substi‐
4260              tution  "${(@)foo}"  produces  the array `(bar baz)'.  The outer
4261              substitution "${...[1]}" detects that this is an array and picks
4262              the first word.  This is similar to the simple case "${foo[1]}".
4263
4264       As an example of the rules for word splitting and joining, suppose $foo
4265       contains the array `(ax1 bx1)'.  Then
4266
4267       ${(s/x/)foo}
4268              produces the words `a', `1 b' and `1'.
4269
4270       ${(j/x/s/x/)foo}
4271              produces `a', `1', `b' and `1'.
4272
4273       ${(s/x/)foo%%1*}
4274              produces `a' and ` b' (note the extra space).   As  substitution
4275              occurs  before either joining or splitting, the operation  first
4276              generates the modified array (ax bx), which is  joined  to  give
4277              "ax  bx",  and  then  split to give `a', ` b' and `'.  The final
4278              empty string will then be elided, as it is not in double quotes.
4279

COMMAND SUBSTITUTION

4281       A command enclosed in parentheses  preceded  by  a  dollar  sign,  like
4282       `$(...)',  or quoted with grave accents, like ``...`', is replaced with
4283       its standard output, with any trailing newlines deleted.  If  the  sub‐
4284       stitution  is  not enclosed in double quotes, the output is broken into
4285       words using the IFS parameter.
4286
4287       The substitution `$(cat foo)' may be replaced by the faster  `$(<foo)'.
4288       In  this case foo undergoes single word shell expansions (parameter ex‐
4289       pansion, command substitution and arithmetic expansion), but not  file‐
4290       name generation.
4291
4292       If  the  option  GLOB_SUBST  is set, the result of any unquoted command
4293       substitution, including the special form just  mentioned,  is  eligible
4294       for filename generation.
4295

ARITHMETIC EXPANSION

4297       A  string  of  the  form `$[exp]' or `$((exp))' is substituted with the
4298       value of the arithmetic expression exp.  exp is subjected to  parameter
4299       expansion,  command  substitution and arithmetic expansion before it is
4300       evaluated.  See the section `Arithmetic Evaluation'.
4301

BRACE EXPANSION

4303       A string of the form `foo{xx,yy,zz}bar' is expanded to  the  individual
4304       words  `fooxxbar',  `fooyybar'  and `foozzbar'.  Left-to-right order is
4305       preserved.  This construct may be nested.  Commas may be quoted in  or‐
4306       der to include them literally in a word.
4307
4308       An  expression of the form `{n1..n2}', where n1 and n2 are integers, is
4309       expanded to every number between n1 and n2 inclusive.  If either number
4310       begins with a zero, all the resulting numbers will be padded with lead‐
4311       ing zeroes to that minimum width, but for negative numbers the -  char‐
4312       acter  is also included in the width.  If the numbers are in decreasing
4313       order the resulting sequence will also be in decreasing order.
4314
4315       An expression of the form `{n1..n2..n3}', where n1, n2, and n3 are  in‐
4316       tegers,  is expanded as above, but only every n3th number starting from
4317       n1 is output.  If n3 is negative the numbers are output in reverse  or‐
4318       der,  this  is slightly different from simply swapping n1 and n2 in the
4319       case that the step n3 doesn't evenly divide the  range.   Zero  padding
4320       can  be  specified  in  any  of the three numbers, specifying it in the
4321       third can be useful to pad for example `{-99..100..01}'  which  is  not
4322       possible  to  specify by putting a 0 on either of the first two numbers
4323       (i.e. pad to two characters).
4324
4325       An expression of the form `{c1..c2}', where c1 and c2 are single  char‐
4326       acters  (which may be multibyte characters), is expanded to every char‐
4327       acter in the range from c1 to c2 in whatever character sequence is used
4328       internally.  For characters with code points below 128 this is US ASCII
4329       (this is the only case most users will need).  If any intervening char‐
4330       acter  is  not  printable,  appropriate  quotation is used to render it
4331       printable.  If the character sequence is reversed, the output is in re‐
4332       verse order, e.g. `{d..a}' is substituted as `d c b a'.
4333
4334       If  a  brace expression matches none of the above forms, it is left un‐
4335       changed, unless the option BRACE_CCL (an abbreviation for `brace  char‐
4336       acter  class')  is  set.  In that case, it is expanded to a list of the
4337       individual characters between the braces sorted into the order  of  the
4338       characters  in  the  ASCII  character set (multibyte characters are not
4339       currently handled).  The syntax is similar to  a  [...]  expression  in
4340       filename  generation:  `-'  is  treated  specially to denote a range of
4341       characters, but `^' or `!' as the first character is treated  normally.
4342       For  example, `{abcdef0-9}' expands to 16 words 0 1 2 3 4 5 6 7 8 9 a b
4343       c d e f.
4344
4345       Note that brace expansion is not part  of  filename  generation  (glob‐
4346       bing);  an  expression  such  as */{foo,bar} is split into two separate
4347       words */foo and */bar before filename generation takes place.  In  par‐
4348       ticular,  note that this is liable to produce a `no match' error if ei‐
4349       ther of the two expressions does not match; this is  to  be  contrasted
4350       with  */(foo|bar),  which  is treated as a single pattern but otherwise
4351       has similar effects.
4352
4353       To combine brace expansion with array expansion, see the ${^spec}  form
4354       described in the section Parameter Expansion above.
4355

FILENAME EXPANSION

4357       Each  word  is checked to see if it begins with an unquoted `~'.  If it
4358       does, then the word up to a `/', or the end of the word if there is  no
4359       `/',  is checked to see if it can be substituted in one of the ways de‐
4360       scribed here.  If so, then the `~' and the checked portion are replaced
4361       with the appropriate substitute value.
4362
4363       A `~' by itself is replaced by the value of $HOME.  A `~' followed by a
4364       `+' or a `-' is replaced by current or previous working directory,  re‐
4365       spectively.
4366
4367       A  `~'  followed by a number is replaced by the directory at that posi‐
4368       tion in the directory stack.  `~0' is equivalent to `~+', and  `~1'  is
4369       the top of the stack.  `~+' followed by a number is replaced by the di‐
4370       rectory at that position in the directory stack.  `~+0'  is  equivalent
4371       to  `~+', and `~+1' is the top of the stack.  `~-' followed by a number
4372       is replaced by the directory that many positions from the bottom of the
4373       stack.   `~-0'  is the bottom of the stack.  The PUSHD_MINUS option ex‐
4374       changes the effects of `~+' and `~-' where they are followed by a  num‐
4375       ber.
4376
4377   Dynamic named directories
4378       If  the  function  zsh_directory_name  exists,  or  the  shell variable
4379       zsh_directory_name_functions exists and contains an array  of  function
4380       names,  then the functions are used to implement dynamic directory nam‐
4381       ing.  The functions are tried in order until one returns  status  zero,
4382       so it is important that functions test whether they can handle the case
4383       in question and return an appropriate status.
4384
4385       A `~' followed by a  string  namstr  in  unquoted  square  brackets  is
4386       treated specially as a dynamic directory name.  Note that the first un‐
4387       quoted closing square bracket  always  terminates  namstr.   The  shell
4388       function  is  passed two arguments: the string n (for name) and namstr.
4389       It should either set the array reply to a single element which  is  the
4390       directory  corresponding  to the name and return status zero (executing
4391       an assignment as the last  statement  is  usually  sufficient),  or  it
4392       should return status non-zero.  In the former case the element of reply
4393       is used as the directory; in the latter case the substitution is deemed
4394       to  have  failed.  If all functions fail and the option NOMATCH is set,
4395       an error results.
4396
4397       The functions defined as above are also used to see if a directory  can
4398       be turned into a name, for example when printing the directory stack or
4399       when expanding %~ in prompts.  In this case each function is passed two
4400       arguments:  the  string d (for directory) and the candidate for dynamic
4401       naming.  The function should either return non-zero status, if the  di‐
4402       rectory cannot be named by the function, or it should set the array re‐
4403       ply to consist of two elements: the first is the dynamic name  for  the
4404       directory (as would appear within `~[...]'), and the second is the pre‐
4405       fix length of the directory to be replaced.  For example, if the  trial
4406       directory  is  /home/myname/src/zsh  and the dynamic name for /home/my‐
4407       name/src (which has 16 characters) is s, then the function sets
4408
4409              reply=(s 16)
4410
4411       The directory name so returned is compared with possible  static  names
4412       for  parts of the directory path, as described below; it is used if the
4413       prefix length matched (16 in the example) is longer than  that  matched
4414       by any static name.
4415
4416       It  is not a requirement that a function implements both n and d calls;
4417       for example, it might be appropriate for certain dynamic forms  of  ex‐
4418       pansion  not to be contracted to names.  In that case any call with the
4419       first argument d should cause a non-zero status to be returned.
4420
4421       The completion system calls `zsh_directory_name c' followed by  equiva‐
4422       lent calls to elements of the array zsh_directory_name_functions, if it
4423       exists, in order to complete dynamic names for directories.   The  code
4424       for this should be as for any other completion function as described in
4425       zshcompsys(1).
4426
4427       As a working example, here is a function that expands any dynamic names
4428       beginning  with  the string p: to directories below /home/pws/perforce.
4429       In this simple case a static name for the directory would  be  just  as
4430       effective.
4431
4432              zsh_directory_name() {
4433                emulate -L zsh
4434                setopt extendedglob
4435                local -a match mbegin mend
4436                if [[ $1 = d ]]; then
4437                  # turn the directory into a name
4438                  if [[ $2 = (#b)(/home/pws/perforce/)([^/]##)* ]]; then
4439                    typeset -ga reply
4440                    reply=(p:$match[2] $(( ${#match[1]} + ${#match[2]} )) )
4441                  else
4442                    return 1
4443                  fi
4444                elif [[ $1 = n ]]; then
4445                  # turn the name into a directory
4446                  [[ $2 != (#b)p:(?*) ]] && return 1
4447                  typeset -ga reply
4448                  reply=(/home/pws/perforce/$match[1])
4449                elif [[ $1 = c ]]; then
4450                  # complete names
4451                  local expl
4452                  local -a dirs
4453                  dirs=(/home/pws/perforce/*(/:t))
4454                  dirs=(p:${^dirs})
4455                  _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs
4456                  return
4457                else
4458                  return 1
4459                fi
4460                return 0
4461              }
4462
4463   Static named directories
4464       A `~' followed by anything not already covered consisting of any number
4465       of alphanumeric characters or underscore (`_'), hyphen  (`-'),  or  dot
4466       (`.')  is  looked up as a named directory, and replaced by the value of
4467       that named directory if found.  Named directories  are  typically  home
4468       directories  for  users on the system.  They may also be defined if the
4469       text after the `~' is the name of a string shell parameter whose  value
4470       begins with a `/'.  Note that trailing slashes will be removed from the
4471       path to the directory (though the original parameter is not modified).
4472
4473       It is also possible to define directory names using the  -d  option  to
4474       the hash builtin.
4475
4476       When the shell prints a path (e.g. when expanding %~ in prompts or when
4477       printing the directory stack), the path is checked to see if it  has  a
4478       named  directory  as its prefix.  If so, then the prefix portion is re‐
4479       placed with a `~' followed by the name of the directory.   The  shorter
4480       of  the two ways of referring to the directory is used, i.e. either the
4481       directory name or the full path; the name is used if they are the  same
4482       length.   The parameters $PWD and $OLDPWD are never abbreviated in this
4483       fashion.
4484
4485   `=' expansion
4486       If a word begins with an unquoted `=' and the EQUALS option is set, the
4487       remainder  of the word is taken as the name of a command.  If a command
4488       exists by that name, the word is replaced by the full pathname  of  the
4489       command.
4490
4491   Notes
4492       Filename  expansion  is performed on the right hand side of a parameter
4493       assignment, including those appearing after  commands  of  the  typeset
4494       family.   In  this  case,  the  right  hand  side  will be treated as a
4495       colon-separated list in the manner of the PATH parameter, so that a `~'
4496       or  an  `=' following a `:' is eligible for expansion.  All such behav‐
4497       iour can be disabled by quoting the `~', the `=', or the whole  expres‐
4498       sion (but not simply the colon); the EQUALS option is also respected.
4499
4500       If  the option MAGIC_EQUAL_SUBST is set, any unquoted shell argument in
4501       the form `identifier=expression' becomes eligible for file expansion as
4502       described  in  the  previous paragraph.  Quoting the first `=' also in‐
4503       hibits this.
4504

FILENAME GENERATION

4506       If a word contains an unquoted instance of one of the  characters  `*',
4507       `(',  `|',  `<',  `[', or `?', it is regarded as a pattern for filename
4508       generation, unless the GLOB option is unset.  If the EXTENDED_GLOB  op‐
4509       tion  is  set, the `^' and `#' characters also denote a pattern; other‐
4510       wise they are not treated specially by the shell.
4511
4512       The word is replaced with a list of sorted  filenames  that  match  the
4513       pattern.   If  no  matching  pattern is found, the shell gives an error
4514       message, unless the NULL_GLOB option is set, in which case the word  is
4515       deleted;  or unless the NOMATCH option is unset, in which case the word
4516       is left unchanged.
4517
4518       In filename generation, the character `/' must be  matched  explicitly;
4519       also, a `.' must be matched explicitly at the beginning of a pattern or
4520       after a `/', unless the GLOB_DOTS option is set.  No  filename  genera‐
4521       tion pattern matches the files `.' or `..'.  In other instances of pat‐
4522       tern matching, the `/' and `.' are not treated specially.
4523
4524   Glob Operators
4525       *      Matches any string, including the null string.
4526
4527       ?      Matches any character.
4528
4529       [...]  Matches any of the enclosed characters.   Ranges  of  characters
4530              can  be  specified by separating two characters by a `-'.  A `-'
4531              or `]' may be matched by including it as the first character  in
4532              the  list.   There are also several named classes of characters,
4533              in the form `[:name:]' with the following meanings.   The  first
4534              set  use the macros provided by the operating system to test for
4535              the given character combinations,  including  any  modifications
4536              due to local language settings, see ctype(3):
4537
4538              [:alnum:]
4539                     The character is alphanumeric
4540
4541              [:alpha:]
4542                     The character is alphabetic
4543
4544              [:ascii:]
4545                     The  character  is 7-bit, i.e. is a single-byte character
4546                     without the top bit set.
4547
4548              [:blank:]
4549                     The character is a blank character
4550
4551              [:cntrl:]
4552                     The character is a control character
4553
4554              [:digit:]
4555                     The character is a decimal digit
4556
4557              [:graph:]
4558                     The character is a printable character other than  white‐
4559                     space
4560
4561              [:lower:]
4562                     The character is a lowercase letter
4563
4564              [:print:]
4565                     The character is printable
4566
4567              [:punct:]
4568                     The  character  is printable but neither alphanumeric nor
4569                     whitespace
4570
4571              [:space:]
4572                     The character is whitespace
4573
4574              [:upper:]
4575                     The character is an uppercase letter
4576
4577              [:xdigit:]
4578                     The character is a hexadecimal digit
4579
4580              Another set of named classes is handled internally by the  shell
4581              and is not sensitive to the locale:
4582
4583              [:IDENT:]
4584                     The  character is allowed to form part of a shell identi‐
4585                     fier, such as a parameter name
4586
4587              [:IFS:]
4588                     The character is used as an input field  separator,  i.e.
4589                     is contained in the IFS parameter
4590
4591              [:IFSSPACE:]
4592                     The  character  is  an IFS white space character; see the
4593                     documentation for IFS in the zshparam(1) manual page.
4594
4595              [:INCOMPLETE:]
4596                     Matches a byte that starts an incomplete multibyte  char‐
4597                     acter.   Note  that  there may be a sequence of more than
4598                     one bytes that taken together form the prefix of a multi‐
4599                     byte  character.   To  test  for a potentially incomplete
4600                     byte sequence, use the pattern `[[:INCOMPLETE:]]*'.  This
4601                     will  never match a sequence starting with a valid multi‐
4602                     byte character.
4603
4604              [:INVALID:]
4605                     Matches a byte that does  not  start  a  valid  multibyte
4606                     character.   Note  this  may be a continuation byte of an
4607                     incomplete multibyte character as any part of a multibyte
4608                     string  consisting  of  invalid  and incomplete multibyte
4609                     characters is treated as single bytes.
4610
4611              [:WORD:]
4612                     The character is treated as part of a word; this test  is
4613                     sensitive to the value of the WORDCHARS parameter
4614
4615              Note  that the square brackets are additional to those enclosing
4616              the whole set of characters, so to test for  a  single  alphanu‐
4617              meric  character  you  need `[[:alnum:]]'.  Named character sets
4618              can be used alongside other types, e.g. `[[:alpha:]0-9]'.
4619
4620       [^...]
4621       [!...] Like [...], except that it matches any character which is not in
4622              the given set.
4623
4624       <[x]-[y]>
4625              Matches  any  number  in the range x to y, inclusive.  Either of
4626              the numbers may be omitted to make the range  open-ended;  hence
4627              `<->' matches any number.  To match individual digits, the [...]
4628              form is more efficient.
4629
4630              Be careful when using other wildcards adjacent  to  patterns  of
4631              this  form;  for  example, <0-9>* will actually match any number
4632              whatsoever at the start of the string, since  the  `<0-9>'  will
4633              match  the first digit, and the `*' will match any others.  This
4634              is a trap for the unwary, but is in fact  an  inevitable  conse‐
4635              quence  of  the rule that the longest possible match always suc‐
4636              ceeds.  Expressions such as `<0-9>[^[:digit:]]*' can be used in‐
4637              stead.
4638
4639       (...)  Matches  the  enclosed  pattern.  This is used for grouping.  If
4640              the KSH_GLOB option is set, then a `@', `*', `+', `?' or `!' im‐
4641              mediately  preceding  the  `(' is treated specially, as detailed
4642              below. The option SH_GLOB prevents bare parentheses  from  being
4643              used in this way, though the KSH_GLOB option is still available.
4644
4645              Note  that  grouping cannot extend over multiple directories: it
4646              is an error to have a `/' within a group (this only applies  for
4647              patterns  used in filename generation).  There is one exception:
4648              a group of the form (pat/)# appearing as a complete path segment
4649              can match a sequence of directories.  For example, foo/(a*/)#bar
4650              matches foo/bar, foo/any/bar, foo/any/anyother/bar, and so on.
4651
4652       x|y    Matches either x or y.  This operator has lower precedence  than
4653              any  other.   The  `|'  character must be within parentheses, to
4654              avoid interpretation as a pipeline.  The alternatives are  tried
4655              in order from left to right.
4656
4657       ^x     (Requires EXTENDED_GLOB to be set.)  Matches anything except the
4658              pattern x.  This has a higher precedence than `/', so `^foo/bar'
4659              will  search  directories in `.' except `./foo' for a file named
4660              `bar'.
4661
4662       x~y    (Requires EXTENDED_GLOB to be set.)  Match anything that matches
4663              the  pattern  x but does not match y.  This has lower precedence
4664              than any operator except `|', so `*/*~foo/bar' will  search  for
4665              all  files in all directories in `.'  and then exclude `foo/bar'
4666              if there was such a match.  Multiple patterns can be excluded by
4667              `foo~bar~baz'.   In  the  exclusion pattern (y), `/' and `.' are
4668              not treated specially the way they usually are in globbing.
4669
4670       x#     (Requires EXTENDED_GLOB to be set.)  Matches zero or more occur‐
4671              rences  of  the  pattern  x.  This operator has high precedence;
4672              `12#' is equivalent to `1(2#)', rather than `(12)#'.  It  is  an
4673              error  for  an  unquoted `#' to follow something which cannot be
4674              repeated; this includes an empty string, a pattern already  fol‐
4675              lowed  by  `##',  or parentheses when part of a KSH_GLOB pattern
4676              (for example, `!(foo)#' is  invalid  and  must  be  replaced  by
4677              `*(!(foo))').
4678
4679       x##    (Requires  EXTENDED_GLOB to be set.)  Matches one or more occur‐
4680              rences of the pattern x.  This  operator  has  high  precedence;
4681              `12##' is equivalent to `1(2##)', rather than `(12)##'.  No more
4682              than two active `#' characters may appear together.   (Note  the
4683              potential  clash with glob qualifiers in the form `1(2##)' which
4684              should therefore be avoided.)
4685
4686   ksh-like Glob Operators
4687       If the KSH_GLOB option is set, the effects of parentheses can be  modi‐
4688       fied by a preceding `@', `*', `+', `?' or `!'.  This character need not
4689       be unquoted to have special effects, but the `(' must be.
4690
4691       @(...) Match the pattern in the parentheses.  (Like `(...)'.)
4692
4693       *(...) Match any number of occurrences.  (Like  `(...)#',  except  that
4694              recursive directory searching is not supported.)
4695
4696       +(...) Match at least one occurrence.  (Like `(...)##', except that re‐
4697              cursive directory searching is not supported.)
4698
4699       ?(...) Match zero or one occurrence.  (Like `(|...)'.)
4700
4701       !(...) Match  anything  but  the  expression  in  parentheses.    (Like
4702              `(^(...))'.)
4703
4704   Precedence
4705       The precedence of the operators given above is (highest) `^', `/', `~',
4706       `|' (lowest); the remaining operators are simply treated from  left  to
4707       right  as  part of a string, with `#' and `##' applying to the shortest
4708       possible preceding unit (i.e. a character, `?', `[...]', `<...>', or  a
4709       parenthesised  expression).  As mentioned above, a `/' used as a direc‐
4710       tory separator may not appear inside parentheses, while a `|'  must  do
4711       so;  in  patterns  used in other contexts than filename generation (for
4712       example, in case statements and tests within `[[...]]'), a `/'  is  not
4713       special;  and  `/'  is  also  not special after a `~' appearing outside
4714       parentheses in a filename pattern.
4715
4716   Globbing Flags
4717       There are various flags which affect any text to their right up to  the
4718       end  of  the enclosing group or to the end of the pattern; they require
4719       the EXTENDED_GLOB option. All take the form (#X) where X may  have  one
4720       of the following forms:
4721
4722       i      Case insensitive:  upper or lower case characters in the pattern
4723              match upper or lower case characters.
4724
4725       l      Lower case characters in the pattern match upper or  lower  case
4726              characters;  upper  case  characters  in  the pattern still only
4727              match upper case characters.
4728
4729       I      Case sensitive:  locally negates the effect of i or l from  that
4730              point on.
4731
4732       b      Activate backreferences for parenthesised groups in the pattern;
4733              this does not work in filename generation.  When a pattern  with
4734              a  set  of active parentheses is matched, the strings matched by
4735              the groups are stored in the array $match, the  indices  of  the
4736              beginning  of  the matched parentheses in the array $mbegin, and
4737              the indices of the end in the array $mend, with the  first  ele‐
4738              ment  of  each  array  corresponding  to the first parenthesised
4739              group, and so on.  These arrays are not otherwise special to the
4740              shell.   The  indices  use the same convention as does parameter
4741              substitution, so that elements of $mend and $mbegin may be  used
4742              in  subscripts;  the  KSH_ARRAYS  option  is respected.  Sets of
4743              globbing flags are not considered parenthesised groups; only the
4744              first nine active parentheses can be referenced.
4745
4746              For example,
4747
4748                     foo="a_string_with_a_message"
4749                     if [[ $foo = (a|an)_(#b)(*) ]]; then
4750                       print ${foo[$mbegin[1],$mend[1]]}
4751                     fi
4752
4753              prints  `string_with_a_message'.   Note  that  the  first set of
4754              parentheses is before the (#b) and does not create a  backrefer‐
4755              ence.
4756
4757              Backreferences  work  with  all  forms of pattern matching other
4758              than filename generation, but note that when performing  matches
4759              on  an  entire array, such as ${array#pattern}, or a global sub‐
4760              stitution, such as ${param//pat/repl}, only  the  data  for  the
4761              last  match  remains  available.  In the case of global replace‐
4762              ments this may still be useful.  See the example for the m  flag
4763              below.
4764
4765              The  numbering  of  backreferences strictly follows the order of
4766              the opening parentheses  from  left  to  right  in  the  pattern
4767              string,  although  sets of parentheses may be nested.  There are
4768              special rules for parentheses followed by `#' or `##'.  Only the
4769              last match of the parenthesis is remembered: for example, in `[[
4770              abab =  (#b)([ab])#  ]]',  only  the  final  `b'  is  stored  in
4771              match[1].   Thus extra parentheses may be necessary to match the
4772              complete segment: for example, use  `X((ab|cd)#)Y'  to  match  a
4773              whole  string  of either `ab' or `cd' between `X' and `Y', using
4774              the value of $match[1] rather than $match[2].
4775
4776              If the match fails none of the parameters is altered, so in some
4777              cases  it  may  be  necessary to initialise them beforehand.  If
4778              some of the backreferences fail to match  --  which  happens  if
4779              they are in an alternate branch which fails to match, or if they
4780              are followed by # and matched zero times  --  then  the  matched
4781              string is set to the empty string, and the start and end indices
4782              are set to -1.
4783
4784              Pattern matching with backreferences  is  slightly  slower  than
4785              without.
4786
4787       B      Deactivate  backreferences,  negating  the  effect of the b flag
4788              from that point on.
4789
4790       cN,M   The flag (#cN,M) can be used anywhere that the # or ## operators
4791              can  be  used  except in the expressions `(*/)#' and `(*/)##' in
4792              filename generation, where `/' has special meaning; it cannot be
4793              combined  with  other globbing flags and a bad pattern error oc‐
4794              curs if it is misplaced.  It is equivalent to the form {N,M}  in
4795              regular  expressions.   The  previous  character or group is re‐
4796              quired to match between N and  M  times,  inclusive.   The  form
4797              (#cN) requires exactly N matches; (#c,M) is equivalent to speci‐
4798              fying N as 0; (#cN,) specifies that there is no maximum limit on
4799              the number of matches.
4800
4801       m      Set  references to the match data for the entire string matched;
4802              this is similar to backreferencing and does not work in filename
4803              generation.   The  flag must be in effect at the end of the pat‐
4804              tern, i.e. not local to a group. The parameters $MATCH,  $MBEGIN
4805              and  $MEND  will be set to the string matched and to the indices
4806              of the beginning and end of the string, respectively.   This  is
4807              most  useful in parameter substitutions, as otherwise the string
4808              matched is obvious.
4809
4810              For example,
4811
4812                     arr=(veldt jynx grimps waqf zho buck)
4813                     print ${arr//(#m)[aeiou]/${(U)MATCH}}
4814
4815              forces all the matches (i.e. all vowels) into uppercase,  print‐
4816              ing `vEldt jynx grImps wAqf zhO bUck'.
4817
4818              Unlike backreferences, there is no speed penalty for using match
4819              references, other than the extra substitutions required for  the
4820              replacement strings in cases such as the example shown.
4821
4822       M      Deactivate the m flag, hence no references to match data will be
4823              created.
4824
4825       anum   Approximate matching: num  errors  are  allowed  in  the  string
4826              matched by the pattern.  The rules for this are described in the
4827              next subsection.
4828
4829       s, e   Unlike the other flags, these have only a local effect, and each
4830              must  appear  on  its own:  `(#s)' and `(#e)' are the only valid
4831              forms.  The `(#s)' flag succeeds only at the start of  the  test
4832              string, and the `(#e)' flag succeeds only at the end of the test
4833              string; they correspond to `^' and `$' in standard  regular  ex‐
4834              pressions.   They  are useful for matching path segments in pat‐
4835              terns other than those in filename generation (where  path  seg‐
4836              ments  are  in  any  case  treated  separately).   For  example,
4837              `*((#s)|/)test((#e)|/)*' matches a path segment `test' in any of
4838              the   following   strings:   test,  test/at/start,  at/end/test,
4839              in/test/middle.
4840
4841              Another use is in parameter  substitution;  for  example  `${ar‐
4842              ray/(#s)A*Z(#e)}'  will  remove  only elements of an array which
4843              match the complete pattern `A*Z'.  There are other ways of  per‐
4844              forming many operations of this type, however the combination of
4845              the substitution operations `/' and `//'  with  the  `(#s)'  and
4846              `(#e)' flags provides a single simple and memorable method.
4847
4848              Note that assertions of the form `(^(#s))' also work, i.e. match
4849              anywhere except at the start of the string, although this  actu‐
4850              ally  means  `anything except a zero-length portion at the start
4851              of  the  string';  you  need  to  use  `(""~(#s))'  to  match  a
4852              zero-length portion of the string not at the start.
4853
4854       q      A  `q' and everything up to the closing parenthesis of the glob‐
4855              bing flags are ignored by the pattern matching  code.   This  is
4856              intended  to support the use of glob qualifiers, see below.  The
4857              result is that the pattern `(#b)(*).c(#q.)' can be used both for
4858              globbing and for matching against a string.  In the former case,
4859              the `(#q.)' will be treated as a glob qualifier and  the  `(#b)'
4860              will  not be useful, while in the latter case the `(#b)' is use‐
4861              ful for backreferences and the `(#q.)' will  be  ignored.   Note
4862              that colon modifiers in the glob qualifiers are also not applied
4863              in ordinary pattern matching.
4864
4865       u      Respect the current locale in determining the presence of multi‐
4866              byte  characters  in  a pattern, provided the shell was compiled
4867              with MULTIBYTE_SUPPORT.  This overrides  the  MULTIBYTE  option;
4868              the  default  behaviour  is  taken  from the option.  Compare U.
4869              (Mnemonic: typically multibyte characters are  from  Unicode  in
4870              the UTF-8 encoding, although any extension of ASCII supported by
4871              the system library may be used.)
4872
4873       U      All characters are considered to be a single byte long.  The op‐
4874              posite of u.  This overrides the MULTIBYTE option.
4875
4876       For  example,  the  test  string  fooxx  can  be matched by the pattern
4877       (#i)FOOXX, but not by (#l)FOOXX,  (#i)FOO(#I)XX  or  ((#i)FOOX)X.   The
4878       string  (#ia2)readme specifies case-insensitive matching of readme with
4879       up to two errors.
4880
4881       When using the ksh syntax for grouping both KSH_GLOB and  EXTENDED_GLOB
4882       must  be  set  and  the left parenthesis should be preceded by @.  Note
4883       also that the flags do not affect letters inside [...] groups, in other
4884       words  (#i)[a-z]  still  matches only lowercase letters.  Finally, note
4885       that when examining whole paths case-insensitively every directory must
4886       be  searched  for  all files which match, so that a pattern of the form
4887       (#i)/foo/bar/... is potentially slow.
4888
4889   Approximate Matching
4890       When matching approximately, the shell keeps  a  count  of  the  errors
4891       found,  which  cannot exceed the number specified in the (#anum) flags.
4892       Four types of error are recognised:
4893
4894       1.     Different characters, as in fooxbar and fooybar.
4895
4896       2.     Transposition of characters, as in banana and abnana.
4897
4898       3.     A character missing in the target string, as  with  the  pattern
4899              road and target string rod.
4900
4901       4.     An extra character appearing in the target string, as with stove
4902              and strove.
4903
4904       Thus, the pattern (#a3)abcd matches dcba, with the errors occurring  by
4905       using  the first rule twice and the second once, grouping the string as
4906       [d][cb][a] and [a][bc][d].
4907
4908       Non-literal parts of the pattern must match exactly, including  charac‐
4909       ters  in  character  ranges:  hence (#a1)???  matches strings of length
4910       four, by applying rule 4 to an empty  part  of  the  pattern,  but  not
4911       strings  of  length  two, since all the ? must match.  Other characters
4912       which must match exactly are initial  dots  in  filenames  (unless  the
4913       GLOB_DOTS option is set), and all slashes in filenames, so that a/bc is
4914       two errors from ab/c (the slash cannot be transposed with another char‐
4915       acter).   Similarly,  errors  are counted separately for non-contiguous
4916       strings in the pattern, so that (ab|cd)ef is two errors from aebf.
4917
4918       When using exclusion  via  the  ~  operator,  approximate  matching  is
4919       treated entirely separately for the excluded part and must be activated
4920       separately.  Thus, (#a1)README~READ_ME matches READ.ME but not READ_ME,
4921       as  the  trailing  READ_ME  is matched without approximation.  However,
4922       (#a1)README~(#a1)READ_ME does not match any pattern of the form READ?ME
4923       as all such forms are now excluded.
4924
4925       Apart  from exclusions, there is only one overall error count; however,
4926       the maximum errors allowed may be altered locally, and this can be  de‐
4927       limited by grouping.  For example, (#a1)cat((#a0)dog)fox allows one er‐
4928       ror in total, which may not occur in the dog section, and  the  pattern
4929       (#a1)cat(#a0)dog(#a1)fox  is  equivalent.  Note that the point at which
4930       an error is first found is the crucial one for establishing whether  to
4931       use   approximation;  for  example,  (#a1)abc(#a0)xyz  will  not  match
4932       abcdxyz, because the error occurs at the `x',  where  approximation  is
4933       turned off.
4934
4935       Entire   path   segments   may   be   matched  approximately,  so  that
4936       `(#a1)/foo/d/is/available/at/the/bar' allows one error in any path seg‐
4937       ment.   This  is  much  less efficient than without the (#a1), however,
4938       since every directory in the path must be scanned for  a  possible  ap‐
4939       proximate match.  It is best to place the (#a1) after any path segments
4940       which are known to be correct.
4941
4942   Recursive Globbing
4943       A pathname component of the form `(foo/)#' matches a path consisting of
4944       zero or more directories matching the pattern foo.
4945
4946       As  a  shorthand, `**/' is equivalent to `(*/)#'; note that this there‐
4947       fore matches files in the current directory as well as  subdirectories.
4948       Thus:
4949
4950              ls -ld -- (*/)#bar
4951
4952       or
4953
4954              ls -ld -- **/bar
4955
4956       does  a  recursive  directory search for files named `bar' (potentially
4957       including the file `bar' in the current directory).  This form does not
4958       follow  symbolic links; the alternative form `***/' does, but is other‐
4959       wise identical.  Neither of these can be combined with other  forms  of
4960       globbing  within the same path segment; in that case, the `*' operators
4961       revert to their usual effect.
4962
4963       Even shorter forms are available when  the  option  GLOB_STAR_SHORT  is
4964       set.   In  that  case  if no / immediately follows a ** or *** they are
4965       treated as if both a / plus a further * are present.  Hence:
4966
4967              setopt GLOBSTARSHORT
4968              ls -ld -- **.c
4969
4970       is equivalent to
4971
4972              ls -ld -- **/*.c
4973
4974   Glob Qualifiers
4975       Patterns used for filename generation may end in a list  of  qualifiers
4976       enclosed  in  parentheses.  The qualifiers specify which filenames that
4977       otherwise match the given pattern will  be  inserted  in  the  argument
4978       list.
4979
4980       If the option BARE_GLOB_QUAL is set, then a trailing set of parentheses
4981       containing no `|' or `(' characters (or `~' if it is special) is  taken
4982       as  a set of glob qualifiers.  A glob subexpression that would normally
4983       be taken as glob qualifiers, for example `(^x)', can be  forced  to  be
4984       treated  as  part  of  the glob pattern by doubling the parentheses, in
4985       this case producing `((^x))'.
4986
4987       If the option EXTENDED_GLOB is set, a different syntax for glob  quali‐
4988       fiers  is  available,  namely  `(#qx)'  where x is any of the same glob
4989       qualifiers used in the other format.  The qualifiers must still  appear
4990       at  the  end  of  the pattern.  However, with this syntax multiple glob
4991       qualifiers may be chained together.  They are treated as a logical  AND
4992       of  the  individual sets of flags.  Also, as the syntax is unambiguous,
4993       the expression will be treated as glob  qualifiers  just  as  long  any
4994       parentheses contained within it are balanced; appearance of `|', `(' or
4995       `~' does not negate the effect.  Note that qualifiers  will  be  recog‐
4996       nised  in  this form even if a bare glob qualifier exists at the end of
4997       the pattern, for example `*(#q*)(.)' will recognise executable  regular
4998       files if both options are set; however, mixed syntax should probably be
4999       avoided for the sake of clarity.  Note that within conditions using the
5000       `[[' form the presence of a parenthesised expression (#q...) at the end
5001       of a string indicates that globbing should be performed; the expression
5002       may include glob qualifiers, but it is also valid if it is simply (#q).
5003       This does not apply to the right hand side of pattern  match  operators
5004       as the syntax already has special significance.
5005
5006       A qualifier may be any one of the following:
5007
5008       /      directories
5009
5010       F      `full'  (i.e.  non-empty)  directories.   Note that the opposite
5011              sense (^F) expands to empty directories and all non-directories.
5012              Use (/^F) for empty directories.
5013
5014       .      plain files
5015
5016       @      symbolic links
5017
5018       =      sockets
5019
5020       p      named pipes (FIFOs)
5021
5022       *      executable plain files (0100 or 0010 or 0001)
5023
5024       %      device files (character or block special)
5025
5026       %b     block special files
5027
5028       %c     character special files
5029
5030       r      owner-readable files (0400)
5031
5032       w      owner-writable files (0200)
5033
5034       x      owner-executable files (0100)
5035
5036       A      group-readable files (0040)
5037
5038       I      group-writable files (0020)
5039
5040       E      group-executable files (0010)
5041
5042       R      world-readable files (0004)
5043
5044       W      world-writable files (0002)
5045
5046       X      world-executable files (0001)
5047
5048       s      setuid files (04000)
5049
5050       S      setgid files (02000)
5051
5052       t      files with the sticky bit (01000)
5053
5054       fspec  files with access rights matching spec. This spec may be a octal
5055              number optionally preceded by a `=', a `+', or a `-'. If none of
5056              these  characters is given, the behavior is the same as for `='.
5057              The octal number describes the mode bits to be expected, if com‐
5058              bined  with a `=', the value given must match the file-modes ex‐
5059              actly, with a `+', at least the bits in the given number must be
5060              set  in  the  file-modes, and with a `-', the bits in the number
5061              must not be set. Giving a `?' instead of a octal digit  anywhere
5062              in  the  number  ensures  that  the  corresponding  bits  in the
5063              file-modes are not checked, this is only useful  in  combination
5064              with `='.
5065
5066              If the qualifier `f' is followed by any other character anything
5067              up to the next matching character (`[', `{', and `<' match  `]',
5068              `}',  and  `>' respectively, any other character matches itself)
5069              is taken as a list of comma-separated sub-specs.  Each  sub-spec
5070              may  be  either  an octal number as described above or a list of
5071              any of the characters `u', `g', `o', and `a', followed by a `=',
5072              a  `+',  or  a  `-', followed by a list of any of the characters
5073              `r', `w', `x', `s', and `t', or an octal digit. The  first  list
5074              of  characters specify which access rights are to be checked. If
5075              a `u' is given, those for the owner of the file are used,  if  a
5076              `g'  is  given,  those  of the group are checked, a `o' means to
5077              test those of other users, and the `a' says to  test  all  three
5078              groups. The `=', `+', and `-' again says how the modes are to be
5079              checked and have the same meaning as  described  for  the  first
5080              form above. The second list of characters finally says which ac‐
5081              cess rights are to be expected: `r' for  read  access,  `w'  for
5082              write  access,  `x'  for  the  right  to execute the file (or to
5083              search a directory), `s' for the setuid and setgid bits, and `t'
5084              for the sticky bit.
5085
5086              Thus,  `*(f70?)'  gives  the files for which the owner has read,
5087              write, and execute permission, and for which other group members
5088              have  no rights, independent of the permissions for other users.
5089              The pattern `*(f-100)' gives all files for which the owner  does
5090              not  have  execute  permission,  and `*(f:gu+w,o-rx:)' gives the
5091              files for which the owner and the other  members  of  the  group
5092              have  at least write permission, and for which other users don't
5093              have read or execute permission.
5094
5095       estring
5096       +cmd   The string will be executed as shell code.  The filename will be
5097              included in the list if and only if the code returns a zero sta‐
5098              tus (usually the status of the last command).
5099
5100              In the first form, the first character after  the  `e'  will  be
5101              used as a separator and anything up to the next matching separa‐
5102              tor will be taken  as the string; `[', `{', and `<'  match  `]',
5103              `}',  and  `>',  respectively, while any other character matches
5104              itself. Note that expansions must be quoted  in  the  string  to
5105              prevent  them  from  being  expanded  before  globbing  is done.
5106              string is then executed as shell code.  The string  globqual  is
5107              appended  to  the  array zsh_eval_context the duration of execu‐
5108              tion.
5109
5110              During the execution of  string  the  filename  currently  being
5111              tested is available in the parameter REPLY; the parameter may be
5112              altered to a string to be inserted into the list instead of  the
5113              original  filename.  In addition, the parameter reply may be set
5114              to an array or a string, which overrides the value of REPLY.  If
5115              set  to  an  array, the latter is inserted into the command line
5116              word by word.
5117
5118              For  example,  suppose  a  directory  contains  a  single   file
5119              `lonely'.   Then  the expression `*(e:'reply=(${REPLY}{1,2})':)'
5120              will cause the words `lonely1' and `lonely2' to be inserted into
5121              the command line.  Note the quoting of string.
5122
5123              The  form  +cmd  has  the  same effect, but no delimiters appear
5124              around cmd.  Instead, cmd is taken as the  longest  sequence  of
5125              characters  following the + that are alphanumeric or underscore.
5126              Typically cmd will be the name of a shell function that contains
5127              the appropriate test.  For example,
5128
5129                     nt() { [[ $REPLY -nt $NTREF ]] }
5130                     NTREF=reffile
5131                     ls -ld -- *(+nt)
5132
5133              lists  all  files  in the directory that have been modified more
5134              recently than reffile.
5135
5136       ddev   files on the device dev
5137
5138       l[-|+]ct
5139              files having a link count less than ct (-), greater than ct (+),
5140              or equal to ct
5141
5142       U      files owned by the effective user ID
5143
5144       G      files owned by the effective group ID
5145
5146       uid    files  owned  by  user ID id if that is a number.  Otherwise, id
5147              specifies a user name: the character after the `u' will be taken
5148              as  a  separator and the string between it and the next matching
5149              separator will be taken as a user name.  The starting separators
5150              `[',  `{', and `<' match the final separators `]', `}', and `>',
5151              respectively; any other character matches itself.  The  selected
5152              files  are  those  owned by this user.  For example, `u:foo:' or
5153              `u[foo]' selects files owned by user `foo'.
5154
5155       gid    like uid but with group IDs or names
5156
5157       a[Mwhms][-|+]n
5158              files accessed exactly n days ago.  Files  accessed  within  the
5159              last  n  days  are  selected  using a negative value for n (-n).
5160              Files accessed more than n days ago are selected by a positive n
5161              value  (+n).  Optional unit specifiers `M', `w', `h', `m' or `s'
5162              (e.g. `ah5') cause the check to be performed with months (of  30
5163              days), weeks, hours, minutes or seconds instead of days, respec‐
5164              tively.  An explicit `d' for days is also allowed.
5165
5166              Any fractional part of the difference between  the  access  time
5167              and  the current part in the appropriate units is ignored in the
5168              comparison.  For instance, `echo *(ah-5)' would echo  files  ac‐
5169              cessed  within  the  last five hours, while `echo *(ah+5)' would
5170              echo files accessed at least six hours ago,  as  times  strictly
5171              between five and six hours are treated as five hours.
5172
5173       m[Mwhms][-|+]n
5174              like  the  file  access  qualifier, except that it uses the file
5175              modification time.
5176
5177       c[Mwhms][-|+]n
5178              like the file access qualifier, except that it uses the file in‐
5179              ode change time.
5180
5181       L[+|-]n
5182              files less than n bytes (-), more than n bytes (+), or exactly n
5183              bytes in length.
5184
5185              If this flag is directly followed by a size specifier `k' (`K'),
5186              `m'  (`M'),  or  `p' (`P') (e.g. `Lk-50') the check is performed
5187              with kilobytes, megabytes, or blocks  (of  512  bytes)  instead.
5188              (On  some  systems additional specifiers are available for giga‐
5189              bytes, `g' or `G', and terabytes, `t' or `T'.) If a size  speci‐
5190              fier  is  used  a  file is regarded as "exactly" the size if the
5191              file size rounded up to the next unit is equal to the test size.
5192              Hence `*(Lm1)' matches files from 1 byte up to 1 Megabyte inclu‐
5193              sive.  Note also that the set of files "less than" the test size
5194              only  includes  files  that  would  not match the equality test;
5195              hence `*(Lm-1)' only matches files of zero size.
5196
5197       ^      negates all qualifiers following it
5198
5199       -      toggles between making the qualifiers  work  on  symbolic  links
5200              (the default) and the files they point to
5201
5202       M      sets the MARK_DIRS option for the current pattern
5203
5204       T      appends a trailing qualifier mark to the filenames, analogous to
5205              the LIST_TYPES option, for the current pattern (overrides M)
5206
5207       N      sets the NULL_GLOB option for the current pattern
5208
5209       D      sets the GLOB_DOTS option for the current pattern
5210
5211       n      sets the NUMERIC_GLOB_SORT option for the current pattern
5212
5213       Yn     enables short-circuit mode: the pattern will expand to at most n
5214              filenames.   If  more  than  n  matches  exist, only the first n
5215              matches in directory traversal order will be considered.
5216
5217              Implies oN when no oc qualifier is used.
5218
5219       oc     specifies how the names of the files should be sorted. If c is n
5220              they are sorted by name; if it is L they are sorted depending on
5221              the size (length) of the files; if l they are sorted by the num‐
5222              ber  of  links; if a, m, or c they are sorted by the time of the
5223              last access, modification, or inode change respectively;  if  d,
5224              files  in  subdirectories appear before those in the current di‐
5225              rectory at each level of the search --  this  is  best  combined
5226              with  other  criteria,  for  example `odon' to sort on names for
5227              files within the same directory; if N, no sorting is  performed.
5228              Note  that a, m, and c compare the age against the current time,
5229              hence the first name in the list is the youngest file. Also note
5230              that  the  modifiers ^ and - are used, so `*(^-oL)' gives a list
5231              of all files sorted by file size in descending order,  following
5232              any  symbolic  links.   Unless oN is used, multiple order speci‐
5233              fiers may occur to resolve ties.
5234
5235              The default sorting is n (by name) unless the Y  glob  qualifier
5236              is used, in which case it is N (unsorted).
5237
5238              oe  and  o+  are  special cases; they are each followed by shell
5239              code, delimited as for the e glob qualifier and the + glob qual‐
5240              ifier  respectively  (see above).  The code is executed for each
5241              matched file with the parameter REPLY set to  the  name  of  the
5242              file  on  entry  and globsort appended to zsh_eval_context.  The
5243              code should modify the parameter REPLY in some fashion.  On  re‐
5244              turn,  the  value  of  the parameter is used instead of the file
5245              name as the string on which to sort.  Unlike other  sort  opera‐
5246              tors,  oe and o+ may be repeated, but note that the maximum num‐
5247              ber of sort operators of any kind that may appear  in  any  glob
5248              expression is 12.
5249
5250       Oc     like  `o',  but  sorts in descending order; i.e. `*(^oc)' is the
5251              same as `*(Oc)' and `*(^Oc)' is the same as `*(oc)';  `Od'  puts
5252              files in the current directory before those in subdirectories at
5253              each level of the search.
5254
5255       [beg[,end]]
5256              specifies which of the matched filenames should be  included  in
5257              the  returned  list.  The  syntax  is the same as for array sub‐
5258              scripts. beg and the optional end may  be  mathematical  expres‐
5259              sions. As in parameter subscripting they may be negative to make
5260              them count from the last  match  backward.  E.g.:  `*(-OL[1,3])'
5261              gives a list of the names of the three largest files.
5262
5263       Pstring
5264              The  string  will  be prepended to each glob match as a separate
5265              word.  string is delimited in the same way as arguments to the e
5266              glob  qualifier described above.  The qualifier can be repeated;
5267              the words are prepended separately so that the resulting command
5268              line contains the words in the same order they were given in the
5269              list of glob qualifiers.
5270
5271              A typical use for this is to prepend an option before all occur‐
5272              rences  of a file name; for example, the pattern `*(P:-f:)' pro‐
5273              duces the command line arguments `-f file1 -f file2 ...'
5274
5275              If the modifier ^ is active, then string will  be  appended  in‐
5276              stead  of  prepended.  Prepending and appending is done indepen‐
5277              dently so both can be used on the same glob expression; for  ex‐
5278              ample  by  writing  `*(P:foo:^P:bar:^P:baz:)' which produces the
5279              command line arguments `foo baz file1 bar ...'
5280
5281       More than one of these lists can be combined, separated by commas.  The
5282       whole  list  matches  if at least one of the sublists matches (they are
5283       `or'ed, the qualifiers in the sublists are `and'ed).  Some  qualifiers,
5284       however,  affect  all  matches generated, independent of the sublist in
5285       which they are given.  These are the qualifiers  `M',  `T',  `N',  `D',
5286       `n', `o', `O' and the subscripts given in brackets (`[...]').
5287
5288       If  a  `:' appears in a qualifier list, the remainder of the expression
5289       in parenthesis is interpreted as a modifier  (see  the  section  `Modi‐
5290       fiers'  in the section `History Expansion').  Each modifier must be in‐
5291       troduced by a separate `:'.  Note also that the result after  modifica‐
5292       tion  does  not  have to be an existing file.  The name of any existing
5293       file can be followed by a modifier of the form `(:...)' even if no  ac‐
5294       tual  filename generation is performed, although note that the presence
5295       of the parentheses causes the entire expression to be subjected to  any
5296       global pattern matching options such as NULL_GLOB. Thus:
5297
5298              ls -ld -- *(-/)
5299
5300       lists all directories and symbolic links that point to directories, and
5301
5302              ls -ld -- *(-@)
5303
5304       lists all broken symbolic links, and
5305
5306              ls -ld -- *(%W)
5307
5308       lists all world-writable device files in the current directory, and
5309
5310              ls -ld -- *(W,X)
5311
5312       lists  all  files  in  the current directory that are world-writable or
5313       world-executable, and
5314
5315              print -rC1 /tmp/foo*(u0^@:t)
5316
5317       outputs the basename of all root-owned files beginning with the  string
5318       `foo' in /tmp, ignoring symlinks, and
5319
5320              ls -ld -- *.*~(lex|parse).[ch](^D^l1)
5321
5322       lists  all  files  having a link count of one whose names contain a dot
5323       (but not those starting with  a  dot,  since  GLOB_DOTS  is  explicitly
5324       switched off) except for lex.c, lex.h, parse.c and parse.h.
5325
5326              print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s/builtin/shmiltin/)
5327
5328       demonstrates  how  colon  modifiers and other qualifiers may be chained
5329       together.  The ordinary qualifier `.' is applied first, then the  colon
5330       modifiers  in order from left to right.  So if EXTENDED_GLOB is set and
5331       the base pattern matches the regular file builtin.pro, the  shell  will
5332       print `shmiltin.shmo'.
5333
5334
5335
5336ZSHPARAM(1)                 General Commands Manual                ZSHPARAM(1)
5337
5338
5339

NAME

5341       zshparam - zsh parameters
5342

DESCRIPTION

5344       A  parameter  has  a name, a value, and a number of attributes.  A name
5345       may be any sequence of alphanumeric characters and underscores, or  the
5346       single  characters  `*',  `@', `#', `?', `-', `$', or `!'.  A parameter
5347       whose name begins with an alphanumeric or underscore is  also  referred
5348       to as a variable.
5349
5350       The  attributes  of  a parameter determine the type of its value, often
5351       referred to as the parameter type or variable type,  and  also  control
5352       other  processing  that  may  be applied to the value when it is refer‐
5353       enced.  The value type may be a scalar (a  string,  an  integer,  or  a
5354       floating  point number), an array (indexed numerically), or an associa‐
5355       tive array (an unordered set of name-value pairs, indexed by name, also
5356       referred to as a hash).
5357
5358       Named  scalar  parameters may have the exported, -x, attribute, to copy
5359       them into the process environment, which is then passed from the  shell
5360       to  any  new  processes that it starts.  Exported parameters are called
5361       environment variables. The shell also imports environment variables  at
5362       startup  time  and  automatically marks the corresponding parameters as
5363       exported.  Some environment variables are not imported for  reasons  of
5364       security  or because they would interfere with the correct operation of
5365       other shell features.
5366
5367       Parameters may also be special, that  is,  they  have  a  predetermined
5368       meaning  to  the  shell.   Special  parameters  cannot  have their type
5369       changed or their readonly attribute turned off, and if a special param‐
5370       eter is unset, then later recreated, the special properties will be re‐
5371       tained.
5372
5373       To declare the type of a parameter, or to assign a  string  or  numeric
5374       value to a scalar parameter, use the typeset builtin.
5375
5376       The value of a scalar parameter may also be assigned by writing:
5377
5378              name=value
5379
5380       In  scalar  assignment,  value is expanded as a single string, in which
5381       the elements of arrays are joined together; filename expansion  is  not
5382       performed unless the option GLOB_ASSIGN is set.
5383
5384       When  the  integer  attribute, -i, or a floating point attribute, -E or
5385       -F, is set for name, the value is  subject  to  arithmetic  evaluation.
5386       Furthermore, by replacing `=' with `+=', a parameter can be incremented
5387       or appended to.  See the  section  `Array  Parameters'  and  Arithmetic
5388       Evaluation (in zshmisc(1)) for additional forms of assignment.
5389
5390       Note  that assignment may implicitly change the attributes of a parame‐
5391       ter.  For example, assigning a number to a variable in arithmetic eval‐
5392       uation  may  change  its type to integer or float, and with GLOB_ASSIGN
5393       assigning a pattern to a variable may change its type to an array.
5394
5395       To reference the value of a parameter, write `$name' or `${name}'.  See
5396       Parameter  Expansion  in zshexpn(1) for complete details.  That section
5397       also explains the effect of the difference between scalar and array as‐
5398       signment on parameter expansion.
5399

ARRAY PARAMETERS

5401       To assign an array value, write one of:
5402
5403              set -A name value ...
5404              name=(value ...)
5405              name=([key]=value ...)
5406
5407       If  no  parameter  name exists, an ordinary array parameter is created.
5408       If the parameter name exists and is a scalar, it is replaced by  a  new
5409       array.
5410
5411       In  the  third  form,  key  is  an expression that will be evaluated in
5412       arithmetic context (in its simplest form, an integer)  that  gives  the
5413       index  of the element to be assigned with value.  In this form any ele‐
5414       ments not explicitly mentioned that come before the  largest  index  to
5415       which  a  value  is assigned are assigned an empty string.  The indices
5416       may be in any order.  Note that this syntax is strict: [  and  ]=  must
5417       not  be  quoted, and key may not consist of the unquoted string ]=, but
5418       is otherwise treated as a simple string.  The enhanced  forms  of  sub‐
5419       script  expression  that may be used when directly subscripting a vari‐
5420       able name, described in the section Array  Subscripts  below,  are  not
5421       available.
5422
5423       The  syntaxes  with  and without the explicit key may be mixed.  An im‐
5424       plicit key is deduced by incrementing the index from the previously as‐
5425       signed  element.  Note that it is not treated as an error if latter as‐
5426       signments in this form overwrite earlier assignments.
5427
5428       For example, assuming the option KSH_ARRAYS is not set, the following:
5429
5430              array=(one [3]=three four)
5431
5432       causes the array variable array to contain four elements one, an  empty
5433       string, three and four, in that order.
5434
5435       In the forms where only value is specified, full command line expansion
5436       is performed.
5437
5438       In the [key]=value form, both key and value undergo all forms of expan‐
5439       sion  allowed  for  single word shell expansions (this does not include
5440       filename generation); these are as performed by the parameter expansion
5441       flag  (e)  as described in zshexpn(1).  Nested parentheses may surround
5442       value and are included as part of the value, which  is  joined  into  a
5443       plain  string; this differs from ksh which allows the values themselves
5444       to be arrays.  A future version of zsh may support that.  To cause  the
5445       brackets  to  be  interpreted as a character class for filename genera‐
5446       tion, and therefore to treat the resulting list of files as  a  set  of
5447       values, quote the equal sign using any form of quoting.  Example:
5448
5449              name=([a-z]'='*)
5450
5451       To  append to an array without changing the existing values, use one of
5452       the following:
5453
5454              name+=(value ...)
5455              name+=([key]=value ...)
5456
5457       In the second form key may specify an existing index as well as an  in‐
5458       dex  off the end of the old array; any existing value is overwritten by
5459       value.  Also, it is possible to use [key]+=value to append to  the  ex‐
5460       isting value at that index.
5461
5462       Within the parentheses on the right hand side of either form of the as‐
5463       signment, newlines and semicolons are treated the same as white  space,
5464       separating individual values.  Any consecutive sequence of such charac‐
5465       ters has the same effect.
5466
5467       Ordinary array parameters may also be explicitly declared with:
5468
5469              typeset -a name
5470
5471       Associative arrays must be declared before assignment, by using:
5472
5473              typeset -A name
5474
5475       When name refers to an associative array, the list in an assignment  is
5476       interpreted as alternating keys and values:
5477
5478              set -A name key value ...
5479              name=(key value ...)
5480              name=([key]=value ...)
5481
5482       Note  that  only one of the two syntaxes above may be used in any given
5483       assignment; the forms may not be mixed.  This is unlike the case of nu‐
5484       merically indexed arrays.
5485
5486       Every  key  must  have a value in this case.  Note that this assigns to
5487       the entire array, deleting any elements that do not appear in the list.
5488       The append syntax may also be used with an associative array:
5489
5490              name+=(key value ...)
5491              name+=([key]=value ...)
5492
5493       This  adds  a new key/value pair if the key is not already present, and
5494       replaces the value for the existing key if it is.  In the  second  form
5495       it is also possible to use [key]+=value to append to the existing value
5496       at that key.  Expansion is performed identically to  the  corresponding
5497       forms for normal arrays, as described above.
5498
5499       To create an empty array (including associative arrays), use one of:
5500
5501              set -A name
5502              name=()
5503
5504   Array Subscripts
5505       Individual  elements  of an array may be selected using a subscript.  A
5506       subscript of the form `[exp]' selects the single element exp, where exp
5507       is  an arithmetic expression which will be subject to arithmetic expan‐
5508       sion as if it were surrounded by `$((...))'.  The elements are numbered
5509       beginning  with  1,  unless  the KSH_ARRAYS option is set in which case
5510       they are numbered from zero.
5511
5512       Subscripts may be used inside braces used to delimit a parameter  name,
5513       thus  `${foo[2]}' is equivalent to `$foo[2]'.  If the KSH_ARRAYS option
5514       is set, the braced form is the only one that works,  as  bracketed  ex‐
5515       pressions otherwise are not treated as subscripts.
5516
5517       If the KSH_ARRAYS option is not set, then by default accesses to an ar‐
5518       ray element with a subscript that evaluates to  zero  return  an  empty
5519       string,  while an attempt to write such an element is treated as an er‐
5520       ror.  For backward compatibility the KSH_ZERO_SUBSCRIPT option  can  be
5521       set  to  cause  subscript  values 0 and 1 to be equivalent; see the de‐
5522       scription of the option in zshoptions(1).
5523
5524       The same subscripting syntax is used  for  associative  arrays,  except
5525       that  no  arithmetic expansion is applied to exp.  However, the parsing
5526       rules for arithmetic expressions still apply,  which  affects  the  way
5527       that  certain special characters must be protected from interpretation.
5528       See Subscript Parsing below for details.
5529
5530       A subscript of the form `[*]' or `[@]' evaluates to all elements of  an
5531       array;  there  is no difference between the two except when they appear
5532       within double  quotes.   `"$foo[*]"'  evaluates  to  `"$foo[1]  $foo[2]
5533       ..."', whereas `"$foo[@]"' evaluates to `"$foo[1]" "$foo[2]" ...'.  For
5534       associative arrays, `[*]' or `[@]' evaluate to all the  values,  in  no
5535       particular order.  Note that this does not substitute the keys; see the
5536       documentation for the `k' flag under Parameter Expansion Flags in  zsh‐
5537       expn(1) for complete details.  When an array parameter is referenced as
5538       `$name' (with no subscript) it  evaluates  to  `$name[*]',  unless  the
5539       KSH_ARRAYS  option  is  set  in which case it evaluates to `${name[0]}'
5540       (for an associative array, this means the value of the key  `0',  which
5541       may not exist even if there are values for other keys).
5542
5543       A subscript of the form `[exp1,exp2]' selects all elements in the range
5544       exp1 to exp2, inclusive. (Associative arrays are unordered, and  so  do
5545       not  support  ranges.) If one of the subscripts evaluates to a negative
5546       number, say -n, then the nth element from the end of the array is used.
5547       Thus `$foo[-3]' is the third element from the end of the array foo, and
5548       `$foo[1,-1]' is the same as `$foo[*]'.
5549
5550       Subscripting may also be performed on non-array values, in  which  case
5551       the  subscripts  specify  a substring to be extracted.  For example, if
5552       FOO is set to `foobar', then `echo $FOO[2,5]' prints `ooba'.  Note that
5553       some  forms  of  subscripting described below perform pattern matching,
5554       and in that case the substring extends from the start of the  match  of
5555       the  first  subscript  to the end of the match of the second subscript.
5556       For example,
5557
5558              string="abcdefghijklm"
5559              print ${string[(r)d?,(r)h?]}
5560
5561       prints `defghi'.  This is an obvious generalisation  of  the  rule  for
5562       single-character  matches.  For a single subscript, only a single char‐
5563       acter is referenced (not the range of characters covered by the match).
5564
5565       Note that in substring operations the second subscript is handled  dif‐
5566       ferently  by the r and R subscript flags: the former takes the shortest
5567       match as the length and the latter the longest  match.   Hence  in  the
5568       former  case  a  *  at the end is redundant while in the latter case it
5569       matches the whole remainder of the string.  This does  not  affect  the
5570       result  of the single subscript case as here the length of the match is
5571       irrelevant.
5572
5573   Array Element Assignment
5574       A subscript may be used on the left side of an assignment like so:
5575
5576              name[exp]=value
5577
5578       In this form of assignment the element or range specified by exp is re‐
5579       placed by the expression on the right side.  An array (but not an asso‐
5580       ciative array) may be created by assignment to a range or element.  Ar‐
5581       rays do not nest, so assigning a parenthesized list of values to an el‐
5582       ement or range changes the number of elements in  the  array,  shifting
5583       the  other  elements  to accommodate the new values.  (This is not sup‐
5584       ported for associative arrays.)
5585
5586       This syntax also works as an argument to the typeset command:
5587
5588              typeset "name[exp]"=value
5589
5590       The value may not be a parenthesized list in this case; only single-el‐
5591       ement  assignments may be made with typeset.  Note that quotes are nec‐
5592       essary in this case to prevent the brackets from being  interpreted  as
5593       filename generation operators.  The noglob precommand modifier could be
5594       used instead.
5595
5596       To delete an element of an ordinary array, assign `()' to that element.
5597       To delete an element of an associative array, use the unset command:
5598
5599              unset "name[exp]"
5600
5601   Subscript Flags
5602       If  the  opening bracket, or the comma in a range, in any subscript ex‐
5603       pression is directly followed by an opening parenthesis, the string  up
5604       to  the matching closing one is considered to be a list of flags, as in
5605       `name[(flags)exp]'.
5606
5607       The flags s, n and b take an argument; the delimiter is shown below  as
5608       `:',  but  any  character,  or  the  matching  pairs  `(...)', `{...}',
5609       `[...]', or `<...>', may be used, but note that  `<...>'  can  only  be
5610       used if the subscript is inside a double quoted expression or a parame‐
5611       ter substitution enclosed in braces as otherwise the expression is  in‐
5612       terpreted as a redirection.
5613
5614       The flags currently understood are:
5615
5616       w      If  the  parameter  subscripted is a scalar then this flag makes
5617              subscripting work on words instead of characters.   The  default
5618              word  separator  is  whitespace.   When combined with the i or I
5619              flag, the effect is to produce the index of the first  character
5620              of  the  first/last  word  which matches the given pattern; note
5621              that a failed match in this case always yields 0.
5622
5623       s:string:
5624              This gives the string that separates words (for use with  the  w
5625              flag).  The delimiter character : is arbitrary; see above.
5626
5627       p      Recognize  the same escape sequences as the print builtin in the
5628              string argument of a subsequent `s' flag.
5629
5630       f      If the parameter subscripted is a scalar then  this  flag  makes
5631              subscripting work on lines instead of characters, i.e. with ele‐
5632              ments separated by newlines.  This is a shorthand for `pws:\n:'.
5633
5634       r      Reverse subscripting: if this flag is given, the exp is taken as
5635              a  pattern  and  the result is the first matching array element,
5636              substring or word (if the parameter is an  array,  if  it  is  a
5637              scalar,  or if it is a scalar and the `w' flag is given, respec‐
5638              tively).  The subscript used is the number of the matching  ele‐
5639              ment,  so  that  pairs of subscripts such as `$foo[(r)??,3]' and
5640              `$foo[(r)??,(r)f*]' are possible if the parameter is not an  as‐
5641              sociative array.  If the parameter is an associative array, only
5642              the value part of each pair is compared to the pattern, and  the
5643              result is that value.
5644
5645              If  a  search  through an ordinary array failed, the search sets
5646              the subscript to one past the end of the array, and hence  ${ar‐
5647              ray[(r)pattern]}  will  substitute  the  empty string.  Thus the
5648              success of a search can be tested by using the (i) flag, for ex‐
5649              ample (assuming the option KSH_ARRAYS is not in effect):
5650
5651                     [[ ${array[(i)pattern]} -le ${#array} ]]
5652
5653              If KSH_ARRAYS is in effect, the -le should be replaced by -lt.
5654
5655       R      Like  `r',  but  gives  the last match.  For associative arrays,
5656              gives all possible matches. May be used for assigning  to  ordi‐
5657              nary  array  elements,  but not for assigning to associative ar‐
5658              rays.  On failure, for normal arrays this has the effect of  re‐
5659              turning  the element corresponding to subscript 0; this is empty
5660              unless one of the options KSH_ARRAYS or KSH_ZERO_SUBSCRIPT is in
5661              effect.
5662
5663              Note that in subscripts with both `r' and `R' pattern characters
5664              are active even if they were substituted for  a  parameter  (re‐
5665              gardless  of  the setting of GLOB_SUBST which controls this fea‐
5666              ture in normal pattern matching).  The flag `e' can be added  to
5667              inhibit  pattern  matching.  As this flag does not inhibit other
5668              forms of substitution, care is still required; using a parameter
5669              to hold the key has the desired effect:
5670
5671                     key2='original key'
5672                     print ${array[(Re)$key2]}
5673
5674       i      Like `r', but gives the index of the match instead; this may not
5675              be combined with a second argument.  On the left side of an  as‐
5676              signment,  behaves  like  `r'.   For associative arrays, the key
5677              part of each pair is compared to  the  pattern,  and  the  first
5678              matching  key  found  is the result.  On failure substitutes the
5679              length of the array plus one, as discussed under the description
5680              of `r', or the empty string for an associative array.
5681
5682       I      Like `i', but gives the index of the last match, or all possible
5683              matching keys in an associative array.  On  failure  substitutes
5684              0,  or  the empty string for an associative array.  This flag is
5685              best when testing for values or keys that do not exist.
5686
5687       k      If used in a subscript on an associative array, this flag causes
5688              the  keys  to  be interpreted as patterns, and returns the value
5689              for the first key found where exp is matched by the  key.   Note
5690              this  could be any such key as no ordering of associative arrays
5691              is defined.  This flag does not work on the left side of an  as‐
5692              signment  to  an  associative array element.  If used on another
5693              type of parameter, this behaves like `r'.
5694
5695       K      On an associative array this is like `k' but returns all  values
5696              where  exp is matched by the keys.  On other types of parameters
5697              this has the same effect as `R'.
5698
5699       n:expr:
5700              If combined with `r', `R', `i' or `I', makes them give  the  nth
5701              or  nth  last  match (if expr evaluates to n).  This flag is ig‐
5702              nored when the array is associative.  The delimiter character  :
5703              is arbitrary; see above.
5704
5705       b:expr:
5706              If  combined  with `r', `R', `i' or `I', makes them begin at the
5707              nth or nth last element, word, or character (if  expr  evaluates
5708              to n).  This flag is ignored when the array is associative.  The
5709              delimiter character : is arbitrary; see above.
5710
5711       e      This flag causes any pattern matching that would be performed on
5712              the  subscript  to  use  plain  string  matching instead.  Hence
5713              `${array[(re)*]}' matches only the array element whose value  is
5714              *.  Note that other forms of substitution such as parameter sub‐
5715              stitution are not inhibited.
5716
5717              This flag can also be used to force * or @ to be interpreted  as
5718              a  single  key rather than as a reference to all values.  It may
5719              be used for either purpose on the left side of an assignment.
5720
5721       See Parameter Expansion Flags (zshexpn(1)) for additional ways  to  ma‐
5722       nipulate the results of array subscripting.
5723
5724   Subscript Parsing
5725       This  discussion applies mainly to associative array key strings and to
5726       patterns used for reverse subscripting (the `r', `R', `i', etc. flags),
5727       but  it  may also affect parameter substitutions that appear as part of
5728       an arithmetic expression in an ordinary subscript.
5729
5730       To avoid subscript parsing limitations in  assignments  to  associative
5731       array elements, use the append syntax:
5732
5733              aa+=('key with "*strange*" characters' 'value string')
5734
5735       The  basic rule to remember when writing a subscript expression is that
5736       all text between the opening `[' and the closing `]' is interpreted  as
5737       if  it  were in double quotes (see zshmisc(1)).  However, unlike double
5738       quotes which normally cannot nest, subscript expressions may appear in‐
5739       side  double-quoted  strings  or inside other subscript expressions (or
5740       both!), so the rules have two important differences.
5741
5742       The first difference is that brackets (`[' and `]') must appear as bal‐
5743       anced  pairs  in  a  subscript expression unless they are preceded by a
5744       backslash (`\').  Therefore, within a subscript expression (and  unlike
5745       true  double-quoting) the sequence `\[' becomes `[', and similarly `\]'
5746       becomes `]'.  This applies even in cases where a backslash is not  nor‐
5747       mally required; for example, the pattern `[^[]' (to match any character
5748       other than an open bracket) should be written `[^\[]' in a reverse-sub‐
5749       script pattern.  However, note that `\[^\[\]' and even `\[^[]' mean the
5750       same thing, because backslashes are always stripped  when  they  appear
5751       before brackets!
5752
5753       The  same rule applies to parentheses (`(' and `)') and braces (`{' and
5754       `}'): they must appear either in balanced pairs or preceded by a  back‐
5755       slash,  and  backslashes that protect parentheses or braces are removed
5756       during parsing.  This is because parameter expansions may be surrounded
5757       by  balanced  braces,  and  subscript  flags are introduced by balanced
5758       parentheses.
5759
5760       The second difference is that a double-quote (`"') may appear  as  part
5761       of  a  subscript  expression without being preceded by a backslash, and
5762       therefore that the two characters `\"' remain as two characters in  the
5763       subscript (in true double-quoting, `\"' becomes `"').  However, because
5764       of the standard shell quoting rules, any double-quotes that appear must
5765       occur  in balanced pairs unless preceded by a backslash.  This makes it
5766       more difficult to write a subscript expression  that  contains  an  odd
5767       number  of  double-quote characters, but the reason for this difference
5768       is so that  when  a  subscript  expression  appears  inside  true  dou‐
5769       ble-quotes, one can still write `\"' (rather than `\\\"') for `"'.
5770
5771       To  use  an  odd number of double quotes as a key in an assignment, use
5772       the typeset builtin and an enclosing pair of double quotes; to refer to
5773       the value of that key, again use double quotes:
5774
5775              typeset -A aa
5776              typeset "aa[one\"two\"three\"quotes]"=QQQ
5777              print "$aa[one\"two\"three\"quotes]"
5778
5779       It is important to note that the quoting rules do not change when a pa‐
5780       rameter expansion with a subscript is nested inside  another  subscript
5781       expression.  That is, it is not necessary to use additional backslashes
5782       within the inner subscript expression; they are removed only once, from
5783       the  innermost  subscript  outwards.  Parameters are also expanded from
5784       the innermost subscript first, as each expansion is encountered left to
5785       right in the outer expression.
5786
5787       A  further complication arises from a way in which subscript parsing is
5788       not different from double quote parsing.  As  in  true  double-quoting,
5789       the  sequences `\*', and `\@' remain as two characters when they appear
5790       in a subscript expression.  To use a literal `*' or `@' as an  associa‐
5791       tive array key, the `e' flag must be used:
5792
5793              typeset -A aa
5794              aa[(e)*]=star
5795              print $aa[(e)*]
5796
5797       A  last  detail  must  be  considered when reverse subscripting is per‐
5798       formed.  Parameters appearing in the subscript expression are first ex‐
5799       panded  and  then  the complete expression is interpreted as a pattern.
5800       This has two effects: first, parameters behave as if GLOB_SUBST were on
5801       (and  it  cannot  be  turned  off); second, backslashes are interpreted
5802       twice, once when parsing the array subscript and again when parsing the
5803       pattern.   In  a  reverse  subscript,  it's necessary to use four back‐
5804       slashes to cause a single backslash to match literally in the  pattern.
5805       For complex patterns, it is often easiest to assign the desired pattern
5806       to a parameter and then refer to that parameter in the  subscript,  be‐
5807       cause  then the backslashes, brackets, parentheses, etc., are seen only
5808       when the complete expression is converted to a pattern.  To  match  the
5809       value of a parameter literally in a reverse subscript, rather than as a
5810       pattern, use `${(q)name}' (see zshexpn(1)) to quote the expanded value.
5811
5812       Note that the `k' and `K' flags are reverse subscripting for  an  ordi‐
5813       nary  array, but are not reverse subscripting for an associative array!
5814       (For an associative array, the keys in the array itself are interpreted
5815       as  patterns  by  those  flags; the subscript is a plain string in that
5816       case.)
5817
5818       One final note, not directly related to subscripting: the numeric names
5819       of positional parameters (described below) are parsed specially, so for
5820       example `$2foo' is equivalent to `${2}foo'.   Therefore,  to  use  sub‐
5821       script  syntax  to extract a substring from a positional parameter, the
5822       expansion must be surrounded by braces; for example, `${2[3,5]}' evalu‐
5823       ates to the third through fifth characters of the second positional pa‐
5824       rameter, but `$2[3,5]' is the entire second parameter concatenated with
5825       the filename generation pattern `[3,5]'.
5826

POSITIONAL PARAMETERS

5828       The  positional parameters provide access to the command-line arguments
5829       of a shell function, shell script, or the shell itself; see the section
5830       `Invocation', and also the section `Functions'.  The parameter n, where
5831       n is a number, is the nth positional parameter.  The parameter `$0'  is
5832       a special case, see the section `Parameters Set By The Shell'.
5833
5834       The  parameters  *, @ and argv are arrays containing all the positional
5835       parameters; thus `$argv[n]', etc., is equivalent to simply `$n'.   Note
5836       that the options KSH_ARRAYS or KSH_ZERO_SUBSCRIPT apply to these arrays
5837       as well, so with either of those options set, `${argv[0]}'  is  equiva‐
5838       lent to `$1' and so on.
5839
5840       Positional parameters may be changed after the shell or function starts
5841       by using the set builtin, by assigning to the argv array, or by  direct
5842       assignment  of  the  form  `n=value' where n is the number of the posi‐
5843       tional parameter to be changed.  This also creates (with empty  values)
5844       any of the positions from 1 to n that do not already have values.  Note
5845       that, because the positional parameters form an array, an array assign‐
5846       ment  of  the  form  `n=(value  ...)' is allowed, and has the effect of
5847       shifting all the values at positions greater than n by  as  many  posi‐
5848       tions as necessary to accommodate the new values.
5849

LOCAL PARAMETERS

5851       Shell function executions delimit scopes for shell parameters.  (Param‐
5852       eters are dynamically scoped.)  The typeset builtin, and  its  alterna‐
5853       tive  forms  declare, integer, local and readonly (but not export), can
5854       be used to declare a parameter as being local to the innermost scope.
5855
5856       When a parameter is read or assigned to, the innermost existing parame‐
5857       ter  of  that  name  is  used.  (That is, the local parameter hides any
5858       less-local parameter.)  However, assigning to a non-existent parameter,
5859       or  declaring  a  new parameter with export, causes it to be created in
5860       the outermost scope.
5861
5862       Local parameters disappear when their scope ends.  unset can be used to
5863       delete  a  parameter while it is still in scope; any outer parameter of
5864       the same name remains hidden.
5865
5866       Special parameters may also be made local; they  retain  their  special
5867       attributes  unless  either  the existing or the newly-created parameter
5868       has the -h (hide) attribute.  This may have unexpected  effects:  there
5869       is  no  default  value,  so  if there is no assignment at the point the
5870       variable is made local, it will be set to an empty value  (or  zero  in
5871       the case of integers).  The following:
5872
5873              typeset PATH=/new/directory:$PATH
5874
5875       is  valid  for temporarily allowing the shell or programmes called from
5876       it to find the programs in /new/directory inside a function.
5877
5878       Note that the restriction in older versions of zsh that  local  parame‐
5879       ters were never exported has been removed.
5880

PARAMETERS SET BY THE SHELL

5882       In  the  parameter lists that follow, the mark `<S>' indicates that the
5883       parameter is special.  `<Z>' indicates that the parameter does not  ex‐
5884       ist when the shell initializes in sh or ksh emulation mode.
5885
5886       The following parameters are automatically set by the shell:
5887
5888       ! <S>  The  process  ID  of  the last command started in the background
5889              with &, put into the background with the bg builtin, or  spawned
5890              with coproc.
5891
5892       # <S>  The  number of positional parameters in decimal.  Note that some
5893              confusion may occur with the syntax  $#param  which  substitutes
5894              the  length of param.  Use ${#} to resolve ambiguities.  In par‐
5895              ticular, the sequence `$#-...' in an  arithmetic  expression  is
5896              interpreted as the length of the parameter -, q.v.
5897
5898       ARGC <S> <Z>
5899              Same as #.
5900
5901       $ <S>  The  process  ID  of  this  shell.  Note that this indicates the
5902              original shell started by invoking  zsh;  all  processes  forked
5903              from  the  shells  without executing a new program, such as sub‐
5904              shells started by (...), substitute the same value.
5905
5906       - <S>  Flags supplied to the shell on invocation or by the set  or  se‐
5907              topt commands.
5908
5909       * <S>  An array containing the positional parameters.
5910
5911       argv <S> <Z>
5912              Same  as  *.  Assigning to argv changes the local positional pa‐
5913              rameters, but argv is not itself a  local  parameter.   Deleting
5914              argv  with unset in any function deletes it everywhere, although
5915              only the innermost positional parameter array is deleted  (so  *
5916              and @ in other scopes are not affected).
5917
5918       @ <S>  Same as argv[@], even when argv is not set.
5919
5920       ? <S>  The exit status returned by the last command.
5921
5922       0 <S>  The  name  used to invoke the current shell, or as set by the -c
5923              command line option upon invocation.   If  the  FUNCTION_ARGZERO
5924              option  is  set, $0 is set upon entry to a shell function to the
5925              name of the function, and upon entry to a sourced script to  the
5926              name  of  the  script,  and reset to its previous value when the
5927              function or script returns.
5928
5929       status <S> <Z>
5930              Same as ?.
5931
5932       pipestatus <S> <Z>
5933              An array containing the exit statuses returned by  all  commands
5934              in the last pipeline.
5935
5936       _ <S>  The last argument of the previous command.  Also, this parameter
5937              is set in the environment of every command executed to the  full
5938              pathname of the command.
5939
5940       CPUTYPE
5941              The machine type (microprocessor class or machine model), as de‐
5942              termined at run time.
5943
5944       EGID <S>
5945              The effective group ID of the shell process.  If you have suffi‐
5946              cient  privileges,  you may change the effective group ID of the
5947              shell process by assigning to this  parameter.   Also  (assuming
5948              sufficient  privileges),  you  may start a single command with a
5949              different effective group ID by `(EGID=gid; command)'
5950
5951              If this is made local, it is not implicitly set to 0, but may be
5952              explicitly set locally.
5953
5954       EUID <S>
5955              The  effective user ID of the shell process.  If you have suffi‐
5956              cient privileges, you may change the effective user  ID  of  the
5957              shell  process  by  assigning to this parameter.  Also (assuming
5958              sufficient privileges), you may start a single  command  with  a
5959              different effective user ID by `(EUID=uid; command)'
5960
5961              If this is made local, it is not implicitly set to 0, but may be
5962              explicitly set locally.
5963
5964       ERRNO <S>
5965              The value of errno (see errno(3)) as set by  the  most  recently
5966              failed  system  call.  This value is system dependent and is in‐
5967              tended for debugging purposes.   It  is  also  useful  with  the
5968              zsh/system  module  which  allows the number to be turned into a
5969              name or message.
5970
5971       FUNCNEST <S>
5972              Integer.  If greater than or equal to zero, the maximum  nesting
5973              depth  of  shell  functions.   When  it is exceeded, an error is
5974              raised at the point where a function  is  called.   The  default
5975              value  is  determined when the shell is configured, but is typi‐
5976              cally 500.  Increasing the value increases the danger of a  run‐
5977              away  function  recursion causing the shell to crash.  Setting a
5978              negative value turns off the check.
5979
5980       GID <S>
5981              The real group ID of the shell process.  If you have  sufficient
5982              privileges,  you may change the group ID of the shell process by
5983              assigning to this parameter.  Also (assuming  sufficient  privi‐
5984              leges),  you  may start a single command under a different group
5985              ID by `(GID=gid; command)'
5986
5987              If this is made local, it is not implicitly set to 0, but may be
5988              explicitly set locally.
5989
5990       HISTCMD
5991              The  current  history  event  number in an interactive shell, in
5992              other words  the  event  number  for  the  command  that  caused
5993              $HISTCMD  to be read.  If the current history event modifies the
5994              history, HISTCMD changes to the new maximum history  event  num‐
5995              ber.
5996
5997       HOST   The current hostname.
5998
5999       LINENO <S>
6000              The  line  number of the current line within the current script,
6001              sourced file, or shell function being  executed,  whichever  was
6002              started most recently.  Note that in the case of shell functions
6003              the line number refers to the function as  it  appeared  in  the
6004              original  definition,  not necessarily as displayed by the func‐
6005              tions builtin.
6006
6007       LOGNAME
6008              If the corresponding variable is not set in the  environment  of
6009              the  shell, it is initialized to the login name corresponding to
6010              the current login session. This parameter is exported by default
6011              but  this  can be disabled using the typeset builtin.  The value
6012              is set to the string returned by the getlogin(3) system call  if
6013              that is available.
6014
6015       MACHTYPE
6016              The machine type (microprocessor class or machine model), as de‐
6017              termined at compile time.
6018
6019       OLDPWD The previous working directory.  This is set when the shell ini‐
6020              tializes and whenever the directory changes.
6021
6022       OPTARG <S>
6023              The  value  of the last option argument processed by the getopts
6024              command.
6025
6026       OPTIND <S>
6027              The index of the last option argument processed by  the  getopts
6028              command.
6029
6030       OSTYPE The operating system, as determined at compile time.
6031
6032       PPID <S>
6033              The process ID of the parent of the shell.  As for $$, the value
6034              indicates the parent of the original shell and does  not  change
6035              in subshells.
6036
6037       PWD    The  present working directory.  This is set when the shell ini‐
6038              tializes and whenever the directory changes.
6039
6040       RANDOM <S>
6041              A pseudo-random integer from 0 to 32767,  newly  generated  each
6042              time  this parameter is referenced.  The random number generator
6043              can be seeded by assigning a numeric value to RANDOM.
6044
6045              The  values   of   RANDOM   form   an   intentionally-repeatable
6046              pseudo-random sequence; subshells that reference RANDOM will re‐
6047              sult in identical pseudo-random values unless the value of  RAN‐
6048              DOM  is referenced or seeded in the parent shell in between sub‐
6049              shell invocations.
6050
6051       SECONDS <S>
6052              The number of seconds since shell invocation.  If this parameter
6053              is assigned a value, then the value returned upon reference will
6054              be the value that was assigned plus the number of seconds  since
6055              the assignment.
6056
6057              Unlike other special parameters, the type of the SECONDS parame‐
6058              ter can be changed using the typeset command.  Only integer  and
6059              one  of  the  floating  point  types  are allowed.  For example,
6060              `typeset -F SECONDS' causes the value to be reported as a float‐
6061              ing  point  number.  The value is available to microsecond accu‐
6062              racy, although the shell may show more or fewer digits depending
6063              on  the  use  of typeset.  See the documentation for the builtin
6064              typeset in zshbuiltins(1) for more details.
6065
6066       SHLVL <S>
6067              Incremented by one each time a new shell is started.
6068
6069       signals
6070              An array containing the names of the signals.   Note  that  with
6071              the standard zsh numbering of array indices, where the first el‐
6072              ement has index 1, the signals are offset by 1 from  the  signal
6073              number  used  by  the operating system.  For example, on typical
6074              Unix-like systems HUP is signal number 1, but is referred to  as
6075              $signals[2].   This  is because of EXIT at position 1 in the ar‐
6076              ray, which is used internally by zsh but is not known to the op‐
6077              erating system.
6078
6079       TRY_BLOCK_ERROR <S>
6080              In an always block, indicates whether the preceding list of code
6081              caused an error.  The value is 1 to indicate an error, 0  other‐
6082              wise.   It may be reset, clearing the error condition.  See Com‐
6083              plex Commands in zshmisc(1)
6084
6085       TRY_BLOCK_INTERRUPT <S>
6086              This variable works in a similar  way  to  TRY_BLOCK_ERROR,  but
6087              represents  the  status  of an interrupt from the signal SIGINT,
6088              which typically comes from the keyboard when the user types  ^C.
6089              If  set  to  0, any such interrupt will be reset; otherwise, the
6090              interrupt is propagated after the always block.
6091
6092              Note that it is possible that an interrupt  arrives  during  the
6093              execution  of  the  always  block; this interrupt is also propa‐
6094              gated.
6095
6096       TTY    The name of the tty associated with the shell, if any.
6097
6098       TTYIDLE <S>
6099              The idle time of the tty associated with the shell in seconds or
6100              -1 if there is no such tty.
6101
6102       UID <S>
6103              The  real  user ID of the shell process.  If you have sufficient
6104              privileges, you may change the user ID of the shell by assigning
6105              to  this  parameter.  Also (assuming sufficient privileges), you
6106              may start  a  single  command  under  a  different  user  ID  by
6107              `(UID=uid; command)'
6108
6109              If this is made local, it is not implicitly set to 0, but may be
6110              explicitly set locally.
6111
6112       USERNAME <S>
6113              The username corresponding to the real  user  ID  of  the  shell
6114              process.   If you have sufficient privileges, you may change the
6115              username (and also the user ID and group ID) of the shell by as‐
6116              signing  to  this  parameter.   Also (assuming sufficient privi‐
6117              leges), you may start a single command under a  different  user‐
6118              name  (and  user  ID  and group ID) by `(USERNAME=username; com‐
6119              mand)'
6120
6121       VENDOR The vendor, as determined at compile time.
6122
6123       zsh_eval_context <S> <Z> (ZSH_EVAL_CONTEXT <S>)
6124              An array (colon-separated list) indicating the context of  shell
6125              code that is being run.  Each time a piece of shell code that is
6126              stored within the shell is executed a string is temporarily  ap‐
6127              pended  to  the  array to indicate the type of operation that is
6128              being performed.  Read in order the array gives an indication of
6129              the  stack of operations being performed with the most immediate
6130              context last.
6131
6132              Note that the variable does not give  information  on  syntactic
6133              context  such  as  pipelines or subshells.  Use $ZSH_SUBSHELL to
6134              detect subshells.
6135
6136              The context is one of the following:
6137              cmdarg Code specified by the -c option to the command line  that
6138                     invoked the shell.
6139
6140              cmdsubst
6141                     Command substitution using the `...` or $(...) construct.
6142
6143              equalsubst
6144                     File substitution using the =(...) construct.
6145
6146              eval   Code executed by the eval builtin.
6147
6148              evalautofunc
6149                     Code executed with the KSH_AUTOLOAD mechanism in order to
6150                     define an autoloaded function.
6151
6152              fc     Code from the shell history executed by the -e option  to
6153                     the fc builtin.
6154
6155              file   Lines  of code being read directly from a file, for exam‐
6156                     ple by the source builtin.
6157
6158              filecode
6159                     Lines of code being read from a .zwc file instead of  di‐
6160                     rectly from the source file.
6161
6162              globqual
6163                     Code executed by the e or + glob qualifier.
6164
6165              globsort
6166                     Code executed to order files by the o glob qualifier.
6167
6168              insubst
6169                     File substitution using the <(...) construct.
6170
6171              loadautofunc
6172                     Code  read  directly  from a file to define an autoloaded
6173                     function.
6174
6175              outsubst
6176                     File substitution using the >(...) construct.
6177
6178              sched  Code executed by the sched builtin.
6179
6180              shfunc A shell function.
6181
6182              stty   Code passed to stty by  the  STTY  environment  variable.
6183                     Normally  this  is  passed  directly to the system's stty
6184                     command, so this value is unlikely to be  seen  in  prac‐
6185                     tice.
6186
6187              style  Code  executed as part of a style retrieved by the zstyle
6188                     builtin from the zsh/zutil module.
6189
6190              toplevel
6191                     The highest execution level of a  script  or  interactive
6192                     shell.
6193
6194              trap   Code  executed  as  a  trap  defined by the trap builtin.
6195                     Traps defined as functions have the context  shfunc.   As
6196                     traps  are asynchronous they may have a different hierar‐
6197                     chy from other code.
6198
6199              zpty   Code executed by the zpty builtin from the zsh/zpty  mod‐
6200                     ule.
6201
6202              zregexparse-guard
6203                     Code  executed as a guard by the zregexparse command from
6204                     the zsh/zutil module.
6205
6206              zregexparse-action
6207                     Code executed as an action  by  the  zregexparse  command
6208                     from the zsh/zutil module.
6209
6210       ZSH_ARGZERO
6211              If  zsh  was  invoked  to  run a script, this is the name of the
6212              script.  Otherwise, it is the name used to  invoke  the  current
6213              shell.    This  is  the  same  as  the  value  of  $0  when  the
6214              POSIX_ARGZERO option is set, but is always available.
6215
6216       ZSH_EXECUTION_STRING
6217              If the shell was started with the option -c, this  contains  the
6218              argument passed to the option.  Otherwise it is not set.
6219
6220       ZSH_NAME
6221              Expands  to  the basename of the command used to invoke this in‐
6222              stance of zsh.
6223
6224       ZSH_PATCHLEVEL
6225              The output of `git describe --tags --long' for the  zsh  reposi‐
6226              tory  used  to build the shell.  This is most useful in order to
6227              keep track of versions of the shell during  development  between
6228              releases;  hence most users should not use it and should instead
6229              rely on $ZSH_VERSION.
6230
6231       zsh_scheduled_events
6232              See the section `The zsh/sched Module' in zshmodules(1).
6233
6234       ZSH_SCRIPT
6235              If zsh was invoked to run a script, this  is  the  name  of  the
6236              script, otherwise it is unset.
6237
6238       ZSH_SUBSHELL
6239              Readonly  integer.   Initially  zero,  incremented each time the
6240              shell forks to create a  subshell  for  executing  code.   Hence
6241              `(print  $ZSH_SUBSHELL)' and `print $(print $ZSH_SUBSHELL)' out‐
6242              put 1, while `( (print $ZSH_SUBSHELL) )' outputs 2.
6243
6244       ZSH_VERSION
6245              The version number of the release of zsh.
6246

PARAMETERS USED BY THE SHELL

6248       The following parameters are used by the shell.  Again, `<S>' indicates
6249       that  the  parameter  is special and `<Z>' indicates that the parameter
6250       does not exist when the shell initializes in sh or ksh emulation mode.
6251
6252       In cases where there are two parameters with an  upper-  and  lowercase
6253       form  of the same name, such as path and PATH, the lowercase form is an
6254       array and the uppercase form is a scalar with the elements of the array
6255       joined  together  by colons.  These are similar to tied parameters cre‐
6256       ated via `typeset -T'.  The normal use for the colon-separated form  is
6257       for exporting to the environment, while the array form is easier to ma‐
6258       nipulate within the shell.  Note that unsetting either of the pair will
6259       unset  the  other; they retain their special properties when recreated,
6260       and recreating one of the pair will recreate the other.
6261
6262       ARGV0  If exported, its value is used as the argv[0] of  external  com‐
6263              mands.  Usually used in constructs like `ARGV0=emacs nethack'.
6264
6265       BAUD   The  rate in bits per second at which data reaches the terminal.
6266              The line editor will use this value in order to compensate for a
6267              slow  terminal  by  delaying updates to the display until neces‐
6268              sary.  If the parameter is unset or the value is zero  the  com‐
6269              pensation  mechanism is turned off.  The parameter is not set by
6270              default.
6271
6272              This parameter may be profitably set in some circumstances, e.g.
6273              for  slow  modems  dialing into a communications server, or on a
6274              slow wide area network.  It should be set to the  baud  rate  of
6275              the slowest part of the link for best performance.
6276
6277       cdpath <S> <Z> (CDPATH <S>)
6278              An  array  (colon-separated  list) of directories specifying the
6279              search path for the cd command.
6280
6281       COLUMNS <S>
6282              The number of columns  for  this  terminal  session.   Used  for
6283              printing select lists and for the line editor.
6284
6285       CORRECT_IGNORE
6286              If set, is treated as a pattern during spelling correction.  Any
6287              potential correction that matches the pattern is  ignored.   For
6288              example,  if the value is `_*' then completion functions (which,
6289              by convention, have names beginning with `_') will never be  of‐
6290              fered  as  spelling  corrections.  The pattern does not apply to
6291              the correction of file names, as applied by the CORRECT_ALL  op‐
6292              tion (so with the example just given files beginning with `_' in
6293              the current directory would still be completed).
6294
6295       CORRECT_IGNORE_FILE
6296              If set, is treated as a pattern during  spelling  correction  of
6297              file names.  Any file name that matches the pattern is never of‐
6298              fered as a correction.  For example, if the value is  `.*'  then
6299              dot  file  names  will never be offered as spelling corrections.
6300              This is useful with the CORRECT_ALL option.
6301
6302       DIRSTACKSIZE
6303              The maximum size of the directory stack, by default there is  no
6304              limit.  If the stack gets larger than this, it will be truncated
6305              automatically.  This is useful with the AUTO_PUSHD option.
6306
6307       ENV    If the ENV environment variable is set when zsh is invoked as sh
6308              or ksh, $ENV is sourced after the profile scripts.  The value of
6309              ENV is subjected to parameter expansion,  command  substitution,
6310              and arithmetic expansion before being interpreted as a pathname.
6311              Note that ENV is not used unless the shell  is  interactive  and
6312              zsh is emulating sh or ksh.
6313
6314       FCEDIT The  default  editor  for the fc builtin.  If FCEDIT is not set,
6315              the parameter EDITOR is used; if  that  is  not  set  either,  a
6316              builtin default, usually vi, is used.
6317
6318       fignore <S> <Z> (FIGNORE <S>)
6319              An array (colon separated list) containing the suffixes of files
6320              to be ignored during filename completion.  However,  if  comple‐
6321              tion only generates files with suffixes in this list, then these
6322              files are completed anyway.
6323
6324       fpath <S> <Z> (FPATH <S>)
6325              An array (colon separated list) of  directories  specifying  the
6326              search  path  for  function  definitions.  This path is searched
6327              when a function with the -u attribute is referenced.  If an exe‐
6328              cutable  file is found, then it is read and executed in the cur‐
6329              rent environment.
6330
6331       histchars <S>
6332              Three characters used by the shell's history and lexical  analy‐
6333              sis  mechanism.  The first character signals the start of a his‐
6334              tory expansion (default `!').  The second character signals  the
6335              start  of a quick history substitution (default `^').  The third
6336              character is the comment character (default `#').
6337
6338              The characters must be in the ASCII character set;  any  attempt
6339              to  set  histchars to characters with a locale-dependent meaning
6340              will be rejected with an error message.
6341
6342       HISTCHARS <S> <Z>
6343              Same as histchars.  (Deprecated.)
6344
6345       HISTFILE
6346              The file to save the history in when an interactive shell exits.
6347              If unset, the history is not saved.
6348
6349       HISTORY_IGNORE
6350              If  set,  is  treated as a pattern at the time history files are
6351              written.  Any potential history entry that matches  the  pattern
6352              is  skipped.   For example, if the value is `fc *' then commands
6353              that invoke the interactive history editor are never written  to
6354              the history file.
6355
6356              Note  that  HISTORY_IGNORE  defines a single pattern: to specify
6357              alternatives use the `(first|second|...)' syntax.
6358
6359              Compare the HIST_NO_STORE option or the zshaddhistory hook,  ei‐
6360              ther  of  which  would prevent such commands from being added to
6361              the interactive history at all.  If you wish to use  HISTORY_IG‐
6362              NORE to stop history being added in the first place, you can de‐
6363              fine the following hook:
6364
6365                     zshaddhistory() {
6366                       emulate -L zsh
6367                       ## uncomment if HISTORY_IGNORE
6368                       ## should use EXTENDED_GLOB syntax
6369                       # setopt extendedglob
6370                       [[ $1 != ${~HISTORY_IGNORE} ]]
6371                     }
6372
6373       HISTSIZE <S>
6374              The maximum number of events  stored  in  the  internal  history
6375              list.   If  you  use  the HIST_EXPIRE_DUPS_FIRST option, setting
6376              this value larger than the SAVEHIST size will give you the  dif‐
6377              ference as a cushion for saving duplicated history events.
6378
6379              If this is made local, it is not implicitly set to 0, but may be
6380              explicitly set locally.
6381
6382       HOME <S>
6383              The default argument for the cd command.  This is not set  auto‐
6384              matically  by  the  shell in sh, ksh or csh emulation, but it is
6385              typically present in the environment anyway, and if  it  becomes
6386              set it has its usual special behaviour.
6387
6388       IFS <S>
6389              Internal  field  separators  (by default space, tab, newline and
6390              NUL), that are used to separate words which result from  command
6391              or  parameter expansion and words read by the read builtin.  Any
6392              characters from the set space, tab and newline  that  appear  in
6393              the IFS are called IFS white space.  One or more IFS white space
6394              characters or one non-IFS white space  character  together  with
6395              any  adjacent  IFS white space character delimit a field.  If an
6396              IFS white space character appears  twice  consecutively  in  the
6397              IFS,  this  character  is treated as if it were not an IFS white
6398              space character.
6399
6400              If the parameter is unset, the default is used.  Note this has a
6401              different effect from setting the parameter to an empty string.
6402
6403       KEYBOARD_HACK
6404              This  variable defines a character to be removed from the end of
6405              the command line  before  interpreting  it  (interactive  shells
6406              only). It is intended to fix the problem with keys placed annoy‐
6407              ingly close to return and replaces  the  SUNKEYBOARDHACK  option
6408              which did this for backquotes only.  Should the chosen character
6409              be one of singlequote, doublequote or backquote, there must also
6410              be an odd number of them on the command line for the last one to
6411              be removed.
6412
6413              For backward compatibility, if the SUNKEYBOARDHACK option is ex‐
6414              plicitly  set,  the value of KEYBOARD_HACK reverts to backquote.
6415              If the option is explicitly  unset,  this  variable  is  set  to
6416              empty.
6417
6418       KEYTIMEOUT
6419              The  time the shell waits, in hundredths of seconds, for another
6420              key to be pressed when reading bound multi-character sequences.
6421
6422       LANG <S>
6423              This variable determines the locale category  for  any  category
6424              not specifically selected via a variable starting with `LC_'.
6425
6426       LC_ALL <S>
6427              This variable overrides the value of the `LANG' variable and the
6428              value of any of the other variables starting with `LC_'.
6429
6430       LC_COLLATE <S>
6431              This variable determines the locale category for character  col‐
6432              lation  information within ranges in glob brackets and for sort‐
6433              ing.
6434
6435       LC_CTYPE <S>
6436              This variable determines the locale category for character  han‐
6437              dling  functions.   If  the  MULTIBYTE  option is in effect this
6438              variable or LANG should contain a value that reflects the  char‐
6439              acter set in use, even if it is a single-byte character set, un‐
6440              less only the 7-bit subset (ASCII) is used.  For example, if the
6441              character   set   is  ISO-8859-1,  a  suitable  value  might  be
6442              en_US.iso88591 (certain Linux distributions) or  en_US.ISO8859-1
6443              (MacOS).
6444
6445       LC_MESSAGES <S>
6446              This  variable  determines the language in which messages should
6447              be written.  Note that zsh does not use message catalogs.
6448
6449       LC_NUMERIC <S>
6450              This variable affects the decimal point character and  thousands
6451              separator character for the formatted input/output functions and
6452              string conversion functions.  Note that zsh ignores this setting
6453              when parsing floating point mathematical expressions.
6454
6455       LC_TIME <S>
6456              This  variable  determines the locale category for date and time
6457              formatting in prompt escape sequences.
6458
6459       LINES <S>
6460              The number of lines for this terminal session.  Used for  print‐
6461              ing select lists and for the line editor.
6462
6463       LISTMAX
6464              In the line editor, the number of matches to list without asking
6465              first. If the value is negative, the list will be  shown  if  it
6466              spans  at most as many lines as given by the absolute value.  If
6467              set to zero, the shell asks only if the top of the listing would
6468              scroll off the screen.
6469
6470       LOGCHECK
6471              The interval in seconds between checks for login/logout activity
6472              using the watch parameter.
6473
6474       MAIL   If this parameter is set and mailpath  is  not  set,  the  shell
6475              looks for mail in the specified file.
6476
6477       MAILCHECK
6478              The interval in seconds between checks for new mail.
6479
6480       mailpath <S> <Z> (MAILPATH <S>)
6481              An  array  (colon-separated  list) of filenames to check for new
6482              mail.  Each filename can be followed by a `?' and a message that
6483              will  be printed.  The message will undergo parameter expansion,
6484              command substitution and arithmetic expansion with the  variable
6485              $_  defined  as  the name of the file that has changed.  The de‐
6486              fault message is `You have new mail'.  If an element is a direc‐
6487              tory  instead  of  a file the shell will recursively check every
6488              file in every subdirectory of the element.
6489
6490       manpath <S> <Z> (MANPATH <S> <Z>)
6491              An array (colon-separated list) whose value is not used  by  the
6492              shell.   The manpath array can be useful, however, since setting
6493              it also sets MANPATH, and vice versa.
6494
6495       match
6496       mbegin
6497       mend   Arrays set by the shell when the b globbing flag is used in pat‐
6498              tern matches.  See the subsection Globbing flags in the documen‐
6499              tation for Filename Generation in zshexpn(1).
6500
6501       MATCH
6502       MBEGIN
6503       MEND   Set by the shell when the m globbing flag  is  used  in  pattern
6504              matches.  See the subsection Globbing flags in the documentation
6505              for Filename Generation in zshexpn(1).
6506
6507       module_path <S> <Z> (MODULE_PATH <S>)
6508              An array (colon-separated list)  of  directories  that  zmodload
6509              searches  for dynamically loadable modules.  This is initialized
6510              to a standard  pathname,  usually  `/usr/local/lib/zsh/$ZSH_VER‐
6511              SION'.   (The  `/usr/local/lib' part varies from installation to
6512              installation.)  For security reasons, any value set in the envi‐
6513              ronment when the shell is started will be ignored.
6514
6515              These parameters only exist if the installation supports dynamic
6516              module loading.
6517
6518       NULLCMD <S>
6519              The command name to assume if a redirection is specified with no
6520              command.   Defaults to cat.  For sh/ksh behavior, change this to
6521              :.  For csh-like behavior, unset this parameter; the shell  will
6522              print an error message if null commands are entered.
6523
6524       path <S> <Z> (PATH <S>)
6525              An  array  (colon-separated  list)  of directories to search for
6526              commands.  When this parameter is set, each directory is scanned
6527              and all files found are put in a hash table.
6528
6529       POSTEDIT <S>
6530              This  string  is output whenever the line editor exits.  It usu‐
6531              ally contains termcap strings to reset the terminal.
6532
6533       PROMPT <S> <Z>
6534       PROMPT2 <S> <Z>
6535       PROMPT3 <S> <Z>
6536       PROMPT4 <S> <Z>
6537              Same as PS1, PS2, PS3 and PS4, respectively.
6538
6539       prompt <S> <Z>
6540              Same as PS1.
6541
6542       PROMPT_EOL_MARK
6543              When  the  PROMPT_CR  and  PROMPT_SP  options   are   set,   the
6544              PROMPT_EOL_MARK  parameter  can be used to customize how the end
6545              of partial lines are shown.  This parameter undergoes prompt ex‐
6546              pansion,  with  the  PROMPT_PERCENT option set.  If not set, the
6547              default behavior is equivalent to the value `%B%S%#%s%b'.
6548
6549       PS1 <S>
6550              The primary prompt string, printed before a command is read.  It
6551              undergoes  a  special  form of expansion before being displayed;
6552              see EXPANSION OF PROMPT SEQUENCES in zshmisc(1).  The default is
6553              `%m%# '.
6554
6555       PS2 <S>
6556              The secondary prompt, printed when the shell needs more informa‐
6557              tion to complete a command.  It is expanded in the same  way  as
6558              PS1.  The default is `%_> ', which displays any shell constructs
6559              or quotation marks which are currently being processed.
6560
6561       PS3 <S>
6562              Selection prompt used within a select loop.  It is  expanded  in
6563              the same way as PS1.  The default is `?# '.
6564
6565       PS4 <S>
6566              The  execution  trace prompt.  Default is `+%N:%i> ', which dis‐
6567              plays the name of the current shell structure and the line  num‐
6568              ber within it.  In sh or ksh emulation, the default is `+ '.
6569
6570       psvar <S> <Z> (PSVAR <S>)
6571              An  array  (colon-separated  list) whose elements can be used in
6572              PROMPT strings.  Setting psvar also sets PSVAR, and vice versa.
6573
6574       READNULLCMD <S>
6575              The command name to assume if  a  single  input  redirection  is
6576              specified with no command.  Defaults to more.
6577
6578       REPORTMEMORY
6579              If   nonnegative,  commands  whose  maximum  resident  set  size
6580              (roughly speaking, main memory usage) in  kilobytes  is  greater
6581              than  this  value  have  timing statistics reported.  The format
6582              used to output statistics is the value of the TIMEFMT parameter,
6583              which  is  the  same as for the REPORTTIME variable and the time
6584              builtin; note that by default this does not output memory usage.
6585              Appending  "  max  RSS  %M" to the value of TIMEFMT causes it to
6586              output the value that triggered the report.   If  REPORTTIME  is
6587              also  in  use, at most a single report is printed for both trig‐
6588              gers.  This feature requires the getrusage() system  call,  com‐
6589              monly supported by modern Unix-like systems.
6590
6591       REPORTTIME
6592              If  nonnegative,  commands whose combined user and system execu‐
6593              tion times (measured in seconds) are  greater  than  this  value
6594              have  timing  statistics printed for them.  Output is suppressed
6595              for commands executed within the line editor, including  comple‐
6596              tion;  commands  explicitly  marked  with the time keyword still
6597              cause the summary to be printed in this case.
6598
6599       REPLY  This parameter is reserved by convention to pass  string  values
6600              between  shell  scripts and shell builtins in situations where a
6601              function call or redirection are impossible or undesirable.  The
6602              read  builtin  and the select complex command may set REPLY, and
6603              filename generation both sets and examines its value when evalu‐
6604              ating  certain  expressions.  Some modules also employ REPLY for
6605              similar purposes.
6606
6607       reply  As REPLY, but for array values rather than strings.
6608
6609       RPROMPT <S>
6610       RPS1 <S>
6611              This prompt is displayed on the right-hand side  of  the  screen
6612              when  the  primary  prompt is being displayed on the left.  This
6613              does not work if the SINGLE_LINE_ZLE option is set.  It  is  ex‐
6614              panded in the same way as PS1.
6615
6616       RPROMPT2 <S>
6617       RPS2 <S>
6618              This  prompt  is  displayed on the right-hand side of the screen
6619              when the secondary prompt is being displayed on the left.   This
6620              does  not  work if the SINGLE_LINE_ZLE option is set.  It is ex‐
6621              panded in the same way as PS2.
6622
6623       SAVEHIST
6624              The maximum number of history events  to  save  in  the  history
6625              file.
6626
6627              If this is made local, it is not implicitly set to 0, but may be
6628              explicitly set locally.
6629
6630       SPROMPT <S>
6631              The prompt used for spelling correction.  The sequence `%R'  ex‐
6632              pands  to the string which presumably needs spelling correction,
6633              and `%r' expands to the proposed correction.  All  other  prompt
6634              escapes are also allowed.
6635
6636              The actions available at the prompt are [nyae]:
6637              n (`no') (default)
6638                     Discard the correction and run the command.
6639              y (`yes')
6640                     Make the correction and run the command.
6641              a (`abort')
6642                     Discard the entire command line without running it.
6643              e (`edit')
6644                     Resume editing the command line.
6645
6646       STTY   If  this  parameter is set in a command's environment, the shell
6647              runs the stty command with the value of this parameter as  argu‐
6648              ments  in order to set up the terminal before executing the com‐
6649              mand. The modes apply only to the command, and are reset when it
6650              finishes  or  is suspended. If the command is suspended and con‐
6651              tinued later with the fg or wait builtins it will see the  modes
6652              specified  by  STTY,  as if it were not suspended.  This (inten‐
6653              tionally) does not apply if the command is continued  via  `kill
6654              -CONT'.   STTY  is  ignored  if  the command is run in the back‐
6655              ground, or if it is in the environment of the shell but not  ex‐
6656              plicitly assigned to in the input line. This avoids running stty
6657              at every external command by  accidentally  exporting  it.  Also
6658              note  that  STTY  should  not be used for window size specifica‐
6659              tions; these will not be local to the command.
6660
6661       TERM <S>
6662              The type of terminal in use.  This is used when looking up term‐
6663              cap  sequences.  An assignment to TERM causes zsh to re-initial‐
6664              ize the terminal, even if  the  value  does  not  change  (e.g.,
6665              `TERM=$TERM').   It is necessary to make such an assignment upon
6666              any change to the terminal definition database or terminal  type
6667              in order for the new settings to take effect.
6668
6669       TERMINFO <S>
6670              A  reference  to  your terminfo database, used by the `terminfo'
6671              library when the system has it; see terminfo(5).  If  set,  this
6672              causes  the shell to reinitialise the terminal, making the work‐
6673              around `TERM=$TERM' unnecessary.
6674
6675       TERMINFO_DIRS <S>
6676              A colon-seprarated list of terminfo databases, used by the `ter‐
6677              minfo'  library  when  the  system has it; see terminfo(5). This
6678              variable is only used by certain terminal libraries, in particu‐
6679              lar  ncurses;  see  terminfo(5) to check support on your system.
6680              If set, this causes the shell to reinitialise the terminal, mak‐
6681              ing  the  workaround `TERM=$TERM' unnecessary.  Note that unlike
6682              other colon-separated arrays this is not tied to a zsh array.
6683
6684       TIMEFMT
6685              The format of process time reports with the time  keyword.   The
6686              default is `%J  %U user %S system %P cpu %*E total'.  Recognizes
6687              the following escape sequences, although not all may  be  avail‐
6688              able on all systems, and some that are available may not be use‐
6689              ful:
6690
6691              %%     A `%'.
6692              %U     CPU seconds spent in user mode.
6693              %S     CPU seconds spent in kernel mode.
6694              %E     Elapsed time in seconds.
6695              %P     The CPU percentage, computed as 100*(%U+%S)/%E.
6696              %W     Number of times the process was swapped.
6697              %X     The average amount in (shared) text space used  in  kilo‐
6698                     bytes.
6699              %D     The average amount in (unshared) data/stack space used in
6700                     kilobytes.
6701              %K     The total space used (%X+%D) in kilobytes.
6702              %M     The  maximum memory the process had in use at any time in
6703                     kilobytes.
6704              %F     The  number  of  major  page  faults  (page  needed to be
6705                     brought from disk).
6706              %R     The number of minor page faults.
6707              %I     The number of input operations.
6708              %O     The number of output operations.
6709              %r     The number of socket messages received.
6710              %s     The number of socket messages sent.
6711              %k     The number of signals received.
6712              %w     Number of voluntary context switches (waits).
6713              %c     Number of involuntary context switches.
6714              %J     The name of this job.
6715
6716              A star may be inserted between the percent sign and flags print‐
6717              ing  time  (e.g.,  `%*E'); this causes the time to be printed in
6718              `hh:mm:ss.ttt' format (hours and minutes  are  only  printed  if
6719              they  are  not  zero).   Alternatively,  `m'  or `u' may be used
6720              (e.g., `%mE') to produce time  output  in  milliseconds  or  mi‐
6721              croseconds, respectively.
6722
6723       TMOUT  If  this  parameter  is  nonzero, the shell will receive an ALRM
6724              signal if a command is not entered within the  specified  number
6725              of  seconds  after  issuing  a  prompt.  If  there  is a trap on
6726              SIGALRM, it will be executed and a new alarm is scheduled  using
6727              the  value  of the TMOUT parameter after executing the trap.  If
6728              no trap is set, and the idle time of the terminal  is  not  less
6729              than  the  value of the TMOUT parameter, zsh terminates.  Other‐
6730              wise a new alarm is scheduled to TMOUT seconds  after  the  last
6731              keypress.
6732
6733       TMPPREFIX
6734              A  pathname  prefix  which  the shell will use for all temporary
6735              files.  Note that this should include an initial  part  for  the
6736              file  name  as  well  as  any  directory  names.  The default is
6737              `/tmp/zsh'.
6738
6739       TMPSUFFIX
6740              A filename suffix which the shell will use for  temporary  files
6741              created  by  process substitutions (e.g., `=(list)').  Note that
6742              the value should include a leading dot `.' if intended to be in‐
6743              terpreted as a file extension.  The default is not to append any
6744              suffix, thus this parameter should be assigned only when  needed
6745              and then unset again.
6746
6747       watch <S> <Z> (WATCH <S>)
6748              An  array  (colon-separated  list) of login/logout events to re‐
6749              port.
6750
6751              If it contains the single  word  `all',  then  all  login/logout
6752              events  are  reported.   If it contains the single word `notme',
6753              then all events are reported as with `all' except $USERNAME.
6754
6755              An entry in this list may consist of a username, an `@' followed
6756              by  a  remote hostname, and a `%' followed by a line (tty).  Any
6757              of these may be a pattern (be sure to quote this during the  as‐
6758              signment  to  watch so that it does not immediately perform file
6759              generation); the setting of  the  EXTENDED_GLOB  option  is  re‐
6760              spected.   Any  or  all of these components may be present in an
6761              entry; if a login/logout event matches all of them,  it  is  re‐
6762              ported.
6763
6764              For example, with the EXTENDED_GLOB option set, the following:
6765
6766                     watch=('^(pws|barts)')
6767
6768              causes  reports for activity associated with any user other than
6769              pws or barts.
6770
6771       WATCHFMT
6772              The format of login/logout reports if  the  watch  parameter  is
6773              set.  Default is `%n has %a %l from %m'.  Recognizes the follow‐
6774              ing escape sequences:
6775
6776              %n     The name of the user that logged in/out.
6777
6778              %a     The observed action, i.e. "logged on" or "logged off".
6779
6780              %l     The line (tty) the user is logged in on.
6781
6782              %M     The full hostname of the remote host.
6783
6784              %m     The hostname up to the first `.'.  If only the IP address
6785                     is  available  or  the utmp field contains the name of an
6786                     X-windows display, the whole name is printed.
6787
6788                     NOTE: The `%m' and `%M' escapes will work only  if  there
6789                     is a host name field in the utmp on your machine.  Other‐
6790                     wise they are treated as ordinary strings.
6791
6792              %S (%s)
6793                     Start (stop) standout mode.
6794
6795              %U (%u)
6796                     Start (stop) underline mode.
6797
6798              %B (%b)
6799                     Start (stop) boldface mode.
6800
6801              %t
6802              %@     The time, in 12-hour, am/pm format.
6803
6804              %T     The time, in 24-hour format.
6805
6806              %w     The date in `day-dd' format.
6807
6808              %W     The date in `mm/dd/yy' format.
6809
6810              %D     The date in `yy-mm-dd' format.
6811
6812              %D{string}
6813                     The date formatted as string using the strftime function,
6814                     with  zsh  extensions as described by EXPANSION OF PROMPT
6815                     SEQUENCES in zshmisc(1).
6816
6817              %(x:true-text:false-text)
6818                     Specifies a ternary expression.  The character  following
6819                     the  x  is arbitrary; the same character is used to sepa‐
6820                     rate the text for the "true" result  from  that  for  the
6821                     "false"  result.  Both the separator and the right paren‐
6822                     thesis may be escaped with a backslash.  Ternary  expres‐
6823                     sions may be nested.
6824
6825                     The  test  character x may be any one of `l', `n', `m' or
6826                     `M', which indicate a `true' result if the  corresponding
6827                     escape sequence would return a non-empty value; or it may
6828                     be `a', which indicates a `true' result  if  the  watched
6829                     user  has  logged  in,  or  `false' if he has logged out.
6830                     Other characters evaluate to neither true nor false;  the
6831                     entire expression is omitted in this case.
6832
6833                     If  the result is `true', then the true-text is formatted
6834                     according  to  the  rules  above  and  printed,  and  the
6835                     false-text  is  skipped.   If  `false',  the true-text is
6836                     skipped and the false-text is formatted and printed.  Ei‐
6837                     ther or both of the branches may be empty, but both sepa‐
6838                     rators must be present in any case.
6839
6840       WORDCHARS <S>
6841              A list of non-alphanumeric characters considered part of a  word
6842              by the line editor.
6843
6844       ZBEEP  If set, this gives a string of characters, which can use all the
6845              same codes as the bindkey command as described  in  the  zsh/zle
6846              module entry in zshmodules(1), that will be output to the termi‐
6847              nal instead of beeping.  This may have a visible instead  of  an
6848              audible  effect;  for  example,  the  string `\e[?5h\e[?5l' on a
6849              vt100 or xterm will have the effect of flashing reverse video on
6850              and  off  (if  you usually use reverse video, you should use the
6851              string `\e[?5l\e[?5h' instead).  This takes precedence over  the
6852              NOBEEP option.
6853
6854       ZDOTDIR
6855              The  directory  to search for shell startup files (.zshrc, etc),
6856              if not $HOME.
6857
6858       zle_bracketed_paste
6859              Many terminal emulators have a feature that allows  applications
6860              to  identify  when  text is pasted into the terminal rather than
6861              being typed normally. For ZLE, this means that  special  charac‐
6862              ters such as tabs and newlines can be inserted instead of invok‐
6863              ing editor commands.  Furthermore, pasted text  forms  a  single
6864              undo event and if the region is active, pasted text will replace
6865              the region.
6866
6867              This two-element array contains the  terminal  escape  sequences
6868              for  enabling  and disabling the feature. These escape sequences
6869              are used to enable bracketed paste when ZLE is active  and  dis‐
6870              able  it at other times.  Unsetting the parameter has the effect
6871              of ensuring that bracketed paste remains disabled.
6872
6873       zle_highlight
6874              An array describing contexts in which ZLE should  highlight  the
6875              input text.  See Character Highlighting in zshzle(1).
6876
6877       ZLE_LINE_ABORTED
6878              This  parameter  is set by the line editor when an error occurs.
6879              It contains the line that was being edited at the point  of  the
6880              error.   `print -zr -- $ZLE_LINE_ABORTED' can be used to recover
6881              the line.  Only the most recent line of this kind is remembered.
6882
6883       ZLE_REMOVE_SUFFIX_CHARS
6884       ZLE_SPACE_SUFFIX_CHARS
6885              These parameters are used by the line editor.  In  certain  cir‐
6886              cumstances suffixes (typically space or slash) added by the com‐
6887              pletion system will be removed automatically, either because the
6888              next editing command was not an insertable character, or because
6889              the character was marked as requiring the suffix to be removed.
6890
6891              These variables can contain the sets  of  characters  that  will
6892              cause  the  suffix to be removed.  If ZLE_REMOVE_SUFFIX_CHARS is
6893              set, those characters will cause the suffix to  be  removed;  if
6894              ZLE_SPACE_SUFFIX_CHARS  is  set, those characters will cause the
6895              suffix to be removed and replaced by a space.
6896
6897              If ZLE_REMOVE_SUFFIX_CHARS is not set, the default behaviour  is
6898              equivalent to:
6899
6900                     ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'
6901
6902              If  ZLE_REMOVE_SUFFIX_CHARS  is  set but is empty, no characters
6903              have this behaviour.  ZLE_SPACE_SUFFIX_CHARS  takes  precedence,
6904              so that the following:
6905
6906                     ZLE_SPACE_SUFFIX_CHARS=$'&|'
6907
6908              causes  the  characters  `&' and `|' to remove the suffix but to
6909              replace it with a space.
6910
6911              To illustrate the difference, suppose that the  option  AUTO_RE‐
6912              MOVE_SLASH is in effect and the directory DIR has just been com‐
6913              pleted, with an appended /, following which the user types  `&'.
6914              The  default result is `DIR&'.  With ZLE_REMOVE_SUFFIX_CHARS set
6915              but  without  including  `&'  the  result  is   `DIR/&'.    With
6916              ZLE_SPACE_SUFFIX_CHARS set to include `&' the result is `DIR &'.
6917
6918              Note  that  certain completions may provide their own suffix re‐
6919              moval or replacement behaviour which overrides  the  values  de‐
6920              scribed  here.   See the completion system documentation in zsh‐
6921              compsys(1).
6922
6923       ZLE_RPROMPT_INDENT <S>
6924              If set, used to give the indentation between the right hand side
6925              of  the  right  prompt  in  the  line editor as given by RPS1 or
6926              RPROMPT and the right hand side of the screen.  If not set,  the
6927              value 1 is used.
6928
6929              Typically  this  will  be used to set the value to 0 so that the
6930              prompt appears flush with the right hand  side  of  the  screen.
6931              This  is  not  the  default as many terminals do not handle this
6932              correctly, in particular when the prompt appears at the  extreme
6933              bottom  right  of the screen.  Recent virtual terminals are more
6934              likely to handle this case correctly.  Some  experimentation  is
6935              necessary.
6936
6937
6938
6939ZSHOPTIONS(1)               General Commands Manual              ZSHOPTIONS(1)
6940
6941
6942

NAME

6944       zshoptions - zsh options
6945

SPECIFYING OPTIONS

6947       Options are primarily referred to by name.  These names are case insen‐
6948       sitive and underscores are ignored.  For example, `allexport' is equiv‐
6949       alent to `A__lleXP_ort'.
6950
6951       The  sense of an option name may be inverted by preceding it with `no',
6952       so `setopt No_Beep' is equivalent to `unsetopt beep'.   This  inversion
6953       can only be done once, so `nonobeep' is not a synonym for `beep'.  Sim‐
6954       ilarly, `tify' is not a synonym for `nonotify' (the inversion  of  `no‐
6955       tify').
6956
6957       Some  options also have one or more single letter names.  There are two
6958       sets of single letter options: one used by default, and another used to
6959       emulate  sh/ksh  (used  when the SH_OPTION_LETTERS option is set).  The
6960       single letter options can be used on the shell command  line,  or  with
6961       the  set, setopt and unsetopt builtins, as normal Unix options preceded
6962       by `-'.
6963
6964       The sense of the single letter options may be inverted by using `+' in‐
6965       stead  of  `-'.  Some of the single letter option names refer to an op‐
6966       tion being off, in which case the inversion of that name refers to  the
6967       option  being  on.   For example, `+n' is the short name of `exec', and
6968       `-n' is the short name of its inversion, `noexec'.
6969
6970       In strings of single letter options supplied to the shell  at  startup,
6971       trailing  whitespace  will  be ignored; for example the string `-f    '
6972       will be treated just as `-f', but the string `-f i' is an error.   This
6973       is  because many systems which implement the `#!' mechanism for calling
6974       scripts do not strip trailing whitespace.
6975

DESCRIPTION OF OPTIONS

6977       In the following list, options set by default  in  all  emulations  are
6978       marked  <D>;  those  set by default only in csh, ksh, sh, or zsh emula‐
6979       tions are marked <C>, <K>, <S>, <Z> as appropriate.  When  listing  op‐
6980       tions  (by `setopt', `unsetopt', `set -o' or `set +o'), those turned on
6981       by default appear in  the  list  prefixed  with  `no'.   Hence  (unless
6982       KSH_OPTION_PRINT is set), `setopt' shows all options whose settings are
6983       changed from the default.
6984
6985   Changing Directories
6986       AUTO_CD (-J)
6987              If a command is issued that can't be executed as a  normal  com‐
6988              mand, and the command is the name of a directory, perform the cd
6989              command to that directory.  This option is  only  applicable  if
6990              the  option  SHIN_STDIN  is set, i.e. if commands are being read
6991              from standard input.  The option  is  designed  for  interactive
6992              use;  it is recommended that cd be used explicitly in scripts to
6993              avoid ambiguity.
6994
6995       AUTO_PUSHD (-N)
6996              Make cd push the old directory onto the directory stack.
6997
6998       CDABLE_VARS (-T)
6999              If the argument to a cd command  (or  an  implied  cd  with  the
7000              AUTO_CD  option set) is not a directory, and does not begin with
7001              a slash, try to expand the expression as if it were preceded  by
7002              a `~' (see the section `Filename Expansion').
7003
7004       CD_SILENT
7005              Never  print  the working directory after a cd (whether explicit
7006              or implied with the AUTO_CD option set). cd normally prints  the
7007              working  directory  when the argument given to it was -, a stack
7008              entry, or the name of a directory found under CDPATH. Note  that
7009              this is distinct from pushd's stack-printing behaviour, which is
7010              controlled by PUSHD_SILENT. This  option  overrides  the  print‐
7011              ing-related effects of POSIX_CD.
7012
7013       CHASE_DOTS
7014              When  changing  to  a  directory  containing a path segment `..'
7015              which would otherwise be treated as canceling the previous  seg‐
7016              ment in the path (in other words, `foo/..' would be removed from
7017              the path, or if `..' is the first part of  the  path,  the  last
7018              part of the current working directory would be removed), instead
7019              resolve the path to the  physical  directory.   This  option  is
7020              overridden by CHASE_LINKS.
7021
7022              For  example,  suppose  /foo/bar  is  a  link  to  the directory
7023              /alt/rod.  Without this option set, `cd /foo/bar/..' changes  to
7024              /foo;  with it set, it changes to /alt.  The same applies if the
7025              current directory is /foo/bar and `cd ..' is  used.   Note  that
7026              all other symbolic links in the path will also be resolved.
7027
7028       CHASE_LINKS (-w)
7029              Resolve symbolic links to their true values when changing direc‐
7030              tory.  This also has the effect of CHASE_DOTS, i.e. a `..'  path
7031              segment  will  be  treated  as referring to the physical parent,
7032              even if the preceding path segment is a symbolic link.
7033
7034       POSIX_CD <K> <S>
7035              Modifies the behaviour of cd, chdir and pushd commands  to  make
7036              them more compatible with the POSIX standard. The behaviour with
7037              the option unset is described in the documentation  for  the  cd
7038              builtin in zshbuiltins(1).  If the option is set, the shell does
7039              not test for directories beneath the local directory (`.') until
7040              after all directories in cdpath have been tested, and the cd and
7041              chdir commands do not recognise arguments of the  form  `{+|-}n'
7042              as directory stack entries.
7043
7044              Also, if the option is set, the conditions under which the shell
7045              prints the new directory after changing to it are modified.   It
7046              is no longer restricted to interactive shells (although printing
7047              of the directory stack with pushd is still limited  to  interac‐
7048              tive  shells); and any use of a component of CDPATH, including a
7049              `.' but excluding an empty component that is  otherwise  treated
7050              as `.', causes the directory to be printed.
7051
7052       PUSHD_IGNORE_DUPS
7053              Don't push multiple copies of the same directory onto the direc‐
7054              tory stack.
7055
7056       PUSHD_MINUS
7057              Exchanges the meanings of `+' and `-' when used with a number to
7058              specify a directory in the stack.
7059
7060       PUSHD_SILENT (-E)
7061              Do not print the directory stack after pushd or popd.
7062
7063       PUSHD_TO_HOME (-D)
7064              Have pushd with no arguments act like `pushd $HOME'.
7065
7066   Completion
7067       ALWAYS_LAST_PROMPT <D>
7068              If  unset,  key functions that list completions try to return to
7069              the last prompt if given a numeric argument. If set these  func‐
7070              tions try to return to the last prompt if given no numeric argu‐
7071              ment.
7072
7073       ALWAYS_TO_END
7074              If a completion is performed with the cursor within a word,  and
7075              a full completion is inserted, the cursor is moved to the end of
7076              the word.  That is, the cursor is moved to the end of  the  word
7077              if  either a single match is inserted or menu completion is per‐
7078              formed.
7079
7080       AUTO_LIST (-9) <D>
7081              Automatically list choices on an ambiguous completion.
7082
7083       AUTO_MENU <D>
7084              Automatically use menu completion after the  second  consecutive
7085              request  for completion, for example by pressing the tab key re‐
7086              peatedly. This option is overridden by MENU_COMPLETE.
7087
7088       AUTO_NAME_DIRS
7089              Any parameter that is set to the absolute name  of  a  directory
7090              immediately becomes a name for that directory, that will be used
7091              by the `%~' and related prompt sequences, and will be  available
7092              when completion is performed on a word starting with `~'.  (Oth‐
7093              erwise, the parameter must be used in the form `~param' first.)
7094
7095       AUTO_PARAM_KEYS <D>
7096              If a parameter name was  completed  and  a  following  character
7097              (normally  a space) automatically inserted, and the next charac‐
7098              ter typed is one of those that have to come directly  after  the
7099              name (like `}', `:', etc.), the automatically added character is
7100              deleted, so that the character typed comes immediately after the
7101              parameter  name.   Completion  in  a brace expansion is affected
7102              similarly: the added character is a `,', which will  be  removed
7103              if `}' is typed next.
7104
7105       AUTO_PARAM_SLASH <D>
7106              If  a  parameter is completed whose content is the name of a di‐
7107              rectory, then add a trailing slash instead of a space.
7108
7109       AUTO_REMOVE_SLASH <D>
7110              When the last character resulting from a completion is  a  slash
7111              and  the next character typed is a word delimiter, a slash, or a
7112              character that ends a command (such as a semicolon or an  amper‐
7113              sand), remove the slash.
7114
7115       BASH_AUTO_LIST
7116              On  an ambiguous completion, automatically list choices when the
7117              completion function is called twice in succession.   This  takes
7118              precedence over AUTO_LIST.  The setting of LIST_AMBIGUOUS is re‐
7119              spected.  If AUTO_MENU is set,  the  menu  behaviour  will  then
7120              start  with  the third press.  Note that this will not work with
7121              MENU_COMPLETE, since repeated completion calls immediately cycle
7122              through the list in that case.
7123
7124       COMPLETE_ALIASES
7125              Prevents  aliases on the command line from being internally sub‐
7126              stituted before completion is attempted.  The effect is to  make
7127              the alias a distinct command for completion purposes.
7128
7129       COMPLETE_IN_WORD
7130              If unset, the cursor is set to the end of the word if completion
7131              is started. Otherwise it stays there and completion is done from
7132              both ends.
7133
7134       GLOB_COMPLETE
7135              When  the current word has a glob pattern, do not insert all the
7136              words resulting from the expansion but generate matches  as  for
7137              completion  and  cycle  through  them  like  MENU_COMPLETE.  The
7138              matches are generated as if a `*' was added to the  end  of  the
7139              word,  or  inserted  at the cursor when COMPLETE_IN_WORD is set.
7140              This actually uses pattern matching, not globbing, so  it  works
7141              not only for files but for any completion, such as options, user
7142              names, etc.
7143
7144              Note that when the pattern matcher  is  used,  matching  control
7145              (for  example,  case-insensitive or anchored matching) cannot be
7146              used.  This limitation only applies when the current  word  con‐
7147              tains a pattern; simply turning on the GLOB_COMPLETE option does
7148              not have this effect.
7149
7150       HASH_LIST_ALL <D>
7151              Whenever a command completion  or  spelling  correction  is  at‐
7152              tempted,  make  sure  the  entire  command path is hashed first.
7153              This makes the first completion slower but avoids false  reports
7154              of spelling errors.
7155
7156       LIST_AMBIGUOUS <D>
7157              This  option works when AUTO_LIST or BASH_AUTO_LIST is also set.
7158              If there is an unambiguous prefix to insert on the command line,
7159              that is done without a completion list being displayed; in other
7160              words, auto-listing behaviour  only  takes  place  when  nothing
7161              would  be  inserted.   In the case of BASH_AUTO_LIST, this means
7162              that the list will be delayed to the third call of the function.
7163
7164       LIST_BEEP <D>
7165              Beep on an ambiguous completion.  More accurately,  this  forces
7166              the  completion  widgets to return status 1 on an ambiguous com‐
7167              pletion, which causes the shell to beep if the  option  BEEP  is
7168              also  set;  this  may be modified if completion is called from a
7169              user-defined widget.
7170
7171       LIST_PACKED
7172              Try to make the completion list smaller (occupying  less  lines)
7173              by printing the matches in columns with different widths.
7174
7175       LIST_ROWS_FIRST
7176              Lay  out  the  matches  in completion lists sorted horizontally,
7177              that is, the second match is to the right of the first one,  not
7178              under it as usual.
7179
7180       LIST_TYPES (-X) <D>
7181              When  listing files that are possible completions, show the type
7182              of each file with a trailing identifying mark.
7183
7184       MENU_COMPLETE (-Y)
7185              On an ambiguous completion, instead of listing possibilities  or
7186              beeping,  insert the first match immediately.  Then when comple‐
7187              tion is requested again, remove the first match and  insert  the
7188              second  match,  etc.  When there are no more matches, go back to
7189              the first one again.  reverse-menu-complete may be used to  loop
7190              through  the  list in the other direction. This option overrides
7191              AUTO_MENU.
7192
7193       REC_EXACT (-S)
7194              If the string on the command line exactly  matches  one  of  the
7195              possible  completions,  it is accepted, even if there is another
7196              completion (i.e. that string with  something  else  added)  that
7197              also matches.
7198
7199   Expansion and Globbing
7200       BAD_PATTERN (+2) <C> <Z>
7201              If  a  pattern for filename generation is badly formed, print an
7202              error message.  (If this option is unset, the  pattern  will  be
7203              left unchanged.)
7204
7205       BARE_GLOB_QUAL <Z>
7206              In  a  glob  pattern,  treat  a trailing set of parentheses as a
7207              qualifier list, if it contains no `|', `(' or (if  special)  `~'
7208              characters.  See the section `Filename Generation'.
7209
7210       BRACE_CCL
7211              Expand  expressions  in braces which would not otherwise undergo
7212              brace expansion to a lexically ordered list of all  the  charac‐
7213              ters.  See the section `Brace Expansion'.
7214
7215       CASE_GLOB <D>
7216              Make  globbing  (filename  generation)  sensitive to case.  Note
7217              that other uses of patterns are always sensitive  to  case.   If
7218              the option is unset, the presence of any character which is spe‐
7219              cial to filename generation will cause  case-insensitive  match‐
7220              ing.   For  example, cvs(/) can match the directory CVS owing to
7221              the  presence  of  the  globbing   flag   (unless   the   option
7222              BARE_GLOB_QUAL is unset).
7223
7224       CASE_MATCH <D>
7225              Make  regular  expressions using the zsh/regex module (including
7226              matches with =~) sensitive to case.
7227
7228       CSH_NULL_GLOB <C>
7229              If a pattern for filename generation has no matches, delete  the
7230              pattern  from  the  argument list; do not report an error unless
7231              all the patterns in a command have no  matches.   Overrides  NO‐
7232              MATCH.
7233
7234       EQUALS <Z>
7235              Perform = filename expansion.  (See the section `Filename Expan‐
7236              sion'.)
7237
7238       EXTENDED_GLOB
7239              Treat the `#', `~' and `^' characters as part  of  patterns  for
7240              filename  generation, etc.  (An initial unquoted `~' always pro‐
7241              duces named directory expansion.)
7242
7243       FORCE_FLOAT
7244              Constants in arithmetic evaluation will be treated  as  floating
7245              point even without the use of a decimal point; the values of in‐
7246              teger variables will be converted to floating point when used in
7247              arithmetic expressions.  Integers in any base will be converted.
7248
7249       GLOB (+F, ksh: +f) <D>
7250              Perform filename generation (globbing).  (See the section `File‐
7251              name Generation'.)
7252
7253       GLOB_ASSIGN <C>
7254              If this option is set, filename generation  (globbing)  is  per‐
7255              formed on the right hand side of scalar parameter assignments of
7256              the form `name=pattern (e.g. `foo=*').  If the result  has  more
7257              than  one  word  the  parameter  will become an array with those
7258              words as arguments. This option is provided for  backwards  com‐
7259              patibility  only: globbing is always performed on the right hand
7260              side of array  assignments  of  the  form  `name=(value)'  (e.g.
7261              `foo=(*)')  and  this form is recommended for clarity; with this
7262              option set, it is not possible to  predict  whether  the  result
7263              will be an array or a scalar.
7264
7265       GLOB_DOTS (-4)
7266              Do not require a leading `.' in a filename to be matched explic‐
7267              itly.
7268
7269       GLOB_STAR_SHORT
7270              When this option is set and the default zsh-style globbing is in
7271              effect,  the  pattern  `**/*' can be abbreviated to `**' and the
7272              pattern `***/*' can be abbreviated to ***.  Hence `**.c' finds a
7273              file ending in .c in any subdirectory, and `***.c' does the same
7274              while also following symbolic links.  A / immediately after  the
7275              `**' or `***' forces the pattern to be treated as the unabbrevi‐
7276              ated form.
7277
7278       GLOB_SUBST <C> <K> <S>
7279              Treat any characters resulting from parameter expansion as being
7280              eligible for filename expansion and filename generation, and any
7281              characters resulting from command substitution as being eligible
7282              for  filename generation.  Braces (and commas in between) do not
7283              become eligible for expansion.
7284
7285       HIST_SUBST_PATTERN
7286              Substitutions using the :s and :&  history  modifiers  are  per‐
7287              formed  with  pattern matching instead of string matching.  This
7288              occurs wherever history  modifiers  are  valid,  including  glob
7289              qualifiers  and  parameters.   See the section Modifiers in zsh‐
7290              expn(1).
7291
7292       IGNORE_BRACES (-I) <S>
7293              Do not perform brace expansion.   For  historical  reasons  this
7294              also includes the effect of the IGNORE_CLOSE_BRACES option.
7295
7296       IGNORE_CLOSE_BRACES
7297              When  neither this option nor IGNORE_BRACES is set, a sole close
7298              brace character `}' is syntactically significant at any point on
7299              a  command  line.  This has the effect that no semicolon or new‐
7300              line is necessary before the brace  terminating  a  function  or
7301              current  shell  construct.  When either option is set, a closing
7302              brace is syntactically significant  only  in  command  position.
7303              Unlike  IGNORE_BRACES, this option does not disable brace expan‐
7304              sion.
7305
7306              For example, with both options unset a function may  be  defined
7307              in the following fashion:
7308
7309                     args() { echo $# }
7310
7311              while  if either option is set, this does not work and something
7312              equivalent to the following is required:
7313
7314                     args() { echo $#; }
7315
7316       KSH_GLOB <K>
7317              In pattern matching, the interpretation of  parentheses  is  af‐
7318              fected  by  a preceding `@', `*', `+', `?' or `!'.  See the sec‐
7319              tion `Filename Generation'.
7320
7321       MAGIC_EQUAL_SUBST
7322              All unquoted arguments of the form `anything=expression' appear‐
7323              ing  after  the  command  name have filename expansion (that is,
7324              where expression has a leading `~' or `=') performed on  expres‐
7325              sion  as if it were a parameter assignment.  The argument is not
7326              otherwise treated specially; it is passed to the  command  as  a
7327              single argument, and not used as an actual parameter assignment.
7328              For example, in echo  foo=~/bar:~/rod,  both  occurrences  of  ~
7329              would  be  replaced.  Note that this happens anyway with typeset
7330              and similar statements.
7331
7332              This option respects the setting of the KSH_TYPESET option.   In
7333              other  words,  if  both options are in effect, arguments looking
7334              like assignments will not undergo word splitting.
7335
7336       MARK_DIRS (-8, ksh: -X)
7337              Append a trailing `/' to  all  directory  names  resulting  from
7338              filename generation (globbing).
7339
7340       MULTIBYTE <D>
7341              Respect  multibyte  characters when found in strings.  When this
7342              option is set, strings are examined using the system library  to
7343              determine how many bytes form a character, depending on the cur‐
7344              rent locale.  This affects the way  characters  are  counted  in
7345              pattern matching, parameter values and various delimiters.
7346
7347              The  option  is  on  by  default  if the shell was compiled with
7348              MULTIBYTE_SUPPORT; otherwise it is off by default and has no ef‐
7349              fect if turned on.
7350
7351              If the option is off a single byte is always treated as a single
7352              character.   This  setting  is  designed  purely  for  examining
7353              strings  known to contain raw bytes or other values that may not
7354              be characters in the current locale.  It is not necessary to un‐
7355              set  the option merely because the character set for the current
7356              locale does not contain multibyte characters.
7357
7358              The option does not affect the  shell's  editor,   which  always
7359              uses  the locale to determine multibyte characters.  This is be‐
7360              cause the character set displayed by the  terminal  emulator  is
7361              independent of shell settings.
7362
7363       NOMATCH (+3) <C> <Z>
7364              If  a  pattern  for filename generation has no matches, print an
7365              error, instead of leaving it unchanged  in  the  argument  list.
7366              This also applies to file expansion of an initial `~' or `='.
7367
7368       NULL_GLOB (-G)
7369              If  a pattern for filename generation has no matches, delete the
7370              pattern from the argument list instead of  reporting  an  error.
7371              Overrides NOMATCH.
7372
7373       NUMERIC_GLOB_SORT
7374              If  numeric  filenames are matched by a filename generation pat‐
7375              tern, sort the filenames numerically rather  than  lexicographi‐
7376              cally.
7377
7378       RC_EXPAND_PARAM (-P)
7379              Array  expansions of the form `foo${xx}bar', where the parameter
7380              xx is set to (a b c),  are  substituted  with  `fooabar  foobbar
7381              foocbar'  instead  of  the  default `fooa b cbar'.  Note that an
7382              empty array will therefore cause all arguments to be removed.
7383
7384       REMATCH_PCRE
7385              If set, regular expression matching with the  =~  operator  will
7386              use  Perl-Compatible  Regular Expressions from the PCRE library.
7387              (The zsh/pcre module must be available.)  If  not  set,  regular
7388              expressions  will use the extended regexp syntax provided by the
7389              system libraries.
7390
7391       SH_GLOB <K> <S>
7392              Disables the special meaning of `(', `|', `)' and '<' for  glob‐
7393              bing  the  result of parameter and command substitutions, and in
7394              some other places where the shell accepts patterns.  If  SH_GLOB
7395              is  set but KSH_GLOB is not, the shell allows the interpretation
7396              of subshell expressions enclosed in parentheses  in  some  cases
7397              where  there  is  no  space before the opening parenthesis, e.g.
7398              !(true) is interpreted as if there were a  space  after  the  !.
7399              This option is set by default if zsh is invoked as sh or ksh.
7400
7401       UNSET (+u, ksh: +u) <K> <S> <Z>
7402              Treat  unset parameters as if they were empty when substituting,
7403              and as if they were zero when reading their values in arithmetic
7404              expansion  and  arithmetic commands.  Otherwise they are treated
7405              as an error.
7406
7407       WARN_CREATE_GLOBAL
7408              Print a warning message when a global parameter is created in  a
7409              function  by an assignment or in math context.  This often indi‐
7410              cates that a parameter has  not  been  declared  local  when  it
7411              should  have  been.   Parameters explicitly declared global from
7412              within a function using typeset -g do not cause a warning.  Note
7413              that  there  is no warning when a local parameter is assigned to
7414              in a nested function, which may also indicate an error.
7415
7416       WARN_NESTED_VAR
7417              Print a warning message when an existing parameter from  an  en‐
7418              closing  function  scope,  or global, is set in a function by an
7419              assignment or in math context.  Assignment to shell special  pa‐
7420              rameters  does  not  cause  a warning.  This is the companion to
7421              WARN_CREATE_GLOBAL as in this case the warning is  only  printed
7422              when a parameter is not created.  Where possible, use of typeset
7423              -g to set the parameter suppresses the error, but note that this
7424              needs  to  be used every time the parameter is set.  To restrict
7425              the effect of this option to a single function scope, use `func‐
7426              tions -W'.
7427
7428              For  example,  the following code produces a warning for the as‐
7429              signment inside the function nested as that overrides the  value
7430              within toplevel
7431
7432                     toplevel() {
7433                       local foo="in fn"
7434                       nested
7435                     }
7436                     nested() {
7437                          foo="in nested"
7438                     }
7439                     setopt warn_nested_var
7440                     toplevel
7441
7442   History
7443       APPEND_HISTORY <D>
7444              If  this  is set, zsh sessions will append their history list to
7445              the history file, rather than replace it. Thus, multiple  paral‐
7446              lel  zsh  sessions will all have the new entries from their his‐
7447              tory lists added to the history file, in  the  order  that  they
7448              exit.  The file will still be periodically re-written to trim it
7449              when the number of lines grows 20% beyond the value specified by
7450              $SAVEHIST (see also the HIST_SAVE_BY_COPY option).
7451
7452       BANG_HIST (+K) <C> <Z>
7453              Perform textual history expansion, csh-style, treating the char‐
7454              acter `!' specially.
7455
7456       EXTENDED_HISTORY <C>
7457              Save each command's beginning timestamp (in  seconds  since  the
7458              epoch)  and  the duration (in seconds) to the history file.  The
7459              format of this prefixed data is:
7460
7461              `: <beginning time>:<elapsed seconds>;<command>'.
7462
7463       HIST_ALLOW_CLOBBER
7464              Add `|' to output redirections in the history.  This allows his‐
7465              tory references to clobber files even when CLOBBER is unset.
7466
7467       HIST_BEEP <D>
7468              Beep  in  ZLE  when  a widget attempts to access a history entry
7469              which isn't there.
7470
7471       HIST_EXPIRE_DUPS_FIRST
7472              If the internal history needs to be trimmed to add  the  current
7473              command  line, setting this option will cause the oldest history
7474              event that has a duplicate to be lost  before  losing  a  unique
7475              event  from  the  list.   You should be sure to set the value of
7476              HISTSIZE to a larger number than SAVEHIST in order to  give  you
7477              some  room for the duplicated events, otherwise this option will
7478              behave just like HIST_IGNORE_ALL_DUPS once the history fills  up
7479              with unique events.
7480
7481       HIST_FCNTL_LOCK
7482              When  writing  out  the history file, by default zsh uses ad-hoc
7483              file locking to avoid known problems with locking on some  oper‐
7484              ating systems.  With this option locking is done by means of the
7485              system's fcntl call, where this method is available.  On  recent
7486              operating  systems  this may provide better performance, in par‐
7487              ticular avoiding history corruption when  files  are  stored  on
7488              NFS.
7489
7490       HIST_FIND_NO_DUPS
7491              When  searching  for  history entries in the line editor, do not
7492              display duplicates of a line previously found, even if  the  du‐
7493              plicates are not contiguous.
7494
7495       HIST_IGNORE_ALL_DUPS
7496              If a new command line being added to the history list duplicates
7497              an older one, the older command is removed from the  list  (even
7498              if it is not the previous event).
7499
7500       HIST_IGNORE_DUPS (-h)
7501              Do not enter command lines into the history list if they are du‐
7502              plicates of the previous event.
7503
7504       HIST_IGNORE_SPACE (-g)
7505              Remove command lines from the history list when the first  char‐
7506              acter  on  the  line  is  a  space,  or when one of the expanded
7507              aliases contains a leading  space.   Only  normal  aliases  (not
7508              global  or  suffix  aliases) have this behaviour.  Note that the
7509              command lingers in the internal history until the  next  command
7510              is  entered before it vanishes, allowing you to briefly reuse or
7511              edit the line.  If you want to make it vanish right away without
7512              entering another command, type a space and press return.
7513
7514       HIST_LEX_WORDS
7515              By  default,  shell  history that is read in from files is split
7516              into words on all white space.  This means that  arguments  with
7517              quoted  whitespace  are  not  correctly handled, with the conse‐
7518              quence that references to words in history lines that have  been
7519              read  from  a  file may be inaccurate.  When this option is set,
7520              words read in from a history file are divided up  in  a  similar
7521              fashion  to  normal  shell command line handling.  Although this
7522              produces more accurately delimited words, if  the  size  of  the
7523              history file is large this can be slow.  Trial and error is nec‐
7524              essary to decide.
7525
7526       HIST_NO_FUNCTIONS
7527              Remove function definitions from the history  list.   Note  that
7528              the function lingers in the internal history until the next com‐
7529              mand is entered before it vanishes, allowing you to briefly  re‐
7530              use or edit the definition.
7531
7532       HIST_NO_STORE
7533              Remove  the  history  (fc -l) command from the history list when
7534              invoked.  Note that the command lingers in the internal  history
7535              until  the  next command is entered before it vanishes, allowing
7536              you to briefly reuse or edit the line.
7537
7538       HIST_REDUCE_BLANKS
7539              Remove superfluous blanks from each command line being added  to
7540              the history list.
7541
7542       HIST_SAVE_BY_COPY <D>
7543              When  the  history  file  is re-written, we normally write out a
7544              copy of the file named $HISTFILE.new and then rename it over the
7545              old  one.  However, if this option is unset, we instead truncate
7546              the old history file and write out the new version in-place.  If
7547              one  of  the  history-appending  options is enabled, this option
7548              only has an effect when the enlarged history file  needs  to  be
7549              re-written  to  trim  it down to size.  Disable this only if you
7550              have special needs, as doing so makes it possible to  lose  his‐
7551              tory entries if zsh gets interrupted during the save.
7552
7553              When  writing  out a copy of the history file, zsh preserves the
7554              old file's permissions and group information, but will refuse to
7555              write  out  a  new  file  if  it would change the history file's
7556              owner.
7557
7558       HIST_SAVE_NO_DUPS
7559              When writing out the history file, older commands that duplicate
7560              newer ones are omitted.
7561
7562       HIST_VERIFY
7563              Whenever  the  user  enters a line with history expansion, don't
7564              execute the line directly; instead,  perform  history  expansion
7565              and reload the line into the editing buffer.
7566
7567       INC_APPEND_HISTORY
7568              This  option  works  like APPEND_HISTORY except that new history
7569              lines are added to the $HISTFILE incrementally (as soon as  they
7570              are  entered),  rather  than waiting until the shell exits.  The
7571              file will still be periodically re-written to trim it  when  the
7572              number  of  lines grows 20% beyond the value specified by $SAVE‐
7573              HIST (see also the HIST_SAVE_BY_COPY option).
7574
7575       INC_APPEND_HISTORY_TIME
7576              This option is a variant of INC_APPEND_HISTORY in  which,  where
7577              possible, the history entry is written out to the file after the
7578              command is finished, so that the time taken by  the  command  is
7579              recorded  correctly in the history file in EXTENDED_HISTORY for‐
7580              mat.  This means that the history entry will  not  be  available
7581              immediately from other instances of the shell that are using the
7582              same history file.
7583
7584              This option is only useful if INC_APPEND_HISTORY and  SHARE_HIS‐
7585              TORY are turned off.  The three options should be considered mu‐
7586              tually exclusive.
7587
7588       SHARE_HISTORY <K>
7589
7590              This option both imports new commands from the history file, and
7591              also  causes  your  typed commands to be appended to the history
7592              file (the latter is like  specifying  INC_APPEND_HISTORY,  which
7593              should  be turned off if this option is in effect).  The history
7594              lines are  also  output  with  timestamps  ala  EXTENDED_HISTORY
7595              (which  makes it easier to find the spot where we left off read‐
7596              ing the file after it gets re-written).
7597
7598              By default, history movement commands visit the  imported  lines
7599              as  well  as the local lines, but you can toggle this on and off
7600              with the set-local-history zle binding.  It is also possible  to
7601              create a zle widget that will make some commands ignore imported
7602              commands, and some include them.
7603
7604              If you find that you want more control over  when  commands  get
7605              imported,  you  may  wish  to  turn  SHARE_HISTORY  off, INC_AP‐
7606              PEND_HISTORY or INC_APPEND_HISTORY_TIME (see above) on, and then
7607              manually import commands whenever you need them using `fc -RI'.
7608
7609   Initialisation
7610       ALL_EXPORT (-a, ksh: -a)
7611              All parameters subsequently defined are automatically exported.
7612
7613       GLOBAL_EXPORT <Z>
7614              If  this  option is set, passing the -x flag to the builtins de‐
7615              clare, float, integer, readonly and typeset (but not local) will
7616              also set the -g flag;  hence parameters exported to the environ‐
7617              ment will not be made local to the  enclosing  function,  unless
7618              they  were  already  or the flag +g is given explicitly.  If the
7619              option is unset, exported parameters will be made local in  just
7620              the same way as any other parameter.
7621
7622              This  option is set by default for backward compatibility; it is
7623              not recommended that its behaviour be relied  upon.   Note  that
7624              the  builtin  export  always  sets both the -x and -g flags, and
7625              hence its effect extends beyond the scope of the enclosing func‐
7626              tion; this is the most portable way to achieve this behaviour.
7627
7628       GLOBAL_RCS (-d) <D>
7629              If  this  option  is  unset,  the  startup  files /etc/zprofile,
7630              /etc/zshrc, /etc/zlogin and /etc/zlogout will not  be  run.   It
7631              can be disabled and re-enabled at any time, including inside lo‐
7632              cal startup files (.zshrc, etc.).
7633
7634       RCS (+f) <D>
7635              After /etc/zshenv is sourced on  startup,  source  the  .zshenv,
7636              /etc/zprofile, .zprofile, /etc/zshrc, .zshrc, /etc/zlogin, .zlo‐
7637              gin, and .zlogout files, as described in  the  section  `Files'.
7638              If  this option is unset, the /etc/zshenv file is still sourced,
7639              but any of the others will not be; it can be set at any time  to
7640              prevent  the remaining startup files after the currently execut‐
7641              ing one from being sourced.
7642
7643   Input/Output
7644       ALIASES <D>
7645              Expand aliases.
7646
7647       CLOBBER (+C, ksh: +C) <D>
7648              Allows `>' redirection to truncate  existing  files.   Otherwise
7649              `>!' or `>|' must be used to truncate a file.
7650
7651              If  the  option is not set, and the option APPEND_CREATE is also
7652              not set, `>>!' or `>>|' must be used to create a file.   If  ei‐
7653              ther option is set, `>>' may be used.
7654
7655       CORRECT (-0)
7656              Try  to  correct  the spelling of commands.  Note that, when the
7657              HASH_LIST_ALL option is not set or when some directories in  the
7658              path  are  not readable, this may falsely report spelling errors
7659              the first time some commands are used.
7660
7661              The shell variable CORRECT_IGNORE may be set  to  a  pattern  to
7662              match words that will never be offered as corrections.
7663
7664       CORRECT_ALL (-O)
7665              Try to correct the spelling of all arguments in a line.
7666
7667              The  shell  variable CORRECT_IGNORE_FILE may be set to a pattern
7668              to match file names that will never be offered as corrections.
7669
7670       DVORAK Use the Dvorak keyboard instead of the standard qwerty  keyboard
7671              as  a  basis for examining spelling mistakes for the CORRECT and
7672              CORRECT_ALL options and the spell-word editor command.
7673
7674       FLOW_CONTROL <D>
7675              If this option is unset,  output  flow  control  via  start/stop
7676              characters  (usually  assigned  to  ^S/^Q)  is  disabled  in the
7677              shell's editor.
7678
7679       IGNORE_EOF (-7)
7680              Do not exit on end-of-file.  Require the use of exit  or  logout
7681              instead.   However, ten consecutive EOFs will cause the shell to
7682              exit anyway, to avoid the shell hanging if its tty goes away.
7683
7684              Also, if this option is set and the Zsh  Line  Editor  is  used,
7685              widgets implemented by shell functions can be bound to EOF (nor‐
7686              mally Control-D) without printing the  normal  warning  message.
7687              This works only for normal widgets, not for completion widgets.
7688
7689       INTERACTIVE_COMMENTS (-k) <K> <S>
7690              Allow comments even in interactive shells.
7691
7692       HASH_CMDS <D>
7693              Note the location of each command the first time it is executed.
7694              Subsequent invocations of the same command will  use  the  saved
7695              location,  avoiding  a path search.  If this option is unset, no
7696              path hashing is done at all.  However, when CORRECT is set, com‐
7697              mands whose names do not appear in the functions or aliases hash
7698              tables are hashed in order to avoid reporting them  as  spelling
7699              errors.
7700
7701       HASH_DIRS <D>
7702              Whenever a command name is hashed, hash the directory containing
7703              it, as well as all directories that occur earlier in  the  path.
7704              Has no effect if neither HASH_CMDS nor CORRECT is set.
7705
7706       HASH_EXECUTABLES_ONLY
7707              When  hashing commands because of HASH_CMDS, check that the file
7708              to be hashed is actually an executable.  This option is unset by
7709              default  as  if the path contains a large number of commands, or
7710              consists of many remote files, the additional tests can  take  a
7711              long  time.  Trial and error is needed to show if this option is
7712              beneficial.
7713
7714       MAIL_WARNING (-U)
7715              Print a warning message if a mail file has been  accessed  since
7716              the shell last checked.
7717
7718       PATH_DIRS (-Q)
7719              Perform  a  path  search  even  on command names with slashes in
7720              them.  Thus if `/usr/local/bin' is in the user's path, and he or
7721              she  types  `X11/xinit',  the command `/usr/local/bin/X11/xinit'
7722              will be executed (assuming it exists).  Commands explicitly  be‐
7723              ginning  with  `/',  `./'  or  `../' are not subject to the path
7724              search.  This also applies to the `.' and source builtins.
7725
7726              Note that subdirectories of the  current  directory  are  always
7727              searched  for  executables  specified  in this form.  This takes
7728              place before any search indicated by this option, and regardless
7729              of  whether  `.'  or the current directory appear in the command
7730              search path.
7731
7732       PATH_SCRIPT <K> <S>
7733              If this option is not set, a script passed as the first  non-op‐
7734              tion  argument to the shell must contain the name of the file to
7735              open.  If this option is set, and the script does not specify  a
7736              directory  path,  the  script is looked for first in the current
7737              directory, then in the command path.  See the section INVOCATION
7738              in zsh(1).
7739
7740       PRINT_EIGHT_BIT
7741              Print  eight  bit characters literally in completion lists, etc.
7742              This option is not necessary if your  system  correctly  returns
7743              the printability of eight bit characters (see ctype(3)).
7744
7745       PRINT_EXIT_VALUE (-1)
7746              Print  the  exit  value  of  programs with non-zero exit status.
7747              This is only  available  at  the  command  line  in  interactive
7748              shells.
7749
7750       RC_QUOTES
7751              Allow  the  character  sequence  `'''  to signify a single quote
7752              within singly quoted strings.   Note  this  does  not  apply  in
7753              quoted strings using the format $'...', where a backslashed sin‐
7754              gle quote can be used.
7755
7756       RM_STAR_SILENT (-H) <K> <S>
7757              Do not query the user before executing `rm *' or `rm path/*'.
7758
7759       RM_STAR_WAIT
7760              If querying the user before executing `rm  *'  or  `rm  path/*',
7761              first  wait  ten seconds and ignore anything typed in that time.
7762              This avoids the problem of reflexively answering  `yes'  to  the
7763              query  when  one  didn't really mean it.  The wait and query can
7764              always be avoided by expanding the `*' in ZLE (with tab).
7765
7766       SHORT_LOOPS <C> <Z>
7767              Allow the short forms of for, repeat, select, if,  and  function
7768              constructs.
7769
7770       SUN_KEYBOARD_HACK (-L)
7771              If  a line ends with a backquote, and there are an odd number of
7772              backquotes on the line, ignore the trailing backquote.  This  is
7773              useful  on some keyboards where the return key is too small, and
7774              the backquote key lies annoyingly close to it.  As  an  alterna‐
7775              tive the variable KEYBOARD_HACK lets you choose the character to
7776              be removed.
7777
7778   Job Control
7779       AUTO_CONTINUE
7780              With this option set, stopped jobs that are removed from the job
7781              table  with  the disown builtin command are automatically sent a
7782              CONT signal to make them running.
7783
7784       AUTO_RESUME (-W)
7785              Treat single word simple commands without redirection as  candi‐
7786              dates for resumption of an existing job.
7787
7788       BG_NICE (-6) <C> <Z>
7789              Run all background jobs at a lower priority.  This option is set
7790              by default.
7791
7792       CHECK_JOBS <Z>
7793              Report the status of background and suspended jobs before  exit‐
7794              ing a shell with job control; a second attempt to exit the shell
7795              will succeed.  NO_CHECK_JOBS is best used  only  in  combination
7796              with NO_HUP, else such jobs will be killed automatically.
7797
7798              The  check is omitted if the commands run from the previous com‐
7799              mand line included a `jobs' command, since  it  is  assumed  the
7800              user  is  aware  that there are background or suspended jobs.  A
7801              `jobs' command run from one of the hook functions defined in the
7802              section  SPECIAL FUNCTIONS in zshmisc(1) is not counted for this
7803              purpose.
7804
7805       CHECK_RUNNING_JOBS <Z>
7806              Check for both running and suspended jobs when CHECK_JOBS is en‐
7807              abled.   When  this option is disabled, zsh checks only for sus‐
7808              pended jobs, which matches the default behavior of bash.
7809
7810              This option has no effect unless CHECK_JOBS is set.
7811
7812       HUP <Z>
7813              Send the HUP signal to running jobs when the shell exits.
7814
7815       LONG_LIST_JOBS (-R)
7816              Print job notifications in the long format by default.
7817
7818       MONITOR (-m, ksh: -m)
7819              Allow job control.  Set by default in interactive shells.
7820
7821       NOTIFY (-5, ksh: -b) <Z>
7822              Report the status of background jobs  immediately,  rather  than
7823              waiting until just before printing a prompt.
7824
7825       POSIX_JOBS <K> <S>
7826              This  option  makes  job  control  more compliant with the POSIX
7827              standard.
7828
7829              When the option is not set, the MONITOR option is unset on entry
7830              to subshells, so that job control is no longer active.  When the
7831              option is set, the MONITOR option and job control remain  active
7832              in  the  subshell,  but  note that the subshell has no access to
7833              jobs in the parent shell.
7834
7835              When the option is not set, jobs put in the background or  fore‐
7836              ground  with  bg  or  fg are displayed with the same information
7837              that would be reported by jobs.  When the option  is  set,  only
7838              the  text  is  printed.   The output from jobs itself is not af‐
7839              fected by the option.
7840
7841              When the option is not set,  job  information  from  the  parent
7842              shell is saved for output within a subshell (for example, within
7843              a pipeline).  When the option is set,  the  output  of  jobs  is
7844              empty until a job is started within the subshell.
7845
7846              In  previous  versions  of the shell, it was necessary to enable
7847              POSIX_JOBS in order for the builtin command wait to  return  the
7848              status  of  background jobs that had already exited.  This is no
7849              longer the case.
7850
7851   Prompting
7852       PROMPT_BANG <K>
7853              If set, `!' is treated specially in prompt expansion.   See  EX‐
7854              PANSION OF PROMPT SEQUENCES in zshmisc(1).
7855
7856       PROMPT_CR (+V) <D>
7857              Print  a  carriage  return  just before printing a prompt in the
7858              line editor.  This is on by default  as  multi-line  editing  is
7859              only  possible  if  the editor knows where the start of the line
7860              appears.
7861
7862       PROMPT_SP <D>
7863              Attempt to preserve a partial line (i.e. a line that did not end
7864              with  a  newline) that would otherwise be covered up by the com‐
7865              mand prompt due to the PROMPT_CR option.   This  works  by  out‐
7866              putting  some  cursor-control  characters, including a series of
7867              spaces, that should make the terminal wrap to the next line when
7868              a  partial line is present (note that this is only successful if
7869              your terminal has automatic margins, which is typical).
7870
7871              When a partial line is preserved, by default you will see an in‐
7872              verse+bold  character at the end of the partial line:  a `%' for
7873              a normal user or a `#' for root.  If set,  the  shell  parameter
7874              PROMPT_EOL_MARK  can be used to customize how the end of partial
7875              lines are shown.
7876
7877              NOTE: if the PROMPT_CR option is not set, enabling  this  option
7878              will have no effect.  This option is on by default.
7879
7880       PROMPT_PERCENT <C> <Z>
7881              If  set,  `%' is treated specially in prompt expansion.  See EX‐
7882              PANSION OF PROMPT SEQUENCES in zshmisc(1).
7883
7884       PROMPT_SUBST <K> <S>
7885              If set, parameter expansion, command substitution and arithmetic
7886              expansion   are  performed  in  prompts.   Substitutions  within
7887              prompts do not affect the command status.
7888
7889       TRANSIENT_RPROMPT
7890              Remove any right prompt from display when  accepting  a  command
7891              line.   This  may  be useful with terminals with other cut/paste
7892              methods.
7893
7894   Scripts and Functions
7895       ALIAS_FUNC_DEF <S>
7896              By default, zsh does not allow the definition of functions using
7897              the  `name  ()'  syntax  if  name was expanded as an alias: this
7898              causes an error.  This is usually the desired behaviour, as oth‐
7899              erwise  the  combination of an alias and a function based on the
7900              same definition can easily cause problems.
7901
7902              When this option is set, aliases can be used for defining  func‐
7903              tions.
7904
7905              For  example,  consider  the following definitions as they might
7906              occur in a startup file.
7907
7908                     alias foo=bar
7909                     foo() {
7910                       print This probably does not do what you expect.
7911                     }
7912
7913              Here, foo is expanded as an alias to bar before the  ()  is  en‐
7914              countered,  so  the function defined would be named bar.  By de‐
7915              fault this is instead an error in native mode.  Note that  quot‐
7916              ing  any  part  of the function name, or using the keyword func‐
7917              tion, avoids the problem, so is recommended  when  the  function
7918              name can also be an alias.
7919
7920       C_BASES
7921              Output hexadecimal numbers in the standard C format, for example
7922              `0xFF' instead of the usual `16#FF'.  If the option OCTAL_ZEROES
7923              is  also  set  (it  is  not  by  default), octal numbers will be
7924              treated similarly and hence appear as `077' instead  of  `8#77'.
7925              This  option has no effect on the choice of the output base, nor
7926              on the output of bases other than hexadecimal and  octal.   Note
7927              that  these  formats will be understood on input irrespective of
7928              the setting of C_BASES.
7929
7930       C_PRECEDENCES
7931              This alters the precedence of arithmetic operators  to  be  more
7932              like  C  and other programming languages; the section ARITHMETIC
7933              EVALUATION in zshmisc(1) has an explicit list.
7934
7935       DEBUG_BEFORE_CMD <D>
7936              Run the DEBUG trap before each command; otherwise it is run  af‐
7937              ter  each  command.  Setting this option mimics the behaviour of
7938              ksh 93; with the option unset the behaviour is that of ksh 88.
7939
7940       ERR_EXIT (-e, ksh: -e)
7941              If a command has a non-zero exit status, execute the ZERR  trap,
7942              if set, and exit.  This is disabled while running initialization
7943              scripts.
7944
7945              The behaviour is also disabled inside DEBUG traps.  In this case
7946              the  option  is  handled  specially: it is unset on entry to the
7947              trap.  If the option DEBUG_BEFORE_CMD is set, as it  is  by  de‐
7948              fault,  and  the  option  ERR_EXIT  is found to have been set on
7949              exit, then the command for which the DEBUG trap  is  being  exe‐
7950              cuted is skipped.  The option is restored after the trap exits.
7951
7952              Non-zero status in a command list containing && or || is ignored
7953              for commands not at the end of the list.  Hence
7954
7955                     false && true
7956
7957              does not trigger exit.
7958
7959              Exiting due to ERR_EXIT has certain interactions with  asynchro‐
7960              nous jobs noted in the section JOBS in zshmisc(1).
7961
7962       ERR_RETURN
7963              If a command has a non-zero exit status, return immediately from
7964              the enclosing function.   The  logic  is  similar  to  that  for
7965              ERR_EXIT,  except  that an implicit return statement is executed
7966              instead of an exit.  This will trigger an exit at the  outermost
7967              level of a non-interactive script.
7968
7969              Normally  this  option  inherits  the behaviour of ERR_EXIT that
7970              code followed by `&&' `||' does not trigger a return.  Hence  in
7971              the following:
7972
7973                     summit || true
7974
7975              no return is forced as the combined effect always has a zero re‐
7976              turn status.
7977
7978              Note. however, that if summit in the above example is  itself  a
7979              function,  code inside it is considered separately: it may force
7980              a return from summit (assuming the  option  remains  set  within
7981              summit),  but not from the enclosing context.  This behaviour is
7982              different from ERR_EXIT which is unaffected by function scope.
7983
7984       EVAL_LINENO <Z>
7985              If set, line numbers of expressions evaluated using the  builtin
7986              eval  are tracked separately of the enclosing environment.  This
7987              applies both to the parameter LINENO and the line number  output
7988              by  the  prompt escape %i.  If the option is set, the prompt es‐
7989              cape %N will output the string `(eval)' instead of the script or
7990              function  name  as  an indication.   (The two prompt escapes are
7991              typically used in the parameter PS4 to be output when the option
7992              XTRACE is set.)  If EVAL_LINENO is unset, the line number of the
7993              surrounding script or function is retained  during  the  evalua‐
7994              tion.
7995
7996       EXEC (+n, ksh: +n) <D>
7997              Do execute commands.  Without this option, commands are read and
7998              checked for syntax errors, but not executed.  This option cannot
7999              be  turned off in an interactive shell, except when `-n' is sup‐
8000              plied to the shell at startup.
8001
8002       FUNCTION_ARGZERO <C> <Z>
8003              When executing a shell function or sourcing  a  script,  set  $0
8004              temporarily  to the name of the function/script.  Note that tog‐
8005              gling FUNCTION_ARGZERO from on to off (or off to  on)  does  not
8006              change  the  current  value of $0.  Only the state upon entry to
8007              the function or script has an effect.  Compare POSIX_ARGZERO.
8008
8009       LOCAL_LOOPS
8010              When this option is not set, the effect of  break  and  continue
8011              commands  may  propagate outside function scope, affecting loops
8012              in calling functions.  When the option is set in a calling func‐
8013              tion,  a  break or a continue that is not caught within a called
8014              function (regardless of the setting of the  option  within  that
8015              function) produces a warning and the effect is cancelled.
8016
8017       LOCAL_OPTIONS <K>
8018              If  this option is set at the point of return from a shell func‐
8019              tion, most options (including this one) which were in force upon
8020              entry  to  the  function  are restored; options that are not re‐
8021              stored are PRIVILEGED and RESTRICTED.  Otherwise, only this  op‐
8022              tion,  and  the LOCAL_LOOPS, XTRACE and PRINT_EXIT_VALUE options
8023              are restored.  Hence if this is  explicitly  unset  by  a  shell
8024              function  the other options in force at the point of return will
8025              remain so.  A shell function can also guarantee itself  a  known
8026              shell  configuration  with  a formulation like `emulate -L zsh';
8027              the -L activates LOCAL_OPTIONS.
8028
8029       LOCAL_PATTERNS
8030              If this option is set at the point of return from a shell  func‐
8031              tion,  the  state  of  pattern disables, as set with the builtin
8032              command `disable -p', is restored to what it was when the  func‐
8033              tion  was  entered.   The behaviour of this option is similar to
8034              the effect of LOCAL_OPTIONS on options; hence  `emulate  -L  sh'
8035              (or indeed any other emulation with the -L option) activates LO‐
8036              CAL_PATTERNS.
8037
8038       LOCAL_TRAPS <K>
8039              If this option is set when a signal trap is set inside  a  func‐
8040              tion,  then the previous status of the trap for that signal will
8041              be restored when the function exits.  Note that this option must
8042              be  set  prior to altering the trap behaviour in a function; un‐
8043              like LOCAL_OPTIONS, the value on exit from the function  is  ir‐
8044              relevant.  However, it does not need to be set before any global
8045              trap for that to be correctly restored by a function.  For exam‐
8046              ple,
8047
8048                     unsetopt localtraps
8049                     trap - INT
8050                     fn() { setopt localtraps; trap '' INT; sleep 3; }
8051
8052              will restore normal handling of SIGINT after the function exits.
8053
8054       MULTI_FUNC_DEF <Z>
8055              Allow definitions of multiple functions at once in the form `fn1
8056              fn2...()'; if the option is not set, this causes a parse  error.
8057              Definition  of  multiple  functions with the function keyword is
8058              always allowed.  Multiple function  definitions  are  not  often
8059              used and can cause obscure errors.
8060
8061       MULTIOS <Z>
8062              Perform implicit tees or cats when multiple redirections are at‐
8063              tempted (see the section `Redirection').
8064
8065       OCTAL_ZEROES <S>
8066              Interpret any integer constant beginning with a 0 as octal,  per
8067              IEEE  Std 1003.2-1992 (ISO 9945-2:1993).  This is not enabled by
8068              default as it causes problems with parsing of, for example, date
8069              and time strings with leading zeroes.
8070
8071              Sequences  of  digits indicating a numeric base such as the `08'
8072              component in `08#77' are always interpreted as decimal,  regard‐
8073              less of leading zeroes.
8074
8075       PIPE_FAIL
8076              By  default,  when  a pipeline exits the exit status recorded by
8077              the shell and returned by the shell variable $? reflects that of
8078              the rightmost element of a pipeline.  If this option is set, the
8079              exit status instead reflects the status of the rightmost element
8080              of  the  pipeline that was non-zero, or zero if all elements ex‐
8081              ited with zero status.
8082
8083       SOURCE_TRACE
8084              If set, zsh will print an informational message  announcing  the
8085              name of each file it loads.  The format of the output is similar
8086              to that for the XTRACE option, with the  message  <sourcetrace>.
8087              A  file  may be loaded by the shell itself when it starts up and
8088              shuts down  (Startup/Shutdown  Files)  or  by  the  use  of  the
8089              `source' and `dot' builtin commands.
8090
8091       TYPESET_SILENT
8092              If  this is unset, executing any of the `typeset' family of com‐
8093              mands with no options and a list of parameters that have no val‐
8094              ues  to  be assigned but already exist will display the value of
8095              the parameter.  If the option is set, they will  only  be  shown
8096              when  parameters  are selected with the `-m' option.  The option
8097              `-p' is available whether or not the option is set.
8098
8099       VERBOSE (-v, ksh: -v)
8100              Print shell input lines as they are read.
8101
8102       XTRACE (-x, ksh: -x)
8103              Print commands and their arguments as they  are  executed.   The
8104              output  is preceded by the value of $PS4, formatted as described
8105              in the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1).
8106
8107   Shell Emulation
8108       APPEND_CREATE <K> <S>
8109              This option only applies when NO_CLOBBER (-C) is in effect.
8110
8111              If this option is not set, the shell will report an error when a
8112              append  redirection (>>) is used on a file that does not already
8113              exists (the traditional zsh behaviour of  NO_CLOBBER).   If  the
8114              option is set, no error is reported (POSIX behaviour).
8115
8116       BASH_REMATCH
8117              When  set,  matches  performed with the =~ operator will set the
8118              BASH_REMATCH array variable, instead of the  default  MATCH  and
8119              match  variables.   The  first element of the BASH_REMATCH array
8120              will contain the entire matched  text  and  subsequent  elements
8121              will contain extracted substrings.  This option makes more sense
8122              when KSH_ARRAYS is also set, so that the entire matched  portion
8123              is  stored  at  index  0  and the first substring is at index 1.
8124              Without this option, the  MATCH  variable  contains  the  entire
8125              matched text and the match array variable contains substrings.
8126
8127       BSD_ECHO <S>
8128              Make  the  echo builtin compatible with the BSD echo(1) command.
8129              This disables backslashed escape sequences in echo  strings  un‐
8130              less the -e option is specified.
8131
8132       CONTINUE_ON_ERROR
8133              If  a fatal error is encountered (see the section ERRORS in zsh‐
8134              misc(1)), and the code is running in a script,  the  shell  will
8135              resume  execution at the next statement in the script at the top
8136              level, in other words outside all functions or shell  constructs
8137              such  as loops and conditions.  This mimics the behaviour of in‐
8138              teractive shells, where the shell returns to the line editor  to
8139              read  a  new command; it was the normal behaviour in versions of
8140              zsh before 5.0.1.
8141
8142       CSH_JUNKIE_HISTORY <C>
8143              A history reference without an event specifier will always refer
8144              to  the  previous  command.  Without this option, such a history
8145              reference refers to the same event as the previous history  ref‐
8146              erence  on  the current command line, defaulting to the previous
8147              command.
8148
8149       CSH_JUNKIE_LOOPS <C>
8150              Allow loop bodies to take the form `list; end'  instead  of  `do
8151              list; done'.
8152
8153       CSH_JUNKIE_QUOTES <C>
8154              Changes  the  rules  for single- and double-quoted text to match
8155              that of csh.  These require that embedded newlines  be  preceded
8156              by  a backslash; unescaped newlines will cause an error message.
8157              In double-quoted strings, it is made impossible to  escape  `$',
8158              ``'  or  `"' (and `\' itself no longer needs escaping).  Command
8159              substitutions are only expanded once, and cannot be nested.
8160
8161       CSH_NULLCMD <C>
8162              Do not use the values of NULLCMD and  READNULLCMD  when  running
8163              redirections  with no command.  This make such redirections fail
8164              (see the section `Redirection').
8165
8166       KSH_ARRAYS <K> <S>
8167              Emulate ksh array handling as closely as possible.  If this  op‐
8168              tion is set, array elements are numbered from zero, an array pa‐
8169              rameter without subscript refers to the first element instead of
8170              the  whole array, and braces are required to delimit a subscript
8171              (`${path[2]}' rather than just `$path[2]') or to apply modifiers
8172              to any parameter (`${PWD:h}' rather than `$PWD:h').
8173
8174       KSH_AUTOLOAD <K> <S>
8175              Emulate  ksh function autoloading.  This means that when a func‐
8176              tion is autoloaded, the corresponding file is  merely  executed,
8177              and  must define the function itself.  (By default, the function
8178              is defined to the contents of the file.  However, the most  com‐
8179              mon  ksh-style case - of the file containing only a simple defi‐
8180              nition of the function - is always handled in the ksh-compatible
8181              manner.)
8182
8183       KSH_OPTION_PRINT <K>
8184              Alters the way options settings are printed: instead of separate
8185              lists of set and unset options, all options  are  shown,  marked
8186              `on' if they are in the non-default state, `off' otherwise.
8187
8188       KSH_TYPESET
8189              This  option is now obsolete: a better appropximation to the be‐
8190              haviour of other shells is obtained with the reserved  word  in‐
8191              terface  to declare, export, float, integer, local, readonly and
8192              typeset.  Note that the option is only applied when the reserved
8193              word interface is not in use.
8194
8195              Alters  the way arguments to the typeset family of commands, in‐
8196              cluding declare, export, float, integer, local and readonly, are
8197              processed.   Without  this  option, zsh will perform normal word
8198              splitting after command and parameter expansion in arguments  of
8199              an  assignment;  with  it, word splitting does not take place in
8200              those cases.
8201
8202       KSH_ZERO_SUBSCRIPT
8203              Treat use of a subscript of value zero in array  or  string  ex‐
8204              pressions  as a reference to the first element, i.e. the element
8205              that usually has the subscript 1.  Ignored if KSH_ARRAYS is also
8206              set.
8207
8208              If neither this option nor KSH_ARRAYS is set, accesses to an el‐
8209              ement of an array or string with subscript zero return an  empty
8210              element  or string, while attempts to set element zero of an ar‐
8211              ray or string are treated as an error.  However, attempts to set
8212              an  otherwise valid subscript range that includes zero will suc‐
8213              ceed.  For example, if KSH_ZERO_SUBSCRIPT is not set,
8214
8215                     array[0]=(element)
8216
8217              is an error, while
8218
8219                     array[0,1]=(element)
8220
8221              is not and will replace the first element of the array.
8222
8223              This option is for compatibility  with  older  versions  of  the
8224              shell and is not recommended in new code.
8225
8226       POSIX_ALIASES <K> <S>
8227              When  this  option is set, reserved words are not candidates for
8228              alias expansion:  it is still possible to declare any of them as
8229              an  alias, but the alias will never be expanded.  Reserved words
8230              are described in the section RESERVED WORDS in zshmisc(1).
8231
8232              Alias expansion takes place while text is being read; hence when
8233              this  option is set it does not take effect until the end of any
8234              function or other piece of shell code parsed as one unit.   Note
8235              this  may  cause differences from other shells even when the op‐
8236              tion is in effect.  For example, when  running  a  command  with
8237              `zsh  -c',  or even `zsh -o posixaliases -c', the entire command
8238              argument is parsed as one unit, so aliases  defined  within  the
8239              argument  are  not  available even in later lines.  If in doubt,
8240              avoid use of aliases in non-interactive code.
8241
8242       POSIX_ARGZERO
8243              This option may be used to temporarily disable  FUNCTION_ARGZERO
8244              and  thereby  restore the value of $0 to the name used to invoke
8245              the shell (or as set by the -c command line option).   For  com‐
8246              patibility  with  previous versions of the shell, emulations use
8247              NO_FUNCTION_ARGZERO instead of POSIX_ARGZERO, which  may  result
8248              in unexpected scoping of $0 if the emulation mode is changed in‐
8249              side a function or script.  To  avoid  this,  explicitly  enable
8250              POSIX_ARGZERO in the emulate command:
8251
8252                     emulate sh -o POSIX_ARGZERO
8253
8254              Note that NO_POSIX_ARGZERO has no effect unless FUNCTION_ARGZERO
8255              was already enabled upon entry to the function or script.
8256
8257       POSIX_BUILTINS <K> <S>
8258              When this option is set the command builtin can be used to  exe‐
8259              cute  shell  builtin  commands.  Parameter assignments specified
8260              before shell functions and special builtins are kept  after  the
8261              command  completes  unless  the special builtin is prefixed with
8262              the command builtin.  Special builtins are  .,  :,  break,  con‐
8263              tinue,  declare,  eval,  exit, export, integer, local, readonly,
8264              return, set, shift, source, times, trap and unset.
8265
8266              In addition, various error conditions associated with the  above
8267              builtins  or  exec  cause a non-interactive shell to exit and an
8268              interactive shell to return to its top-level processing.
8269
8270              Furthermore, functions and shell builtins are not executed after
8271              an  exec  prefix; the command to be executed must be an external
8272              command found in the path.
8273
8274              Furthermore, the getopts builtin behaves in  a  POSIX-compatible
8275              fashion in that the associated variable OPTIND is not made local
8276              to functions.
8277
8278              Moreover, the warning and special exit code from [[ -o non_exis‐
8279              tent_option ]] are suppressed.
8280
8281       POSIX_IDENTIFIERS <K> <S>
8282              When  this option is set, only the ASCII characters a to z, A to
8283              Z, 0 to 9 and _ may be used in identifiers (names of  shell  pa‐
8284              rameters and modules).
8285
8286              In  addition, setting this option limits the effect of parameter
8287              substitution with no  braces,  so  that  the  expression  $#  is
8288              treated  as the parameter $# even if followed by a valid parame‐
8289              ter name.  When it is unset, zsh allows expressions of the  form
8290              $#name  to  refer to the length of $name, even for special vari‐
8291              ables, for example in expressions such as $#- and $#*.
8292
8293              Another difference is that with the option set assignment to  an
8294              unset  variable  in arithmetic context causes the variable to be
8295              created as a scalar rather than a numeric type.  So after `unset
8296              t;  ((  t  =  3 ))'. without POSIX_IDENTIFIERS set t has integer
8297              type, while with it set it has scalar type.
8298
8299              When the option is unset and multibyte character support is  en‐
8300              abled  (i.e. it is compiled in and the option MULTIBYTE is set),
8301              then additionally any alphanumeric characters in the local char‐
8302              acter  set  may  be  used in identifiers.  Note that scripts and
8303              functions written with this feature are not portable,  and  also
8304              that  both  options must be set before the script or function is
8305              parsed; setting them during execution is not sufficient  as  the
8306              syntax  variable=value  has  already  been  parsed  as a command
8307              rather than an assignment.
8308
8309              If multibyte character support is not compiled  into  the  shell
8310              this  option  is ignored; all octets with the top bit set may be
8311              used in identifiers.  This is non-standard  but  is  the  tradi‐
8312              tional zsh behaviour.
8313
8314       POSIX_STRINGS <K> <S>
8315              This  option affects processing of quoted strings.  Currently it
8316              only affects the behaviour of null characters, i.e. character  0
8317              in the portable character set corresponding to US ASCII.
8318
8319              When  this  option  is  not set, null characters embedded within
8320              strings of the form $'...' are treated as  ordinary  characters.
8321              The  entire  string is maintained within the shell and output to
8322              files where necessary, although owing to restrictions of the li‐
8323              brary interface the string is truncated at the null character in
8324              file names, environment variables, or in arguments  to  external
8325              programs.
8326
8327              When  this  option is set, the $'...' expression is truncated at
8328              the null character.  Note  that  remaining  parts  of  the  same
8329              string beyond the termination of the quotes are not truncated.
8330
8331              For example, the command line argument a$'b\0c'd is treated with
8332              the option off as the characters a, b, null, c, d, and with  the
8333              option on as the characters a, b, d.
8334
8335       POSIX_TRAPS <K> <S>
8336              When  this  option  is set, the usual zsh behaviour of executing
8337              traps for EXIT on exit from shell functions is  suppressed.   In
8338              that case, manipulating EXIT traps always alters the global trap
8339              for exiting the shell; the LOCAL_TRAPS option is ignored for the
8340              EXIT  trap.   Furthermore, a return statement executed in a trap
8341              with no argument passes back from the function  the  value  from
8342              the surrounding context, not from code executed within the trap.
8343
8344       SH_FILE_EXPANSION <K> <S>
8345              Perform  filename expansion (e.g., ~ expansion) before parameter
8346              expansion, command substitution, arithmetic expansion and  brace
8347              expansion.  If this option is unset, it is performed after brace
8348              expansion, so things like `~$USERNAME' and `~{pfalstad,rc}' will
8349              work.
8350
8351       SH_NULLCMD <K> <S>
8352              Do  not  use  the  values  of NULLCMD and READNULLCMD when doing
8353              redirections, use `:' instead (see the section `Redirection').
8354
8355       SH_OPTION_LETTERS <K> <S>
8356              If this option is set the shell tries to interpret single letter
8357              options  (which  are  used  with  set and setopt) like ksh does.
8358              This also affects the value of the - special parameter.
8359
8360       SH_WORD_SPLIT (-y) <K> <S>
8361              Causes field splitting to be performed on unquoted parameter ex‐
8362              pansions.   Note  that  this  option has nothing to do with word
8363              splitting.  (See zshexpn(1).)
8364
8365       TRAPS_ASYNC
8366              While waiting for a program to  exit,  handle  signals  and  run
8367              traps  immediately.   Otherwise  the  trap  is run after a child
8368              process has exited.  Note this does  not  affect  the  point  at
8369              which  traps  are  run for any case other than when the shell is
8370              waiting for a child process.
8371
8372   Shell State
8373       INTERACTIVE (-i, ksh: -i)
8374              This is an interactive shell.  This option is set upon initiali‐
8375              sation  if  the  standard  input is a tty and commands are being
8376              read from standard input.  (See the discussion  of  SHIN_STDIN.)
8377              This  heuristic may be overridden by specifying a state for this
8378              option on the command line.  The value of this option  can  only
8379              be  changed  via  flags supplied at invocation of the shell.  It
8380              cannot be changed once zsh is running.
8381
8382       LOGIN (-l, ksh: -l)
8383              This is a login shell.  If this option is  not  explicitly  set,
8384              the  shell  becomes  a login shell if the first character of the
8385              argv[0] passed to the shell is a `-'.
8386
8387       PRIVILEGED (-p, ksh: -p)
8388              Turn on privileged mode. Typically this is used when  script  is
8389              to  be run with elevated privileges. This should be done as fol‐
8390              lows directly with the -p option to zsh so that it takes  effect
8391              during startup.
8392
8393                     #!/bin/zsh -p
8394
8395              The  option is enabled automatically on startup if the effective
8396              user (group) ID is not equal to the real  user  (group)  ID.  In
8397              this  case, turning the option off causes the effective user and
8398              group IDs to be set to the real user and  group  IDs.  Be  aware
8399              that  if  that fails the shell may be running with different IDs
8400              than was intended so a script should check for failure  and  act
8401              accordingly, for example:
8402
8403                     unsetopt privileged || exit
8404
8405              The  PRIVILEGED option disables sourcing user startup files.  If
8406              zsh  is  invoked  as  `sh'  or  `ksh'  with  this  option   set,
8407              /etc/suid_profile  is sourced (after /etc/profile on interactive
8408              shells). Sourcing ~/.profile is disabled and the contents of the
8409              ENV variable is ignored. This option cannot be changed using the
8410              -m option of setopt and unsetopt, and changing it inside a func‐
8411              tion  always changes it globally regardless of the LOCAL_OPTIONS
8412              option.
8413
8414       RESTRICTED (-r)
8415              Enables restricted mode.  This option cannot  be  changed  using
8416              unsetopt,  and  setting  it  inside a function always changes it
8417              globally regardless of the LOCAL_OPTIONS option.  See  the  sec‐
8418              tion `Restricted Shell'.
8419
8420       SHIN_STDIN (-s, ksh: -s)
8421              Commands  are  being read from the standard input.  Commands are
8422              read from standard input if no command is specified with -c  and
8423              no  file of commands is specified.  If SHIN_STDIN is set explic‐
8424              itly on the command line, any argument that would otherwise have
8425              been  taken as a file to run will instead be treated as a normal
8426              positional parameter.  Note that setting or unsetting  this  op‐
8427              tion  on  the command line does not necessarily affect the state
8428              the option will have while the shell is running - that is purely
8429              an  indicator of whether or not commands are actually being read
8430              from standard input.  The value  of  this  option  can  only  be
8431              changed  via flags supplied at invocation of the shell.  It can‐
8432              not be changed once zsh is running.
8433
8434       SINGLE_COMMAND (-t, ksh: -t)
8435              If the shell is reading from standard input, it  exits  after  a
8436              single  command  has  been  executed.  This also makes the shell
8437              non-interactive, unless the INTERACTIVE option is explicitly set
8438              on  the  command  line.   The  value  of this option can only be
8439              changed via flags supplied at invocation of the shell.  It  can‐
8440              not be changed once zsh is running.
8441
8442   Zle
8443       BEEP (+B) <D>
8444              Beep on error in ZLE.
8445
8446       COMBINING_CHARS
8447              Assume  that  the  terminal  displays  combining characters cor‐
8448              rectly.  Specifically, if a base alphanumeric character is  fol‐
8449              lowed  by  one or more zero-width punctuation characters, assume
8450              that the zero-width characters will be  displayed  as  modifica‐
8451              tions to the base character within the same width.  Not all ter‐
8452              minals handle this.  If this option is not set, zero-width char‐
8453              acters are displayed separately with special mark-up.
8454
8455              If  this  option  is  set, the pattern test [[:WORD:]] matches a
8456              zero-width punctuation character on the assumption that it  will
8457              be  used as part of a word in combination with a word character.
8458              Otherwise the base shell does not  handle  combining  characters
8459              specially.
8460
8461       EMACS  If  ZLE is loaded, turning on this option has the equivalent ef‐
8462              fect of `bindkey -e'.  In addition,  the  VI  option  is  unset.
8463              Turning it off has no effect.  The option setting is not guaran‐
8464              teed to reflect the current keymap.  This option is provided for
8465              compatibility; bindkey is the recommended interface.
8466
8467       OVERSTRIKE
8468              Start up the line editor in overstrike mode.
8469
8470       SINGLE_LINE_ZLE (-M) <K>
8471              Use single-line command line editing instead of multi-line.
8472
8473              Note  that  although  this  is on by default in ksh emulation it
8474              only provides superficial compatibility with the ksh line editor
8475              and reduces the effectiveness of the zsh line editor.  As it has
8476              no effect on shell syntax, many users may wish to  disable  this
8477              option when using ksh emulation interactively.
8478
8479       VI     If  ZLE is loaded, turning on this option has the equivalent ef‐
8480              fect of `bindkey -v'.  In addition, the EMACS option  is  unset.
8481              Turning it off has no effect.  The option setting is not guaran‐
8482              teed to reflect the current keymap.  This option is provided for
8483              compatibility; bindkey is the recommended interface.
8484
8485       ZLE (-Z)
8486              Use  the  zsh line editor.  Set by default in interactive shells
8487              connected to a terminal.
8488

OPTION ALIASES

8490       Some options have alternative names.  These aliases are never used  for
8491       output,  but  can be used just like normal option names when specifying
8492       options to the shell.
8493
8494       BRACE_EXPAND
8495              NO_IGNORE_BRACES (ksh and bash compatibility)
8496
8497       DOT_GLOB
8498              GLOB_DOTS (bash compatibility)
8499
8500       HASH_ALL
8501              HASH_CMDS (bash compatibility)
8502
8503       HIST_APPEND
8504              APPEND_HISTORY (bash compatibility)
8505
8506       HIST_EXPAND
8507              BANG_HIST (bash compatibility)
8508
8509       LOG    NO_HIST_NO_FUNCTIONS (ksh compatibility)
8510
8511       MAIL_WARN
8512              MAIL_WARNING (bash compatibility)
8513
8514       ONE_CMD
8515              SINGLE_COMMAND (bash compatibility)
8516
8517       PHYSICAL
8518              CHASE_LINKS (ksh and bash compatibility)
8519
8520       PROMPT_VARS
8521              PROMPT_SUBST (bash compatibility)
8522
8523       STDIN  SHIN_STDIN (ksh compatibility)
8524
8525       TRACK_ALL
8526              HASH_CMDS (ksh compatibility)
8527

SINGLE LETTER OPTIONS

8529   Default set
8530       -0     CORRECT
8531       -1     PRINT_EXIT_VALUE
8532       -2     NO_BAD_PATTERN
8533       -3     NO_NOMATCH
8534       -4     GLOB_DOTS
8535       -5     NOTIFY
8536       -6     BG_NICE
8537       -7     IGNORE_EOF
8538       -8     MARK_DIRS
8539       -9     AUTO_LIST
8540       -B     NO_BEEP
8541       -C     NO_CLOBBER
8542       -D     PUSHD_TO_HOME
8543       -E     PUSHD_SILENT
8544       -F     NO_GLOB
8545       -G     NULL_GLOB
8546       -H     RM_STAR_SILENT
8547       -I     IGNORE_BRACES
8548       -J     AUTO_CD
8549       -K     NO_BANG_HIST
8550       -L     SUN_KEYBOARD_HACK
8551       -M     SINGLE_LINE_ZLE
8552       -N     AUTO_PUSHD
8553       -O     CORRECT_ALL
8554       -P     RC_EXPAND_PARAM
8555       -Q     PATH_DIRS
8556       -R     LONG_LIST_JOBS
8557       -S     REC_EXACT
8558       -T     CDABLE_VARS
8559       -U     MAIL_WARNING
8560       -V     NO_PROMPT_CR
8561       -W     AUTO_RESUME
8562       -X     LIST_TYPES
8563       -Y     MENU_COMPLETE
8564       -Z     ZLE
8565       -a     ALL_EXPORT
8566       -e     ERR_EXIT
8567       -f     NO_RCS
8568       -g     HIST_IGNORE_SPACE
8569       -h     HIST_IGNORE_DUPS
8570       -i     INTERACTIVE
8571       -k     INTERACTIVE_COMMENTS
8572       -l     LOGIN
8573       -m     MONITOR
8574       -n     NO_EXEC
8575       -p     PRIVILEGED
8576       -r     RESTRICTED
8577       -s     SHIN_STDIN
8578       -t     SINGLE_COMMAND
8579       -u     NO_UNSET
8580       -v     VERBOSE
8581       -w     CHASE_LINKS
8582       -x     XTRACE
8583       -y     SH_WORD_SPLIT
8584
8585   sh/ksh emulation set
8586       -C     NO_CLOBBER
8587       -T     TRAPS_ASYNC
8588       -X     MARK_DIRS
8589       -a     ALL_EXPORT
8590       -b     NOTIFY
8591       -e     ERR_EXIT
8592       -f     NO_GLOB
8593       -i     INTERACTIVE
8594       -l     LOGIN
8595       -m     MONITOR
8596       -n     NO_EXEC
8597       -p     PRIVILEGED
8598       -r     RESTRICTED
8599       -s     SHIN_STDIN
8600       -t     SINGLE_COMMAND
8601       -u     NO_UNSET
8602       -v     VERBOSE
8603       -x     XTRACE
8604
8605   Also note
8606       -A     Used by set for setting arrays
8607       -b     Used on the command line to specify end of option processing
8608       -c     Used on the command line to specify a single command
8609       -m     Used by setopt for pattern-matching option setting
8610       -o     Used in all places to allow use of long option names
8611       -s     Used by set to sort positional parameters
8612
8613
8614
8615ZSHBUILTINS(1)              General Commands Manual             ZSHBUILTINS(1)
8616
8617
8618

NAME

8620       zshbuiltins - zsh built-in commands
8621

SHELL BUILTIN COMMANDS

8623       Some shell builtin commands take options as described in individual en‐
8624       tries;  these  are  often  referred  to in the list below as `flags' to
8625       avoid confusion with shell options, which may also have  an  effect  on
8626       the  behaviour of builtin commands.  In this introductory section, `op‐
8627       tion' always has the meaning of an option to a command that  should  be
8628       familiar to most command line users.
8629
8630       Typically,  options  are  single letters preceded by a hyphen (-).  Op‐
8631       tions that take an argument accept it either immediately following  the
8632       option  letter  or after white space, for example `print -C3 {1..9}' or
8633       `print -C 3 {1..9}' are equivalent.  Arguments to options are  not  the
8634       same  as arguments to the command; the documentation indicates which is
8635       which.  Options that do not take an argument may be combined in a  sin‐
8636       gle  word,  for example `print -rca -- *' and `print -r -c -a -- *' are
8637       equivalent.
8638
8639       Some shell builtin commands also take options that begin with  `+'  in‐
8640       stead of `-'.  The list below makes clear which commands these are.
8641
8642       Options  (together with their individual arguments, if any) must appear
8643       in a group before any non-option arguments; once the  first  non-option
8644       argument has been found, option processing is terminated.
8645
8646       All  builtin  commands other than `echo' and precommand modifiers, even
8647       those that have no options, can be given the argument `--' to terminate
8648       option processing.  This indicates that the following words are non-op‐
8649       tion arguments, but is otherwise ignored.   This  is  useful  in  cases
8650       where arguments to the command may begin with `-'.  For historical rea‐
8651       sons, most builtin commands (including `echo') also recognize a  single
8652       `-'  in  a separate word for this purpose; note that this is less stan‐
8653       dard and use of `--' is recommended.
8654
8655       - simple command
8656              See the section `Precommand Modifiers' in zshmisc(1).
8657
8658       . file [ arg ... ]
8659              Read commands from file and execute them in  the  current  shell
8660              environment.
8661
8662              If  file  does  not contain a slash, or if PATH_DIRS is set, the
8663              shell looks in the components of $path  to  find  the  directory
8664              containing  file.   Files  in the current directory are not read
8665              unless  `.'  appears  somewhere  in  $path.   If  a  file  named
8666              `file.zwc'  is  found,  is  newer than file, and is the compiled
8667              form (created with the zcompile builtin) of file, then  commands
8668              are read from that file instead of file.
8669
8670              If  any  arguments arg are given, they become the positional pa‐
8671              rameters; the old positional parameters are  restored  when  the
8672              file is done executing.  However, if no arguments are given, the
8673              positional parameters remain those of the calling  context,  and
8674              no restoring is done.
8675
8676              If  file  was  not  found  the return status is 127; if file was
8677              found but contained a syntax error the  return  status  is  126;
8678              else  the  return  status is the exit status of the last command
8679              executed.
8680
8681       : [ arg ... ]
8682              This command does nothing, although normal  argument  expansions
8683              is performed which may have effects on shell parameters.  A zero
8684              exit status is returned.
8685
8686       alias [ {+|-}gmrsL ] [ name[=value] ... ]
8687              For each name with a corresponding value, define an  alias  with
8688              that  value.   A trailing space in value causes the next word to
8689              be checked for alias expansion.  If the -g flag is present,  de‐
8690              fine a global alias; global aliases are expanded even if they do
8691              not occur in command position.
8692
8693              If the -s flag is present, define a suffix alias: if the command
8694              word on a command line is in the form `text.name', where text is
8695              any  non-empty  string,  it  is  replaced  by  the  text  `value
8696              text.name'.   Note that name is treated as a literal string, not
8697              a pattern.  A trailing space in value is  not  special  in  this
8698              case.  For example,
8699
8700                     alias -s ps='gv --'
8701
8702              will  cause  the  command `*.ps' to be expanded to `gv -- *.ps'.
8703              As alias expansion is carried out  earlier  than  globbing,  the
8704              `*.ps'  will then be expanded.  Suffix aliases constitute a dif‐
8705              ferent name space from other aliases (so in the above example it
8706              is still possible to create an alias for the command ps) and the
8707              two sets are never listed together.
8708
8709              For each name with no value, print the value of  name,  if  any.
8710              With  no  arguments,  print  all currently defined aliases other
8711              than suffix aliases.  If the -m flag is given the arguments  are
8712              taken  as  patterns (they should be quoted to preserve them from
8713              being interpreted as glob patterns), and  the  aliases  matching
8714              these  patterns  are  printed.  When printing aliases and one of
8715              the -g, -r or -s flags is  present,  restrict  the  printing  to
8716              global, regular or suffix aliases, respectively; a regular alias
8717              is one which is neither a global nor a suffix alias.   Using `+'
8718              instead  of  `-',  or  ending the option list with a single `+',
8719              prevents the values of the aliases from being printed.
8720
8721              If the -L flag is present, then print each  alias  in  a  manner
8722              suitable  for  putting  in a startup script.  The exit status is
8723              nonzero if a name (with no value) is given for  which  no  alias
8724              has been defined.
8725
8726              For  more  on  aliases, include common problems, see the section
8727              ALIASING in zshmisc(1).
8728
8729       autoload [ {+|-}RTUXdkmrtWz ] [ -w ] [ name ... ]
8730              See the section `Autoloading Functions' in zshmisc(1)  for  full
8731              details.  The fpath parameter will be searched to find the func‐
8732              tion definition when the function is first referenced.
8733
8734              If name consists of an absolute path, the function is defined to
8735              load  from  the file given (searching as usual for dump files in
8736              the given location).  The name of the function is  the  basename
8737              (non-directory  part)  of  the file.  It is normally an error if
8738              the function is not found in the given location; however, if the
8739              option  -d  is  given,  searching  for  the function defaults to
8740              $fpath.  If a function is loaded by absolute path, any functions
8741              loaded  from it that are marked for autoload without an absolute
8742              path have the load  path  of  the  parent  function  temporarily
8743              prepended to $fpath.
8744
8745              If  the  option  -r or -R is given, the function is searched for
8746              immediately and the location is recorded internally for use when
8747              the  function is executed; a relative path is expanded using the
8748              value of $PWD.  This protects against a change to  $fpath  after
8749              the call to autoload.  With -r, if the function is not found, it
8750              is silently left unresolved until execution; with -R,  an  error
8751              message  is  printed  and command processing aborted immediately
8752              the search fails, i.e. at the autoload command  rather  than  at
8753              function execution..
8754
8755              The flag -X may be used only inside a shell function.  It causes
8756              the calling function to be marked for autoloading and then imme‐
8757              diately  loaded  and  executed,  with the current array of posi‐
8758              tional parameters as arguments.  This replaces the previous def‐
8759              inition of the function.  If no function definition is found, an
8760              error is printed and the function remains undefined  and  marked
8761              for  autoloading.   If an argument is given, it is used as a di‐
8762              rectory (i.e. it does not include the name of the  function)  in
8763              which the function is to be found; this may be combined with the
8764              -d option to allow the function search to default to  $fpath  if
8765              it is not in the given location.
8766
8767              The  flag  +X  attempts to load each name as an autoloaded func‐
8768              tion, but does not execute it.  The exit status  is  zero  (suc‐
8769              cess)  if  the function was not previously defined and a defini‐
8770              tion for it was found.  This does not replace any existing defi‐
8771              nition of the function.  The exit status is nonzero (failure) if
8772              the function was already  defined  or  when  no  definition  was
8773              found.   In  the  latter case the function remains undefined and
8774              marked for autoloading.  If ksh-style  autoloading  is  enabled,
8775              the  function created will contain the contents of the file plus
8776              a call to the function itself appended to it, thus giving normal
8777              ksh autoloading behaviour on the first call to the function.  If
8778              the -m flag is also given each name is treated as a pattern  and
8779              all functions already marked for autoload that match the pattern
8780              are loaded.
8781
8782              With the -t flag, turn on execution tracing; with  -T,  turn  on
8783              execution  tracing only for the current function, turning it off
8784              on entry to any called functions that do not also  have  tracing
8785              enabled.
8786
8787              With  the  -U flag, alias expansion is suppressed when the func‐
8788              tion is loaded.
8789
8790              With the -w flag, the names are taken as names of files compiled
8791              with the zcompile builtin, and all functions defined in them are
8792              marked for autoloading.
8793
8794              The flags -z and -k mark the function to be autoloaded using the
8795              zsh  or  ksh  style, as if the option KSH_AUTOLOAD were unset or
8796              were set, respectively.  The flags override the setting  of  the
8797              option at the time the function is loaded.
8798
8799              Note  that  the  autoload command makes no attempt to ensure the
8800              shell options set during the loading or execution  of  the  file
8801              have any particular value.  For this, the emulate command can be
8802              used:
8803
8804                     emulate zsh -c 'autoload -Uz func'
8805
8806              arranges that when func is loaded the shell is in native zsh em‐
8807              ulation, and this emulation is also applied when func is run.
8808
8809              Some of the functions of autoload are also provided by functions
8810              -u or functions -U, but autoload is a more comprehensive  inter‐
8811              face.
8812
8813       bg [ job ... ]
8814       job ... &
8815              Put  each specified job in the background, or the current job if
8816              none is specified.
8817
8818       bindkey
8819              See the section `Zle Builtins' in zshzle(1).
8820
8821       break [ n ]
8822              Exit from an enclosing for, while, until, select or repeat loop.
8823              If  an arithmetic expression n is specified, then break n levels
8824              instead of just one.
8825
8826       builtin name [ args ... ]
8827              Executes the builtin name, with the given args.
8828
8829       bye    Same as exit.
8830
8831       cap    See the section `The zsh/cap Module' in zshmodules(1).
8832
8833       cd [ -qsLP ] [ arg ]
8834       cd [ -qsLP ] old new
8835       cd [ -qsLP ] {+|-}n
8836              Change the current directory.  In the  first  form,  change  the
8837              current directory to arg, or to the value of $HOME if arg is not
8838              specified.  If arg is `-', change to the previous directory.
8839
8840              Otherwise, if arg begins with a slash, attempt to change to  the
8841              directory given by arg.
8842
8843              If  arg  does  not  begin with a slash, the behaviour depends on
8844              whether the current directory `.' occurs in the list of directo‐
8845              ries  contained  in the shell parameter cdpath.  If it does not,
8846              first attempt to change to the directory arg under  the  current
8847              directory,  and  if that fails but cdpath is set and contains at
8848              least one element attempt to change to the directory  arg  under
8849              each  component  of cdpath in turn until successful.  If `.' oc‐
8850              curs in cdpath, then cdpath is searched  strictly  in  order  so
8851              that `.' is only tried at the appropriate point.
8852
8853              The  order  of testing cdpath is modified if the option POSIX_CD
8854              is set, as described in the documentation for the option.
8855
8856              If no directory is found, the option CDABLE_VARS is set,  and  a
8857              parameter  named  arg  exists  whose  value begins with a slash,
8858              treat its value as the directory.  In that case,  the  parameter
8859              is added to the named directory hash table.
8860
8861              The  second form of cd substitutes the string new for the string
8862              old in the name of the current directory, and tries to change to
8863              this new directory.
8864
8865              The third form of cd extracts an entry from the directory stack,
8866              and changes to that directory.  An argument  of  the  form  `+n'
8867              identifies  a  stack entry by counting from the left of the list
8868              shown by the dirs command, starting with zero.  An  argument  of
8869              the  form `-n' counts from the right.  If the PUSHD_MINUS option
8870              is set, the meanings of `+' and `-' in this context are swapped.
8871              If the POSIX_CD option is set, this form of cd is not recognised
8872              and will be interpreted as the first form.
8873
8874              If the -q (quiet) option is specified, the hook  function  chpwd
8875              and  the  functions in the array chpwd_functions are not called.
8876              This is useful for calls to cd that do not change  the  environ‐
8877              ment seen by an interactive user.
8878
8879              If  the -s option is specified, cd refuses to change the current
8880              directory if the given pathname contains symlinks.   If  the  -P
8881              option is given or the CHASE_LINKS option is set, symbolic links
8882              are resolved to their true values.  If the -L  option  is  given
8883              symbolic  links are retained in the directory (and not resolved)
8884              regardless of the state of the CHASE_LINKS option.
8885
8886       chdir  Same as cd.
8887
8888       clone  See the section `The zsh/clone Module' in zshmodules(1).
8889
8890       command [ -pvV ] simple command
8891              The simple command argument is taken as an external command  in‐
8892              stead  of  a  function  or  builtin  and  is  executed.  If  the
8893              POSIX_BUILTINS option is set, builtins will also be executed but
8894              certain  special  properties of them are suppressed. The -p flag
8895              causes a default path to be searched instead of that  in  $path.
8896              With  the  -v flag, command is similar to whence and with -V, it
8897              is equivalent to whence -v.
8898
8899              See also the section `Precommand Modifiers' in zshmisc(1).
8900
8901       comparguments
8902              See the section `The zsh/computil Module' in zshmodules(1).
8903
8904       compcall
8905              See the section `The zsh/compctl Module' in zshmodules(1).
8906
8907       compctl
8908              See the section `The zsh/compctl Module' in zshmodules(1).
8909
8910       compdescribe
8911              See the section `The zsh/computil Module' in zshmodules(1).
8912
8913       compfiles
8914              See the section `The zsh/computil Module' in zshmodules(1).
8915
8916       compgroups
8917              See the section `The zsh/computil Module' in zshmodules(1).
8918
8919       compquote
8920              See the section `The zsh/computil Module' in zshmodules(1).
8921
8922       comptags
8923              See the section `The zsh/computil Module' in zshmodules(1).
8924
8925       comptry
8926              See the section `The zsh/computil Module' in zshmodules(1).
8927
8928       compvalues
8929              See the section `The zsh/computil Module' in zshmodules(1).
8930
8931       continue [ n ]
8932              Resume the next iteration of the enclosing  for,  while,  until,
8933              select  or  repeat loop. If an arithmetic expression n is speci‐
8934              fied, break out of n-1 loops and resume  at  the  nth  enclosing
8935              loop.
8936
8937       declare
8938              Same as typeset.
8939
8940       dirs [ -c ] [ arg ... ]
8941       dirs [ -lpv ]
8942              With  no  arguments,  print the contents of the directory stack.
8943              Directories are added to this stack with the pushd command,  and
8944              removed  with  the cd or popd commands.  If arguments are speci‐
8945              fied, load them onto the  directory  stack,  replacing  anything
8946              that was there, and push the current directory onto the stack.
8947
8948              -c     clear the directory stack.
8949
8950              -l     print directory names in full instead of using of using ~
8951                     expressions (see Dynamic and Static named directories  in
8952                     zshexpn(1)).
8953
8954              -p     print directory entries one per line.
8955
8956              -v     number the directories in the stack when printing.
8957
8958       disable [ -afmprs ] name ...
8959              Temporarily  disable  the named hash table elements or patterns.
8960              The default is to disable builtin commands.  This allows you  to
8961              use an external command with the same name as a builtin command.
8962              The -a option  causes  disable  to  act  on  regular  or  global
8963              aliases.  The -s option causes disable to act on suffix aliases.
8964              The -f option causes disable to act on shell functions.  The  -r
8965              options  causes disable to act on reserved words.  Without argu‐
8966              ments all disabled hash table elements  from  the  corresponding
8967              hash  table  are  printed.   With  the -m flag the arguments are
8968              taken as patterns (which should be quoted to prevent  them  from
8969              undergoing filename expansion), and all hash table elements from
8970              the corresponding hash table matching these  patterns  are  dis‐
8971              abled.  Disabled objects can be enabled with the enable command.
8972
8973              With  the  option  -p, name ... refer to elements of the shell's
8974              pattern syntax as described in  the  section  `Filename  Genera‐
8975              tion'.   Certain  elements  can be disabled separately, as given
8976              below.
8977
8978              Note that patterns not allowed by the current settings  for  the
8979              options  EXTENDED_GLOB,  KSH_GLOB and SH_GLOB are never enabled,
8980              regardless of the setting here.  For example,  if  EXTENDED_GLOB
8981              is  not active, the pattern ^ is ineffective even if `disable -p
8982              "^"' has not been issued.  The list below indicates  any  option
8983              settings  that  restrict  the  use of the pattern.  It should be
8984              noted that setting SH_GLOB has a wider effect than  merely  dis‐
8985              abling  patterns as certain expressions, in particular those in‐
8986              volving parentheses, are parsed differently.
8987
8988              The following patterns may be disabled;  all  the  strings  need
8989              quoting  on  the  command line to prevent them from being inter‐
8990              preted immediately as patterns and the patterns are shown  below
8991              in single quotes as a reminder.
8992
8993              '?'    The  pattern  character  ?  wherever it occurs, including
8994                     when preceding a parenthesis with KSH_GLOB.
8995
8996              '*'    The pattern character * wherever it occurs, including re‐
8997                     cursive  globbing  and  when preceding a parenthesis with
8998                     KSH_GLOB.
8999
9000              '['    Character classes.
9001
9002              '<' (NO_SH_GLOB)
9003                     Numeric ranges.
9004
9005              '|' (NO_SH_GLOB)
9006                     Alternation in  grouped  patterns,  case  statements,  or
9007                     KSH_GLOB parenthesised expressions.
9008
9009              '(' (NO_SH_GLOB)
9010                     Grouping  using  single parentheses.  Disabling this does
9011                     not disable the use of  parentheses  for  KSH_GLOB  where
9012                     they  are introduced by a special character, nor for glob
9013                     qualifiers (use  `setopt  NO_BARE_GLOB_QUAL'  to  disable
9014                     glob qualifiers that use parentheses only).
9015
9016              '~' (EXTENDED_GLOB)
9017                     Exclusion in the form A~B.
9018
9019              '^' (EXTENDED_GLOB)
9020                     Exclusion in the form A^B.
9021
9022              '#' (EXTENDED_GLOB)
9023                     The pattern character # wherever it occurs, both for rep‐
9024                     etition of a previous pattern and for indicating globbing
9025                     flags.
9026
9027              '?(' (KSH_GLOB)
9028                     The  grouping form ?(...).  Note this is also disabled if
9029                     '?' is disabled.
9030
9031              '*(' (KSH_GLOB)
9032                     The grouping form *(...).  Note this is also disabled  if
9033                     '*' is disabled.
9034
9035              '+(' (KSH_GLOB)
9036                     The grouping form +(...).
9037
9038              '!(' (KSH_GLOB)
9039                     The grouping form !(...).
9040
9041              '@(' (KSH_GLOB)
9042                     The grouping form @(...).
9043
9044       disown [ job ... ]
9045       job ... &|
9046       job ... &!
9047              Remove  the specified jobs from the job table; the shell will no
9048              longer report their status, and will not complain if you try  to
9049              exit  an  interactive shell with them running or stopped.  If no
9050              job is specified, disown the current job.
9051
9052              If the jobs are currently stopped and the  AUTO_CONTINUE  option
9053              is  not  set,  a warning is printed containing information about
9054              how to make them running after they have been disowned.  If  one
9055              of  the latter two forms is used, the jobs will automatically be
9056              made running, independent of the setting  of  the  AUTO_CONTINUE
9057              option.
9058
9059       echo [ -neE ] [ arg ... ]
9060              Write  each  arg on the standard output, with a space separating
9061              each one.  If the -n flag is not present, print a newline at the
9062              end.  echo recognizes the following escape sequences:
9063
9064              \a     bell character
9065              \b     backspace
9066              \c     suppress subsequent characters and final newline
9067              \e     escape
9068              \f     form feed
9069              \n     linefeed (newline)
9070              \r     carriage return
9071              \t     horizontal tab
9072              \v     vertical tab
9073              \\     backslash
9074              \0NNN  character code in octal
9075              \xNN   character code in hexadecimal
9076              \uNNNN unicode character code in hexadecimal
9077              \UNNNNNNNN
9078                     unicode character code in hexadecimal
9079
9080              The  -E  flag,  or  the  BSD_ECHO option, can be used to disable
9081              these escape sequences.  In the latter case, -e flag can be used
9082              to enable them.
9083
9084              Note that for standards compliance a double dash does not termi‐
9085              nate option processing; instead, it is printed  directly.   How‐
9086              ever,  a  single  dash  does terminate option processing, so the
9087              first dash, possibly following options, is not printed, but  ev‐
9088              erything  following  it  is  printed as an argument.  The single
9089              dash behaviour is different from other shells.  For a more  por‐
9090              table  way of printing text, see printf, and for a more control‐
9091              lable way of printing text within zsh, see print.
9092
9093       echotc See the section `The zsh/termcap Module' in zshmodules(1).
9094
9095       echoti See the section `The zsh/terminfo Module' in zshmodules(1).
9096
9097       emulate [ -lLR ] [ {zsh|sh|ksh|csh} [ flags ... ] ]
9098              Without any argument print current emulation mode.
9099
9100              With single argument set up zsh options to emulate the specified
9101              shell  as  much  as possible.  csh will never be fully emulated.
9102              If the argument is not one of the shells listed above, zsh  will
9103              be used as a default; more precisely, the tests performed on the
9104              argument are the same as those used to determine  the  emulation
9105              at  startup based on the shell name, see the section COMPATIBIL‐
9106              ITY in zsh(1) .  In addition to setting shell options, the  com‐
9107              mand  also restores the pristine state of pattern enables, as if
9108              all patterns had been enabled using enable -p.
9109
9110              If the emulate command occurs inside a function  that  has  been
9111              marked  for  execution tracing with functions -t then the xtrace
9112              option will be turned on regardless of emulation mode  or  other
9113              options.   Note that code executed inside the function by the .,
9114              source, or eval commands is not considered  to  be  running  di‐
9115              rectly from the function, hence does not provoke this behaviour.
9116
9117              If  the  -R  switch  is given, all settable options are reset to
9118              their default value corresponding  to  the  specified  emulation
9119              mode,  except for certain options describing the interactive en‐
9120              vironment; otherwise, only those options likely to cause  porta‐
9121              bility problems in scripts and functions are altered.  If the -L
9122              switch is given, the options LOCAL_OPTIONS,  LOCAL_PATTERNS  and
9123              LOCAL_TRAPS will be set as well, causing the effects of the emu‐
9124              late command and any setopt, disable -p or enable -p,  and  trap
9125              commands  to be local to the immediately surrounding shell func‐
9126              tion, if any; normally these options are turned off in all  emu‐
9127              lation  modes  except  ksh.  The -L switch is mutually exclusive
9128              with the use of -c in flags.
9129
9130              If there is a single argument and the -l switch  is  given,  the
9131              options  that  would  be set or unset (the latter indicated with
9132              the prefix `no') are listed.  -l can be combined with -L  or  -R
9133              and  the list will be modified in the appropriate way.  Note the
9134              list does not depend on the current setting of options, i.e.  it
9135              includes  all  options  that  may  in principle change, not just
9136              those that would actually change.
9137
9138              The flags may be any of the invocation-time flags  described  in
9139              the section INVOCATION in zsh(1), except that `-o EMACS' and `-o
9140              VI' may not be used.  Flags such as `+r'/`+o RESTRICTED' may  be
9141              prohibited in some circumstances.
9142
9143              If -c arg appears in flags, arg is evaluated while the requested
9144              emulation is temporarily in effect.  In this case the  emulation
9145              mode  and  all options are restored to their previous values be‐
9146              fore emulate returns.  The -R switch may precede the name of the
9147              shell  to emulate; note this has a meaning distinct from includ‐
9148              ing -R in flags.
9149
9150              Use of -c enables `sticky' emulation mode for functions  defined
9151              within  the evaluated expression:  the emulation mode is associ‐
9152              ated thereafter with the function so that whenever the  function
9153              is executed the emulation (respecting the -R switch, if present)
9154              and all options are set (and pattern  disables  cleared)  before
9155              entry to the function, and the state is restored after exit.  If
9156              the function is called when the sticky emulation is  already  in
9157              effect, either within an `emulate shell -c' expression or within
9158              another function with the same sticky emulation, entry and  exit
9159              from the function do not cause options to be altered (except due
9160              to standard processing such as the LOCAL_OPTIONS option).   This
9161              also  applies to functions marked for autoload within the sticky
9162              emulation; the appropriate set of options will be applied at the
9163              point the function is loaded as well as when it is run.
9164
9165              For example:
9166
9167                     emulate sh -c 'fni() { setopt cshnullglob; }
9168                     fno() { fni; }'
9169                     fno
9170
9171              The  two functions fni and fno are defined with sticky sh emula‐
9172              tion.  fno is then executed, causing options associated with em‐
9173              ulations  to  be set to their values in sh.  fno then calls fni;
9174              because fni is also marked for sticky sh  emulation,  no  option
9175              changes  take  place on entry to or exit from it.  Hence the op‐
9176              tion cshnullglob, turned off by sh emulation, will be turned  on
9177              within  fni  and remain on return to fno.  On exit from fno, the
9178              emulation mode and all options will be  restored  to  the  state
9179              they were in before entry to the temporary emulation.
9180
9181              The documentation above is typically sufficient for the intended
9182              purpose of executing code designed for other shells in  a  suit‐
9183              able environment.  More detailed rules follow.
9184              1.     The  sticky  emulation  environment  provided by `emulate
9185                     shell -c' is identical to that provided  by  entry  to  a
9186                     function  marked for sticky emulation as a consequence of
9187                     being defined in such an environment.  Hence,  for  exam‐
9188                     ple,  the  sticky  emulation is inherited by subfunctions
9189                     defined within functions with sticky emulation.
9190              2.     No change of options takes place on entry to or exit from
9191                     functions that are not marked for sticky emulation, other
9192                     than those that would normally take place, even if  those
9193                     functions are called within sticky emulation.
9194              3.     No  special handling is provided for functions marked for
9195                     autoload nor for functions present in wordcode created by
9196                     the zcompile command.
9197              4.     The  presence or absence of the -R switch to emulate cor‐
9198                     responds to different sticky emulation modes, so for  ex‐
9199                     ample  `emulate  sh  -c', `emulate -R sh -c' and `emulate
9200                     csh -c' are treated as three distinct sticky emulations.
9201              5.     Difference in shell options supplied in addition  to  the
9202                     basic  emulation also mean the sticky emulations are dif‐
9203                     ferent, so for example `emulate zsh -c' and `emulate  zsh
9204                     -o cbases -c' are treated as distinct sticky emulations.
9205
9206       enable [ -afmprs ] name ...
9207              Enable  the  named hash table elements, presumably disabled ear‐
9208              lier with disable.  The default is to enable  builtin  commands.
9209              The -a option causes enable to act on regular or global aliases.
9210              The -s option causes enable to act on suffix  aliases.   The  -f
9211              option  causes  enable to act on shell functions.  The -r option
9212              causes enable to act on reserved words.  Without  arguments  all
9213              enabled  hash  table  elements from the corresponding hash table
9214              are printed.  With the -m flag the arguments are taken  as  pat‐
9215              terns  (should  be  quoted) and all hash table elements from the
9216              corresponding hash table matching these  patterns  are  enabled.
9217              Enabled  objects  can  be disabled with the disable builtin com‐
9218              mand.
9219
9220              enable -p reenables patterns disabled  with  disable  -p.   Note
9221              that it does not override globbing options; for example, `enable
9222              -p "~"' does not cause the pattern character ~ to be active  un‐
9223              less the EXTENDED_GLOB option is also set.  To enable all possi‐
9224              ble patterns (so that they may  be  individually  disabled  with
9225              disable -p), use `setopt EXTENDED_GLOB KSH_GLOB NO_SH_GLOB'.
9226
9227       eval [ arg ... ]
9228              Read the arguments as input to the shell and execute the result‐
9229              ing command(s) in the current shell process.  The return  status
9230              is the same as if the commands had been executed directly by the
9231              shell; if there are no args or they contain  no  commands  (i.e.
9232              are an empty string or whitespace) the return status is zero.
9233
9234       exec [ -cl ] [ -a argv0 ] [ command [ arg ... ] ]
9235              Replace  the current shell with command rather than forking.  If
9236              command is a shell builtin command  or  a  shell  function,  the
9237              shell executes it, and exits when the command is complete.
9238
9239              With  -c clear the environment; with -l prepend - to the argv[0]
9240              string of the command executed (to simulate a login shell); with
9241              -a  argv0  set  the argv[0] string of the command executed.  See
9242              the section `Precommand Modifiers' in zshmisc(1).
9243
9244              If the option POSIX_BUILTINS is set,  command  is  never  inter‐
9245              preted as a shell builtin command or shell function.  This means
9246              further precommand modifiers such as builtin and noglob are also
9247              not interpreted within the shell.  Hence command is always found
9248              by searching the command path.
9249
9250              If command is omitted but any redirections are  specified,  then
9251              the redirections will take effect in the current shell.
9252
9253       exit [ n ]
9254              Exit  the  shell with the exit status specified by an arithmetic
9255              expression n; if none is specified, use the exit status from the
9256              last  command  executed.   An  EOF condition will also cause the
9257              shell to exit, unless the IGNORE_EOF option is set.
9258
9259              See notes at the end of the section JOBS in zshmisc(1) for  some
9260              possibly unexpected interactions of the exit command with jobs.
9261
9262       export [ name[=value] ... ]
9263              The specified names are marked for automatic export to the envi‐
9264              ronment of subsequently executed commands.  Equivalent to  type‐
9265              set -gx.  If a parameter specified does not already exist, it is
9266              created in the global scope.
9267
9268       false [ arg ... ]
9269              Do nothing and return an exit status of 1.
9270
9271
9272       fc [ -e ename ] [ -LI ] [ -m match ] [ old=new ... ] [ first [ last ] ]
9273       fc -l [ -LI ] [ -nrdfEiD ] [ -t timefmt ] [ -m match ]
9274             [ old=new ... ] [ first [ last ] ]
9275       fc -p [ -a ] [ filename [ histsize [ savehistsize ] ] ]
9276       fc -P
9277       fc -ARWI [ filename ]
9278              The fc command controls the interactive history mechanism.  Note
9279              that reading and writing of history options is only performed if
9280              the shell is interactive.  Usually this  is  detected  automati‐
9281              cally,  but  it  can be forced by setting the interactive option
9282              when starting the shell.
9283
9284              The first two forms of this command select  a  range  of  events
9285              from  first  to last from the history list.  The arguments first
9286              and last may be specified as a number or as a string.   A  nega‐
9287              tive  number  is  used as an offset to the current history event
9288              number.  A string specifies the most recent event beginning with
9289              the  given  string.  All substitutions old=new, if any, are then
9290              performed on the text of the events.
9291
9292              In addition to the number range,
9293              -I     restricts to only internal events (not from $HISTFILE)
9294              -L     restricts to only local events (not  from  other  shells,
9295                     see SHARE_HISTORY in zshoptions(1) -- note that $HISTFILE
9296                     is considered local when read at startup)
9297              -m     takes the first argument as a pattern (should be  quoted)
9298                     and  only  the  history  events matching this pattern are
9299                     considered
9300
9301              If first is not specified, it will be set to -1 (the most recent
9302              event), or to -16 if the -l flag is given.  If last is not spec‐
9303              ified, it will be set to first, or to  -1  if  the  -l  flag  is
9304              given.   However,  if the current event has added entries to the
9305              history with `print -s' or `fc -R', then the default last for -l
9306              includes all new history entries since the current event began.
9307
9308              When  the  -l  flag is given, the resulting events are listed on
9309              standard output.  Otherwise the editor program specified  by  -e
9310              ename  is invoked on a file containing these history events.  If
9311              -e is not given, the value of the parameter FCEDIT is  used;  if
9312              that  is  not  set the value of the parameter EDITOR is used; if
9313              that is not set a builtin default, usually  `vi'  is  used.   If
9314              ename  is  `-', no editor is invoked.  When editing is complete,
9315              the edited command is executed.
9316
9317              The flag -r reverses the order of the events  and  the  flag  -n
9318              suppresses event numbers when listing.
9319
9320              Also when listing,
9321              -d     prints timestamps for each event
9322              -f     prints  full  time-date stamps in the US `MM/DD/YY hh:mm'
9323                     format
9324              -E     prints full time-date stamps in the European  `dd.mm.yyyy
9325                     hh:mm' format
9326              -i     prints  full  time-date  stamps  in  ISO8601  `yyyy-mm-dd
9327                     hh:mm' format
9328              -t fmt prints time and date stamps in the given format;  fmt  is
9329                     formatted  with the strftime function with the zsh exten‐
9330                     sions described for the %D{string} prompt format  in  the
9331                     section EXPANSION OF PROMPT SEQUENCES in zshmisc(1).  The
9332                     resulting formatted string must be no more than 256 char‐
9333                     acters or will not be printed
9334              -D     prints elapsed times; may be combined with one of the op‐
9335                     tions above
9336
9337              `fc -p' pushes  the  current  history  list  onto  a  stack  and
9338              switches to a new history list.  If the -a option is also speci‐
9339              fied, this history list will be automatically  popped  when  the
9340              current  function  scope is exited, which is a much better solu‐
9341              tion than creating a trap function to call `fc -P' manually.  If
9342              no  arguments  are  specified,  the  history list is left empty,
9343              $HISTFILE is unset, and $HISTSIZE & $SAVEHIST are set  to  their
9344              default  values.   If one argument is given, $HISTFILE is set to
9345              that filename, $HISTSIZE & $SAVEHIST are left unchanged, and the
9346              history  file  is  read  in (if it exists) to initialize the new
9347              list.  If a second argument is specified, $HISTSIZE &  $SAVEHIST
9348              are instead set to the single specified numeric value.  Finally,
9349              if a third argument is specified, $SAVEHIST is set to a separate
9350              value  from $HISTSIZE.  You are free to change these environment
9351              values for the new history list however you desire in  order  to
9352              manipulate the new history list.
9353
9354              `fc -P' pops the history list back to an older list saved by `fc
9355              -p'.  The current list is saved to its $HISTFILE  before  it  is
9356              destroyed  (assuming that $HISTFILE and $SAVEHIST are set appro‐
9357              priately, of course).  The values of $HISTFILE,  $HISTSIZE,  and
9358              $SAVEHIST  are  restored to the values they had when `fc -p' was
9359              called.  Note that this restoration  can  conflict  with  making
9360              these variables "local", so your best bet is to avoid local dec‐
9361              larations for these variables in functions  that  use  `fc  -p'.
9362              The  one  other  guaranteed-safe  combination is declaring these
9363              variables to be local at the top of your function and using  the
9364              automatic  option  (-a)  with `fc -p'.  Finally, note that it is
9365              legal to manually pop a push marked for automatic popping if you
9366              need to do so before the function exits.
9367
9368              `fc  -R'  reads  the history from the given file, `fc -W' writes
9369              the history out to the given file, and `fc -A' appends the  his‐
9370              tory  out  to  the given file.  If no filename is specified, the
9371              $HISTFILE is assumed.  If the -I option is  added  to  -R,  only
9372              those  events that are not already contained within the internal
9373              history list are added.  If the -I option is added to -A or  -W,
9374              only  those  events  that  are  new  since  last incremental ap‐
9375              pend/write to the history file  are  appended/written.   In  any
9376              case, the created file will have no more than $SAVEHIST entries.
9377
9378       fg [ job ... ]
9379       job ...
9380              Bring  each  specified job in turn to the foreground.  If no job
9381              is specified, resume the current job.
9382
9383       float [ {+|-}Hghlprtux ] [ {+|-}EFLRZ [ n ] ] [ name[=value] ... ]
9384              Equivalent to typeset -E,  except  that  options  irrelevant  to
9385              floating point numbers are not permitted.
9386
9387       functions [ {+|-}UkmtTuWz ] [ -x num ] [ name ... ]
9388       functions -c oldfn newfn
9389       functions -M [-s] mathfn [ min [ max [ shellfn ] ] ]
9390       functions -M [ -m pattern ... ]
9391       functions +M [ -m ] mathfn ...
9392              Equivalent  to  typeset -f, with the exception of the -c, -x, -M
9393              and -W options.  For functions -u  and  functions  -U,  see  au‐
9394              toload, which provides additional options.
9395
9396              The -x option indicates that any functions output will have each
9397              leading tab for indentation, added by the shell to show  syntac‐
9398              tic  structure, expanded to the given number num of spaces.  num
9399              can also be 0 to suppress all indentation.
9400
9401              The -W option turns on the option WARN_NESTED_VAR for the  named
9402              function  or  functions  only.   The option is turned off at the
9403              start of nested functions (apart from anonoymous functions)  un‐
9404              less the called function also has the -W attribute.
9405
9406              The  -c  option causes oldfn to be copied to newfn.  The copy is
9407              efficiently handled internally by reference counting.  If  oldfn
9408              was marked for autoload it is first loaded and if this fails the
9409              copy fails.  Either function may subsequently be redefined with‐
9410              out  affecting  the other.  A typical idiom is that oldfn is the
9411              name of a library shell function which is then redefined to call
9412              newfn, thereby installing a modified version of the function.
9413
9414              Use of the -M option may not be combined with any of the options
9415              handled by typeset -f.
9416
9417              functions -M mathfn defines mathfn as the name of a mathematical
9418              function  recognised  in  all forms of arithmetical expressions;
9419              see the section `Arithmetic Evaluation' in zshmisc(1).   By  de‐
9420              fault  mathfn  may take any number of comma-separated arguments.
9421              If min is given, it must have exactly min args; if min  and  max
9422              are  both given, it must have at least min and at most max args.
9423              max may be -1 to indicate that there is no upper limit.
9424
9425              By default the function is implemented by a  shell  function  of
9426              the  same name; if shellfn is specified it gives the name of the
9427              corresponding shell function while mathfn remains the name  used
9428              in  arithmetical expressions.  The name of the function in $0 is
9429              mathfn (not shellfn as would usually be the case), provided  the
9430              option FUNCTION_ARGZERO is in effect.  The positional parameters
9431              in the shell function correspond to the arguments of the  mathe‐
9432              matical  function call.  The result of the last arithmetical ex‐
9433              pression evaluated inside the shell function (even if  it  is  a
9434              form  that  normally  only returns a status) gives the result of
9435              the mathematical function.
9436
9437              If the additional option -s is given to functions -M, the  argu‐
9438              ment  to  the  function is a single string: anything between the
9439              opening and matching closing parenthesis is passed to the  func‐
9440              tion  as  a single argument, even if it includes commas or white
9441              space.  The minimum and maximum argument specifiers must  there‐
9442              fore  be  1  if  given.   An  empty argument list is passed as a
9443              zero-length string.
9444
9445              functions -M with no arguments lists all such user-defined func‐
9446              tions in the same form as a definition.  With the additional op‐
9447              tion -m and a list of  arguments,  all  functions  whose  mathfn
9448              matches one of the pattern arguments are listed.
9449
9450              function +M removes the list of mathematical functions; with the
9451              additional option -m the arguments are treated as  patterns  and
9452              all  functions  whose  mathfn  matches  the pattern are removed.
9453              Note that the shell function implementing the behaviour  is  not
9454              removed (regardless of whether its name coincides with mathfn).
9455
9456              For example, the following prints the cube of 3:
9457
9458                     zmath_cube() { (( $1 * $1 * $1 )) }
9459                     functions -M cube 1 1 zmath_cube
9460                     print $(( cube(3) ))
9461
9462              The following string function takes a single argument, including
9463              the commas, so prints 11:
9464
9465                     stringfn() { (( $#1 )) }
9466                     functions -Ms stringfn
9467                     print $(( stringfn(foo,bar,rod) ))
9468
9469       getcap See the section `The zsh/cap Module' in zshmodules(1).
9470
9471       getln [ -AclneE ] name ...
9472              Read the top value from the buffer stack and put it in the shell
9473              parameter name.  Equivalent to read -zr.
9474
9475       getopts optstring name [ arg ... ]
9476              Checks the args for legal options.  If the args are omitted, use
9477              the positional parameters.  A valid option argument begins  with
9478              a  `+' or a `-'.  An argument not beginning with a `+' or a `-',
9479              or the argument `--', ends the options.  Note that a single  `-'
9480              is  not  considered a valid option argument.  optstring contains
9481              the letters that getopts recognizes.  If a letter is followed by
9482              a  `:',  that  option  requires an argument.  The options can be
9483              separated from the argument by blanks.
9484
9485              Each time it is invoked, getopts places  the  option  letter  it
9486              finds in the shell parameter name, prepended with a `+' when arg
9487              begins with a `+'.  The index of  the  next  arg  is  stored  in
9488              OPTIND.  The option argument, if any, is stored in OPTARG.
9489
9490              The first option to be examined may be changed by explicitly as‐
9491              signing to OPTIND.  OPTIND has an initial value  of  1,  and  is
9492              normally  set  to  1 upon entry to a shell function and restored
9493              upon exit (this is disabled by the POSIX_BUILTINS option).   OP‐
9494              TARG  is  not  reset  and retains its value from the most recent
9495              call to getopts.  If either of OPTIND or  OPTARG  is  explicitly
9496              unset, it remains unset, and the index or option argument is not
9497              stored.  The option itself is still stored in name in this case.
9498
9499              A leading `:' in optstring causes getopts to store the letter of
9500              any  invalid option in OPTARG, and to set name to `?' for an un‐
9501              known option and to `:' when a  required  argument  is  missing.
9502              Otherwise,  getopts sets name to `?' and prints an error message
9503              when an option is invalid.  The  exit  status  is  nonzero  when
9504              there are no more options.
9505
9506       hash [ -Ldfmrv ] [ name[=value] ] ...
9507              hash  can be used to directly modify the contents of the command
9508              hash table, and the named directory hash  table.   Normally  one
9509              would  modify these tables by modifying one's PATH (for the com‐
9510              mand hash table) or by  creating  appropriate  shell  parameters
9511              (for  the named directory hash table).  The choice of hash table
9512              to work on is determined by the -d option;  without  the  option
9513              the  command  hash  table is used, and with the option the named
9514              directory hash table is used.
9515
9516              A command name starting with a / is never hashed, whether by ex‐
9517              plicit  use of the hash command or otherwise.  Such a command is
9518              always found by direct look up in the file system.
9519
9520              Given no arguments, and neither the -r or -f  options,  the  se‐
9521              lected hash table will be listed in full.
9522
9523              The  -r option causes the selected hash table to be emptied.  It
9524              will be subsequently rebuilt in the normal fashion.  The -f  op‐
9525              tion  causes the selected hash table to be fully rebuilt immedi‐
9526              ately.  For the command hash table this hashes all the  absolute
9527              directories  in the PATH, and for the named directory hash table
9528              this adds all users' home directories.  These two options cannot
9529              be used with any arguments.
9530
9531              The  -m  option  causes  the  arguments  to be taken as patterns
9532              (which should be quoted) and the  elements  of  the  hash  table
9533              matching  those  patterns  are printed.  This is the only way to
9534              display a limited selection of hash table elements.
9535
9536              For each name with a corresponding value, put `name' in the  se‐
9537              lected hash table, associating it with the pathname `value'.  In
9538              the command hash table, this means that whenever `name' is  used
9539              as  a  command  argument, the shell will try to execute the file
9540              given by `value'.  In the named directory hash table, this means
9541              that `value' may be referred to as `~name'.
9542
9543              For  each  name with no corresponding value, attempt to add name
9544              to the hash table, checking what the appropriate value is in the
9545              normal  manner  for  that  hash  table.  If an appropriate value
9546              can't be found, then the hash table will be unchanged.
9547
9548              The -v option causes hash table entries to be listed as they are
9549              added  by explicit specification.  If has no effect if used with
9550              -f.
9551
9552              If the -L flag is present, then each hash table entry is printed
9553              in the form of a call to hash.
9554
9555       history
9556              Same as fc -l.
9557
9558       integer [ {+|-}Hghlprtux ] [ {+|-}LRZi [ n ] ] [ name[=value] ... ]
9559              Equivalent  to typeset -i, except that options irrelevant to in‐
9560              tegers are not permitted.
9561
9562       jobs [ -dlprs ] [ job ... ]
9563       jobs -Z string
9564              Lists information about each given job, or all jobs  if  job  is
9565              omitted.   The  -l flag lists process IDs, and the -p flag lists
9566              process groups.  If the -r flag is specified only  running  jobs
9567              will be listed and if the -s flag is given only stopped jobs are
9568              shown.  If the -d flag is given, the directory  from  which  the
9569              job  was  started (which may not be the current directory of the
9570              job) will also be shown.
9571
9572              The -Z option replaces  the  shell's  argument  and  environment
9573              space  with  the  given  string,  truncated if necessary to fit.
9574              This will normally be visible in ps (ps(1)) listings.  This fea‐
9575              ture is typically used by daemons, to indicate their state.
9576
9577       kill [ -s signal_name | -n signal_number | -sig ] job ...
9578       kill -l [ sig ... ]
9579              Sends  either  SIGTERM or the specified signal to the given jobs
9580              or processes.  Signals are given by number or by names, with  or
9581              without  the  `SIG'  prefix.   If  the  signal being sent is not
9582              `KILL' or `CONT', then the job will be sent a `CONT'  signal  if
9583              it  is stopped.  The argument job can be the process ID of a job
9584              not in the job list.  In the second form, kill -l, if sig is not
9585              specified  the signal names are listed.  Otherwise, for each sig
9586              that is a name, the corresponding signal number is listed.   For
9587              each  sig  that  is a signal number or a number representing the
9588              exit status of a process which was terminated or  stopped  by  a
9589              signal the name of the signal is printed.
9590
9591              On  some systems, alternative signal names are allowed for a few
9592              signals.  Typical examples are SIGCHLD and SIGCLD or SIGPOLL and
9593              SIGIO, assuming they correspond to the same signal number.  kill
9594              -l will only list the preferred form, however kill -l  alt  will
9595              show  if  the  alternative  form corresponds to a signal number.
9596              For example, under Linux kill -l IO and kill -l POLL both output
9597              29, hence kill -IO and kill -POLL have the same effect.
9598
9599              Many  systems  will  allow  process IDs to be negative to kill a
9600              process group or zero to kill the current process group.
9601
9602       let arg ...
9603              Evaluate each arg as an arithmetic expression.  See the  section
9604              `Arithmetic  Evaluation'  in  zshmisc(1)  for  a  description of
9605              arithmetic expressions.  The exit status is 0 if  the  value  of
9606              the last expression is nonzero, 1 if it is zero, and 2 if an er‐
9607              ror occurred.
9608
9609       limit [ -hs ] [ resource [ limit ] ] ...
9610              Set or display resource limits.  Unless the -s  flag  is  given,
9611              the  limit  applies  only  the  children of the shell.  If -s is
9612              given without other arguments, the resource limits of  the  cur‐
9613              rent  shell  is set to the previously set resource limits of the
9614              children.
9615
9616              If limit is not specified, print the current limit placed on re‐
9617              source,  otherwise set the limit to the specified value.  If the
9618              -h flag is given, use hard limits instead of soft limits.  If no
9619              resource is given, print all limits.
9620
9621              When looping over multiple resources, the shell will abort imme‐
9622              diately if it detects a badly formed argument.  However,  if  it
9623              fails to set a limit for some other reason it will continue try‐
9624              ing to set the remaining limits.
9625
9626              resource can be one of:
9627
9628              addressspace
9629                     Maximum amount of address space used.
9630              aiomemorylocked
9631                     Maximum amount of memory locked in  RAM  for  AIO  opera‐
9632                     tions.
9633              aiooperations
9634                     Maximum number of AIO operations.
9635              cachedthreads
9636                     Maximum number of cached threads.
9637              coredumpsize
9638                     Maximum size of a core dump.
9639              cputime
9640                     Maximum CPU seconds per process.
9641              datasize
9642                     Maximum data size (including stack) for each process.
9643              descriptors
9644                     Maximum value for a file descriptor.
9645              filesize
9646                     Largest single file allowed.
9647              kqueues
9648                     Maximum number of kqueues allocated.
9649              maxproc
9650                     Maximum number of processes.
9651              maxpthreads
9652                     Maximum number of threads per process.
9653              memorylocked
9654                     Maximum amount of memory locked in RAM.
9655              memoryuse
9656                     Maximum resident set size.
9657              msgqueue
9658                     Maximum number of bytes in POSIX message queues.
9659              posixlocks
9660                     Maximum number of POSIX locks per user.
9661              pseudoterminals
9662                     Maximum number of pseudo-terminals.
9663              resident
9664                     Maximum resident set size.
9665              sigpending
9666                     Maximum number of pending signals.
9667              sockbufsize
9668                     Maximum size of all socket buffers.
9669              stacksize
9670                     Maximum stack size for each process.
9671              swapsize
9672                     Maximum amount of swap used.
9673              vmemorysize
9674                     Maximum amount of virtual memory.
9675
9676              Which of these resource limits are available depends on the sys‐
9677              tem.  resource can be abbreviated to any unambiguous prefix.  It
9678              can also be an integer, which corresponds to the integer defined
9679              for the resource by the operating system.
9680
9681              If argument corresponds to a number which is out of the range of
9682              the  resources  configured into the shell, the shell will try to
9683              read or write the limit anyway, and will report an error if this
9684              fails.   As  the shell does not store such resources internally,
9685              an attempt to set the limit will fail unless the  -s  option  is
9686              present.
9687
9688              limit is a number, with an optional scaling factor, as follows:
9689
9690              nh     hours
9691              nk     kilobytes (default)
9692              nm     megabytes or minutes
9693              ng     gigabytes
9694              [mm:]ss
9695                     minutes and seconds
9696
9697              The  limit  command  is  not  made available by default when the
9698              shell starts in a mode emulating another shell.  It can be  made
9699              available with the command `zmodload -F zsh/rlimits b:limit'.
9700
9701       local [ {+|-}AHUahlprtux ] [ {+|-}EFLRZi [ n ] ] [ name[=value] ... ]
9702              Same as typeset, except that the options -g, and -f are not per‐
9703              mitted.  In this case the -x option does not force  the  use  of
9704              -g, i.e. exported variables will be local to functions.
9705
9706       log    List  all users currently logged in who are affected by the cur‐
9707              rent setting of the watch parameter.
9708
9709       logout [ n ]
9710              Same as exit, except that it only works in a login shell.
9711
9712       noglob simple command
9713              See the section `Precommand Modifiers' in zshmisc(1).
9714
9715       popd [ -q ] [ {+|-}n ]
9716              Remove an entry from the directory stack, and perform  a  cd  to
9717              the  new top directory.  With no argument, the current top entry
9718              is removed.  An argument of the form `+n' identifies a stack en‐
9719              try by counting from the left of the list shown by the dirs com‐
9720              mand, starting with zero.  An argument of  the  form  -n  counts
9721              from  the right.  If the PUSHD_MINUS option is set, the meanings
9722              of `+' and `-' in this context are swapped.
9723
9724              If the -q (quiet) option is specified, the hook  function  chpwd
9725              and  the functions in the array $chpwd_functions are not called,
9726              and the new directory stack is not printed.  This is useful  for
9727              calls  to popd that do not change the environment seen by an in‐
9728              teractive user.
9729
9730       print [ -abcDilmnNoOpPrsSz ] [ -u n ] [ -f format ] [ -C cols ]
9731             [ -v name ] [ -xX tabstop ] [ -R [ -en ]] [ arg ... ]
9732              With the `-f' option the arguments are printed as  described  by
9733              printf.   With  no flags or with the flag `-', the arguments are
9734              printed on the standard output as described by  echo,  with  the
9735              following  differences:  the  escape  sequence `\M-x' (or `\Mx')
9736              metafies the character x (sets  the  highest  bit),  `\C-x'  (or
9737              `\Cx')  produces a control character (`\C-@' and `\C-?' give the
9738              characters NULL and delete), a character code in octal is repre‐
9739              sented by `\NNN' (instead of `\0NNN'), and `\E' is a synonym for
9740              `\e'.  Finally, if not in an escape sequence,  `\'  escapes  the
9741              following character and is not printed.
9742
9743              -a     Print arguments with the column incrementing first.  Only
9744                     useful with the -c and -C options.
9745
9746              -b     Recognize all the escape sequences defined for the  bind‐
9747                     key command, see the section `Zle Builtins' in zshzle(1).
9748
9749              -c     Print the arguments in columns.  Unless -a is also given,
9750                     arguments are printed with the row incrementing first.
9751
9752              -C cols
9753                     Print the arguments in cols columns.  Unless -a  is  also
9754                     given,  arguments  are  printed with the row incrementing
9755                     first.
9756
9757              -D     Treat the arguments as paths,  replacing  directory  pre‐
9758                     fixes  with  ~  expressions  corresponding  to  directory
9759                     names, as appropriate.
9760
9761              -i     If given together with -o or  -O,  sorting  is  performed
9762                     case-independently.
9763
9764              -l     Print the arguments separated by newlines instead of spa‐
9765                     ces.  Note: if the list of arguments is empty,  print  -l
9766                     will  still  output  one  empty  line.  To print a possi‐
9767                     bly-empty list of arguments one per line, use print  -C1,
9768                     as in `print -rC1 -- "$list[@]"'.
9769
9770              -m     Take  the first argument as a pattern (should be quoted),
9771                     and remove it from the argument list together with subse‐
9772                     quent arguments that do not match this pattern.
9773
9774              -n     Do not add a newline to the output.
9775
9776              -N     Print  the  arguments  separated and terminated by nulls.
9777                     Again, print -rNC1 -- "$list[@]" is a  canonical  way  to
9778                     print an arbitrary list as null-delimited records.
9779
9780              -o     Print the arguments sorted in ascending order.
9781
9782              -O     Print the arguments sorted in descending order.
9783
9784              -p     Print the arguments to the input of the coprocess.
9785
9786              -P     Perform  prompt  expansion  (see  EXPANSION OF PROMPT SE‐
9787                     QUENCES in zshmisc(1)).  In combination with `-f', prompt
9788                     escape  sequences are parsed only within interpolated ar‐
9789                     guments, not within the format string.
9790
9791              -r     Ignore the escape conventions of echo.
9792
9793              -R     Emulate the BSD echo command, which does not process  es‐
9794                     cape  sequences unless the -e flag is given.  The -n flag
9795                     suppresses the trailing newline.   Only  the  -e  and  -n
9796                     flags  are  recognized  after -R; all other arguments and
9797                     options are printed.
9798
9799              -s     Place the results in the history list instead of  on  the
9800                     standard  output.   Each argument to the print command is
9801                     treated as a single word in the  history,  regardless  of
9802                     its content.
9803
9804              -S     Place  the  results in the history list instead of on the
9805                     standard output.  In this case only a single argument  is
9806                     allowed; it will be split into words as if it were a full
9807                     shell command line.  The effect is similar to reading the
9808                     line  from  a history file with the HIST_LEX_WORDS option
9809                     active.
9810
9811              -u n   Print the arguments to file descriptor n.
9812
9813              -v name
9814                     Store the printed arguments as the value of the parameter
9815                     name.
9816
9817              -x tab-stop
9818                     Expand leading tabs on each line of output in the printed
9819                     string assuming a tab  stop  every  tab-stop  characters.
9820                     This  is  appropriate for formatting code that may be in‐
9821                     dented with tabs.  Note that leading tabs of any argument
9822                     to print, not just the first, are expanded, even if print
9823                     is using spaces to separate arguments (the  column  count
9824                     is  maintained  across  arguments but may be incorrect on
9825                     output owing to previous unexpanded tabs).
9826
9827                     The start of the output of each print command is  assumed
9828                     to be aligned with a tab stop.  Widths of multibyte char‐
9829                     acters are handled if the option MULTIBYTE is in  effect.
9830                     This option is ignored if other formatting options are in
9831                     effect, namely column alignment or printf  style,  or  if
9832                     output  is to a special location such as shell history or
9833                     the command line editor.
9834
9835              -X tab-stop
9836                     This is similar to  -x,  except  that  all  tabs  in  the
9837                     printed string are expanded.  This is appropriate if tabs
9838                     in the arguments are being used to produce a  table  for‐
9839                     mat.
9840
9841              -z     Push  the  arguments onto the editing buffer stack, sepa‐
9842                     rated by spaces.
9843
9844              If any of `-m', `-o' or `-O' are used in combination  with  `-f'
9845              and  there  are  no  arguments (after the removal process in the
9846              case of `-m') then nothing is printed.
9847
9848       printf [ -v name ] format [ arg ... ]
9849              Print the arguments according to the format specification.  For‐
9850              matting  rules  are  the  same as used in C. The same escape se‐
9851              quences as for echo are recognised in the format. All C  conver‐
9852              sion specifications ending in one of csdiouxXeEfgGn are handled.
9853              In addition to this, `%b' can be used instead of `%s'  to  cause
9854              escape  sequences  in the argument to be recognised and `%q' can
9855              be used to quote the argument in such a way that allows it to be
9856              reused  as  shell  input. With the numeric format specifiers, if
9857              the corresponding argument starts with a  quote  character,  the
9858              numeric  value  of the following character is used as the number
9859              to print; otherwise the argument is evaluated as  an  arithmetic
9860              expression.  See  the  section  `Arithmetic  Evaluation' in zsh‐
9861              misc(1) for a description of arithmetic expressions. With  `%n',
9862              the  corresponding  argument  is taken as an identifier which is
9863              created as an integer parameter.
9864
9865              Normally, conversion specifications are applied to each argument
9866              in  order but they can explicitly specify the nth argument is to
9867              be used by replacing `%' by `%n$' and `*' by `*n$'.  It is  rec‐
9868              ommended  that  you do not mix references of this explicit style
9869              with the normal style and the handling of such mixed styles  may
9870              be subject to future change.
9871
9872              If  arguments  remain unused after formatting, the format string
9873              is reused until all arguments have been consumed. With the print
9874              builtin,  this can be suppressed by using the -r option. If more
9875              arguments are required by the format than have  been  specified,
9876              the  behaviour  is as if zero or an empty string had been speci‐
9877              fied as the argument.
9878
9879              The -v option causes the output to be stored as the value of the
9880              parameter  name, instead of printed. If name is an array and the
9881              format string is reused when consuming arguments then one  array
9882              element will be used for each use of the format string.
9883
9884       pushd [ -qsLP ] [ arg ]
9885       pushd [ -qsLP ] old new
9886       pushd [ -qsLP ] {+|-}n
9887              Change the current directory, and push the old current directory
9888              onto the directory stack.  In the first form, change the current
9889              directory to arg.  If arg is not specified, change to the second
9890              directory on the stack (that is, exchange the top two  entries),
9891              or  change  to  $HOME  if  the PUSHD_TO_HOME option is set or if
9892              there is only one entry on the stack.  Otherwise, arg is  inter‐
9893              preted  as it would be by cd.  The meaning of old and new in the
9894              second form is also the same as for cd.
9895
9896              The third form of pushd changes directory by rotating the direc‐
9897              tory  list.  An argument of the form `+n' identifies a stack en‐
9898              try by counting from the left of the list shown by the dirs com‐
9899              mand,  starting  with zero.  An argument of the form `-n' counts
9900              from the right.  If the PUSHD_MINUS option is set, the  meanings
9901              of `+' and `-' in this context are swapped.
9902
9903              If  the  -q (quiet) option is specified, the hook function chpwd
9904              and the functions in the array $chpwd_functions are not  called,
9905              and  the new directory stack is not printed.  This is useful for
9906              calls to pushd that do not change the environment seen by an in‐
9907              teractive user.
9908
9909              If  the  option  -q  is  not  specified  and  the  shell  option
9910              PUSHD_SILENT is not set, the directory stack will be printed af‐
9911              ter a pushd is performed.
9912
9913              The  options  -s, -L and -P have the same meanings as for the cd
9914              builtin.
9915
9916       pushln [ arg ... ]
9917              Equivalent to print -nz.
9918
9919       pwd [ -rLP ]
9920              Print the absolute pathname of the  current  working  directory.
9921              If the -r or the -P flag is specified, or the CHASE_LINKS option
9922              is set and the -L flag is not given, the printed path  will  not
9923              contain symbolic links.
9924
9925       r      Same as fc -e -.
9926
9927
9928       read [ -rszpqAclneE ] [ -t [ num ] ] [ -k [ num ] ] [ -d delim ]
9929            [ -u n ] [ name[?prompt] ] [ name ...  ]
9930              Read  one  line and break it into fields using the characters in
9931              $IFS as separators, except as noted below.  The first  field  is
9932              assigned to the first name, the second field to the second name,
9933              etc., with leftover fields assigned to the last name.   If  name
9934              is omitted then REPLY is used for scalars and reply for arrays.
9935
9936              -r     Raw  mode:  a  `\'  at the end of a line does not signify
9937                     line continuation and backslashes in the line don't quote
9938                     the following character and are not removed.
9939
9940              -s     Don't echo back characters if reading from the terminal.
9941
9942              -q     Read only one character from the terminal and set name to
9943                     `y' if this character was `y' or `Y' and  to  `n'  other‐
9944                     wise.   With this flag set the return status is zero only
9945                     if the character was `y' or `Y'.  This option may be used
9946                     with  a  timeout  (see -t); if the read times out, or en‐
9947                     counters end of file, status 2  is  returned.   Input  is
9948                     read from the terminal unless one of -u or -p is present.
9949                     This option may also be used within zle widgets.
9950
9951              -k [ num ]
9952                     Read only one (or num) characters.  All are  assigned  to
9953                     the first name, without word splitting.  This flag is ig‐
9954                     nored when -q is present.  Input is read from the  termi‐
9955                     nal  unless  one of -u or -p is present.  This option may
9956                     also be used within zle widgets.
9957
9958                     Note that despite the mnemonic  `key'  this  option  does
9959                     read full characters, which may consist of multiple bytes
9960                     if the option MULTIBYTE is set.
9961
9962              -z     Read one entry from the editor buffer stack and assign it
9963                     to  the  first  name,  without  word  splitting.  Text is
9964                     pushed onto the stack with `print -z' or  with  push-line
9965                     from  the  line editor (see zshzle(1)).  This flag is ig‐
9966                     nored when the -k or -q flags are present.
9967
9968              -e
9969              -E     The input read is printed (echoed) to the  standard  out‐
9970                     put.  If the -e flag is used, no input is assigned to the
9971                     parameters.
9972
9973              -A     The first name is taken as the name of an array  and  all
9974                     words are assigned to it.
9975
9976              -c
9977              -l     These  flags are allowed only if called inside a function
9978                     used for completion (specified with the -K flag  to  com‐
9979                     pctl).  If the -c flag is given, the words of the current
9980                     command are read. If the -l flag is given, the whole line
9981                     is  assigned  as a scalar.  If both flags are present, -l
9982                     is used and -c is ignored.
9983
9984              -n     Together with -c, the number of the word the cursor is on
9985                     is  read.  With -l, the index of the character the cursor
9986                     is on is read.  Note that the command name is word number
9987                     1,  not word 0, and that when the cursor is at the end of
9988                     the line, its character index is the length of  the  line
9989                     plus one.
9990
9991              -u n   Input is read from file descriptor n.
9992
9993              -p     Input is read from the coprocess.
9994
9995              -d delim
9996                     Input  is  terminated by the first character of delim in‐
9997                     stead of by newline.
9998
9999              -t [ num ]
10000                     Test if input is available before attempting to read.  If
10001                     num  is  present,  it must begin with a digit and will be
10002                     evaluated to give a number of seconds,  which  may  be  a
10003                     floating point number; in this case the read times out if
10004                     input is not available within this time.  If num  is  not
10005                     present, it is taken to be zero, so that read returns im‐
10006                     mediately if no input  is  available.   If  no  input  is
10007                     available, return status 1 and do not set any variables.
10008
10009                     This option is not available when reading from the editor
10010                     buffer with -z, when called from within  completion  with
10011                     -c  or  -l,  with  -q which clears the input queue before
10012                     reading, or within zle where other mechanisms  should  be
10013                     used to test for input.
10014
10015                     Note  that  read does not attempt to alter the input pro‐
10016                     cessing mode.  The default mode is  canonical  input,  in
10017                     which  an entire line is read at a time, so usually `read
10018                     -t' will not read anything until an entire line has  been
10019                     typed.   However,  when reading from the terminal with -k
10020                     input is processed one key at a time; in this case,  only
10021                     availability  of  the  first character is tested, so that
10022                     e.g. `read -t -k 2' can still block on the second charac‐
10023                     ter.   Use  two  instances of `read -t -k' if this is not
10024                     what is wanted.
10025
10026              If the first argument contains a `?', the remainder of this word
10027              is used as a prompt on standard error when the shell is interac‐
10028              tive.
10029
10030              The value (exit status) of read is 1 when an end-of-file is  en‐
10031              countered,  or  when  -c or -l is present and the command is not
10032              called from a compctl function, or as described for -q.   Other‐
10033              wise the value is 0.
10034
10035              The  behavior  of some combinations of the -k, -p, -q, -u and -z
10036              flags is undefined.  Presently -q cancels  all  the  others,  -p
10037              cancels  -u, -k cancels -z, and otherwise -z cancels both -p and
10038              -u.
10039
10040              The -c or -l flags cancel any and all of -kpquz.
10041
10042       readonly
10043              Same as typeset -r.  With the POSIX_BUILTINS option set, same as
10044              typeset -gr.
10045
10046       rehash Same as hash -r.
10047
10048       return [ n ]
10049              Causes  a shell function or `.' script to return to the invoking
10050              script with the return status specified by an arithmetic expres‐
10051              sion  n.  If n is omitted, the return status is that of the last
10052              command executed.
10053
10054              If return was executed from a trap in a  TRAPNAL  function,  the
10055              effect  is  different for zero and non-zero return status.  With
10056              zero status (or after an implicit  return  at  the  end  of  the
10057              trap),  the shell will return to whatever it was previously pro‐
10058              cessing; with a non-zero status, the shell will behave as inter‐
10059              rupted  except  that  the return status of the trap is retained.
10060              Note that the numeric value of the signal which caused the  trap
10061              is  passed  as  the  first  argument,  so  the statement `return
10062              $((128+$1))' will return the same status as if  the  signal  had
10063              not been trapped.
10064
10065       sched  See the section `The zsh/sched Module' in zshmodules(1).
10066
10067
10068       set [ {+|-}options | {+|-}o [ option_name ] ] ... [ {+|-}A [ name ] ]
10069           [ arg ... ]
10070              Set  the options for the shell and/or set the positional parame‐
10071              ters, or declare and set an array.  If the -s option  is  given,
10072              it  causes the specified arguments to be sorted before assigning
10073              them to the positional parameters (or to the array name if -A is
10074              used).   With  +s  sort  arguments in descending order.  For the
10075              meaning of the other flags, see  zshoptions(1).   Flags  may  be
10076              specified by name using the -o option. If no option name is sup‐
10077              plied with -o, the current option states are printed:   see  the
10078              description  of setopt below for more information on the format.
10079              With +o they are printed in a form that can be used as input  to
10080              the shell.
10081
10082              If  the -A flag is specified, name is set to an array containing
10083              the given args; if no name is specified, all arrays are  printed
10084              together with their values.
10085
10086              If +A is used and name is an array, the given arguments will re‐
10087              place the initial elements of that array; if no name  is  speci‐
10088              fied, all arrays are printed without their values.
10089
10090              The  behaviour  of arguments after -A name or +A name depends on
10091              whether the option KSH_ARRAYS is set.  If it is not set, all ar‐
10092              guments  following name are treated as values for the array, re‐
10093              gardless of their form.  If the option  is  set,  normal  option
10094              processing  continues  at that point; only regular arguments are
10095              treated as values for the array.  This means that
10096
10097                     set -A array -x -- foo
10098
10099              sets array to `-x -- foo' if KSH_ARRAYS is not set, but sets the
10100              array to foo and turns on the option `-x' if it is set.
10101
10102              If  the  -A  flag is not present, but there are arguments beyond
10103              the options, the positional parameters are set.  If  the  option
10104              list  (if  any)  is terminated by `--', and there are no further
10105              arguments, the positional parameters will be unset.
10106
10107              If no arguments and no `--' are given, then the names and values
10108              of  all  parameters  are printed on the standard output.  If the
10109              only argument is `+', the names of all parameters are printed.
10110
10111              For historical reasons, `set -' is treated as `set +xv' and `set
10112              -  args'  as  `set +xv -- args' when in any other emulation mode
10113              than zsh's native mode.
10114
10115       setcap See the section `The zsh/cap Module' in zshmodules(1).
10116
10117       setopt [ {+|-}options | {+|-}o option_name ] [ -m ] [ name ... ]
10118              Set the options for the shell.   All  options  specified  either
10119              with flags or by name are set.
10120
10121              If no arguments are supplied, the names of all options currently
10122              set are printed.  The form is chosen so as to minimize the  dif‐
10123              ferences from the default options for the current emulation (the
10124              default emulation being native  zsh,  shown  as  <Z>  in  zshop‐
10125              tions(1)).  Options that are on by default for the emulation are
10126              shown with the prefix no only if they are off, while  other  op‐
10127              tions  are  shown without the prefix no and only if they are on.
10128              In addition to options changed from the  default  state  by  the
10129              user,  any options activated automatically by the shell (for ex‐
10130              ample, SHIN_STDIN or INTERACTIVE) will be  shown  in  the  list.
10131              The  format  is further modified by the option KSH_OPTION_PRINT,
10132              however the rationale for choosing options with or  without  the
10133              no prefix remains the same in this case.
10134
10135              If  the  -m  flag  is  given the arguments are taken as patterns
10136              (which should be quoted to protect  them  from  filename  expan‐
10137              sion),  and  all  options with names matching these patterns are
10138              set.
10139
10140              Note that a bad option name does not cause execution  of  subse‐
10141              quent  shell  code to be aborted; this is behaviour is different
10142              from that of `set -o'.  This is because set  is  regarded  as  a
10143              special builtin by the POSIX standard, but setopt is not.
10144
10145       shift [ -p ] [ n ] [ name ... ]
10146              The  positional  parameters  ${n+1}  ...  are renamed to $1 ...,
10147              where n is an arithmetic expression that defaults to 1.  If  any
10148              names are given then the arrays with these names are shifted in‐
10149              stead of the positional parameters.
10150
10151              If the option -p is given arguments are instead removed (popped)
10152              from the end rather than the start of the array.
10153
10154       source file [ arg ... ]
10155              Same  as  `.',  except  that  the  current  directory  is always
10156              searched and is always searched  first,  before  directories  in
10157              $path.
10158
10159       stat   See the section `The zsh/stat Module' in zshmodules(1).
10160
10161       suspend [ -f ]
10162              Suspend  the execution of the shell (send it a SIGTSTP) until it
10163              receives a SIGCONT.  Unless the -f option is  given,  this  will
10164              refuse to suspend a login shell.
10165
10166       test [ arg ... ]
10167       [ [ arg ... ] ]
10168              Like  the  system version of test.  Added for compatibility; use
10169              conditional expressions instead (see  the  section  `Conditional
10170              Expressions').  The main differences between the conditional ex‐
10171              pression syntax and the test and [ builtins are:  these commands
10172              are  not handled syntactically, so for example an empty variable
10173              expansion may cause an argument to  be  omitted;  syntax  errors
10174              cause  status  2  to  be  returned instead of a shell error; and
10175              arithmetic operators expect integer arguments rather than arith‐
10176              metic expressions.
10177
10178              The command attempts to implement POSIX and its extensions where
10179              these are specified.  Unfortunately there are intrinsic ambigui‐
10180              ties  in  the  syntax; in particular there is no distinction be‐
10181              tween test operators and strings that resemble them.  The  stan‐
10182              dard  attempts  to  resolve these for small numbers of arguments
10183              (up to four); for five or more arguments compatibility cannot be
10184              relied  on.   Users  are urged wherever possible to use the `[['
10185              test syntax which does not have these ambiguities.
10186
10187       times  Print the accumulated user and system times for  the  shell  and
10188              for processes run from the shell.
10189
10190       trap [ arg ] [ sig ... ]
10191              arg  is  a series of commands (usually quoted to protect it from
10192              immediate evaluation by the shell) to be read and executed  when
10193              the  shell  receives any of the signals specified by one or more
10194              sig args.  Each sig can be given as a number, or as the name  of
10195              a signal either with or without the string SIG in front (e.g. 1,
10196              HUP, and SIGHUP are all the same signal).
10197
10198              If arg is `-', then the specified signals are reset to their de‐
10199              faults, or, if no sig args are present, all traps are reset.
10200
10201              If  arg  is  an empty string, then the specified signals are ig‐
10202              nored by the shell (and by the commands it invokes).
10203
10204              If arg is omitted but one or more sig args  are  provided  (i.e.
10205              the first argument is a valid signal number or name), the effect
10206              is the same as if arg had been specified as `-'.
10207
10208              The trap command with no arguments prints a list of commands as‐
10209              sociated with each signal.
10210
10211              If sig is ZERR then arg will be executed after each command with
10212              a nonzero exit status.  ERR is an alias for ZERR on systems that
10213              have no SIGERR signal (this is the usual case).
10214
10215              If sig is DEBUG then arg will be executed before each command if
10216              the option DEBUG_BEFORE_CMD is set (as it is by  default),  else
10217              after each command.  Here, a `command' is what is described as a
10218              `sublist' in the shell grammar, see the section SIMPLE  COMMANDS
10219              &  PIPELINES  in zshmisc(1).  If DEBUG_BEFORE_CMD is set various
10220              additional features are available.  First,  it  is  possible  to
10221              skip  the  next  command by setting the option ERR_EXIT; see the
10222              description of the ERR_EXIT option in zshoptions(1).  Also,  the
10223              shell parameter ZSH_DEBUG_CMD is set to the string corresponding
10224              to the command to be executed following  the  trap.   Note  that
10225              this  string  is  reconstructed from the internal format and may
10226              not be formatted the same way as the original text.  The parame‐
10227              ter is unset after the trap is executed.
10228
10229              If  sig  is  0 or EXIT and the trap statement is executed inside
10230              the body of a function, then the command arg is  executed  after
10231              the  function completes.  The value of $? at the start of execu‐
10232              tion is the exit status of the shell or the return status of the
10233              function exiting.  If sig is 0 or EXIT and the trap statement is
10234              not executed inside the body of a function, then the command arg
10235              is  executed when the shell terminates; the trap runs before any
10236              zshexit hook functions.
10237
10238              ZERR, DEBUG, and EXIT traps are not executed inside other traps.
10239              ZERR  and  DEBUG  traps  are  kept within subshells, while other
10240              traps are reset.
10241
10242              Note that traps defined with the trap builtin are slightly  dif‐
10243              ferent from those defined as `TRAPNAL () { ... }', as the latter
10244              have their own function environment (line numbers,  local  vari‐
10245              ables, etc.) while the former use the environment of the command
10246              in which they were called.  For example,
10247
10248                     trap 'print $LINENO' DEBUG
10249
10250              will print the line number of a command executed  after  it  has
10251              run, while
10252
10253                     TRAPDEBUG() { print $LINENO; }
10254
10255              will always print the number zero.
10256
10257              Alternative  signal  names  are  allowed as described under kill
10258              above.  Defining a trap under either name causes any trap  under
10259              an  alternative  name to be removed.  However, it is recommended
10260              that for consistency users stick exclusively to one name or  an‐
10261              other.
10262
10263       true [ arg ... ]
10264              Do nothing and return an exit status of 0.
10265
10266       ttyctl [ -fu ]
10267              The  -f option freezes the tty (i.e. terminal or terminal emula‐
10268              tor), and -u unfreezes it.  When the tty is frozen,  no  changes
10269              made to the tty settings by external programs will be honored by
10270              the shell, except for changes in the size  of  the  screen;  the
10271              shell will simply reset the settings to their previous values as
10272              soon as each command exits or is suspended.  Thus, stty and sim‐
10273              ilar  programs  have no effect when the tty is frozen.  Freezing
10274              the tty does not cause the current state to be  remembered:  in‐
10275              stead, it causes future changes to the state to be blocked.
10276
10277              Without  options  it  reports  whether the terminal is frozen or
10278              not.
10279
10280              Note that, regardless of whether the tty is frozen or  not,  the
10281              shell  needs to change the settings when the line editor starts,
10282              so unfreezing the tty does not guarantee settings  made  on  the
10283              command  line  are  preserved.   Strings of commands run between
10284              editing the command line will see a consistent tty  state.   See
10285              also the shell variable STTY for a means of initialising the tty
10286              before running external commands.
10287
10288       type [ -wfpamsS ] name ...
10289              Equivalent to whence -v.
10290
10291
10292       typeset [ {+|-}AHUaghlmrtux ] [ {+|-}EFLRZip [ n ] ]
10293               [ + ] [ name[=value] ... ]
10294       typeset -T [ {+|-}Uglrux ] [ {+|-}LRZp [ n ] ]
10295               [ + | SCALAR[=value] array[=(value ...)] [ sep ] ]
10296       typeset -f [ {+|-}TUkmtuz ] [ + ] [ name ... ]
10297              Set or display attributes and values for shell parameters.
10298
10299              Except as noted below for control flags that change  the  behav‐
10300              ior,  a parameter is created for each name that does not already
10301              refer to one.  When inside a function, a new parameter  is  cre‐
10302              ated  for every name (even those that already exist), and is un‐
10303              set again when the function completes.  See  `Local  Parameters'
10304              in  zshparam(1).   The same rules apply to special shell parame‐
10305              ters, which retain their special attributes when made local.
10306
10307              For each name=value assignment, the parameter  name  is  set  to
10308              value.
10309
10310              If  the shell option TYPESET_SILENT is not set, for each remain‐
10311              ing name that refers to a parameter that  is  already  set,  the
10312              name  and  value  of the parameter are printed in the form of an
10313              assignment.  Nothing is printed for newly-created parameters, or
10314              when  any  attribute flags listed below are given along with the
10315              name.  Using `+' instead of  minus  to  introduce  an  attribute
10316              turns it off.
10317
10318              If  no  name  is present, the names and values of all parameters
10319              are printed.  In this case the attribute flags restrict the dis‐
10320              play  to  only  those  parameters  that  have  the specified at‐
10321              tributes, and using `+' rather than `-' to  introduce  the  flag
10322              suppresses printing of the values of parameters when there is no
10323              parameter name.
10324
10325              All forms of the command handle scalar  assignment.   Array  as‐
10326              signment  is  possible if any of the reserved words declare, ex‐
10327              port, float, integer, local, readonly or typeset is matched when
10328              the line is parsed (N.B. not when it is executed).  In this case
10329              the arguments are parsed as assignments, except  that  the  `+='
10330              syntax  and the GLOB_ASSIGN option are not supported, and scalar
10331              values after = are not split further into  words,  even  if  ex‐
10332              panded  (regardless  of  the  setting of the KSH_TYPESET option;
10333              this option is obsolete).
10334
10335              Examples of the differences between command  and  reserved  word
10336              parsing:
10337
10338                     # Reserved word parsing
10339                     typeset svar=$(echo one word) avar=(several words)
10340
10341              The above creates a scalar parameter svar and an array parameter
10342              avar as if the assignments had been
10343
10344                     svar="one word"
10345                     avar=(several words)
10346
10347              On the other hand:
10348
10349                     # Normal builtin interface
10350                     builtin typeset svar=$(echo two words)
10351
10352              The builtin keyword causes the above to use the standard builtin
10353              interface  to  typeset in which argument parsing is performed in
10354              the same way as for other  commands.   This  example  creates  a
10355              scalar  svar containing the value two and another scalar parame‐
10356              ter words with no value.  An array value in this case would  ei‐
10357              ther  cause  an  error  or  be treated as an obscure set of glob
10358              qualifiers.
10359
10360              Arbitrary arguments are allowed if they take the form of assign‐
10361              ments  after command line expansion; however, these only perform
10362              scalar assignment:
10363
10364                     var='svar=val'
10365                     typeset $var
10366
10367              The above sets the scalar  parameter  svar  to  the  value  val.
10368              Parentheses  around  the  value within var would not cause array
10369              assignment as they will be treated as ordinary  characters  when
10370              $var is substituted.  Any non-trivial expansion in the name part
10371              of the assignment causes the argument  to  be  treated  in  this
10372              fashion:
10373
10374                     typeset {var1,var2,var3}=name
10375
10376              The  above  syntax is valid, and has the expected effect of set‐
10377              ting the three parameters to the same  value,  but  the  command
10378              line  is  parsed as a set of three normal command line arguments
10379              to typeset after expansion.  Hence it is not possible to  assign
10380              to multiple arrays by this means.
10381
10382              Note  that  each interface to any of the commands my be disabled
10383              separately.  For example, `disable -r typeset' disables the  re‐
10384              served  word  interface  to typeset, exposing the builtin inter‐
10385              face, while `disable typeset' disables the builtin.   Note  that
10386              disabling  the  reserved  word  interface  for typeset may cause
10387              problems with the output of `typeset -p', which assumes the  re‐
10388              served word interface is available in order to restore array and
10389              associative array values.
10390
10391              Unlike parameter assignment statements, typeset's exit status on
10392              an  assignment that involves a command substitution does not re‐
10393              flect the exit status of the command  substitution.   Therefore,
10394              to  test  for  an  error in a command substitution, separate the
10395              declaration of the parameter from its initialization:
10396
10397                     # WRONG
10398                     typeset var1=$(exit 1) || echo "Trouble with var1"
10399
10400                     # RIGHT
10401                     typeset var1 && var1=$(exit 1) || echo "Trouble with var1"
10402
10403              To initialize a parameter param to a command output and mark  it
10404              readonly,  use  typeset -r param or readonly param after the pa‐
10405              rameter assignment statement.
10406
10407              If no attribute flags are given, and either  no  name  arguments
10408              are  present  or  the  flag +m is used, then each parameter name
10409              printed is preceded by a list of the attributes of that  parame‐
10410              ter  (array, association, exported, float, integer, readonly, or
10411              undefined for autoloaded parameters not yet loaded).  If  +m  is
10412              used  with  attribute  flags, and all those flags are introduced
10413              with +, the matching parameter names are printed but their  val‐
10414              ues are not.
10415
10416              The following control flags change the behavior of typeset:
10417
10418              +      If  `+'  appears by itself in a separate word as the last
10419                     option, then the names of all parameters (functions  with
10420                     -f)  are  printed,  but  the values (function bodies) are
10421                     not.  No name arguments may appear, and it  is  an  error
10422                     for  any  other options to follow `+'.  The effect of `+'
10423                     is as if all attribute flags which precede it were  given
10424                     with a `+' prefix.  For example, `typeset -U +' is equiv‐
10425                     alent to `typeset +U' and displays the names of  all  ar‐
10426                     rays having the uniqueness attribute, whereas `typeset -f
10427                     -U +' displays the names of all  autoloadable  functions.
10428                     If  +  is  the only option, then type information (array,
10429                     readonly, etc.) is also printed for  each  parameter,  in
10430                     the same manner as `typeset +m "*"'.
10431
10432              -g     The  -g  (global) means that any resulting parameter will
10433                     not be restricted to local scope.  Note  that  this  does
10434                     not  necessarily  mean that the parameter will be global,
10435                     as the flag will apply to any existing parameter (even if
10436                     unset)  from  an  enclosing function.  This flag does not
10437                     affect the parameter after creation, hence it has no  ef‐
10438                     fect  when listing existing parameters, nor does the flag
10439                     +g have any effect except in combination with -m (see be‐
10440                     low).
10441
10442              -m     If  the  -m flag is given the name arguments are taken as
10443                     patterns (use quoting to prevent these from being  inter‐
10444                     preted  as  file patterns).  With no attribute flags, all
10445                     parameters (or functions with the -f flag) with  matching
10446                     names are printed (the shell option TYPESET_SILENT is not
10447                     used in this case).
10448
10449                     If the +g flag is combined with -m, a new local parameter
10450                     is  created  for every matching parameter that is not al‐
10451                     ready local.  Otherwise -m applies all other flags or as‐
10452                     signments to the existing parameters.
10453
10454                     Except  when  assignments are made with name=value, using
10455                     +m forces the matching parameters and their attributes to
10456                     be  printed, even inside a function.  Note that -m is ig‐
10457                     nored if no patterns are given, so `typeset -m'  displays
10458                     attributes but `typeset -a +m' does not.
10459
10460              -p [ n ]
10461                     If  the  -p  option  is  given, parameters and values are
10462                     printed in the form of a typeset command with an  assign‐
10463                     ment,  regardless  of other flags and options.  Note that
10464                     the -H flag on parameters is respected; no value will  be
10465                     shown for these parameters.
10466
10467                     -p may be followed by an optional integer argument.  Cur‐
10468                     rently only the value 1 is supported.  In this  case  ar‐
10469                     rays and associative arrays are printed with newlines be‐
10470                     tween indented elements for readability.
10471
10472              -T [ scalar[=value] array[=(value ...)] [ sep ] ]
10473                     This flag has a different meaning when used with -f;  see
10474                     below.   Otherwise  the  -T option requires zero, two, or
10475                     three arguments to be present.  With  no  arguments,  the
10476                     list  of  parameters  created  in  this fashion is shown.
10477                     With two or three arguments, the first two are  the  name
10478                     of  a  scalar  and  of an array parameter (in that order)
10479                     that will be tied together in the  manner  of  $PATH  and
10480                     $path.  The optional third argument is a single-character
10481                     separator which will be used to join the elements of  the
10482                     array  to form the scalar; if absent, a colon is used, as
10483                     with $PATH.  Only the first character of the separator is
10484                     significant;   any   remaining  characters  are  ignored.
10485                     Multibyte characters are not yet supported.
10486
10487                     Only one of the scalar and array parameters  may  be  as‐
10488                     signed  an  initial value (the restrictions on assignment
10489                     forms described above also apply).
10490
10491                     Both the scalar and the array may be manipulated as  nor‐
10492                     mal.   If  one  is unset, the other will automatically be
10493                     unset too.  There is no  way  of  untying  the  variables
10494                     without unsetting them, nor of converting the type of one
10495                     of them with another typeset command; +T does  not  work,
10496                     assigning an array to scalar is an error, and assigning a
10497                     scalar to array sets it to be a single-element array.
10498
10499                     Note that both `typeset -xT ...'   and  `export  -T  ...'
10500                     work,  but  only  the  scalar  will be marked for export.
10501                     Setting the value using the scalar version causes a split
10502                     on all separators (which cannot be quoted).  It is possi‐
10503                     ble to apply -T to two previously tied variables but with
10504                     a  different separator character, in which case the vari‐
10505                     ables remain  joined  as  before  but  the  separator  is
10506                     changed.
10507
10508                     When an existing scalar is tied to a new array, the value
10509                     of the scalar is preserved but no  attribute  other  than
10510                     export will be preserved.
10511
10512              Attribute  flags that transform the final value (-L, -R, -Z, -l,
10513              -u) are only applied to the expanded value at the point of a pa‐
10514              rameter  expansion  expression  using `$'.  They are not applied
10515              when a parameter is retrieved internally by the  shell  for  any
10516              purpose.
10517
10518              The following attribute flags may be specified:
10519
10520              -A     The names refer to associative array parameters; see `Ar‐
10521                     ray Parameters' in zshparam(1).
10522
10523              -L [ n ]
10524                     Left justify and remove leading  blanks  from  the  value
10525                     when  the parameter is expanded.  If n is nonzero, it de‐
10526                     fines the width of the field.  If n is zero, the width is
10527                     determined by the width of the value of the first assign‐
10528                     ment.  In the case of numeric parameters, the  length  of
10529                     the  complete  value assigned to the parameter is used to
10530                     determine the width, not the value that would be output.
10531
10532                     The width is the count of characters, which may be multi‐
10533                     byte  characters  if  the  MULTIBYTE option is in effect.
10534                     Note that the screen width of the character is not  taken
10535                     into  account;  if this is required, use padding with pa‐
10536                     rameter expansion flags  ${(ml...)...}  as  described  in
10537                     `Parameter Expansion Flags' in zshexpn(1).
10538
10539                     When the parameter is expanded, it is filled on the right
10540                     with blanks or truncated if necessary to fit  the  field.
10541                     Note  truncation  can lead to unexpected results with nu‐
10542                     meric parameters.  Leading zeros are removed  if  the  -Z
10543                     flag is also set.
10544
10545              -R [ n ]
10546                     Similar  to  -L, except that right justification is used;
10547                     when the parameter is expanded, the field is left  filled
10548                     with  blanks  or truncated from the end.  May not be com‐
10549                     bined with the -Z flag.
10550
10551              -U     For arrays (but not for associative  arrays),  keep  only
10552                     the  first occurrence of each duplicated value.  This may
10553                     also be set for tied parameters (see -T)  or  colon-sepa‐
10554                     rated special parameters like PATH or FIGNORE, etc.  Note
10555                     the flag takes effect on assignment, and the type of  the
10556                     variable  being  assigned  to is determinative; for vari‐
10557                     ables with shared values it is therefore  recommended  to
10558                     set  the  flag  for all interfaces, e.g. `typeset -U PATH
10559                     path'.
10560
10561                     This flag has a different meaning when used with -f;  see
10562                     below.
10563
10564              -Z [ n ]
10565                     Specially  handled if set along with the -L flag.  Other‐
10566                     wise, similar to -R, except that leading zeros  are  used
10567                     for  padding  instead  of  blanks  if the first non-blank
10568                     character is a digit.  Numeric parameters  are  specially
10569                     handled:  they  are  always eligible for padding with ze‐
10570                     roes, and the zeroes are inserted at an appropriate place
10571                     in the output.
10572
10573              -a     The  names refer to array parameters.  An array parameter
10574                     may be created this way, but it may be assigned to in the
10575                     typeset statement only if the reserved word form of type‐
10576                     set is enabled (as it is by default).   When  displaying,
10577                     both normal and associative arrays are shown.
10578
10579              -f     The  names refer to functions rather than parameters.  No
10580                     assignments can be made, and the only other  valid  flags
10581                     are -t, -T, -k, -u, -U and -z.  The flag -t turns on exe‐
10582                     cution tracing for this function; the flag  -T  does  the
10583                     same, but turns off tracing for any named (not anonymous)
10584                     function called from the present one, unless  that  func‐
10585                     tion  also  has  the  -t or -T flag.  The -u and -U flags
10586                     cause the function to be marked for autoloading; -U  also
10587                     causes alias expansion to be suppressed when the function
10588                     is loaded.  See the description of the `autoload' builtin
10589                     for details.
10590
10591                     Note  that  the builtin functions provides the same basic
10592                     capabilities as typeset -f but gives access to a few  ex‐
10593                     tra  options;  autoload  gives further additional options
10594                     for the case typeset -fu and typeset -fU.
10595
10596              -h     Hide: only useful for special  parameters  (those  marked
10597                     `<S>' in the table in zshparam(1)), and for local parame‐
10598                     ters with the same name as a  special  parameter,  though
10599                     harmless  for  others.  A special parameter with this at‐
10600                     tribute will not retain its special effect when made  lo‐
10601                     cal.  Thus after `typeset -h PATH', a function containing
10602                     `typeset PATH' will create an  ordinary  local  parameter
10603                     without  the usual behaviour of PATH.  Alternatively, the
10604                     local parameter may itself be given this attribute; hence
10605                     inside  a  function `typeset -h PATH' creates an ordinary
10606                     local parameter and the special PATH parameter is not al‐
10607                     tered  in any way.  It is also possible to create a local
10608                     parameter using `typeset +h  special',  where  the  local
10609                     copy  of  special  will retain its special properties re‐
10610                     gardless of having the -h attribute.  Global special  pa‐
10611                     rameters  loaded  from  shell modules (currently those in
10612                     zsh/mapfile and zsh/parameter)  are  automatically  given
10613                     the -h attribute to avoid name clashes.
10614
10615              -H     Hide  value:  specifies that typeset will not display the
10616                     value of the parameter when listing parameters; the  dis‐
10617                     play for such parameters is always as if the `+' flag had
10618                     been given.  Use of the parameter is  in  other  respects
10619                     normal, and the option does not apply if the parameter is
10620                     specified by name, or by  pattern  with  the  -m  option.
10621                     This  is  on by default for the parameters in the zsh/pa‐
10622                     rameter and zsh/mapfile modules.  Note, however, that un‐
10623                     like  the -h flag this is also useful for non-special pa‐
10624                     rameters.
10625
10626              -i [ n ]
10627                     Use an internal integer representation.  If n is  nonzero
10628                     it  defines  the  output arithmetic base, otherwise it is
10629                     determined by the first assignment.  Bases from 2  to  36
10630                     inclusive are allowed.
10631
10632              -E [ n ]
10633                     Use an internal double-precision floating point represen‐
10634                     tation.  On output the variable will be converted to sci‐
10635                     entific  notation.  If n is nonzero it defines the number
10636                     of significant figures to display; the default is ten.
10637
10638              -F [ n ]
10639                     Use an internal double-precision floating point represen‐
10640                     tation.   On  output  the  variable  will be converted to
10641                     fixed-point decimal notation.  If n is nonzero it defines
10642                     the  number of digits to display after the decimal point;
10643                     the default is ten.
10644
10645              -l     Convert the result to lower case whenever  the  parameter
10646                     is expanded.  The value is not converted when assigned.
10647
10648              -r     The  given  names are marked readonly.  Note that if name
10649                     is a special parameter, the  readonly  attribute  can  be
10650                     turned on, but cannot then be turned off.
10651
10652                     If  the POSIX_BUILTINS option is set, the readonly attri‐
10653                     bute is more restrictive: unset variables can  be  marked
10654                     readonly  and  cannot then be set; furthermore, the read‐
10655                     only attribute cannot be removed from any variable.
10656
10657                     It is still possible to change other  attributes  of  the
10658                     variable though, some of which like -U or -Z would affect
10659                     the value. More generally, the readonly attribute  should
10660                     not be relied on as a security mechanism.
10661
10662                     Note  that  in  zsh  (like in pdksh but unlike most other
10663                     shells) it is still possible to create a  local  variable
10664                     of  the same name as this is considered a different vari‐
10665                     able (though this variable, too, can be marked readonly).
10666                     Special  variables  that  have  been made readonly retain
10667                     their value and readonly attribute when made local.
10668
10669              -t     Tags the named parameters.  Tags have no special  meaning
10670                     to  the  shell.   This  flag has a different meaning when
10671                     used with -f; see above.
10672
10673              -u     Convert the result to upper case whenever  the  parameter
10674                     is  expanded.   The value is not converted when assigned.
10675                     This flag has a different meaning when used with -f;  see
10676                     above.
10677
10678              -x     Mark  for  automatic  export to the environment of subse‐
10679                     quently executed commands.  If the  option  GLOBAL_EXPORT
10680                     is set, this implies the option -g, unless +g is also ex‐
10681                     plicitly given; in other words the parameter is not  made
10682                     local to the enclosing function.  This is for compatibil‐
10683                     ity with previous versions of zsh.
10684
10685       ulimit [ -HSa ] [ { -bcdfiklmnpqrsTtvwx | -N resource } [ limit ] ... ]
10686              Set or display resource limits of the shell  and  the  processes
10687              started by the shell.  The value of limit can be a number in the
10688              unit specified below or one of the values `unlimited', which re‐
10689              moves  the limit on the resource, or `hard', which uses the cur‐
10690              rent value of the hard limit on the resource.
10691
10692              By default, only soft limits are manipulated. If the -H flag  is
10693              given use hard limits instead of soft limits.  If the -S flag is
10694              given together with the -H flag set both hard and soft limits.
10695
10696              If no options are used, the file size limit (-f) is assumed.
10697
10698              If limit is omitted the current value of the specified resources
10699              are  printed.  When more than one resource value is printed, the
10700              limit name and unit is printed before each value.
10701
10702              When looping over multiple resources, the shell will abort imme‐
10703              diately  if  it detects a badly formed argument.  However, if it
10704              fails to set a limit for some other reason it will continue try‐
10705              ing to set the remaining limits.
10706
10707              Not  all  the  following resources are supported on all systems.
10708              Running ulimit -a will show which are supported.
10709
10710              -a     Lists all of the current resource limits.
10711              -b     Socket buffer size in bytes (N.B. not kilobytes)
10712              -c     512-byte blocks on the size of core dumps.
10713              -d     Kilobytes on the size of the data segment.
10714              -f     512-byte blocks on the size of files written.
10715              -i     The number of pending signals.
10716              -k     The number of kqueues allocated.
10717              -l     Kilobytes on the size of locked-in memory.
10718              -m     Kilobytes on the size of physical memory.
10719              -n     open file descriptors.
10720              -p     The number of pseudo-terminals.
10721              -q     Bytes in POSIX message queues.
10722              -r     Maximum real time priority.  On some systems  where  this
10723                     is  not  available, such as NetBSD, this has the same ef‐
10724                     fect as -T for compatibility with sh.
10725              -s     Kilobytes on the size of the stack.
10726              -T     The number of simultaneous threads available to the user.
10727              -t     CPU seconds to be used.
10728              -u     The number of processes available to the user.
10729              -v     Kilobytes on the size of virtual memory.  On some systems
10730                     this refers to the limit called `address space'.
10731              -w     Kilobytes on the size of swapped out memory.
10732              -x     The number of locks on files.
10733
10734              A  resource may also be specified by integer in the form `-N re‐
10735              source', where resource corresponds to the integer  defined  for
10736              the  resource  by the operating system.  This may be used to set
10737              the limits for resources known to the shell which do not  corre‐
10738              spond to option letters.  Such limits will be shown by number in
10739              the output of `ulimit -a'.
10740
10741              The number may alternatively be out of the range of limits  com‐
10742              piled  into  the shell.  The shell will try to read or write the
10743              limit anyway, and will report an error if this fails.
10744
10745       umask [ -S ] [ mask ]
10746              The umask is set to mask.  mask can be either an octal number or
10747              a  symbolic value as described in chmod(1).  If mask is omitted,
10748              the current value is printed.  The -S option causes the mask  to
10749              be  printed as a symbolic value.  Otherwise, the mask is printed
10750              as an octal number.  Note that in the symbolic form the  permis‐
10751              sions you specify are those which are to be allowed (not denied)
10752              to the users specified.
10753
10754       unalias [ -ams ] name ...
10755              Removes aliases.  This command works the same as unhash -a,  ex‐
10756              cept  that  the -a option removes all regular or global aliases,
10757              or with -s all suffix aliases: in this case  no  name  arguments
10758              may  appear.   The options -m (remove by pattern) and -s without
10759              -a (remove listed suffix aliases) behave as for unhash -a.  Note
10760              that the meaning of -a is different between unalias and unhash.
10761
10762       unfunction
10763              Same as unhash -f.
10764
10765       unhash [ -adfms ] name ...
10766              Remove  the element named name from an internal hash table.  The
10767              default is remove elements from the command hash table.  The  -a
10768              option  causes  unhash to remove regular or global aliases; note
10769              when removing a global aliases that the argument must be  quoted
10770              to  prevent  it  from  being expanded before being passed to the
10771              command.  The -s option causes unhash to remove suffix  aliases.
10772              The  -f  option causes unhash to remove shell functions.  The -d
10773              options causes unhash to remove named directories.   If  the  -m
10774              flag  is  given  the  arguments are taken as patterns (should be
10775              quoted) and all elements of the corresponding  hash  table  with
10776              matching names will be removed.
10777
10778       unlimit [ -hs ] resource ...
10779              The  resource  limit for each resource is set to the hard limit.
10780              If the -h flag is given and the  shell  has  appropriate  privi‐
10781              leges,  the  hard  resource  limit for each resource is removed.
10782              The resources of the shell process are only changed  if  the  -s
10783              flag is given.
10784
10785              The  unlimit  command  is not made available by default when the
10786              shell starts in a mode emulating another shell.  It can be  made
10787              available with the command `zmodload -F zsh/rlimits b:unlimit'.
10788
10789       unset [ -fmv ] name ...
10790              Each  named  parameter  is unset.  Local parameters remain local
10791              even if unset; they appear unset within scope, but the  previous
10792              value will still reappear when the scope ends.
10793
10794              Individual elements of associative array parameters may be unset
10795              by using subscript syntax on name, which should  be  quoted  (or
10796              the  entire  command  prefixed  with noglob) to protect the sub‐
10797              script from filename generation.
10798
10799              If the -m flag is specified the arguments are taken as  patterns
10800              (should  be  quoted)  and all parameters with matching names are
10801              unset.  Note that this cannot be used when unsetting associative
10802              array  elements, as the subscript will be treated as part of the
10803              pattern.
10804
10805              The -v flag specifies that name refers to  parameters.  This  is
10806              the default behaviour.
10807
10808              unset -f is equivalent to unfunction.
10809
10810       unsetopt [ {+|-}options | {+|-}o option_name ] [ name ... ]
10811              Unset  the  options for the shell.  All options specified either
10812              with flags or by name are unset.  If no arguments are  supplied,
10813              the names of all options currently unset are printed.  If the -m
10814              flag is given the arguments are taken as patterns (which  should
10815              be  quoted  to preserve them from being interpreted as glob pat‐
10816              terns), and all options with names matching these  patterns  are
10817              unset.
10818
10819       vared  See the section `Zle Builtins' in zshzle(1).
10820
10821       wait [ job ... ]
10822              Wait  for  the specified jobs or processes.  If job is not given
10823              then all currently active child processes are waited for.   Each
10824              job can be either a job specification or the process ID of a job
10825              in the job table.  The exit status from this command is that  of
10826              the job waited for.  If job represents an unknown job or process
10827              ID, a warning is printed (unless the  POSIX_BUILTINS  option  is
10828              set) and the exit status is 127.
10829
10830              It  is  possible  to  wait  for  recent  processes (specified by
10831              process ID, not by job) that were running in the background even
10832              if  the  process  has  exited.  Typically the process ID will be
10833              recorded by capturing the value of the variable  $!  immediately
10834              after  the  process  has  been started.  There is a limit on the
10835              number of process IDs remembered by the shell; this is given  by
10836              the value of the system configuration parameter CHILD_MAX.  When
10837              this limit is reached, older process IDs  are  discarded,  least
10838              recently started processes first.
10839
10840              Note  there  is  no  protection against the process ID wrapping,
10841              i.e. if the wait is not executed soon enough there is  a  chance
10842              the  process  waited  for  is the wrong one.  A conflict implies
10843              both process IDs have been generated by the shell, as other pro‐
10844              cesses are not recorded, and that the user is potentially inter‐
10845              ested in both, so this problem is intrinsic to process IDs.
10846
10847       whence [ -vcwfpamsS ] [ -x num ] name ...
10848              For each name, indicate how it would be interpreted if used as a
10849              command name.
10850
10851              If  name  is  not  an alias, built-in command, external command,
10852              shell function, hashed command, or a  reserved  word,  the  exit
10853              status  shall be non-zero, and -- if -v, -c, or -w was passed --
10854              a message will be written to standard output.  (This is  differ‐
10855              ent  from  other  shells that write that message to standard er‐
10856              ror.)
10857
10858              whence is most useful when name is only the last path  component
10859              of  a  command, i.e. does not include a `/'; in particular, pat‐
10860              tern matching only succeeds if just the non-directory  component
10861              of the command is passed.
10862
10863              -v     Produce a more verbose report.
10864
10865              -c     Print  the  results  in  a  csh-like  format.  This takes
10866                     precedence over -v.
10867
10868              -w     For each name, print `name: word' where word  is  one  of
10869                     alias,  builtin,  command,  function, hashed, reserved or
10870                     none, according  as  name  corresponds  to  an  alias,  a
10871                     built-in  command, an external command, a shell function,
10872                     a command defined with the hash builtin, a reserved word,
10873                     or  is not recognised.  This takes precedence over -v and
10874                     -c.
10875
10876              -f     Causes the contents of a shell function to be  displayed,
10877                     which  would otherwise not happen unless the -c flag were
10878                     used.
10879
10880              -p     Do a path search for name even if it  is  an  alias,  re‐
10881                     served word, shell function or builtin.
10882
10883              -a     Do  a  search  for all occurrences of name throughout the
10884                     command path.  Normally  only  the  first  occurrence  is
10885                     printed.
10886
10887              -m     The  arguments  are taken as patterns (pattern characters
10888                     should be quoted), and the information is  displayed  for
10889                     each command matching one of these patterns.
10890
10891              -s     If  a  pathname contains symlinks, print the symlink-free
10892                     pathname as well.
10893
10894              -S     As -s, but if the pathname had to be resolved by  follow‐
10895                     ing   multiple   symlinks,  the  intermediate  steps  are
10896                     printed, too.  The symlink resolved at each step might be
10897                     anywhere in the path.
10898
10899              -x num Expand  tabs when outputting shell functions using the -c
10900                     option.  This has the same effect as the -x option to the
10901                     functions builtin.
10902
10903       where [ -wpmsS ] [ -x num ] name ...
10904              Equivalent to whence -ca.
10905
10906       which [ -wpamsS ] [ -x num ] name ...
10907              Equivalent to whence -c.
10908
10909       zcompile [ -U ] [ -z | -k ] [ -R | -M ] file [ name ... ]
10910       zcompile -ca [ -m ] [ -R | -M ] file [ name ... ]
10911       zcompile -t file [ name ... ]
10912              This  builtin  command  can  be  used  to  compile  functions or
10913              scripts, storing the compiled form in a  file,  and  to  examine
10914              files  containing  the  compiled  form.   This allows faster au‐
10915              toloading of functions and sourcing of scripts by avoiding pars‐
10916              ing of the text when the files are read.
10917
10918              The first form (without the -c, -a or -t options) creates a com‐
10919              piled file.  If only the file argument is given, the output file
10920              has the name `file.zwc' and will be placed in the same directory
10921              as the file.  The shell will load the compiled file  instead  of
10922              the  normal  function  file when the function is autoloaded; see
10923              the section `Autoloading Functions' in zshmisc(1) for a descrip‐
10924              tion  of  how  autoloaded functions are searched.  The extension
10925              .zwc stands for `zsh word code'.
10926
10927              If there is at least one name argument, all the named files  are
10928              compiled  into  the output file given as the first argument.  If
10929              file does not end in .zwc, this extension is  automatically  ap‐
10930              pended.  Files containing multiple compiled functions are called
10931              `digest' files, and are intended to be used as elements  of  the
10932              FPATH/fpath special array.
10933
10934              The  second form, with the -c or -a options, writes the compiled
10935              definitions for all the named functions into file.  For -c,  the
10936              names  must  be  functions  currently  defined in the shell, not
10937              those marked for  autoloading.   Undefined  functions  that  are
10938              marked for autoloading may be written by using the -a option, in
10939              which case the fpath is searched and the contents of the defini‐
10940              tion  files  for  those  functions,  if found, are compiled into
10941              file.  If both -c and -a are given, names of both defined  func‐
10942              tions and functions marked for autoloading may be given.  In ei‐
10943              ther case, the functions in files written with the -c or -a  op‐
10944              tion  will  be autoloaded as if the KSH_AUTOLOAD option were un‐
10945              set.
10946
10947              The reason for handling loaded and not-yet-loaded functions with
10948              different  options is that some definition files for autoloading
10949              define multiple functions, including the function with the  same
10950              name  as the file, and, at the end, call that function.  In such
10951              cases the output of `zcompile -c' does  not  include  the  addi‐
10952              tional  functions defined in the file, and any other initializa‐
10953              tion code in the file is lost.  Using `zcompile -a' captures all
10954              this extra information.
10955
10956              If  the  -m option is combined with -c or -a, the names are used
10957              as patterns and all functions whose names  match  one  of  these
10958              patterns  will  be written. If no name is given, the definitions
10959              of all functions currently defined or marked as autoloaded  will
10960              be written.
10961
10962              Note the second form cannot be used for compiling functions that
10963              include redirections as  part  of  the  definition  rather  than
10964              within the body of the function; for example
10965
10966                     fn1() { { ... } >~/logfile }
10967
10968              can be compiled but
10969
10970                     fn1() { ... } >~/logfile
10971
10972              cannot.   It  is  possible  to use the first form of zcompile to
10973              compile autoloadable functions that include  the  full  function
10974              definition instead of just the body of the function.
10975
10976              The  third  form,  with the -t option, examines an existing com‐
10977              piled file.  Without further arguments, the names of the  origi‐
10978              nal files compiled into it are listed.  The first line of output
10979              shows the version of the shell which compiled the file  and  how
10980              the file will be used (i.e. by reading it directly or by mapping
10981              it into memory).  With arguments, nothing is output and the  re‐
10982              turn  status  is  set  to zero if definitions for all names were
10983              found in the compiled file, and non-zero if the  definition  for
10984              at least one name was not found.
10985
10986              Other options:
10987
10988              -U     Aliases are not expanded when compiling the named files.
10989
10990              -R     When  the  compiled file is read, its contents are copied
10991                     into the shell's memory, rather than  memory-mapped  (see
10992                     -M).   This  happens automatically on systems that do not
10993                     support memory mapping.
10994
10995                     When compiling scripts instead of autoloadable functions,
10996                     it  is  often desirable to use this option; otherwise the
10997                     whole file, including the code to define functions  which
10998                     have  already  been  defined,  will remain mapped, conse‐
10999                     quently wasting memory.
11000
11001              -M     The compiled file is mapped into the shell's memory  when
11002                     read.  This is done in such a way that multiple instances
11003                     of the shell running on the same  host  will  share  this
11004                     mapped file.  If neither -R nor -M is given, the zcompile
11005                     builtin decides what to do based on the size of the  com‐
11006                     piled file.
11007
11008              -k
11009              -z     These  options  are  used when the compiled file contains
11010                     functions which are to be autoloaded. If -z is given, the
11011                     function will be autoloaded as if the KSH_AUTOLOAD option
11012                     is not set, even if it is set at the  time  the  compiled
11013                     file is read, while if the -k is given, the function will
11014                     be loaded as if KSH_AUTOLOAD is set.  These options  also
11015                     take  precedence  over  any -k or -z options specified to
11016                     the autoload builtin. If  neither  of  these  options  is
11017                     given,  the  function will be loaded as determined by the
11018                     setting of the KSH_AUTOLOAD option at the time  the  com‐
11019                     piled file is read.
11020
11021                     These  options may also appear as many times as necessary
11022                     between the listed names to specify the loading style  of
11023                     all following functions, up to the next -k or -z.
11024
11025                     The created file always contains two versions of the com‐
11026                     piled format, one for big-endian  machines  and  one  for
11027                     small-endian  machines.   The  upshot of this is that the
11028                     compiled file is machine independent and if it is read or
11029                     mapped,  only  one half of the file is actually used (and
11030                     mapped).
11031
11032       zformat
11033              See the section `The zsh/zutil Module' in zshmodules(1).
11034
11035       zftp   See the section `The zsh/zftp Module' in zshmodules(1).
11036
11037       zle    See the section `Zle Builtins' in zshzle(1).
11038
11039       zmodload [ -dL ] [ -s ] [ ... ]
11040       zmodload -F [ -alLme -P param ] module [ [+-]feature ... ]
11041       zmodload -e [ -A ] [ ... ]
11042       zmodload [ -a [ -bcpf [ -I ] ] ] [ -iL ] ...
11043       zmodload -u [ -abcdpf [ -I ] ] [ -iL ] ...
11044       zmodload -A [ -L ] [ modalias[=module] ... ]
11045       zmodload -R modalias ...
11046              Performs operations relating to zsh's loadable modules.  Loading
11047              of  modules  while the shell is running (`dynamical loading') is
11048              not available on all operating systems, or on all  installations
11049              on  a particular operating system, although the zmodload command
11050              itself is always available and can be used to manipulate modules
11051              built  into  versions  of the shell executable without dynamical
11052              loading.
11053
11054              Without arguments the names of all currently loaded binary  mod‐
11055              ules  are  printed.  The -L option causes this list to be in the
11056              form of a series of zmodload  commands.   Forms  with  arguments
11057              are:
11058
11059              zmodload [ -is ] name ...
11060              zmodload -u [ -i ] name ...
11061                     In  the  simplest  case,  zmodload loads a binary module.
11062                     The module must be in a file with a  name  consisting  of
11063                     the specified name followed by a standard suffix, usually
11064                     `.so' (`.sl' on HPUX).  If the module to be loaded is al‐
11065                     ready  loaded  the duplicate module is ignored.  If zmod‐
11066                     load detects an inconsistency, such as an invalid  module
11067                     name  or circular dependency list, the current code block
11068                     is aborted.  If it is available, the module is loaded  if
11069                     necessary,  while if it is not available, non-zero status
11070                     is silently returned.  The option -i is accepted for com‐
11071                     patibility but has no effect.
11072
11073                     The  named  module is searched for in the same way a com‐
11074                     mand is, using $module_path instead of  $path.   However,
11075                     the  path  search  is performed even when the module name
11076                     contains a `/', which it usually does.  There is  no  way
11077                     to prevent the path search.
11078
11079                     If  the  module  supports  features (see below), zmodload
11080                     tries to enable all features when loading a  module.   If
11081                     the  module  was successfully loaded but not all features
11082                     could be enabled, zmodload returns status 2.
11083
11084                     If the option -s is given, no error  is  printed  if  the
11085                     module  was not available (though other errors indicating
11086                     a problem with the module are printed).  The return  sta‐
11087                     tus  indicates  if the module was loaded.  This is appro‐
11088                     priate if the caller considers the module optional.
11089
11090                     With -u, zmodload unloads modules.  The same name must be
11091                     given  that  was given when the module was loaded, but it
11092                     is not necessary for the module to exist in the file sys‐
11093                     tem.  The -i option suppresses the error if the module is
11094                     already unloaded (or was never loaded).
11095
11096                     Each module has a boot and a cleanup function.  The  mod‐
11097                     ule will not be loaded if its boot function fails.  Simi‐
11098                     larly a module can only be unloaded if its cleanup  func‐
11099                     tion runs successfully.
11100
11101              zmodload -F [ -almLe -P param ] module [ [+-]feature ... ]
11102                     zmodload  -F  allows more selective control over the fea‐
11103                     tures provided by modules.  With no  options  apart  from
11104                     -F,  the module named module is loaded, if it was not al‐
11105                     ready loaded, and the list of features is set to the  re‐
11106                     quired  state.   If no features are specified, the module
11107                     is loaded, if it was not already loaded, but the state of
11108                     features is unchanged.  Each feature may be preceded by a
11109                     + to turn the feature on, or - to turn it off; the  +  is
11110                     assumed if neither character is present.  Any feature not
11111                     explicitly mentioned is left in its current state; if the
11112                     module was not previously loaded this means any such fea‐
11113                     tures will remain disabled.  The return status is zero if
11114                     all  features  were  set, 1 if the module failed to load,
11115                     and 2 if some features could not be set (for  example,  a
11116                     parameter couldn't be added because there was a different
11117                     parameter of the same name) but the module was loaded.
11118
11119                     The standard features are builtins,  conditions,  parame‐
11120                     ters  and math functions; these are indicated by the pre‐
11121                     fix `b:', `c:' (`C:' for an infix  condition),  `p:'  and
11122                     `f:',  respectively, followed by the name that the corre‐
11123                     sponding feature would have in the shell.   For  example,
11124                     `b:strftime'  indicates  a  builtin  named  strftime  and
11125                     p:EPOCHSECONDS indicates a parameter named  EPOCHSECONDS.
11126                     The module may provide other (`abstract') features of its
11127                     own as indicated by its documentation; these have no pre‐
11128                     fix.
11129
11130                     With  -l  or  -L,  features  provided  by  the module are
11131                     listed.  With -l alone, a list of features together  with
11132                     their  states  is  shown,  one feature per line.  With -L
11133                     alone, a zmodload -F command  that  would  cause  enabled
11134                     features  of  the  module to be turned on is shown.  With
11135                     -lL, a zmodload -F command that would cause all the  fea‐
11136                     tures  to be set to their current state is shown.  If one
11137                     of these combinations is given with the option  -P  param
11138                     then  the parameter param is set to an array of features,
11139                     either features together with their state or (if -L alone
11140                     is given) enabled features.
11141
11142                     With the option -L the module name may be omitted; then a
11143                     list of all enabled features for  all  modules  providing
11144                     features  is printed in the form of zmodload -F commands.
11145                     If -l is also given, the state of both enabled  and  dis‐
11146                     abled features is output in that form.
11147
11148                     A  set of features may be provided together with -l or -L
11149                     and a module name; in that case only the state  of  those
11150                     features  is considered.  Each feature may be preceded by
11151                     + or - but the character has no effect.   If  no  set  of
11152                     features is provided, all features are considered.
11153
11154                     With  -e,  the  command  first  tests  that the module is
11155                     loaded; if it is not, status 1 is returned.  If the  mod‐
11156                     ule  is loaded, the list of features given as an argument
11157                     is examined.  Any feature given with no prefix is  simply
11158                     tested  to  see  if  the  module provides it; any feature
11159                     given with a prefix + or - is tested to see  if  is  pro‐
11160                     vided  and  in the given state.  If the tests on all fea‐
11161                     tures in the list succeed, status  0  is  returned,  else
11162                     status 1.
11163
11164                     With  -m,  each  entry  in  the given list of features is
11165                     taken as a pattern to be matched against the list of fea‐
11166                     tures  provided by the module.  An initial + or - must be
11167                     given explicitly.  This may not be combined with  the  -a
11168                     option as autoloads must be specified explicitly.
11169
11170                     With  -a,  the  given  list of features is marked for au‐
11171                     toload from the specified module, which may  not  yet  be
11172                     loaded.   An  optional  +  may  appear before the feature
11173                     name.  If the feature is prefixed with  -,  any  existing
11174                     autoload  is  removed.  The options -l and -L may be used
11175                     to list autoloads.  Autoloading is specific to individual
11176                     features;  when  the  module is loaded only the requested
11177                     feature is enabled.  Autoload requests are  preserved  if
11178                     the  module  is  subsequently  unloaded until an explicit
11179                     `zmodload -Fa module -feature' is issued.  It is  not  an
11180                     error  to  request  an autoload for a feature of a module
11181                     that is already loaded.
11182
11183                     When the  module  is  loaded  each  autoload  is  checked
11184                     against  the features actually provided by the module; if
11185                     the feature is  not  provided  the  autoload  request  is
11186                     deleted.   A  warning message is output; if the module is
11187                     being loaded to provide a different feature, and that au‐
11188                     toload is successful, there is no effect on the status of
11189                     the current command.  If the module is already loaded  at
11190                     the  time  when  zmodload -Fa is run, an error message is
11191                     printed and status 1 returned.
11192
11193                     zmodload -Fa can be used with the -l, -L, -e and  -P  op‐
11194                     tions  for listing and testing the existence of autoload‐
11195                     able features.  In this case -l is ignored if -L is spec‐
11196                     ified.  zmodload -FaL with no module name lists autoloads
11197                     for all modules.
11198
11199                     Note that only standard features as described  above  can
11200                     be  autoloaded;  other  features require the module to be
11201                     loaded before enabling.
11202
11203              zmodload -d [ -L ] [ name ]
11204              zmodload -d name dep ...
11205              zmodload -ud name [ dep ... ]
11206                     The -d option can be used to specify module dependencies.
11207                     The  modules named in the second and subsequent arguments
11208                     will be loaded before the module named in the first argu‐
11209                     ment.
11210
11211                     With  -d and one argument, all dependencies for that mod‐
11212                     ule are listed.  With -d and no arguments, all module de‐
11213                     pendencies  are  listed.  This listing is by default in a
11214                     Makefile-like format.  The -L option changes this  format
11215                     to a list of zmodload -d commands.
11216
11217                     If -d and -u are both used, dependencies are removed.  If
11218                     only one argument is given,  all  dependencies  for  that
11219                     module are removed.
11220
11221              zmodload -ab [ -L ]
11222              zmodload -ab [ -i ] name [ builtin ... ]
11223              zmodload -ub [ -i ] builtin ...
11224                     The  -ab  option defines autoloaded builtins.  It defines
11225                     the specified builtins.  When any of  those  builtins  is
11226                     called,  the  module  specified  in the first argument is
11227                     loaded and all its features are  enabled  (for  selective
11228                     control  of  features  use  `zmodload -F -a' as described
11229                     above).  If only the name is given, one  builtin  is  de‐
11230                     fined,  with  the same name as the module.  -i suppresses
11231                     the error if  the  builtin  is  already  defined  or  au‐
11232                     toloaded,  but not if another builtin of the same name is
11233                     already defined.
11234
11235                     With -ab and no arguments, all  autoloaded  builtins  are
11236                     listed,  with  the  module  name  (if different) shown in
11237                     parentheses  after  the  builtin  name.   The  -L  option
11238                     changes this format to a list of zmodload -a commands.
11239
11240                     If  -b  is  used  together with the -u option, it removes
11241                     builtins previously defined with -ab.  This is only  pos‐
11242                     sible  if  the  builtin is not yet loaded.  -i suppresses
11243                     the error if the builtin is already removed (or never ex‐
11244                     isted).
11245
11246                     Autoload  requests  are  retained if the module is subse‐
11247                     quently unloaded until an explicit `zmodload -ub builtin'
11248                     is issued.
11249
11250              zmodload -ac [ -IL ]
11251              zmodload -ac [ -iI ] name [ cond ... ]
11252              zmodload -uc [ -iI ] cond ...
11253                     The  -ac  option  is  used to define autoloaded condition
11254                     codes. The cond strings give the names of the  conditions
11255                     defined  by the module. The optional -I option is used to
11256                     define infix condition names. Without this option  prefix
11257                     condition names are defined.
11258
11259                     If given no condition names, all defined names are listed
11260                     (as a series of zmodload commands if  the  -L  option  is
11261                     given).
11262
11263                     The  -uc option removes definitions for autoloaded condi‐
11264                     tions.
11265
11266              zmodload -ap [ -L ]
11267              zmodload -ap [ -i ] name [ parameter ... ]
11268              zmodload -up [ -i ] parameter ...
11269                     The -p option is like the -b and -c  options,  but  makes
11270                     zmodload work on autoloaded parameters instead.
11271
11272              zmodload -af [ -L ]
11273              zmodload -af [ -i ] name [ function ... ]
11274              zmodload -uf [ -i ] function ...
11275                     The  -f  option  is  like the -b, -p, and -c options, but
11276                     makes zmodload work on autoloaded math functions instead.
11277
11278              zmodload -a [ -L ]
11279              zmodload -a [ -i ] name [ builtin ... ]
11280              zmodload -ua [ -i ] builtin ...
11281                     Equivalent to -ab and -ub.
11282
11283              zmodload -e [ -A ] [ string ... ]
11284                     The -e option without arguments lists all loaded modules;
11285                     if  the  -A  option  is also given, module aliases corre‐
11286                     sponding to loaded modules are also shown.  If  arguments
11287                     are  provided,  nothing  is printed; the return status is
11288                     set to zero if all strings given as arguments  are  names
11289                     of loaded modules and to one if at least on string is not
11290                     the name of a loaded module.  This can be  used  to  test
11291                     for  the  availability  of things implemented by modules.
11292                     In this case, any aliases are automatically resolved  and
11293                     the -A flag is not used.
11294
11295              zmodload -A [ -L ] [ modalias[=module] ... ]
11296                     For each argument, if both modalias and module are given,
11297                     define modalias to be an alias for the module module.  If
11298                     the  module  modalias is ever subsequently requested, ei‐
11299                     ther via a call to zmodload or implicitly, the shell will
11300                     attempt  to load module instead.  If module is not given,
11301                     show the definition of modalias.   If  no  arguments  are
11302                     given, list all defined module aliases.  When listing, if
11303                     the -L flag was also given,  list  the  definition  as  a
11304                     zmodload command to recreate the alias.
11305
11306                     The  existence of aliases for modules is completely inde‐
11307                     pendent of whether the name resolved is  actually  loaded
11308                     as  a module: while the alias exists, loading and unload‐
11309                     ing the module under any alias has exactly the  same  ef‐
11310                     fect  as using the resolved name, and does not affect the
11311                     connection between the alias and the resolved name  which
11312                     can be removed either by zmodload -R or by redefining the
11313                     alias.  Chains of aliases (i.e. where the first  resolved
11314                     name  is  itself an alias) are valid so long as these are
11315                     not circular.  As the aliases take  the  same  format  as
11316                     module  names, they may include path separators:  in this
11317                     case, there is no requirement for any part  of  the  path
11318                     named  to exist as the alias will be resolved first.  For
11319                     example, `any/old/alias' is always a valid alias.
11320
11321                     Dependencies added to aliased modules are actually  added
11322                     to  the resolved module; these remain if the alias is re‐
11323                     moved.  It is valid to create an alias whose name is  one
11324                     of  the  standard  shell  modules and which resolves to a
11325                     different module.  However, if a module has dependencies,
11326                     it  will  not  be  possible  to use the module name as an
11327                     alias as the module will already be marked as a  loadable
11328                     module in its own right.
11329
11330                     Apart from the above, aliases can be used in the zmodload
11331                     command anywhere module  names  are  required.   However,
11332                     aliases will not be shown in lists of loaded modules with
11333                     a bare `zmodload'.
11334
11335              zmodload -R modalias ...
11336                     For each modalias argument that was previously defined as
11337                     a module alias via zmodload -A, delete the alias.  If any
11338                     was not defined, an error is caused and the remainder  of
11339                     the line is ignored.
11340
11341              Note  that  zsh  makes  no distinction between modules that were
11342              linked into the shell and modules that are  loaded  dynamically.
11343              In both cases this builtin command has to be used to make avail‐
11344              able the builtins and other things defined  by  modules  (unless
11345              the  module  is  autoloaded  on these definitions). This is true
11346              even for systems that don't support dynamic loading of modules.
11347
11348       zparseopts
11349              See the section `The zsh/zutil Module' in zshmodules(1).
11350
11351       zprof  See the section `The zsh/zprof Module' in zshmodules(1).
11352
11353       zpty   See the section `The zsh/zpty Module' in zshmodules(1).
11354
11355       zregexparse
11356              See the section `The zsh/zutil Module' in zshmodules(1).
11357
11358       zsocket
11359              See the section `The zsh/net/socket Module' in zshmodules(1).
11360
11361       zstyle See the section `The zsh/zutil Module' in zshmodules(1).
11362
11363       ztcp   See the section `The zsh/net/tcp Module' in zshmodules(1).
11364
11365
11366
11367ZSHZLE(1)                   General Commands Manual                  ZSHZLE(1)
11368
11369
11370

NAME

11372       zshzle - zsh command line editor
11373

DESCRIPTION

11375       If the ZLE option is set (which it is by default in interactive shells)
11376       and  the  shell  input is attached to the terminal, the user is able to
11377       edit command lines.
11378
11379       There are two display modes.  The first, multiline  mode,  is  the  de‐
11380       fault.   It only works if the TERM parameter is set to a valid terminal
11381       type that can move the cursor up.  The second,  single  line  mode,  is
11382       used if TERM is invalid or incapable of moving the cursor up, or if the
11383       SINGLE_LINE_ZLE option is set.  This mode is similar to ksh,  and  uses
11384       no termcap sequences.  If TERM is "emacs", the ZLE option will be unset
11385       by default.
11386
11387       The parameters BAUD, COLUMNS, and LINES are also used by the line  edi‐
11388       tor. See Parameters Used By The Shell in zshparam(1).
11389
11390       The  parameter zle_highlight is also used by the line editor; see Char‐
11391       acter Highlighting below.  Highlighting of special characters  and  the
11392       region between the cursor and the mark (as set with set-mark-command in
11393       Emacs mode, or by visual-mode in Vi mode) is enabled by  default;  con‐
11394       sult this reference for more information.  Irascible conservatives will
11395       wish to know that all highlighting may be  disabled  by  the  following
11396       setting:
11397
11398              zle_highlight=(none)
11399
11400       In  many places, references are made to the numeric argument.  This can
11401       by default be entered in emacs mode by holding the alt key and typing a
11402       number, or pressing escape before each digit, and in vi command mode by
11403       typing the number before entering a command.  Generally the numeric ar‐
11404       gument  causes  the  next  command entered to be repeated the specified
11405       number of times, unless otherwise noted below; this is  implemented  by
11406       the  digit-argument  widget.  See  also the Arguments subsection of the
11407       Widgets section for some other ways the numeric argument can  be  modi‐
11408       fied.
11409

KEYMAPS

11411       A  keymap  in  ZLE contains a set of bindings between key sequences and
11412       ZLE commands.  The empty key sequence cannot be bound.
11413
11414       There can be any number of keymaps at any time, and each keymap has one
11415       or  more names.  If all of a keymap's names are deleted, it disappears.
11416       bindkey can be used to manipulate keymap names.
11417
11418       Initially, there are eight keymaps:
11419
11420       emacs  EMACS emulation
11421       viins  vi emulation - insert mode
11422       vicmd  vi emulation - command mode
11423       viopp  vi emulation - operator pending
11424       visual vi emulation - selection active
11425       isearch
11426              incremental search mode
11427       command
11428              read a command name
11429       .safe  fallback keymap
11430
11431       The `.safe' keymap is special.  It can never be altered, and  the  name
11432       can  never be removed.  However, it can be linked to other names, which
11433       can be removed.  In the future other  special  keymaps  may  be  added;
11434       users  should  avoid  using  names  beginning  with  `.'  for their own
11435       keymaps.
11436
11437       In addition to these names, either `emacs' or `viins' is also linked to
11438       the  name `main'.  If one of the VISUAL or EDITOR environment variables
11439       contain the string `vi' when the shell starts up then it will  be  `vi‐
11440       ins',  otherwise  it will be `emacs'.  bindkey's -e and -v options pro‐
11441       vide a convenient way to override this default choice.
11442
11443       When the editor starts up, it will select the `main' keymap.   If  that
11444       keymap doesn't exist, it will use `.safe' instead.
11445
11446       In  the `.safe' keymap, each single key is bound to self-insert, except
11447       for ^J (line feed) and ^M (return)  which  are  bound  to  accept-line.
11448       This is deliberately not pleasant to use; if you are using it, it means
11449       you deleted the main keymap, and you should put it back.
11450
11451   Reading Commands
11452       When ZLE is reading a command from the terminal, it may read a sequence
11453       that  is  bound  to some command and is also a prefix of a longer bound
11454       string.  In this case ZLE will wait a certain time to see if more char‐
11455       acters are typed, and if not (or they don't match any longer string) it
11456       will execute the binding.  This timeout is defined  by  the  KEYTIMEOUT
11457       parameter;  its  default is 0.4 sec.  There is no timeout if the prefix
11458       string is not itself bound to a command.
11459
11460       The key timeout is also applied when ZLE is reading the  bytes  from  a
11461       multibyte  character  string when it is in the appropriate mode.  (This
11462       requires that the shell was compiled with multibyte mode enabled; typi‐
11463       cally  also the locale has characters with the UTF-8 encoding, although
11464       any multibyte encoding known to the operating system is supported.)  If
11465       the  second or a subsequent byte is not read within the timeout period,
11466       the shell acts as if ? were typed and resets the input state.
11467
11468       As well as ZLE commands, key sequences can be bound to  other  strings,
11469       by  using  `bindkey -s'.  When such a sequence is read, the replacement
11470       string is pushed back as input, and the command reading process  starts
11471       again  using  these fake keystrokes.  This input can itself invoke fur‐
11472       ther replacement strings, but in order to detect loops the process will
11473       be stopped if there are twenty such replacements without a real command
11474       being read.
11475
11476       A key sequence typed by the user can be turned into a command name  for
11477       use  in user-defined widgets with the read-command widget, described in
11478       the subsection `Miscellaneous' of the section `Standard Widgets' below.
11479
11480   Local Keymaps
11481       While for normal editing a single keymap is used exclusively,  in  many
11482       modes  a  local keymap allows for some keys to be customised. For exam‐
11483       ple, in an incremental search mode, a binding  in  the  isearch  keymap
11484       will  override  a  binding in the main keymap but all keys that are not
11485       overridden can still be used.
11486
11487       If a key sequence is defined in a local keymap, it will hide a key  se‐
11488       quence in the global keymap that is a prefix of that sequence. An exam‐
11489       ple of this occurs with the binding of iw in viopp as  this  hides  the
11490       binding  of i in vicmd. However, a longer sequence in the global keymap
11491       that shares the same prefix can still apply so for example the  binding
11492       of ^Xa in the global keymap will be unaffected by the binding of ^Xb in
11493       the local keymap.
11494

ZLE BUILTINS

11496       The ZLE module contains three related  builtin  commands.  The  bindkey
11497       command manipulates keymaps and key bindings; the vared command invokes
11498       ZLE on the value of a shell parameter; and the zle command  manipulates
11499       editing  widgets  and  allows  command line access to ZLE commands from
11500       within shell functions.
11501
11502       bindkey [ options ] -l [ -L ] [ keymap ... ]
11503       bindkey [ options ] -d
11504       bindkey [ options ] -D keymap ...
11505       bindkey [ options ] -A old-keymap new-keymap
11506       bindkey [ options ] -N new-keymap [ old-keymap ]
11507       bindkey [ options ] -m
11508       bindkey [ options ] -r in-string ...
11509       bindkey [ options ] -s in-string out-string ...
11510       bindkey [ options ] in-string command ...
11511       bindkey [ options ] [ in-string ]
11512              bindkey's options can be divided into three  categories:  keymap
11513              selection for the current command, operation selection, and oth‐
11514              ers.  The keymap selection options are:
11515
11516              -e     Selects keymap `emacs' for any operations by the  current
11517                     command,  and  also links `emacs' to `main' so that it is
11518                     selected by default the next time the editor starts.
11519
11520              -v     Selects keymap `viins' for any operations by the  current
11521                     command,  and  also links `viins' to `main' so that it is
11522                     selected by default the next time the editor starts.
11523
11524              -a     Selects keymap `vicmd' for any operations by the  current
11525                     command.
11526
11527              -M keymap
11528                     The  keymap  specifies a keymap name that is selected for
11529                     any operations by the current command.
11530
11531              If a keymap selection is required and none of the options  above
11532              are  used,  the  `main'  keymap is used.  Some operations do not
11533              permit a keymap to be selected, namely:
11534
11535              -l     List all existing keymap  names;  if  any  arguments  are
11536                     given, list just those keymaps.
11537
11538                     If  the -L option is also used, list in the form of bind‐
11539                     key commands to create or link the keymaps.  `bindkey -lL
11540                     main' shows which keymap is linked to `main', if any, and
11541                     hence if the standard emacs or vi emulation is in effect.
11542                     This  option  does  not  show the .safe keymap because it
11543                     cannot be created in that fashion;  however,  neither  is
11544                     `bindkey  -lL .safe' reported as an error, it simply out‐
11545                     puts nothing.
11546
11547              -d     Delete all existing keymaps  and  reset  to  the  default
11548                     state.
11549
11550              -D keymap ...
11551                     Delete the named keymaps.
11552
11553              -A old-keymap new-keymap
11554                     Make the new-keymap name an alias for old-keymap, so that
11555                     both names refer to the  same  keymap.   The  names  have
11556                     equal  standing; if either is deleted, the other remains.
11557                     If there is already a keymap with the new-keymap name, it
11558                     is deleted.
11559
11560              -N new-keymap [ old-keymap ]
11561                     Create  a  new keymap, named new-keymap.  If a keymap al‐
11562                     ready has that name, it is  deleted.   If  an  old-keymap
11563                     name  is given, the new keymap is initialized to be a du‐
11564                     plicate of it, otherwise the new keymap will be empty.
11565
11566              To use a newly created keymap, it  should  be  linked  to  main.
11567              Hence  the  sequence  of commands to create and use a new keymap
11568              `mymap' initialized from the emacs  keymap  (which  remains  un‐
11569              changed) is:
11570
11571                     bindkey -N mymap emacs
11572                     bindkey -A mymap main
11573
11574              Note  that  while `bindkey -A newmap main' will work when newmap
11575              is emacs or viins, it will not work for vicmd, as switching from
11576              vi insert to command mode becomes impossible.
11577
11578              The  following  operations act on the `main' keymap if no keymap
11579              selection option was given:
11580
11581              -m     Add the built-in set of meta-key bindings to the selected
11582                     keymap.   Only keys that are unbound or bound to self-in‐
11583                     sert are affected.
11584
11585              -r in-string ...
11586                     Unbind the specified in-strings in the  selected  keymap.
11587                     This  is exactly equivalent to binding the strings to un‐
11588                     defined-key.
11589
11590                     When -R is also used, interpret the in-strings as ranges.
11591
11592                     When -p is also used, the  in-strings  specify  prefixes.
11593                     Any binding that has the given in-string as a prefix, not
11594                     including the binding for the in-string itself,  if  any,
11595                     will be removed.  For example,
11596
11597                            bindkey -rpM viins '^['
11598
11599                     will  remove  all bindings in the vi-insert keymap begin‐
11600                     ning with an escape character (probably cursor keys), but
11601                     leave the binding for the escape character itself (proba‐
11602                     bly vi-cmd-mode).  This is incompatible with  the  option
11603                     -R.
11604
11605              -s in-string out-string ...
11606                     Bind  each  in-string to each out-string.  When in-string
11607                     is typed, out-string will be pushed back and  treated  as
11608                     input  to  the line editor.  When -R is also used, inter‐
11609                     pret the in-strings as ranges.
11610
11611                     Note that both in-string and out-string  are  subject  to
11612                     the same form of interpretation, as described below.
11613
11614              in-string command ...
11615                     Bind  each  in-string  to each command.  When -R is used,
11616                     interpret the in-strings as ranges.
11617
11618              [ in-string ]
11619                     List key bindings.  If an  in-string  is  specified,  the
11620                     binding  of  that  string  in the selected keymap is dis‐
11621                     played.  Otherwise, all  key  bindings  in  the  selected
11622                     keymap  are  displayed.  (As a special case, if the -e or
11623                     -v option is used alone, the keymap is  not  displayed  -
11624                     the  implicit  linking  of keymaps is the only thing that
11625                     happens.)
11626
11627                     When the  option  -p  is  used,  the  in-string  must  be
11628                     present.   The  listing shows all bindings which have the
11629                     given key sequence as a prefix, not including  any  bind‐
11630                     ings for the key sequence itself.
11631
11632                     When  the  -L  option is used, the list is in the form of
11633                     bindkey commands to create the key bindings.
11634
11635              When the -R option is used as noted above, a  valid  range  con‐
11636              sists of two characters, with an optional `-' between them.  All
11637              characters between the two specified, inclusive,  are  bound  as
11638              specified.
11639
11640              For  either  in-string  or  out-string, the following escape se‐
11641              quences are recognised:
11642
11643              \a     bell character
11644              \b     backspace
11645              \e, \E escape
11646              \f     form feed
11647              \n     linefeed (newline)
11648              \r     carriage return
11649              \t     horizontal tab
11650              \v     vertical tab
11651              \NNN   character code in octal
11652              \xNN   character code in hexadecimal
11653              \uNNNN unicode character code in hexadecimal
11654              \UNNNNNNNN
11655                     unicode character code in hexadecimal
11656              \M[-]X character with meta bit set
11657              \C[-]X control character
11658              ^X     control character
11659
11660              In all other cases, `\' escapes the following character.  Delete
11661              is  written  as  `^?'.   Note that `\M^?' and `^\M?' are not the
11662              same, and that (unlike emacs), the bindings `\M-X' and `\eX' are
11663              entirely  distinct,  although  they  are initialized to the same
11664              bindings by `bindkey -m'.
11665
11666
11667       vared [ -Aacghe ] [ -p prompt ] [ -r rprompt ]
11668             [ -M main-keymap ] [ -m vicmd-keymap ]
11669             [ -i init-widget ] [ -f finish-widget ]
11670             [ -t tty ] name
11671              The value of the parameter name is loaded into the edit  buffer,
11672              and  the line editor is invoked.  When the editor exits, name is
11673              set to the string value returned by the  editor.   When  the  -c
11674              flag  is  given,  the parameter is created if it doesn't already
11675              exist.  The -a flag may be given with -c to create an array  pa‐
11676              rameter,  or the -A flag to create an associative array.  If the
11677              type of an existing parameter does not match the type to be cre‐
11678              ated,  the parameter is unset and recreated.  The -g flag may be
11679              given to  suppress  warnings  from  the  WARN_CREATE_GLOBAL  and
11680              WARN_NESTED_VAR options.
11681
11682              If an array or array slice is being edited, separator characters
11683              as defined in $IFS will be shown quoted  with  a  backslash,  as
11684              will  backslashes  themselves.  Conversely, when the edited text
11685              is split into an array, a backslash quotes an  immediately  fol‐
11686              lowing  separator  character or backslash; no other special han‐
11687              dling of backslashes, or any handling of quotes, is performed.
11688
11689              Individual elements of existing array or associative  array  pa‐
11690              rameters  may  be edited by using subscript syntax on name.  New
11691              elements are created automatically, even without -c.
11692
11693              If the -p flag is given, the following string will be  taken  as
11694              the prompt to display at the left.  If the -r flag is given, the
11695              following string gives the prompt to display at the  right.   If
11696              the  -h flag is specified, the history can be accessed from ZLE.
11697              If the -e flag is given, typing ^D (Control-D) on an empty  line
11698              causes vared to exit immediately with a non-zero return value.
11699
11700              The  -M  option gives a keymap to link to the main keymap during
11701              editing, and the -m option gives a keymap to link to  the  vicmd
11702              keymap during editing.  For vi-style editing, this allows a pair
11703              of keymaps to override viins and vicmd.  For  emacs-style  edit‐
11704              ing,  only  -M is normally needed but the -m option may still be
11705              used.  On exit, the previous keymaps will be restored.
11706
11707              Vared calls  the  usual  `zle-line-init'  and  `zle-line-finish'
11708              hooks before and after it takes control. Using the -i and -f op‐
11709              tions, it is possible to replace these with  other  custom  wid‐
11710              gets.
11711
11712              If `-t tty' is given, tty is the name of a terminal device to be
11713              used instead of the default /dev/tty.  If tty does not refer  to
11714              a terminal an error is reported.
11715
11716       zle
11717       zle -l [ -L | -a ] [ string ... ]
11718       zle -D widget ...
11719       zle -A old-widget new-widget
11720       zle -N widget [ function ]
11721       zle -f flag [ flag... ]
11722       zle -C widget completion-widget function
11723       zle -R [ -c ] [ display-string ] [ string ... ]
11724       zle -M string
11725       zle -U string
11726       zle -K keymap
11727       zle -F [ -L | -w ] [ fd [ handler ] ]
11728       zle -I
11729       zle -T [ tc function | -r tc | -L ]
11730       zle widget [ -n num ] [ -Nw ] [ -K keymap ] args ...
11731              The  zle builtin performs a number of different actions concern‐
11732              ing ZLE.
11733
11734              With no options and no arguments, only the return status will be
11735              set.  It is zero if ZLE is currently active and widgets could be
11736              invoked using this builtin command and non-zero otherwise.  Note
11737              that  even  if non-zero status is returned, zle may still be ac‐
11738              tive as part of the completion system; this does not  allow  di‐
11739              rect calls to ZLE widgets.
11740
11741              Otherwise, which operation it performs depends on its options:
11742
11743              -l [ -L | -a ] [ string ]
11744                     List all existing user-defined widgets.  If the -L option
11745                     is used, list in the form of zle commands to  create  the
11746                     widgets.
11747
11748                     When  combined  with  the -a option, all widget names are
11749                     listed, including the builtin ones. In this case  the  -L
11750                     option is ignored.
11751
11752                     If  at least one string is given, and -a is present or -L
11753                     is not used, nothing will be printed.  The return  status
11754                     will be zero if all strings are names of existing widgets
11755                     and non-zero if at least one string is not a  name  of  a
11756                     defined  widget.  If -a is also present, all widget names
11757                     are used for the comparison  including  builtin  widgets,
11758                     else only user-defined widgets are used.
11759
11760                     If  at  least  one string is present and the -L option is
11761                     used, user-defined widgets matching any string are listed
11762                     in the form of zle commands to create the widgets.
11763
11764              -D widget ...
11765                     Delete the named widgets.
11766
11767              -A old-widget new-widget
11768                     Make the new-widget name an alias for old-widget, so that
11769                     both names refer to the  same  widget.   The  names  have
11770                     equal  standing; if either is deleted, the other remains.
11771                     If there is already a widget with the new-widget name, it
11772                     is deleted.
11773
11774              -N widget [ function ]
11775                     Create a user-defined widget.  If there is already a wid‐
11776                     get with the specified name, it is overwritten.  When the
11777                     new  widget is invoked from within the editor, the speci‐
11778                     fied shell function is called.  If no  function  name  is
11779                     specified,  it  defaults  to the same name as the widget.
11780                     For further information, see the section `Widgets' below.
11781
11782              -f flag [ flag... ]
11783                     Set various flags on the running widget.  Possible values
11784                     for flag are:
11785
11786                     yank  for indicating that the widget has yanked text into
11787                     the buffer.  If the widget is wrapping an existing inter‐
11788                     nal widget, no further action is necessary, but if it has
11789                     inserted the text manually, then it should also take care
11790                     to  set  YANK_START  and  YANK_END correctly.  yankbefore
11791                     does the same but is used when the  yanked  text  appears
11792                     after the cursor.
11793
11794                     kill  for  indicating  that text has been killed into the
11795                     cutbuffer.  When repeatedly invoking a kill widget,  text
11796                     is appended to the cutbuffer instead of replacing it, but
11797                     when wrapping such widgets, it is necessary to call  `zle
11798                     -f kill' to retain this effect.
11799
11800                     vichange  for  indicating that the widget represents a vi
11801                     change that can be  repeated  as  a  whole  with  `vi-re‐
11802                     peat-change'.  The  flag should be set early in the func‐
11803                     tion before inspecting the value of NUMERIC  or  invoking
11804                     other  widgets.  This  has no effect for a widget invoked
11805                     from insert mode. If insert mode is active when the  wid‐
11806                     get  finishes, the change extends until next returning to
11807                     command mode.
11808
11809              -C widget completion-widget function
11810                     Create a user-defined completion widget named widget. The
11811                     completion  widget  will behave like the built-in comple‐
11812                     tion-widget whose name is given as completion-widget.  To
11813                     generate  the  completions,  the  shell function function
11814                     will be called.  For further  information,  see  zshcomp‐
11815                     wid(1).
11816
11817              -R [ -c ] [ display-string ] [ string ... ]
11818                     Redisplay  the  command  line;  this is to be called from
11819                     within a user-defined widget to allow changes  to  become
11820                     visible.   If  a  display-string  is given and not empty,
11821                     this is shown in the status line (immediately  below  the
11822                     line being edited).
11823
11824                     If  the  optional strings are given they are listed below
11825                     the prompt in  the  same  way  as  completion  lists  are
11826                     printed.  If  no  strings  are given but the -c option is
11827                     used such a list is cleared.
11828
11829                     Note that this option is only useful for widgets that  do
11830                     not  exit  immediately after using it because the strings
11831                     displayed will be erased immediately  after  return  from
11832                     the widget.
11833
11834                     This  command  can  safely be called outside user defined
11835                     widgets; if zle is active, the display will be refreshed,
11836                     while  if  zle  is not active, the command has no effect.
11837                     In this case there will usually be no other arguments.
11838
11839                     The status is zero if zle was active, else one.
11840
11841              -M string
11842                     As with the -R option, the string will be displayed below
11843                     the  command  line; unlike the -R option, the string will
11844                     not be put into the  status  line  but  will  instead  be
11845                     printed  normally  below the prompt.  This means that the
11846                     string will still be displayed after the  widget  returns
11847                     (until it is overwritten by subsequent commands).
11848
11849              -U string
11850                     This  pushes  the characters in the string onto the input
11851                     stack of ZLE.  After the widget currently  executed  fin‐
11852                     ishes  ZLE will behave as if the characters in the string
11853                     were typed by the user.
11854
11855                     As ZLE uses a stack, if this option  is  used  repeatedly
11856                     the  last  string pushed onto the stack will be processed
11857                     first.  However, the characters in each  string  will  be
11858                     processed  in  the  order  in  which  they  appear in the
11859                     string.
11860
11861              -K keymap
11862                     Selects the keymap named keymap.  An error  message  will
11863                     be displayed if there is no such keymap.
11864
11865                     This  keymap selection affects the interpretation of fol‐
11866                     lowing keystrokes within this  invocation  of  ZLE.   Any
11867                     following  invocation  (e.g., the next command line) will
11868                     start as usual with the `main' keymap selected.
11869
11870              -F [ -L | -w ] [ fd [ handler ] ]
11871                     Only available if your system supports one of the  `poll'
11872                     or `select' system calls; most modern systems do.
11873
11874                     Installs handler (the name of a shell function) to handle
11875                     input from file descriptor fd.  Installing a handler  for
11876                     an  fd  which is already handled causes the existing han‐
11877                     dler to be replaced.  Any number of handlers for any num‐
11878                     ber  of readable file descriptors may be installed.  Note
11879                     that zle makes no attempt to check whether this fd is ac‐
11880                     tually  readable  when  installing the handler.  The user
11881                     must make their own arrangements for  handling  the  file
11882                     descriptor when zle is not active.
11883
11884                     When zle is attempting to read data, it will examine both
11885                     the terminal and the list of handled fd's.  If  data  be‐
11886                     comes  available  on a handled fd, zle calls handler with
11887                     the fd which is ready for reading as the first  argument.
11888                     Under normal circumstances this is the only argument, but
11889                     if an error was detected, a second argument provides  de‐
11890                     tails:  `hup'  for  a  disconnect, `nval' for a closed or
11891                     otherwise invalid descriptor, or `err' for any other con‐
11892                     dition.   Systems  that  support only the `select' system
11893                     call always use `err'.
11894
11895                     If the option -w is also given, the handler is instead  a
11896                     line  editor widget, typically a shell function made into
11897                     a widget using `zle -N'.  In that case  handler  can  use
11898                     all  the  facilities of zle to update the current editing
11899                     line.  Note, however, that as handling fd takes place  at
11900                     a low level changes to the display will not automatically
11901                     appear; the widget should call `zle -R' to  force  redis‐
11902                     play.  As of this writing, widget handlers only support a
11903                     single argument and thus are never passed  a  string  for
11904                     error  state, so widgets must be prepared to test the de‐
11905                     scriptor themselves.
11906
11907                     If either type of handler produces output to  the  termi‐
11908                     nal, it should call `zle -I' before doing so (see below).
11909                     Handlers should not attempt to read from the terminal.
11910
11911                     If no handler is given, but an fd is present, any handler
11912                     for  that fd is removed.  If there is none, an error mes‐
11913                     sage is printed and status 1 is returned.
11914
11915                     If no arguments are given, or the -L option is  supplied,
11916                     a  list  of  handlers  is  printed in a form which can be
11917                     stored for later execution.
11918
11919                     An fd (but not a handler) may optionally  be  given  with
11920                     the  -L  option; in this case, the function will list the
11921                     handler if any, else silently return status 1.
11922
11923                     Note that this feature should be used with care.   Activ‐
11924                     ity  on one of the fd's which is not properly handled can
11925                     cause the terminal to become unusable.   Removing  an  fd
11926                     handler from within a signal trap may cause unpredictable
11927                     behavior.
11928
11929                     Here is a simple example of using this feature.   A  con‐
11930                     nection  to  a  remote TCP port is created using the ztcp
11931                     command; see the description of the zsh/net/tcp module in
11932                     zshmodules(1).   Then a handler is installed which simply
11933                     prints out any data which  arrives  on  this  connection.
11934                     Note that `select' will indicate that the file descriptor
11935                     needs handling if the remote side has closed the  connec‐
11936                     tion; we handle that by testing for a failed read.
11937
11938                            if ztcp pwspc 2811; then
11939                              tcpfd=$REPLY
11940                              handler() {
11941                                zle -I
11942                                local line
11943                                if ! read -r line <&$1; then
11944                                  # select marks this fd if we reach EOF,
11945                                  # so handle this specially.
11946                                  print "[Read on fd $1 failed, removing.]" >&2
11947                                  zle -F $1
11948                                  return 1
11949                                fi
11950                                print -r - $line
11951                              }
11952                              zle -F $tcpfd handler
11953                            fi
11954
11955              -I     Unusually,  this  option  is most useful outside ordinary
11956                     widget functions, though it may be used within if  normal
11957                     output  to  the terminal is required.  It invalidates the
11958                     current zle display in preparation for output;  typically
11959                     this  will  be from a trap function.  It has no effect if
11960                     zle is not active.  When a trap exits, the  shell  checks
11961                     to  see if the display needs restoring, hence the follow‐
11962                     ing will print output in such a way as not to disturb the
11963                     line being edited:
11964
11965                            TRAPUSR1() {
11966                              # Invalidate zle display
11967                              [[ -o zle ]] && zle -I
11968                              # Show output
11969                              print Hello
11970                            }
11971
11972                     In  general,  the  trap function may need to test whether
11973                     zle is active before using this method (as shown  in  the
11974                     example),  since  the  zsh/zle  module  may  not  even be
11975                     loaded; if it is not, the command can be skipped.
11976
11977                     It is possible to call `zle -I' several times before con‐
11978                     trol  is returned to the editor; the display will only be
11979                     invalidated the first time to minimise disruption.
11980
11981                     Note that there are normally better ways of  manipulating
11982                     the  display  from  within zle widgets; see, for example,
11983                     `zle -R' above.
11984
11985                     The returned status is zero if zle was invalidated,  even
11986                     though  this may have been by a previous call to `zle -I'
11987                     or by a system notification.  To test if a zle widget may
11988                     be  called  at  this point, execute zle with no arguments
11989                     and examine the return status.
11990
11991              -T     This is used to add, list or remove internal  transforma‐
11992                     tions on the processing performed by the line editor.  It
11993                     is typically used only for debugging or  testing  and  is
11994                     therefore of little interest to the general user.
11995
11996                     `zle  -T  transformation  func'  specifies that the given
11997                     transformation (see below) is effected by shell  function
11998                     func.
11999
12000                     `zle -Tr transformation' removes the given transformation
12001                     if it was present (it is not an error if none was).
12002
12003                     `zle -TL' can be used to list  all  transformations  cur‐
12004                     rently in operation.
12005
12006                     Currently  the  only  transformation is tc.  This is used
12007                     instead of outputting  termcap  codes  to  the  terminal.
12008                     When  the  transformation is in operation the shell func‐
12009                     tion is passed the termcap code that would be  output  as
12010                     its  first  argument; if the operation required a numeric
12011                     argument, that is passed as a second argument.  The func‐
12012                     tion  should  set  the shell variable REPLY to the trans‐
12013                     formed termcap code.  Typically this is used  to  produce
12014                     some  simply  formatted  version of the code and optional
12015                     argument for debugging or testing.  Note that this trans‐
12016                     formation is not applied to other non-printing characters
12017                     such as carriage returns and newlines.
12018
12019              widget [ -n num ] [ -Nw ] [ -K keymap ] args ...
12020                     Invoke the specified widget.  This can only be done  when
12021                     ZLE  is  active;  normally this will be within a user-de‐
12022                     fined widget.
12023
12024                     With the options -n and -N, the current numeric  argument
12025                     will be saved and then restored after the call to widget;
12026                     `-n num' sets the numeric argument  temporarily  to  num,
12027                     while  `-N' sets it to the default, i.e. as if there were
12028                     none.
12029
12030                     With the option -K, keymap will be used  as  the  current
12031                     keymap  during the execution of the widget.  The previous
12032                     keymap will be restored when the widget exits.
12033
12034                     Normally, calling a widget in this way does not  set  the
12035                     special  parameter WIDGET and related parameters, so that
12036                     the environment appears as if the top-level widget called
12037                     by  the user were still active.  With the option -w, WID‐
12038                     GET and related parameters are set to reflect the  widget
12039                     being executed by the zle call.
12040
12041                     Any  further arguments will be passed to the widget; note
12042                     that as standard argument handling is performed, any gen‐
12043                     eral  argument list should be preceded by --.  If it is a
12044                     shell function, these are passed down as  positional  pa‐
12045                     rameters;  for  builtin widgets it is up to the widget in
12046                     question what it does with them.  Currently arguments are
12047                     only handled by the incremental-search commands, the his‐
12048                     tory-search-forward and -backward and  the  corresponding
12049                     functions prefixed by vi-, and by universal-argument.  No
12050                     error is flagged if the command does not  use  the  argu‐
12051                     ments, or only uses some of them.
12052
12053                     The  return status reflects the success or failure of the
12054                     operation carried out by  the  widget,  or  if  it  is  a
12055                     user-defined  widget the return status of the shell func‐
12056                     tion.
12057
12058                     A non-zero return status causes the shell  to  beep  when
12059                     the  widget  exits,  unless the BEEP options was unset or
12060                     the widget was called via the zle  command.   Thus  if  a
12061                     user defined widget requires an immediate beep, it should
12062                     call the beep widget directly.
12063

WIDGETS

12065       All actions in the editor are performed by `widgets'.  A  widget's  job
12066       is  simply to perform some small action.  The ZLE commands that key se‐
12067       quences in keymaps are bound to are in fact widgets.   Widgets  can  be
12068       user-defined or built in.
12069
12070       The  standard widgets built into ZLE are listed in Standard Widgets be‐
12071       low.  Other built-in widgets can be defined by other modules (see  zsh‐
12072       modules(1)).   Each built-in widget has two names: its normal canonical
12073       name, and the same name preceded by a `.'.  The `.' name is special: it
12074       can't  be  rebound to a different widget.  This makes the widget avail‐
12075       able even when its usual name has been redefined.
12076
12077       User-defined widgets are defined using `zle  -N',  and  implemented  as
12078       shell  functions.  When the widget is executed, the corresponding shell
12079       function is executed, and can perform editing (or other)  actions.   It
12080       is recommended that user-defined widgets should not have names starting
12081       with `.'.
12082

USER-DEFINED WIDGETS

12084       User-defined widgets, being implemented as shell functions, can execute
12085       any  normal  shell  command.   They can also run other widgets (whether
12086       built-in or user-defined) using the zle builtin command.  The  standard
12087       input  of the function is redirected from /dev/null to prevent external
12088       commands from unintentionally blocking ZLE by reading from  the  termi‐
12089       nal,  but  read -k or read -q can be used to read characters.  Finally,
12090       they can examine and edit the ZLE buffer being edited  by  reading  and
12091       setting the special parameters described below.
12092
12093       These  special parameters are always available in widget functions, but
12094       are not in any way special outside ZLE.  If they have some normal value
12095       outside  ZLE,  that  value is temporarily inaccessible, but will return
12096       when the widget function exits.  These special parameters in fact  have
12097       local scope, like parameters created in a function using local.
12098
12099       Inside  completion  widgets and traps called while ZLE is active, these
12100       parameters are available read-only.
12101
12102       Note that the parameters appear as local to any  ZLE  widget  in  which
12103       they  appear.  Hence if it is desired to override them this needs to be
12104       done within a nested function:
12105
12106              widget-function() {
12107                # $WIDGET here refers to the special variable
12108                # that is local inside widget-function
12109                () {
12110                   # This anonymous nested function allows WIDGET
12111                   # to be used as a local variable.  The -h
12112                   # removes the special status of the variable.
12113                   local -h WIDGET
12114                }
12115              }
12116
12117       BUFFER (scalar)
12118              The entire contents of the edit buffer.  If it  is  written  to,
12119              the  cursor remains at the same offset, unless that would put it
12120              outside the buffer.
12121
12122       BUFFERLINES (integer)
12123              The number of screen lines needed for the edit buffer  currently
12124              displayed  on  screen (i.e. without any changes to the preceding
12125              parameters done after the last redisplay); read-only.
12126
12127       CONTEXT (scalar)
12128              The context in which zle was called to read a  line;  read-only.
12129              One of the values:
12130
12131              start  The start of a command line (at prompt PS1).
12132
12133              cont   A continuation to a command line (at prompt PS2).
12134
12135              select In a select loop (at prompt PS3).
12136
12137              vared  Editing a variable in vared.
12138
12139       CURSOR (integer)
12140              The  offset  of  the cursor, within the edit buffer.  This is in
12141              the  range  0  to  $#BUFFER,  and  is  by  definition  equal  to
12142              $#LBUFFER.   Attempts to move the cursor outside the buffer will
12143              result in the cursor being moved to the appropriate end  of  the
12144              buffer.
12145
12146       CUTBUFFER (scalar)
12147              The  last item cut using one of the `kill-' commands; the string
12148              which the next yank would insert in the line.  Later entries  in
12149              the  kill ring are in the array killring.  Note that the command
12150              `zle copy-region-as-kill string' can be used to set the text  of
12151              the  cut buffer from a shell function and cycle the kill ring in
12152              the same way as interactively killing text.
12153
12154       HISTNO (integer)
12155              The current history number.  Setting this has the same effect as
12156              moving  up  or  down in the history to the corresponding history
12157              line.  An attempt to set it is ignored if the line is not stored
12158              in  the  history.   Note  this  is not the same as the parameter
12159              HISTCMD, which always gives the number of the history line being
12160              added  to  the  main shell's history.  HISTNO refers to the line
12161              being retrieved within zle.
12162
12163       ISEARCHMATCH_ACTIVE (integer)
12164       ISEARCHMATCH_START (integer)
12165       ISEARCHMATCH_END (integer)
12166              ISEARCHMATCH_ACTIVE indicates whether a part of  the  BUFFER  is
12167              currently  matched  by  an  incremental search pattern. ISEARCH‐
12168              MATCH_START  and  ISEARCHMATCH_END  give  the  location  of  the
12169              matched  part and are in the same units as CURSOR. They are only
12170              valid for reading when ISEARCHMATCH_ACTIVE is non-zero.
12171
12172              All parameters are read-only.
12173
12174       KEYMAP (scalar)
12175              The name of the currently selected keymap; read-only.
12176
12177       KEYS (scalar)
12178              The keys typed to invoke  this  widget,  as  a  literal  string;
12179              read-only.
12180
12181       KEYS_QUEUED_COUNT (integer)
12182              The number of bytes pushed back to the input queue and therefore
12183              available for  reading  immediately  before  any  I/O  is  done;
12184              read-only.  See also PENDING; the two values are distinct.
12185
12186       killring (array)
12187              The  array  of  previously  killed items, with the most recently
12188              killed first.  This gives the items that would be retrieved by a
12189              yank-pop  in  the  same order.  Note, however, that the most re‐
12190              cently killed item is in $CUTBUFFER; $killring shows  the  array
12191              of previous entries.
12192
12193              The  default size for the kill ring is eight, however the length
12194              may be changed by normal array operations.  Any empty string  in
12195              the kill ring is ignored by the yank-pop command, hence the size
12196              of the array effectively sets the maximum  length  of  the  kill
12197              ring,  while  the  number  of non-zero strings gives the current
12198              length, both as seen by the user at the command line.
12199
12200       LASTABORTEDSEARCH (scalar)
12201              The last search string used by an interactive  search  that  was
12202              aborted by the user (status 3 returned by the search widget).
12203
12204       LASTSEARCH (scalar)
12205              The last search string used by an interactive search; read-only.
12206              This is set even if the search failed (status 0, 1 or 2 returned
12207              by the search widget), but not if it was aborted by the user.
12208
12209       LASTWIDGET (scalar)
12210              The name of the last widget that was executed; read-only.
12211
12212       LBUFFER (scalar)
12213              The part of the buffer that lies to the left of the cursor posi‐
12214              tion.  If it is assigned to, only that part of the buffer is re‐
12215              placed,  and the cursor remains between the new $LBUFFER and the
12216              old $RBUFFER.
12217
12218       MARK (integer)
12219              Like CURSOR, but for the mark. With vi-mode operators that  wait
12220              for  a movement command to select a region of text, setting MARK
12221              allows the selection to extend in both directions from the  ini‐
12222              tial cursor position.
12223
12224       NUMERIC (integer)
12225              The numeric argument. If no numeric argument was given, this pa‐
12226              rameter is unset. When this is set  inside  a  widget  function,
12227              builtin widgets called with the zle builtin command will use the
12228              value assigned. If it is unset inside a widget function, builtin
12229              widgets called behave as if no numeric argument was given.
12230
12231       PENDING (integer)
12232              The  number of bytes pending for input, i.e. the number of bytes
12233              which have already been typed and can immediately  be  read.  On
12234              systems  where  the  shell  is not able to get this information,
12235              this parameter will always have a  value  of  zero.   Read-only.
12236              See also KEYS_QUEUED_COUNT; the two values are distinct.
12237
12238       PREBUFFER (scalar)
12239              In  a  multi-line  input at the secondary prompt, this read-only
12240              parameter contains the contents of the lines before the one  the
12241              cursor is currently in.
12242
12243       PREDISPLAY (scalar)
12244              Text  to be displayed before the start of the editable text buf‐
12245              fer.  This does not have to be a complete  line;  to  display  a
12246              complete  line, a newline must be appended explicitly.  The text
12247              is reset on each new invocation (but not  recursive  invocation)
12248              of zle.
12249
12250       POSTDISPLAY (scalar)
12251              Text  to be displayed after the end of the editable text buffer.
12252              This does not have to be a complete line; to display a  complete
12253              line, a newline must be prepended explicitly.  The text is reset
12254              on each new invocation (but not recursive invocation) of zle.
12255
12256       RBUFFER (scalar)
12257              The part of the buffer that lies to the right of the cursor  po‐
12258              sition.   If  it is assigned to, only that part of the buffer is
12259              replaced, and the cursor remains between the  old  $LBUFFER  and
12260              the new $RBUFFER.
12261
12262       REGION_ACTIVE (integer)
12263              Indicates if the region is currently active.  It can be assigned
12264              0 or 1 to deactivate and activate  the  region  respectively.  A
12265              value of 2 activates the region in line-wise mode with the high‐
12266              lighted text extending for whole lines only; see Character High‐
12267              lighting below.
12268
12269       region_highlight (array)
12270              Each element of this array may be set to a string that describes
12271              highlighting for an arbitrary region of the  command  line  that
12272              will  take effect the next time the command line is redisplayed.
12273              Highlighting of the non-editable parts of the  command  line  in
12274              PREDISPLAY  and  POSTDISPLAY  are  possible, but note that the P
12275              flag is needed for character indexing to include PREDISPLAY.
12276
12277              Each string consists of the following parts:
12278
12279              •      Optionally, a `P' to signify that the start and end  off‐
12280                     set  that follow include any string set by the PREDISPLAY
12281                     special parameter;  this  is  needed  if  the  predisplay
12282                     string  itself is to be highlighted.  Whitespace may fol‐
12283                     low the `P'.
12284
12285              •      A start offset in the same units as CURSOR, terminated by
12286                     whitespace.
12287
12288              •      An  end offset in the same units as CURSOR, terminated by
12289                     whitespace.
12290
12291              •      A highlight specification in the same format as used  for
12292                     contexts  in the parameter zle_highlight, see the section
12293                     `Character Highlighting' below; for example, standout  or
12294                     fg=red,bold
12295
12296              For example,
12297
12298                     region_highlight=("P0 20 bold")
12299
12300              specifies that the first twenty characters of the text including
12301              any predisplay string should be highlighted in bold.
12302
12303              Note that the effect of region_highlight is not saved and disap‐
12304              pears as soon as the line is accepted.
12305
12306              The  final  highlighting on the command line depends on both re‐
12307              gion_highlight and  zle_highlight;  see  the  section  CHARACTER
12308              HIGHLIGHTING below for details.
12309
12310       registers (associative array)
12311              The contents of each of the vi register buffers. These are typi‐
12312              cally set using vi-set-buffer followed by a  delete,  change  or
12313              yank command.
12314
12315       SUFFIX_ACTIVE (integer)
12316       SUFFIX_START (integer)
12317       SUFFIX_END (integer)
12318              SUFFIX_ACTIVE  indicates  whether  an  auto-removable completion
12319              suffix is currently active. SUFFIX_START and SUFFIX_END give the
12320              location of the suffix and are in the same units as CURSOR. They
12321              are only valid for reading when SUFFIX_ACTIVE is non-zero.
12322
12323              All parameters are read-only.
12324
12325       UNDO_CHANGE_NO (integer)
12326              A number representing the state of the undo history.   The  only
12327              use  of this is passing as an argument to the undo widget in or‐
12328              der to undo back to the recorded point.  Read-only.
12329
12330       UNDO_LIMIT_NO (integer)
12331              A number corresponding to an existing change in  the  undo  his‐
12332              tory; compare UNDO_CHANGE_NO.  If this is set to a value greater
12333              than zero, the undo command will not allow the line to be undone
12334              beyond  the  given  change  number.  It is still possible to use
12335              `zle undo change' in a widget to undo beyond that point; in that
12336              case, it will not be possible to undo at all until UNDO_LIMIT_NO
12337              is reduced.  Set to 0 to disable the limit.
12338
12339              A typical use of this variable in a widget function is  as  fol‐
12340              lows (note the additional function scope is required):
12341
12342                     () {
12343                       local UNDO_LIMIT_NO=$UNDO_CHANGE_NO
12344                       # Perform some form of recursive edit.
12345                     }
12346
12347       WIDGET (scalar)
12348              The name of the widget currently being executed; read-only.
12349
12350       WIDGETFUNC (scalar)
12351              The  name of the shell function that implements a widget defined
12352              with either zle -N or zle -C.  In the former case, this  is  the
12353              second  argument  to the zle -N command that defined the widget,
12354              or the first argument if there was no second argument.   In  the
12355              latter  case  this  is  the third argument to the zle -C command
12356              that defined the widget.  Read-only.
12357
12358       WIDGETSTYLE (scalar)
12359              Describes the implementation behind the completion  widget  cur‐
12360              rently  being executed; the second argument that followed zle -C
12361              when the widget was defined.  This is the name of a builtin com‐
12362              pletion  widget.  For widgets defined with zle -N this is set to
12363              the empty string.  Read-only.
12364
12365       YANK_ACTIVE (integer)
12366       YANK_START (integer)
12367       YANK_END (integer)
12368              YANK_ACTIVE indicates whether text has just been yanked (pasted)
12369              into  the  buffer.  YANK_START and YANK_END give the location of
12370              the pasted text and are in the same units as CURSOR.   They  are
12371              only  valid  for reading when YANK_ACTIVE is non-zero.  They can
12372              also be assigned by widgets that  insert  text  in  a  yank-like
12373              fashion,  for example wrappers of bracketed-paste.  See also zle
12374              -f.
12375
12376              YANK_ACTIVE is read-only.
12377
12378       ZLE_RECURSIVE (integer)
12379              Usually zero, but incremented  inside  any  instance  of  recur‐
12380              sive-edit.  Hence indicates the current recursion level.
12381
12382              ZLE_RECURSIVE is read-only.
12383
12384       ZLE_STATE (scalar)
12385              Contains  a  set of space-separated words that describe the cur‐
12386              rent zle state.
12387
12388              Currently, the states shown are the insert mode as  set  by  the
12389              overwrite-mode  or  vi-replace  widgets and whether history com‐
12390              mands will visit imported entries as controlled by  the  set-lo‐
12391              cal-history  widget.  The string contains `insert' if characters
12392              to be inserted on the command line move existing  characters  to
12393              the  right or `overwrite' if characters to be inserted overwrite
12394              existing characters. It contains `localhistory'  if  only  local
12395              history  commands will be visited or `globalhistory' if imported
12396              history commands will also be visited.
12397
12398              The substrings are sorted in alphabetical order so that  if  you
12399              want  to test for two specific substrings in a future-proof way,
12400              you can do match by doing:
12401
12402                     if [[ $ZLE_STATE == *globalhistory*insert* ]]; then ...; fi
12403
12404   Special Widgets
12405       There are a few user-defined widgets which are special  to  the  shell.
12406       If they do not exist, no special action is taken.  The environment pro‐
12407       vided is identical to that for any other editing widget.
12408
12409       zle-isearch-exit
12410              Executed at the end of incremental search at the point where the
12411              isearch prompt is removed from the display.  See zle-isearch-up‐
12412              date for an example.
12413
12414       zle-isearch-update
12415              Executed within incremental search when the display is about  to
12416              be  redrawn.   Additional  output  below  the incremental search
12417              prompt can be generated by using `zle  -M'  within  the  widget.
12418              For example,
12419
12420                     zle-isearch-update() { zle -M "Line $HISTNO"; }
12421                     zle -N zle-isearch-update
12422
12423              Note the line output by `zle -M' is not deleted on exit from in‐
12424              cremental search.  This can be done from a zle-isearch-exit wid‐
12425              get:
12426
12427                     zle-isearch-exit() { zle -M ""; }
12428                     zle -N zle-isearch-exit
12429
12430       zle-line-pre-redraw
12431              Executed whenever the input line is about to be redrawn, provid‐
12432              ing an opportunity to update the region_highlight array.
12433
12434       zle-line-init
12435              Executed every time the line editor is started  to  read  a  new
12436              line  of input.  The following example puts the line editor into
12437              vi command mode when it starts up.
12438
12439                     zle-line-init() { zle -K vicmd; }
12440                     zle -N zle-line-init
12441
12442              (The command inside the function sets the keymap directly; it is
12443              equivalent to zle vi-cmd-mode.)
12444
12445       zle-line-finish
12446              This  is similar to zle-line-init but is executed every time the
12447              line editor has finished reading a line of input.
12448
12449       zle-history-line-set
12450              Executed when the history line changes.
12451
12452       zle-keymap-select
12453              Executed every time the keymap changes, i.e. the special parame‐
12454              ter KEYMAP is set to a different value, while the line editor is
12455              active.  Initialising the keymap when  the  line  editor  starts
12456              does not cause the widget to be called.
12457
12458              The  value  $KEYMAP within the function reflects the new keymap.
12459              The old keymap is passed as the sole argument.
12460
12461              This can be used for detecting switches between the  vi  command
12462              (vicmd) and insert (usually main) keymaps.
12463

STANDARD WIDGETS

12465       The  following is a list of all the standard widgets, and their default
12466       bindings in emacs mode,  vi  command  mode  and  vi  insert  mode  (the
12467       `emacs', `vicmd' and `viins' keymaps, respectively).
12468
12469       Note  that cursor keys are bound to movement keys in all three keymaps;
12470       the shell assumes that the cursor keys send the key sequences  reported
12471       by  the  terminal-handling  library (termcap or terminfo).  The key se‐
12472       quences shown in the list are those based on the VT100, common on  many
12473       modern  terminals, but in fact these are not necessarily bound.  In the
12474       case of the viins keymap, the initial escape character of the sequences
12475       serves  also to return to the vicmd keymap: whether this happens is de‐
12476       termined by the KEYTIMEOUT parameter, see zshparam(1).
12477
12478   Movement
12479       vi-backward-blank-word (unbound) (B) (unbound)
12480              Move backward one word, where a word is defined as a  series  of
12481              non-blank characters.
12482
12483       vi-backward-blank-word-end (unbound) (gE) (unbound)
12484              Move to the end of the previous word, where a word is defined as
12485              a series of non-blank characters.
12486
12487       backward-char (^B ESC-[D) (unbound) (unbound)
12488              Move backward one character.
12489
12490       vi-backward-char (unbound) (^H h ^?) (ESC-[D)
12491              Move backward one character, without changing lines.
12492
12493       backward-word (ESC-B ESC-b) (unbound) (unbound)
12494              Move to the beginning of the previous word.
12495
12496       emacs-backward-word
12497              Move to the beginning of the previous word.
12498
12499       vi-backward-word (unbound) (b) (unbound)
12500              Move to the beginning of the previous word, vi-style.
12501
12502       vi-backward-word-end (unbound) (ge) (unbound)
12503              Move to the end of the previous word, vi-style.
12504
12505       beginning-of-line (^A) (unbound) (unbound)
12506              Move to the beginning of the line.  If already at the  beginning
12507              of the line, move to the beginning of the previous line, if any.
12508
12509       vi-beginning-of-line
12510              Move to the beginning of the line, without changing lines.
12511
12512       down-line (unbound) (unbound) (unbound)
12513              Move down a line in the buffer.
12514
12515       end-of-line (^E) (unbound) (unbound)
12516              Move to the end of the line.  If already at the end of the line,
12517              move to the end of the next line, if any.
12518
12519       vi-end-of-line (unbound) ($) (unbound)
12520              Move to the end of the line.  If an argument is  given  to  this
12521              command,  the cursor will be moved to the end of the line (argu‐
12522              ment - 1) lines down.
12523
12524       vi-forward-blank-word (unbound) (W) (unbound)
12525              Move forward one word, where a word is defined as  a  series  of
12526              non-blank characters.
12527
12528       vi-forward-blank-word-end (unbound) (E) (unbound)
12529              Move  to  the  end of the current word, or, if at the end of the
12530              current word, to the end of the next word, where a word  is  de‐
12531              fined as a series of non-blank characters.
12532
12533       forward-char (^F ESC-[C) (unbound) (unbound)
12534              Move forward one character.
12535
12536       vi-forward-char (unbound) (space l) (ESC-[C)
12537              Move forward one character.
12538
12539       vi-find-next-char (^X^F) (f) (unbound)
12540              Read  a character from the keyboard, and move to the next occur‐
12541              rence of it in the line.
12542
12543       vi-find-next-char-skip (unbound) (t) (unbound)
12544              Read a character from the keyboard, and  move  to  the  position
12545              just before the next occurrence of it in the line.
12546
12547       vi-find-prev-char (unbound) (F) (unbound)
12548              Read a character from the keyboard, and move to the previous oc‐
12549              currence of it in the line.
12550
12551       vi-find-prev-char-skip (unbound) (T) (unbound)
12552              Read a character from the keyboard, and  move  to  the  position
12553              just after the previous occurrence of it in the line.
12554
12555       vi-first-non-blank (unbound) (^) (unbound)
12556              Move to the first non-blank character in the line.
12557
12558       vi-forward-word (unbound) (w) (unbound)
12559              Move forward one word, vi-style.
12560
12561       forward-word (ESC-F ESC-f) (unbound) (unbound)
12562              Move  to the beginning of the next word.  The editor's idea of a
12563              word is specified with the WORDCHARS parameter.
12564
12565       emacs-forward-word
12566              Move to the end of the next word.
12567
12568       vi-forward-word-end (unbound) (e) (unbound)
12569              Move to the end of the next word.
12570
12571       vi-goto-column (ESC-|) (|) (unbound)
12572              Move to the column specified by the numeric argument.
12573
12574       vi-goto-mark (unbound) (`) (unbound)
12575              Move to the specified mark.
12576
12577       vi-goto-mark-line (unbound) (') (unbound)
12578              Move to beginning of the line containing the specified mark.
12579
12580       vi-repeat-find (unbound) (;) (unbound)
12581              Repeat the last vi-find command.
12582
12583       vi-rev-repeat-find (unbound) (,) (unbound)
12584              Repeat the last vi-find command in the opposite direction.
12585
12586       up-line (unbound) (unbound) (unbound)
12587              Move up a line in the buffer.
12588
12589   History Control
12590       beginning-of-buffer-or-history (ESC-<) (gg) (unbound)
12591              Move to the beginning of the buffer, or if already  there,  move
12592              to the first event in the history list.
12593
12594       beginning-of-line-hist
12595              Move  to the beginning of the line.  If already at the beginning
12596              of the buffer, move to the previous history line.
12597
12598       beginning-of-history
12599              Move to the first event in the history list.
12600
12601       down-line-or-history (^N ESC-[B) (j) (ESC-[B)
12602              Move down a line in the buffer, or  if  already  at  the  bottom
12603              line, move to the next event in the history list.
12604
12605       vi-down-line-or-history (unbound) (+) (unbound)
12606              Move  down  a  line  in  the buffer, or if already at the bottom
12607              line, move to the next event in the history list.  Then move  to
12608              the first non-blank character on the line.
12609
12610       down-line-or-search
12611              Move  down  a  line  in  the buffer, or if already at the bottom
12612              line, search forward in the history for a  line  beginning  with
12613              the first word in the buffer.
12614
12615              If called from a function by the zle command with arguments, the
12616              first argument is taken as  the  string  for  which  to  search,
12617              rather than the first word in the buffer.
12618
12619       down-history (unbound) (^N) (unbound)
12620              Move to the next event in the history list.
12621
12622       history-beginning-search-backward
12623              Search  backward  in  the  history for a line beginning with the
12624              current line up to the cursor.  This leaves the  cursor  in  its
12625              original position.
12626
12627       end-of-buffer-or-history (ESC->) (unbound) (unbound)
12628              Move  to the end of the buffer, or if already there, move to the
12629              last event in the history list.
12630
12631       end-of-line-hist
12632              Move to the end of the line.  If already at the end of the  buf‐
12633              fer, move to the next history line.
12634
12635       end-of-history
12636              Move to the last event in the history list.
12637
12638       vi-fetch-history (unbound) (G) (unbound)
12639              Fetch  the history line specified by the numeric argument.  This
12640              defaults to the current history line (i.e. the  one  that  isn't
12641              history yet).
12642
12643       history-incremental-search-backward (^R ^Xr) (unbound) (unbound)
12644              Search  backward  incrementally  for  a  specified  string.  The
12645              search is case-insensitive if the search string  does  not  have
12646              uppercase letters and no numeric argument was given.  The string
12647              may begin with `^' to anchor the search to the beginning of  the
12648              line.  When called from a user-defined function returns the fol‐
12649              lowing statuses: 0, if the search succeeded; 1,  if  the  search
12650              failed;  2,  if  the  search  term  was a bad pattern; 3, if the
12651              search was aborted by the send-break command.
12652
12653              A restricted set  of  editing  functions  is  available  in  the
12654              mini-buffer.   Keys are looked up in the special isearch keymap,
12655              and if not found there in the main keymap (note that by  default
12656              the  isearch  keymap is empty).  An interrupt signal, as defined
12657              by the stty setting, will stop the search and  go  back  to  the
12658              original  line.   An  undefined  key  will have the same effect.
12659              Note that the following always perform the same task within  in‐
12660              cremental  searches  and cannot be replaced by user defined wid‐
12661              gets, nor can the set of functions be extended.   The  supported
12662              functions are:
12663
12664              accept-and-hold
12665              accept-and-infer-next-history
12666              accept-line
12667              accept-line-and-down-history
12668                     Perform  the  usual  function  after  exiting incremental
12669                     search.  The command line displayed is executed.
12670
12671              backward-delete-char
12672              vi-backward-delete-char
12673                     Back up one place in the search history.  If  the  search
12674                     has been repeated this does not immediately erase a char‐
12675                     acter in the minibuffer.
12676
12677              accept-search
12678                     Exit incremental search, retaining the command  line  but
12679                     performing no further action.  Note that this function is
12680                     not bound by default and has no effect outside  incremen‐
12681                     tal search.
12682
12683              backward-delete-word
12684              backward-kill-word
12685              vi-backward-kill-word
12686                     Back  up  one  character  in  the minibuffer; if multiple
12687                     searches have been performed since the character was  in‐
12688                     serted  the  search  history is rewound to the point just
12689                     before the character was entered.  Hence this has the ef‐
12690                     fect of repeating backward-delete-char.
12691
12692              clear-screen
12693                     Clear the screen, remaining in incremental search mode.
12694
12695              history-incremental-search-backward
12696                     Find the next occurrence of the contents of the mini-buf‐
12697                     fer. If the mini-buffer is empty, the most recent  previ‐
12698                     ously used search string is reinstated.
12699
12700              history-incremental-search-forward
12701                     Invert the sense of the search.
12702
12703              magic-space
12704                     Inserts a non-magical space.
12705
12706              quoted-insert
12707              vi-quoted-insert
12708                     Quote the character to insert into the minibuffer.
12709
12710              redisplay
12711                     Redisplay  the  command  line,  remaining  in incremental
12712                     search mode.
12713
12714              vi-cmd-mode
12715                     Select the `vicmd'  keymap;  the  `main'  keymap  (insert
12716                     mode) will be selected initially.
12717
12718                     In addition, the modifications that were made while in vi
12719                     insert mode are merged to form a single undo event.
12720
12721              vi-repeat-search
12722              vi-rev-repeat-search
12723                     Repeat the search.  The direction of the search is  indi‐
12724                     cated in the mini-buffer.
12725
12726              Any  character  that is not bound to one of the above functions,
12727              or self-insert or self-insert-unmeta, will cause the mode to  be
12728              exited.   The  character  is  then looked up and executed in the
12729              keymap in effect at that point.
12730
12731              When called from a widget function by the zle command,  the  in‐
12732              cremental search commands can take a string argument.  This will
12733              be treated as a string of keys, as for arguments to the  bindkey
12734              command, and used as initial input for the command.  Any charac‐
12735              ters in the string which are unused by  the  incremental  search
12736              will be silently ignored.  For example,
12737
12738                     zle history-incremental-search-backward forceps
12739
12740              will  search  backwards for forceps, leaving the minibuffer con‐
12741              taining the string `forceps'.
12742
12743       history-incremental-search-forward (^S ^Xs) (unbound) (unbound)
12744              Search forward incrementally for a specified string.  The search
12745              is case-insensitive if the search string does not have uppercase
12746              letters and no numeric argument was given.  The string may begin
12747              with `^' to anchor the search to the beginning of the line.  The
12748              functions available in the mini-buffer are the same as for  his‐
12749              tory-incremental-search-backward.
12750
12751       history-incremental-pattern-search-backward
12752       history-incremental-pattern-search-forward
12753              These widgets behave similarly to the corresponding widgets with
12754              no -pattern, but the search string typed by the user is  treated
12755              as a pattern, respecting the current settings of the various op‐
12756              tions affecting pattern matching.  See  FILENAME  GENERATION  in
12757              zshexpn(1)  for  a description of patterns.  If no numeric argu‐
12758              ment was given lowercase letters in the search string may  match
12759              uppercase letters in the history.  The string may begin with `^'
12760              to anchor the search to the beginning of the line.
12761
12762              The prompt changes to indicate an invalid pattern; this may sim‐
12763              ply indicate the pattern is not yet complete.
12764
12765              Note  that  only non-overlapping matches are reported, so an ex‐
12766              pression with wildcards may return fewer matches on a line  than
12767              are visible by inspection.
12768
12769       history-search-backward (ESC-P ESC-p) (unbound) (unbound)
12770              Search  backward  in  the  history for a line beginning with the
12771              first word in the buffer.
12772
12773              If called from a function by the zle command with arguments, the
12774              first  argument  is  taken  as  the  string for which to search,
12775              rather than the first word in the buffer.
12776
12777       vi-history-search-backward (unbound) (/) (unbound)
12778              Search backward in the history  for  a  specified  string.   The
12779              string  may begin with `^' to anchor the search to the beginning
12780              of the line.
12781
12782              A restricted set  of  editing  functions  is  available  in  the
12783              mini-buffer.   An  interrupt signal, as defined by the stty set‐
12784              ting,  will stop the search.  The  functions  available  in  the
12785              mini-buffer  are:  accept-line,  backward-delete-char,  vi-back‐
12786              ward-delete-char,   backward-kill-word,   vi-backward-kill-word,
12787              clear-screen, redisplay, quoted-insert and vi-quoted-insert.
12788
12789              vi-cmd-mode  is treated the same as accept-line, and magic-space
12790              is treated as a space.  Any other character that is not bound to
12791              self-insert  or  self-insert-unmeta will beep and be ignored. If
12792              the function is called from vi command mode, the bindings of the
12793              current insert mode will be used.
12794
12795              If called from a function by the zle command with arguments, the
12796              first argument is taken as  the  string  for  which  to  search,
12797              rather than the first word in the buffer.
12798
12799       history-search-forward (ESC-N ESC-n) (unbound) (unbound)
12800              Search  forward  in  the  history  for a line beginning with the
12801              first word in the buffer.
12802
12803              If called from a function by the zle command with arguments, the
12804              first  argument  is  taken  as  the  string for which to search,
12805              rather than the first word in the buffer.
12806
12807       vi-history-search-forward (unbound) (?) (unbound)
12808              Search forward in the  history  for  a  specified  string.   The
12809              string  may begin with `^' to anchor the search to the beginning
12810              of the line. The functions available in the mini-buffer are  the
12811              same  as  for  vi-history-search-backward.  Argument handling is
12812              also the same as for that command.
12813
12814       infer-next-history (^X^N) (unbound) (unbound)
12815              Search in the history list for a line matching the  current  one
12816              and fetch the event following it.
12817
12818       insert-last-word (ESC-_ ESC-.) (unbound) (unbound)
12819              Insert the last word from the previous history event at the cur‐
12820              sor position.  If a positive numeric argument is  given,  insert
12821              that  word  from  the end of the previous history event.  If the
12822              argument is zero or negative insert  that  word  from  the  left
12823              (zero  inserts  the previous command word).  Repeating this com‐
12824              mand replaces the word just inserted with the last word from the
12825              history  event prior to the one just used; numeric arguments can
12826              be used in the same way to pick a word from that event.
12827
12828              When called from a shell function invoked  from  a  user-defined
12829              widget,  the command can take one to three arguments.  The first
12830              argument specifies a history offset which applies to  successive
12831              calls  to  this  widget:  if  it is -1, the default behaviour is
12832              used, while if it is 1,  successive  calls  will  move  forwards
12833              through  the  history.  The value 0 can be used to indicate that
12834              the history line examined by the previous execution of the  com‐
12835              mand  will  be reexamined.  Note that negative numbers should be
12836              preceded by a `--' argument to avoid  confusing  them  with  op‐
12837              tions.
12838
12839              If two arguments are given, the second specifies the word on the
12840              command line in normal array index notation (as a  more  natural
12841              alternative  to  the  numeric  argument).   Hence 1 is the first
12842              word, and -1 (the default) is the last word.
12843
12844              If a third argument is given, its value is ignored,  but  it  is
12845              used  to signify that the history offset is relative to the cur‐
12846              rent history line, rather than the one remembered after the pre‐
12847              vious invocations of insert-last-word.
12848
12849              For example, the default behaviour of the command corresponds to
12850
12851                     zle insert-last-word -- -1 -1
12852
12853              while the command
12854
12855                     zle insert-last-word -- -1 1 -
12856
12857              always  copies the first word of the line in the history immedi‐
12858              ately before the line being edited.  This has  the  side  effect
12859              that  later  invocations  of the widget will be relative to that
12860              line.
12861
12862       vi-repeat-search (unbound) (n) (unbound)
12863              Repeat the last vi history search.
12864
12865       vi-rev-repeat-search (unbound) (N) (unbound)
12866              Repeat the last vi history search, but in reverse.
12867
12868       up-line-or-history (^P ESC-[A) (k) (ESC-[A)
12869              Move up a line in the buffer, or if already  at  the  top  line,
12870              move to the previous event in the history list.
12871
12872       vi-up-line-or-history (unbound) (-) (unbound)
12873              Move  up  a  line  in the buffer, or if already at the top line,
12874              move to the previous event in the history list.   Then  move  to
12875              the first non-blank character on the line.
12876
12877       up-line-or-search
12878              Move  up  a  line  in the buffer, or if already at the top line,
12879              search backward in the history for a  line  beginning  with  the
12880              first word in the buffer.
12881
12882              If called from a function by the zle command with arguments, the
12883              first argument is taken as  the  string  for  which  to  search,
12884              rather than the first word in the buffer.
12885
12886       up-history (unbound) (^P) (unbound)
12887              Move to the previous event in the history list.
12888
12889       history-beginning-search-forward
12890              Search forward in the history for a line beginning with the cur‐
12891              rent line up to the cursor.  This leaves the cursor in its orig‐
12892              inal position.
12893
12894       set-local-history
12895              By  default,  history movement commands visit the imported lines
12896              as well as the local lines. This widget lets you toggle this  on
12897              and  off, or set it with the numeric argument. Zero for both lo‐
12898              cal and imported lines and nonzero for only local lines.
12899
12900   Modifying Text
12901       vi-add-eol (unbound) (A) (unbound)
12902              Move to the end of the line and enter insert mode.
12903
12904       vi-add-next (unbound) (a) (unbound)
12905              Enter insert mode after the  current  cursor  position,  without
12906              changing lines.
12907
12908       backward-delete-char (^H ^?) (unbound) (unbound)
12909              Delete the character behind the cursor.
12910
12911       vi-backward-delete-char (unbound) (X) (^H)
12912              Delete  the character behind the cursor, without changing lines.
12913              If in insert mode, this won't delete past the point where insert
12914              mode was last entered.
12915
12916       backward-delete-word
12917              Delete the word behind the cursor.
12918
12919       backward-kill-line
12920              Kill from the beginning of the line to the cursor position.
12921
12922       backward-kill-word (^W ESC-^H ESC-^?) (unbound) (unbound)
12923              Kill the word behind the cursor.
12924
12925       vi-backward-kill-word (unbound) (unbound) (^W)
12926              Kill  the  word  behind the cursor, without going past the point
12927              where insert mode was last entered.
12928
12929       capitalize-word (ESC-C ESC-c) (unbound) (unbound)
12930              Capitalize the current word and move past it.
12931
12932       vi-change (unbound) (c) (unbound)
12933              Read a movement command from the keyboard,  and  kill  from  the
12934              cursor position to the endpoint of the movement.  Then enter in‐
12935              sert mode.  If the command  is  vi-change,  change  the  current
12936              line.
12937
12938              For  compatibility with vi, if the command is vi-forward-word or
12939              vi-forward-blank-word, the whitespace after the word is not  in‐
12940              cluded.  If  you  prefer  the more consistent behaviour with the
12941              whitespace included use the following key binding:
12942
12943                     bindkey -a -s cw dwi
12944
12945       vi-change-eol (unbound) (C) (unbound)
12946              Kill to the end of the line and enter insert mode.
12947
12948       vi-change-whole-line (unbound) (S) (unbound)
12949              Kill the current line and enter insert mode.
12950
12951       copy-region-as-kill (ESC-W ESC-w) (unbound) (unbound)
12952              Copy the area from the cursor to the mark to the kill buffer.
12953
12954              If called from a ZLE widget function in the form  `zle  copy-re‐
12955              gion-as-kill  string'  then  string will be taken as the text to
12956              copy to the kill buffer.  The cursor, the mark and the  text  on
12957              the command line are not used in this case.
12958
12959       copy-prev-word (ESC-^_) (unbound) (unbound)
12960              Duplicate the word to the left of the cursor.
12961
12962       copy-prev-shell-word
12963              Like  copy-prev-word, but the word is found by using shell pars‐
12964              ing, whereas copy-prev-word looks for blanks. This makes a  dif‐
12965              ference when the word is quoted and contains spaces.
12966
12967       vi-delete (unbound) (d) (unbound)
12968              Read  a  movement  command  from the keyboard, and kill from the
12969              cursor position to the endpoint of the movement.  If the command
12970              is vi-delete, kill the current line.
12971
12972       delete-char
12973              Delete the character under the cursor.
12974
12975       vi-delete-char (unbound) (x) (unbound)
12976              Delete  the  character  under the cursor, without going past the
12977              end of the line.
12978
12979       delete-word
12980              Delete the current word.
12981
12982       down-case-word (ESC-L ESC-l) (unbound) (unbound)
12983              Convert the current word to all lowercase and move past it.
12984
12985       vi-down-case (unbound) (gu) (unbound)
12986              Read a movement command from the keyboard, and convert all char‐
12987              acters  from the cursor position to the endpoint of the movement
12988              to lowercase.  If the movement command is vi-down-case, swap the
12989              case of all characters on the current line.
12990
12991       kill-word (ESC-D ESC-d) (unbound) (unbound)
12992              Kill the current word.
12993
12994       gosmacs-transpose-chars
12995              Exchange the two characters behind the cursor.
12996
12997       vi-indent (unbound) (>) (unbound)
12998              Indent a number of lines.
12999
13000       vi-insert (unbound) (i) (unbound)
13001              Enter insert mode.
13002
13003       vi-insert-bol (unbound) (I) (unbound)
13004              Move  to the first non-blank character on the line and enter in‐
13005              sert mode.
13006
13007       vi-join (^X^J) (J) (unbound)
13008              Join the current line with the next one.
13009
13010       kill-line (^K) (unbound) (unbound)
13011              Kill from the cursor to the end of the line.  If already on  the
13012              end of the line, kill the newline character.
13013
13014       vi-kill-line (unbound) (unbound) (^U)
13015              Kill  from  the cursor back to wherever insert mode was last en‐
13016              tered.
13017
13018       vi-kill-eol (unbound) (D) (unbound)
13019              Kill from the cursor to the end of the line.
13020
13021       kill-region
13022              Kill from the cursor to the mark.
13023
13024       kill-buffer (^X^K) (unbound) (unbound)
13025              Kill the entire buffer.
13026
13027       kill-whole-line (^U) (unbound) (unbound)
13028              Kill the current line.
13029
13030       vi-match-bracket (^X^B) (%) (unbound)
13031              Move to the bracket character (one of {}, () or []) that matches
13032              the  one  under  the  cursor.  If the cursor is not on a bracket
13033              character, move forward without going past the end of  the  line
13034              to find one, and then go to the matching bracket.
13035
13036       vi-open-line-above (unbound) (O) (unbound)
13037              Open a line above the cursor and enter insert mode.
13038
13039       vi-open-line-below (unbound) (o) (unbound)
13040              Open a line below the cursor and enter insert mode.
13041
13042       vi-oper-swap-case (unbound) (g~) (unbound)
13043              Read  a movement command from the keyboard, and swap the case of
13044              all characters from the cursor position to the endpoint  of  the
13045              movement.   If  the  movement command is vi-oper-swap-case, swap
13046              the case of all characters on the current line.
13047
13048       overwrite-mode (^X^O) (unbound) (unbound)
13049              Toggle between overwrite mode and insert mode.
13050
13051       vi-put-before (unbound) (P) (unbound)
13052              Insert the contents of the kill buffer before  the  cursor.   If
13053              the  kill  buffer  contains  a  sequence of lines (as opposed to
13054              characters), paste it above the current line.
13055
13056       vi-put-after (unbound) (p) (unbound)
13057              Insert the contents of the kill buffer after the cursor.  If the
13058              kill  buffer contains a sequence of lines (as opposed to charac‐
13059              ters), paste it below the current line.
13060
13061       put-replace-selection (unbound) (unbound) (unbound)
13062              Replace the contents of the current region or selection with the
13063              contents  of  the kill buffer. If the kill buffer contains a se‐
13064              quence of lines (as opposed to  characters),  the  current  line
13065              will be split by the pasted lines.
13066
13067       quoted-insert (^V) (unbound) (unbound)
13068              Insert  the  next character typed into the buffer literally.  An
13069              interrupt character will not be inserted.
13070
13071       vi-quoted-insert (unbound) (unbound) (^Q ^V)
13072              Display a `^' at the cursor position, and insert the next  char‐
13073              acter  typed  into the buffer literally.  An interrupt character
13074              will not be inserted.
13075
13076       quote-line (ESC-') (unbound) (unbound)
13077              Quote the current line; that is, put a `'' character at the  be‐
13078              ginning and the end, and convert all `'' characters to `'\'''.
13079
13080       quote-region (ESC-") (unbound) (unbound)
13081              Quote the region from the cursor to the mark.
13082
13083       vi-replace (unbound) (R) (unbound)
13084              Enter overwrite mode.
13085
13086       vi-repeat-change (unbound) (.) (unbound)
13087              Repeat  the last vi mode text modification.  If a count was used
13088              with the modification, it is remembered.  If a count is given to
13089              this  command,  it overrides the remembered count, and is remem‐
13090              bered for future uses of this command.  The cut buffer  specifi‐
13091              cation is similarly remembered.
13092
13093       vi-replace-chars (unbound) (r) (unbound)
13094              Replace  the  character  under  the cursor with a character read
13095              from the keyboard.
13096
13097       self-insert (printable characters) (unbound) (printable characters  and
13098       some control characters)
13099              Insert a character into the buffer at the cursor position.
13100
13101       self-insert-unmeta (ESC-^I ESC-^J ESC-^M) (unbound) (unbound)
13102              Insert  a character into the buffer after stripping the meta bit
13103              and converting ^M to ^J.
13104
13105       vi-substitute (unbound) (s) (unbound)
13106              Substitute the next character(s).
13107
13108       vi-swap-case (unbound) (~) (unbound)
13109              Swap the case of the character under the cursor  and  move  past
13110              it.
13111
13112       transpose-chars (^T) (unbound) (unbound)
13113              Exchange  the two characters to the left of the cursor if at end
13114              of line, else exchange the character under the cursor  with  the
13115              character to the left.
13116
13117       transpose-words (ESC-T ESC-t) (unbound) (unbound)
13118              Exchange the current word with the one before it.
13119
13120              With  a positive numeric argument N, the word around the cursor,
13121              or following it if the cursor is between  words,  is  transposed
13122              with the preceding N words.  The cursor is put at the end of the
13123              resulting group of words.
13124
13125              With a negative numeric argument -N, the effect is the  same  as
13126              using  a positive argument N except that the original cursor po‐
13127              sition is retained, regardless of how the words are rearranged.
13128
13129       vi-unindent (unbound) (<) (unbound)
13130              Unindent a number of lines.
13131
13132       vi-up-case (unbound) (gU) (unbound)
13133              Read a movement command from the keyboard, and convert all char‐
13134              acters  from the cursor position to the endpoint of the movement
13135              to lowercase.  If the movement command is vi-up-case,  swap  the
13136              case of all characters on the current line.
13137
13138       up-case-word (ESC-U ESC-u) (unbound) (unbound)
13139              Convert the current word to all caps and move past it.
13140
13141       yank (^Y) (unbound) (unbound)
13142              Insert the contents of the kill buffer at the cursor position.
13143
13144       yank-pop (ESC-y) (unbound) (unbound)
13145              Remove  the  text just yanked, rotate the kill-ring (the history
13146              of previously killed text) and yank the  new  top.   Only  works
13147              following yank, vi-put-before, vi-put-after or yank-pop.
13148
13149       vi-yank (unbound) (y) (unbound)
13150              Read  a  movement command from the keyboard, and copy the region
13151              from the cursor position to the endpoint of  the  movement  into
13152              the  kill  buffer.   If the command is vi-yank, copy the current
13153              line.
13154
13155       vi-yank-whole-line (unbound) (Y) (unbound)
13156              Copy the current line into the kill buffer.
13157
13158       vi-yank-eol
13159              Copy the region from the cursor position to the end of the  line
13160              into the kill buffer.  Arguably, this is what Y should do in vi,
13161              but it isn't what it actually does.
13162
13163   Arguments
13164       digit-argument (ESC-0..ESC-9) (1-9) (unbound)
13165              Start a new numeric argument, or add to the  current  one.   See
13166              also vi-digit-or-beginning-of-line.  This only works if bound to
13167              a key sequence ending in a decimal digit.
13168
13169              Inside a widget function, a call to  this  function  treats  the
13170              last  key  of  the  key  sequence which called the widget as the
13171              digit.
13172
13173       neg-argument (ESC--) (unbound) (unbound)
13174              Changes the sign of the following argument.
13175
13176       universal-argument
13177              Multiply the argument of the next command by 4.   Alternatively,
13178              if  this  command  is  followed by an integer (positive or nega‐
13179              tive), use that as the argument for the next command.  Thus dig‐
13180              its cannot be repeated using this command.  For example, if this
13181              command occurs twice, followed immediately by forward-char, move
13182              forward  sixteen  spaces;  if instead it is followed by -2, then
13183              forward-char, move backward two spaces.
13184
13185              Inside a widget function, if passed an argument, i.e. `zle  uni‐
13186              versal-argument  num',  the numeric argument will be set to num;
13187              this is equivalent to `NUMERIC=num'.
13188
13189       argument-base
13190              Use the existing numeric argument as a numeric base, which  must
13191              be  in the range 2 to 36 inclusive.  Subsequent use of digit-ar‐
13192              gument and universal-argument will input a new numeric  argument
13193              in  the  given  base.  The usual hexadecimal convention is used:
13194              the letter a or A corresponds to 10, and so  on.   Arguments  in
13195              bases requiring digits from 10 upwards are more conveniently in‐
13196              put with universal-argument, since ESC-a etc.  are  not  usually
13197              bound to digit-argument.
13198
13199              The  function  can  be  used  with  a  command argument inside a
13200              user-defined widget.  The following code sets the base to 16 and
13201              lets  the  user  input a hexadecimal argument until a key out of
13202              the digit range is typed:
13203
13204                     zle argument-base 16
13205                     zle universal-argument
13206
13207   Completion
13208       accept-and-menu-complete
13209              In a menu completion, insert the  current  completion  into  the
13210              buffer, and advance to the next possible completion.
13211
13212       complete-word
13213              Attempt completion on the current word.
13214
13215       delete-char-or-list (^D) (unbound) (unbound)
13216              Delete  the character under the cursor.  If the cursor is at the
13217              end of the line, list possible completions for the current word.
13218
13219       expand-cmd-path
13220              Expand the current command to its full pathname.
13221
13222       expand-or-complete (TAB) (unbound) (TAB)
13223              Attempt shell expansion on the current word.  If that fails, at‐
13224              tempt completion.
13225
13226       expand-or-complete-prefix
13227              Attempt shell expansion on the current word up to cursor.
13228
13229       expand-history (ESC-space ESC-!) (unbound) (unbound)
13230              Perform history expansion on the edit buffer.
13231
13232       expand-word (^X*) (unbound) (unbound)
13233              Attempt shell expansion on the current word.
13234
13235       list-choices (ESC-^D) (^D =) (^D)
13236              List possible completions for the current word.
13237
13238       list-expand (^Xg ^XG) (^G) (^G)
13239              List the expansion of the current word.
13240
13241       magic-space
13242              Perform  history  expansion  and insert a space into the buffer.
13243              This is intended to be bound to space.
13244
13245       menu-complete
13246              Like complete-word, except that menu completion  is  used.   See
13247              the MENU_COMPLETE option.
13248
13249       menu-expand-or-complete
13250              Like expand-or-complete, except that menu completion is used.
13251
13252       reverse-menu-complete
13253              Perform  menu  completion,  like menu-complete, except that if a
13254              menu completion is already in progress,  move  to  the  previous
13255              completion rather than the next.
13256
13257       end-of-list
13258              When  a  previous  completion displayed a list below the prompt,
13259              this widget can be used to move the prompt below the list.
13260
13261   Miscellaneous
13262       accept-and-hold (ESC-A ESC-a) (unbound) (unbound)
13263              Push the contents of the buffer on the buffer stack and  execute
13264              it.
13265
13266       accept-and-infer-next-history
13267              Execute  the  contents  of  the buffer.  Then search the history
13268              list for a line matching the current one and push the event fol‐
13269              lowing onto the buffer stack.
13270
13271       accept-line (^J ^M) (^J ^M) (^J ^M)
13272              Finish  editing  the buffer.  Normally this causes the buffer to
13273              be executed as a shell command.
13274
13275       accept-line-and-down-history (^O) (unbound) (unbound)
13276              Execute the current line, and push the next history event on the
13277              buffer stack.
13278
13279       auto-suffix-remove
13280              If  the  previous  action added a suffix (space, slash, etc.) to
13281              the word on the command line, remove it.  Otherwise do  nothing.
13282              Removing  the suffix ends any active menu completion or menu se‐
13283              lection.
13284
13285              This widget is intended to be called from  user-defined  widgets
13286              to enforce a desired suffix-removal behavior.
13287
13288       auto-suffix-retain
13289              If  the  previous  action added a suffix (space, slash, etc.) to
13290              the word on the command line, force it to be preserved.   Other‐
13291              wise do nothing.  Retaining the suffix ends any active menu com‐
13292              pletion or menu selection.
13293
13294              This widget is intended to be called from  user-defined  widgets
13295              to enforce a desired suffix-preservation behavior.
13296
13297       beep   Beep, unless the BEEP option is unset.
13298
13299       bracketed-paste
13300              This  widget is invoked when text is pasted to the terminal emu‐
13301              lator. It is not intended to be bound to actual keys but instead
13302              to  the special sequence generated by the terminal emulator when
13303              text is pasted.
13304
13305              When invoked interactively, the pasted text is inserted  to  the
13306              buffer  and  placed  in the cutbuffer.  If a numeric argument is
13307              given, shell quoting will be applied to the pasted  text  before
13308              it is inserted.
13309
13310              When  a  named  buffer is specified with vi-set-buffer ("x), the
13311              pasted text is stored in that named buffer but not inserted.
13312
13313              When called from a widget function  as  `bracketed-paste  name`,
13314              the  pasted  text  is assigned to the variable name and no other
13315              processing is done.
13316
13317              See also the zle_bracketed_paste parameter.
13318
13319       vi-cmd-mode (^X^V) (unbound) (^[)
13320              Enter command mode; that is, select the  `vicmd'  keymap.   Yes,
13321              this is bound by default in emacs mode.
13322
13323       vi-caps-lock-panic
13324              Hang  until  any lowercase key is pressed.  This is for vi users
13325              without the mental capacity to keep track of their caps lock key
13326              (like the author).
13327
13328       clear-screen (^L ESC-^L) (^L) (^L)
13329              Clear the screen and redraw the prompt.
13330
13331       deactivate-region
13332              Make the current region inactive. This disables vim-style visual
13333              selection mode if it is active.
13334
13335       describe-key-briefly
13336              Reads a key sequence, then prints the function bound to that se‐
13337              quence.
13338
13339       exchange-point-and-mark (^X^X) (unbound) (unbound)
13340              Exchange  the  cursor  position (point) with the position of the
13341              mark.  Unless a negative numeric argument is given,  the  region
13342              between  point  and  mark  is  activated so that it can be high‐
13343              lighted.  If a zero numeric argument is given, the region is ac‐
13344              tivated but point and mark are not swapped.
13345
13346       execute-named-cmd (ESC-x) (:) (unbound)
13347              Read  the  name  of  an editor command and execute it.  Aliasing
13348              this widget with `zle -A' or replacing it with `zle -N'  has  no
13349              effect   when   interpreting   key   bindings,   but  `zle  exe‐
13350              cute-named-cmd' will invoke such an alias or replacement.
13351
13352              A restricted set  of  editing  functions  is  available  in  the
13353              mini-buffer.   Keys are looked up in the special command keymap,
13354              and if not found there in the main keymap.  An interrupt signal,
13355              as  defined  by the stty setting, will abort the function.  Note
13356              that the following always perform the same task within the  exe‐
13357              cuted-named-cmd  environment  and cannot be replaced by user de‐
13358              fined widgets, nor can the set of functions  be  extended.   The
13359              allowed    functions    are:    backward-delete-char,   vi-back‐
13360              ward-delete-char,   clear-screen,   redisplay,    quoted-insert,
13361              vi-quoted-insert,   backward-kill-word,   vi-backward-kill-word,
13362              kill-whole-line, vi-kill-line, backward-kill-line, list-choices,
13363              delete-char-or-list,  complete-word, accept-line, expand-or-com‐
13364              plete and expand-or-complete-prefix.
13365
13366              kill-region kills the last word, and vi-cmd-mode is treated  the
13367              same as accept-line.  The space and tab characters, if not bound
13368              to one of these functions, will complete the name and then  list
13369              the  possibilities  if  the  AUTO_LIST option is set.  Any other
13370              character that is not bound to self-insert or self-insert-unmeta
13371              will  beep  and  be ignored.  The bindings of the current insert
13372              mode will be used.
13373
13374              Currently this command may not be redefined or called by name.
13375
13376       execute-last-named-cmd (ESC-z) (unbound) (unbound)
13377              Redo the last function executed with execute-named-cmd.
13378
13379              Like execute-named-cmd, this command may not be  redefined,  but
13380              it may be called by name.
13381
13382       get-line (ESC-G ESC-g) (unbound) (unbound)
13383              Pop  the top line off the buffer stack and insert it at the cur‐
13384              sor position.
13385
13386       pound-insert (unbound) (#) (unbound)
13387              If there is no # character at the beginning of the  buffer,  add
13388              one  to the beginning of each line.  If there is one, remove a #
13389              from each line that has one.  In either case, accept the current
13390              line.   The  INTERACTIVE_COMMENTS option must be set for this to
13391              have any usefulness.
13392
13393       vi-pound-insert
13394              If there is no # character at the beginning of the current line,
13395              add  one.  If there is one, remove it.  The INTERACTIVE_COMMENTS
13396              option must be set for this to have any usefulness.
13397
13398       push-input
13399              Push the entire current  multiline  construct  onto  the  buffer
13400              stack  and return to the top-level (PS1) prompt.  If the current
13401              parser construct is only a single line,  this  is  exactly  like
13402              push-line.   Next  time  the  editor starts up or is popped with
13403              get-line, the construct will be popped off the top of the buffer
13404              stack and loaded into the editing buffer.
13405
13406       push-line (^Q ESC-Q ESC-q) (unbound) (unbound)
13407              Push the current buffer onto the buffer stack and clear the buf‐
13408              fer.  Next time the editor starts up, the buffer will be  popped
13409              off the top of the buffer stack and loaded into the editing buf‐
13410              fer.
13411
13412       push-line-or-edit
13413              At the top-level (PS1) prompt, equivalent to  push-line.   At  a
13414              secondary  (PS2)  prompt, move the entire current multiline con‐
13415              struct into the editor buffer.   The  latter  is  equivalent  to
13416              push-input followed by get-line.
13417
13418       read-command
13419              Only  useful  from  a  user-defined widget.  A keystroke is read
13420              just as in normal operation, but instead of  the  command  being
13421              executed  the  name  of  the  command  that would be executed is
13422              stored in the shell parameter REPLY.  This can be  used  as  the
13423              argument  of  a  future zle command.  If the key sequence is not
13424              bound, status 1 is returned; typically, however, REPLY is set to
13425              undefined-key to indicate a useless key sequence.
13426
13427       recursive-edit
13428              Only  useful  from  a user-defined widget.  At this point in the
13429              function, the editor regains control until one of  the  standard
13430              widgets which would normally cause zle to exit (typically an ac‐
13431              cept-line caused by hitting the return key)  is  executed.   In‐
13432              stead,  control  returns to the user-defined widget.  The status
13433              returned is non-zero if the return was caused by an  error,  but
13434              the  function  still  continues executing and hence may tidy up.
13435              This makes it safe for the user-defined widget to alter the com‐
13436              mand line or key bindings temporarily.
13437
13438              The following widget, caps-lock, serves as an example.
13439
13440                     self-insert-ucase() {
13441                       LBUFFER+=${(U)KEYS[-1]}
13442                     }
13443
13444                     integer stat
13445
13446                     zle -N self-insert self-insert-ucase
13447                     zle -A caps-lock save-caps-lock
13448                     zle -A accept-line caps-lock
13449
13450                     zle recursive-edit
13451                     stat=$?
13452
13453                     zle -A .self-insert self-insert
13454                     zle -A save-caps-lock caps-lock
13455                     zle -D save-caps-lock
13456
13457                     (( stat )) && zle send-break
13458
13459                     return $stat
13460
13461              This  causes  typed letters to be inserted capitalised until ei‐
13462              ther accept-line (i.e. typically the return key) is typed or the
13463              caps-lock  widget is invoked again; the later is handled by sav‐
13464              ing the old definition of caps-lock as save-caps-lock  and  then
13465              rebinding it to invoke accept-line.  Note that an error from the
13466              recursive edit is detected as a non-zero return status and prop‐
13467              agated by using the send-break widget.
13468
13469       redisplay (unbound) (^R) (^R)
13470              Redisplays the edit buffer.
13471
13472       reset-prompt (unbound) (unbound) (unbound)
13473              Force the prompts on both the left and right of the screen to be
13474              re-expanded, then redisplay  the  edit  buffer.   This  reflects
13475              changes  both  to the prompt variables themselves and changes in
13476              the expansion of the values (for example, changes in time or di‐
13477              rectory, or changes to the value of variables referred to by the
13478              prompt).
13479
13480              Otherwise, the prompt is only expanded each time zle starts, and
13481              when  the  display  has  been interrupted by output from another
13482              part of the shell (such as a job notification) which causes  the
13483              command line to be reprinted.
13484
13485              reset-prompt doesn't alter the special parameter LASTWIDGET.
13486
13487       send-break (^G ESC-^G) (unbound) (unbound)
13488              Abort  the  current editor function, e.g. execute-named-command,
13489              or the editor itself, e.g. if you are in vared. Otherwise  abort
13490              the  parsing  of the current line; in this case the aborted line
13491              is available in the shell variable ZLE_LINE_ABORTED.  If the ed‐
13492              itor    is    aborted    from   within   vared,   the   variable
13493              ZLE_VARED_ABORTED is set.
13494
13495       run-help (ESC-H ESC-h) (unbound) (unbound)
13496              Push the buffer onto the buffer stack, and execute  the  command
13497              `run-help  cmd',  where cmd is the current command.  run-help is
13498              normally aliased to man.
13499
13500       vi-set-buffer (unbound) (") (unbound)
13501              Specify a buffer to be used in the following command.  There are
13502              37  buffers  that can be specified: the 26 `named' buffers "a to
13503              "z, the `yank' buffer "0, the nine `queued' buffers "1 to "9 and
13504              the `black hole' buffer "_.  The named buffers can also be spec‐
13505              ified as "A to "Z.
13506
13507              When a buffer is specified for a cut, change  or  yank  command,
13508              the  text concerned replaces the previous contents of the speci‐
13509              fied buffer. If a named buffer is specified using a capital, the
13510              newly  cut text is appended to the buffer instead of overwriting
13511              it. When using the "_ buffer, nothing happens. This can be  use‐
13512              ful for deleting text without affecting any buffers.
13513
13514              If  no  buffer  is  specified for a cut or change command, "1 is
13515              used, and the contents of "1 to "8 are each  shifted  along  one
13516              buffer;  the  contents  of "9 is lost. If no buffer is specified
13517              for a yank command, "0 is used. Finally, a paste command without
13518              a specified buffer will paste the text from the most recent com‐
13519              mand regardless of any buffer that might  have  been  used  with
13520              that command.
13521
13522              When  called from a widget function by the zle command, the buf‐
13523              fer can optionally be specified with an argument. For example,
13524
13525                     zle vi-set-buffer A
13526
13527       vi-set-mark (unbound) (m) (unbound)
13528              Set the specified mark at the cursor position.
13529
13530       set-mark-command (^@) (unbound) (unbound)
13531              Set the mark at the cursor position.  If called with a  negative
13532              numeric  argument, do not set the mark but deactivate the region
13533              so that it is no longer highlighted  (it  is  still  usable  for
13534              other purposes).  Otherwise the region is marked as active.
13535
13536       spell-word (ESC-$ ESC-S ESC-s) (unbound) (unbound)
13537              Attempt spelling correction on the current word.
13538
13539       split-undo
13540              Breaks  the undo sequence at the current change.  This is useful
13541              in vi mode as changes made in insert mode are coalesced  on  en‐
13542              tering  command  mode.   Similarly, undo will normally revert as
13543              one all the changes made by a user-defined widget.
13544
13545       undefined-key
13546              This command is executed when a key sequence that is  not  bound
13547              to any command is typed.  By default it beeps.
13548
13549       undo (^_ ^Xu ^X^U) (u) (unbound)
13550              Incrementally undo the last text modification.  When called from
13551              a user-defined widget, takes an optional argument  indicating  a
13552              previous   state   of  the  undo  history  as  returned  by  the
13553              UNDO_CHANGE_NO variable; modifications  are  undone  until  that
13554              state   is   reached,  subject  to  any  limit  imposed  by  the
13555              UNDO_LIMIT_NO variable.
13556
13557              Note that when invoked from vi  command  mode,  the  full  prior
13558              change  made in insert mode is reverted, the changes having been
13559              merged when command mode was selected.
13560
13561       redo (unbound) (^R) (unbound)
13562              Incrementally redo undone text modifications.
13563
13564       vi-undo-change (unbound) (unbound) (unbound)
13565              Undo the last text modification.  If repeated, redo the  modifi‐
13566              cation.
13567
13568       visual-mode (unbound) (v) (unbound)
13569              Toggle vim-style visual selection mode. If line-wise visual mode
13570              is currently enabled then it is changed to being character-wise.
13571              If used following an operator, it forces the subsequent movement
13572              command to be treated as a character-wise movement.
13573
13574       visual-line-mode (unbound) (V) (unbound)
13575              Toggle vim-style line-wise visual  selection  mode.  If  charac‐
13576              ter-wise  visual mode is currently enabled then it is changed to
13577              being line-wise. If used following an operator,  it  forces  the
13578              subsequent  movement  command to be treated as a line-wise move‐
13579              ment.
13580
13581       what-cursor-position (^X=) (ga) (unbound)
13582              Print the character under the cursor, its code as an octal, dec‐
13583              imal  and hexadecimal number, the current cursor position within
13584              the buffer and the column of the cursor in the current line.
13585
13586       where-is
13587              Read the name of an editor command and print the listing of  key
13588              sequences  that  invoke the specified command.  A restricted set
13589              of editing functions is available in the mini-buffer.  Keys  are
13590              looked  up in the special command keymap, and if not found there
13591              in the main keymap.
13592
13593       which-command (ESC-?) (unbound) (unbound)
13594              Push the buffer onto the buffer stack, and execute  the  command
13595              `which-command   cmd'.   where   cmd  is  the  current  command.
13596              which-command is normally aliased to whence.
13597
13598       vi-digit-or-beginning-of-line (unbound) (0) (unbound)
13599              If the last command executed was a digit as part of an argument,
13600              continue the argument.  Otherwise, execute vi-beginning-of-line.
13601
13602   Text Objects
13603       Text  objects  are  commands that can be used to select a block of text
13604       according to some criteria. They are a feature of the vim  text  editor
13605       and  so are primarily intended for use with vi operators or from visual
13606       selection mode. However, they can also be used from vi-insert or  emacs
13607       mode. Key bindings listed below apply to the viopp and visual keymaps.
13608
13609       select-a-blank-word (aW)
13610              Select a word including adjacent blanks, where a word is defined
13611              as a series of non-blank characters. With  a  numeric  argument,
13612              multiple words will be selected.
13613
13614       select-a-shell-word (aa)
13615              Select  the  current  command argument applying the normal rules
13616              for quoting.
13617
13618       select-a-word (aw)
13619              Select a  word  including  adjacent  blanks,  using  the  normal
13620              vi-style  word  definition.  With  a  numeric argument, multiple
13621              words will be selected.
13622
13623       select-in-blank-word (iW)
13624              Select a word, where a word is defined as a series of  non-blank
13625              characters.  With a numeric argument, multiple words will be se‐
13626              lected.
13627
13628       select-in-shell-word (ia)
13629              Select the current command argument applying  the  normal  rules
13630              for quoting. If the argument begins and ends with matching quote
13631              characters, these are not included in the selection.
13632
13633       select-in-word (iw)
13634              Select a word, using the normal vi-style word definition. With a
13635              numeric argument, multiple words will be selected.
13636

CHARACTER HIGHLIGHTING

13638       The  line  editor has the ability to highlight characters or regions of
13639       the line that have a particular significance.  This  is  controlled  by
13640       the array parameter zle_highlight, if it has been set by the user.
13641
13642       If  the  parameter  contains  the single entry none all highlighting is
13643       turned off.  Note the parameter is still expected to be an array.
13644
13645       Otherwise each entry of the array should consist of a word indicating a
13646       context  for highlighting, then a colon, then a comma-separated list of
13647       the types of highlighting to apply in that context.
13648
13649       The contexts available for highlighting are the following:
13650
13651       default
13652              Any text within the command line not affected by any other high‐
13653              lighting.  Text outside the editable area of the command line is
13654              not affected.
13655
13656       isearch
13657              When one of the incremental history search  widgets  is  active,
13658              the  area  of  the  command line matched by the search string or
13659              pattern.
13660
13661       region The currently selected text. In emacs terminology, this  is  re‐
13662              ferred to as the region and is bounded by the cursor (point) and
13663              the mark. The region is only highlighted if it is active,  which
13664              is  the case after the mark is modified with set-mark-command or
13665              exchange-point-and-mark.  Note that whether or not the region is
13666              active  has  no effect on its use within emacs style widgets, it
13667              simply determines whether it is highlighted. In vi mode, the re‐
13668              gion corresponds to selected text in visual mode.
13669
13670       special
13671              Individual  characters that have no direct printable representa‐
13672              tion but are shown in a  special  manner  by  the  line  editor.
13673              These characters are described below.
13674
13675       suffix This  context  is  used  in  completion  for characters that are
13676              marked as suffixes that will be removed if the  completion  ends
13677              at  that point, the most obvious example being a slash (/) after
13678              a directory name.  Note that suffix removal is configurable; the
13679              circumstances  under which the suffix will be removed may differ
13680              for different completions.
13681
13682       paste  Following a command to paste text, the characters that were  in‐
13683              serted.
13684
13685       When  region_highlight  is  set, the contexts that describe a region --
13686       isearch, region, suffix, and paste  --  are  applied  first,  then  re‐
13687       gion_highlight  is  applied,  then the remaining zle_highlight contexts
13688       are applied.  If a particular character is affected by multiple  speci‐
13689       fications, the last specification wins.
13690
13691       zle_highlight  may contain additional fields for controlling how termi‐
13692       nal sequences to change colours are output.  Each of the  following  is
13693       followed  by a colon and a string in the same form as for key bindings.
13694       This will not be necessary for the vast majority of  terminals  as  the
13695       defaults shown in parentheses are widely used.
13696
13697       fg_start_code (\e[3)
13698              The  start  of  the  escape  sequence for the foreground colour.
13699              This is followed by one to three ASCII digits  representing  the
13700              colour.   Only  used  for palette colors, i.e. not 24-bit colors
13701              specified via a color triplet.
13702
13703       fg_default_code (9)
13704              The number to use instead of the colour  to  reset  the  default
13705              foreground colour.
13706
13707       fg_end_code (m)
13708              The end of the escape sequence for the foreground colour.
13709
13710       bg_start_code (\e[4)
13711              The start of the escape sequence for the background colour.  See
13712              fg_start_code above.
13713
13714       bg_default_code (9)
13715              The number to use instead of the colour  to  reset  the  default
13716              background colour.
13717
13718       bg_end_code (m)
13719              The end of the escape sequence for the background colour.
13720
13721       The  available  types of highlighting are the following.  Note that not
13722       all types of highlighting are available on all terminals:
13723
13724       none   No highlighting is applied to the given context.  It is not use‐
13725              ful  for  this to appear with other types of highlighting; it is
13726              used to override a default.
13727
13728       fg=colour
13729              The foreground colour should be set to colour, a  decimal  inte‐
13730              ger,  the name of one of the eight most widely-supported colours
13731              or as a `#' followed by an RGB triplet in hexadecimal format.
13732
13733              Not all terminals support this and, of those that  do,  not  all
13734              provide  facilities  to  test the support, hence the user should
13735              decide based on the terminal type.  Most terminals  support  the
13736              colours  black,  red,  green,  yellow,  blue,  magenta, cyan and
13737              white, which can be set by name.  In addition.  default  may  be
13738              used to set the terminal's default foreground colour.  Abbrevia‐
13739              tions are allowed; b or bl selects black.   Some  terminals  may
13740              generate  additional  colours  if  the  bold  attribute  is also
13741              present.
13742
13743              On recent terminals and on systems with an  up-to-date  terminal
13744              database  the  number  of colours supported may be tested by the
13745              command `echotc Co'; if this succeeds, it indicates a  limit  on
13746              the number of colours which will be enforced by the line editor.
13747              The number of colours is in any case limited to  256  (i.e.  the
13748              range 0 to 255).
13749
13750              Some  modern  terminal  emulators  have  support for 24-bit true
13751              colour (16 million colours). In this case, the hex triplet  for‐
13752              mat  can  be  used.  This consists of a `#' followed by either a
13753              three or six digit hexadecimal number describing the red,  green
13754              and blue components of the colour. Hex triplets can also be used
13755              with 88 and 256 colour terminals via  the  zsh/nearcolor  module
13756              (see zshmodules(1)).
13757
13758              Colour is also known as color.
13759
13760       bg=colour
13761              The background colour should be set to colour.  This works simi‐
13762              larly to the foreground colour, except  the  background  is  not
13763              usually affected by the bold attribute.
13764
13765       bold   The  characters  in  the given context are shown in a bold font.
13766              Not all terminals distinguish bold fonts.
13767
13768       standout
13769              The characters in the given context are shown in the  terminal's
13770              standout  mode.   The actual effect is specific to the terminal;
13771              on many terminals it is inverse video.  On some such  terminals,
13772              where  the  cursor  does not blink it appears with standout mode
13773              negated, making it less than clear where the cursor actually is.
13774              On such terminals one of the other effects may be preferable for
13775              highlighting the region and matched search string.
13776
13777       underline
13778              The characters in the given context are shown underlined.   Some
13779              terminals  show the foreground in a different colour instead; in
13780              this case whitespace will not be highlighted.
13781
13782       The characters described above as `special' are as follows.   The  for‐
13783       matting  described  here is used irrespective of whether the characters
13784       are highlighted:
13785
13786       ASCII control characters
13787              Control characters in the ASCII range are shown as `^'  followed
13788              by the base character.
13789
13790       Unprintable multibyte characters
13791              This  item applies to control characters not in the ASCII range,
13792              plus other characters as follows.  If the MULTIBYTE option is in
13793              effect, multibyte characters not in the ASCII character set that
13794              are reported as having zero width are treated as combining char‐
13795              acters  when the option COMBINING_CHARS is on.  If the option is
13796              off, or if a character appears where a  combining  character  is
13797              not valid, the character is treated as unprintable.
13798
13799              Unprintable multibyte characters are shown as a hexadecimal num‐
13800              ber between angle brackets.  The number is the code point of the
13801              character in the wide character set; this may or may not be Uni‐
13802              code, depending on the operating system.
13803
13804       Invalid multibyte characters
13805              If the MULTIBYTE option is in effect, any  sequence  of  one  or
13806              more  bytes  that does not form a valid character in the current
13807              character set is treated as a series of bytes each  shown  as  a
13808              special  character.   This  case can be distinguished from other
13809              unprintable characters as the bytes are represented as two hexa‐
13810              decimal digits between angle brackets, as distinct from the four
13811              or eight digits that are used for  unprintable  characters  that
13812              are nonetheless valid in the current character set.
13813
13814              Not  all systems support this: for it to work, the system's rep‐
13815              resentation of wide characters must be code values from the Uni‐
13816              versal  Character  Set,  as  defined by IS0 10646 (also known as
13817              Unicode).
13818
13819       Wrapped double-width characters
13820              When a double-width character appears in the final column  of  a
13821              line, it is instead shown on the next line. The empty space left
13822              in the original position is highlighted as a special character.
13823
13824       If zle_highlight is not set or no value applies to  a  particular  con‐
13825       text, the defaults applied are equivalent to
13826
13827              zle_highlight=(region:standout special:standout
13828              suffix:bold isearch:underline paste:standout)
13829
13830       i.e. both the region and special characters are shown in standout mode.
13831
13832       Within  widgets,  arbitrary  regions  may be highlighted by setting the
13833       special array parameter region_highlight; see above.
13834
13835ZSHCOMPWID(1)               General Commands Manual              ZSHCOMPWID(1)
13836
13837
13838

NAME

13840       zshcompwid - zsh completion widgets
13841

DESCRIPTION

13843       The shell's programmable completion mechanism can be manipulated in two
13844       ways;  here the low-level features supporting the newer, function-based
13845       mechanism are defined.  A complete set  of  shell  functions  based  on
13846       these  features is described in zshcompsys(1), and users with no inter‐
13847       est in adding to that system (or, potentially, writing their own -- see
13848       dictionary  entry  for  `hubris') should skip the current section.  The
13849       older system based on the compctl builtin command is described in  zsh‐
13850       compctl(1).
13851
13852       Completion widgets are defined by the -C option to the zle builtin com‐
13853       mand provided by the zsh/zle module (see zshzle(1)). For example,
13854
13855              zle -C complete expand-or-complete completer
13856
13857       defines a widget named `complete'.  The second argument is the name  of
13858       any  of the builtin widgets that handle completions: complete-word, ex‐
13859       pand-or-complete,  expand-or-complete-prefix,  menu-complete,  menu-ex‐
13860       pand-or-complete,      reverse-menu-complete,      list-choices,     or
13861       delete-char-or-list.  Note that this will still work even if the widget
13862       in question has been re-bound.
13863
13864       When  this  newly  defined  widget  is bound to a key using the bindkey
13865       builtin command defined in the zsh/zle module (see  zshzle(1)),  typing
13866       that key will call the shell function `completer'. This function is re‐
13867       sponsible for generating the possible matches using  the  builtins  de‐
13868       scribed  below.  As with other ZLE widgets, the function is called with
13869       its standard input closed.
13870
13871       Once the function returns, the completion code takes over control again
13872       and treats the matches in the same manner as the specified builtin wid‐
13873       get, in this case expand-or-complete.
13874

COMPLETION SPECIAL PARAMETERS

13876       The parameters ZLE_REMOVE_SUFFIX_CHARS and  ZLE_SPACE_SUFFIX_CHARS  are
13877       used  by  the completion mechanism, but are not special. See Parameters
13878       Used By The Shell in zshparam(1).
13879
13880       Inside completion widgets, and any functions called from them, some pa‐
13881       rameters  have  special  meaning;  outside these functions they are not
13882       special to the shell in any way.  These parameters are used to pass in‐
13883       formation  between  the completion code and the completion widget. Some
13884       of the builtin commands and the condition codes use or change the  cur‐
13885       rent  values  of  these parameters.  Any existing values will be hidden
13886       during execution of completion widgets; except for compstate,  the  pa‐
13887       rameters  are  reset  on  each function exit (including nested function
13888       calls from within the completion widget) to the values  they  had  when
13889       the function was entered.
13890
13891       CURRENT
13892              This is the number of the current word, i.e. the word the cursor
13893              is currently on in the words array.  Note  that  this  value  is
13894              only correct if the ksharrays option is not set.
13895
13896       IPREFIX
13897              Initially  this will be set to the empty string.  This parameter
13898              functions like PREFIX; it contains a string which  precedes  the
13899              one in PREFIX and is not considered part of the list of matches.
13900              Typically, a string is transferred from the beginning of  PREFIX
13901              to the end of IPREFIX, for example:
13902
13903                     IPREFIX=${PREFIX%%\=*}=
13904                     PREFIX=${PREFIX#*=}
13905
13906              causes  the  part  of  the  prefix up to and including the first
13907              equal sign not to be treated as part of a matched string.   This
13908              can be done automatically by the compset builtin, see below.
13909
13910       ISUFFIX
13911              As  IPREFIX, but for a suffix that should not be considered part
13912              of the matches; note that the ISUFFIX string follows the  SUFFIX
13913              string.
13914
13915       PREFIX Initially  this will be set to the part of the current word from
13916              the beginning of the word up to the position of the  cursor;  it
13917              may be altered to give a common prefix for all matches.
13918
13919       QIPREFIX
13920              This parameter is read-only and contains the quoted string up to
13921              the word being completed. E.g. when completing `"foo', this  pa‐
13922              rameter  contains  the double quote. If the -q option of compset
13923              is used (see below), and the original string was `"foo bar' with
13924              the cursor on the `bar', this parameter contains `"foo '.
13925
13926       QISUFFIX
13927              Like QIPREFIX, but containing the suffix.
13928
13929       SUFFIX Initially  this will be set to the part of the current word from
13930              the cursor position to the end; it may be altered to give a com‐
13931              mon  suffix  for all matches.  It is most useful when the option
13932              COMPLETE_IN_WORD is set, as otherwise the whole word on the com‐
13933              mand line is treated as a prefix.
13934
13935       compstate
13936              This  is  an associative array with various keys and values that
13937              the completion code uses to exchange information with  the  com‐
13938              pletion widget.  The keys are:
13939
13940              all_quotes
13941                     The  -q option of the compset builtin command (see below)
13942                     allows a quoted string to be broken into separate  words;
13943                     if the cursor is on one of those words, that word will be
13944                     completed, possibly invoking  `compset  -q'  recursively.
13945                     With  this key it is possible to test the types of quoted
13946                     strings which are currently broken  into  parts  in  this
13947                     fashion.  Its value contains one character for each quot‐
13948                     ing level.  The characters are a single quote or a double
13949                     quote for strings quoted with these characters, a dollars
13950                     sign for strings quoted with $'...' and a  backslash  for
13951                     strings  not  starting with a quote character.  The first
13952                     character in the value always corresponds to  the  inner‐
13953                     most quoting level.
13954
13955              context
13956                     This  will  be  set by the completion code to the overall
13957                     context in which completion is attempted. Possible values
13958                     are:
13959
13960                     array_value
13961                            when  completing  inside the value of an array pa‐
13962                            rameter assignment; in this case the  words  array
13963                            contains the words inside the parentheses.
13964
13965                     brace_parameter
13966                            when  completing  the name of a parameter in a pa‐
13967                            rameter expansion beginning with ${.  This context
13968                            will  also  be set when completing parameter flags
13969                            following ${(; the full command line  argument  is
13970                            presented  and  the handler must test the value to
13971                            be completed to ascertain that this is the case.
13972
13973                     assign_parameter
13974                            when completing the name of a parameter in  a  pa‐
13975                            rameter assignment.
13976
13977                     command
13978                            when  completing  for  a normal command (either in
13979                            command position or for an argument  of  the  com‐
13980                            mand).
13981
13982                     condition
13983                            when completing inside a `[[...]]' conditional ex‐
13984                            pression; in this case the  words  array  contains
13985                            only the words inside the conditional expression.
13986
13987                     math   when completing in a mathematical environment such
13988                            as a `((...))' construct.
13989
13990                     parameter
13991                            when completing the name of a parameter in  a  pa‐
13992                            rameter expansion beginning with $ but not ${.
13993
13994                     redirect
13995                            when completing after a redirection operator.
13996
13997                     subscript
13998                            when completing inside a parameter subscript.
13999
14000                     value  when  completing  the value of a parameter assign‐
14001                            ment.
14002
14003              exact  Controls the behaviour when the REC_EXACT option is  set.
14004                     It  will  be set to accept if an exact match would be ac‐
14005                     cepted, and will be unset otherwise.
14006
14007                     If it was set when at least one match equal to the string
14008                     on the line was generated, the match is accepted.
14009
14010              exact_string
14011                     The  string of an exact match if one was found, otherwise
14012                     unset.
14013
14014              ignored
14015                     The number  of  words  that  were  ignored  because  they
14016                     matched  one  of the patterns given with the -F option to
14017                     the compadd builtin command.
14018
14019              insert This controls the manner in which  a  match  is  inserted
14020                     into  the command line.  On entry to the widget function,
14021                     if it is unset the command line is not to be changed;  if
14022                     set  to  unambiguous, any prefix common to all matches is
14023                     to be inserted; if set to automenu-unambiguous, the  com‐
14024                     mon  prefix  is to be inserted and the next invocation of
14025                     the completion code may start menu completion (due to the
14026                     AUTO_MENU  option  being set); if set to menu or automenu
14027                     menu completion will be started for the matches currently
14028                     generated  (in  the  latter case this will happen because
14029                     the AUTO_MENU is set). The value  may  also  contain  the
14030                     string  `tab' when the completion code would normally not
14031                     really do completion, but only insert the TAB character.
14032
14033                     On exit it may be set to any of the values  above  (where
14034                     setting  it  to the empty string is the same as unsetting
14035                     it), or to a number, in which case the match whose number
14036                     is  given  will be inserted into the command line.  Nega‐
14037                     tive numbers count backward from  the  last  match  (with
14038                     `-1'  selecting  the  last match) and out-of-range values
14039                     are wrapped around, so that a value of zero  selects  the
14040                     last  match and a value one more than the maximum selects
14041                     the first. Unless the value of this key ends in a  space,
14042                     the match is inserted as in a menu completion, i.e. with‐
14043                     out automatically appending a space.
14044
14045                     Both menu and automenu may also specify the number of the
14046                     match  to  insert,  given  after  a  colon.  For example,
14047                     `menu:2' says to start menu  completion,  beginning  with
14048                     the second match.
14049
14050                     Note  that  a  value containing the substring `tab' makes
14051                     the matches generated be ignored and only the TAB be  in‐
14052                     serted.
14053
14054                     Finally,  it  may  also  be  set  to all, which makes all
14055                     matches generated be inserted into the line.
14056
14057              insert_positions
14058                     When the completion system inserts an unambiguous  string
14059                     into the line, there may be multiple places where charac‐
14060                     ters are missing or where the character inserted  differs
14061                     from  at least one match.  The value of this key contains
14062                     a colon separated list of all these positions, as indexes
14063                     into the command line.
14064
14065              last_prompt
14066                     If  this  is  set  to  a non-empty string for every match
14067                     added, the completion code will move the cursor  back  to
14068                     the  previous  prompt  after  the list of completions has
14069                     been displayed.  Initially this is set or unset according
14070                     to the ALWAYS_LAST_PROMPT option.
14071
14072              list   This  controls whether or how the list of matches will be
14073                     displayed.  If it is unset or empty they  will  never  be
14074                     listed;  if  its value begins with list, they will always
14075                     be listed; if it begins with autolist or ambiguous,  they
14076                     will  be  listed when the AUTO_LIST or LIST_AMBIGUOUS op‐
14077                     tions respectively would normally cause them to be.
14078
14079                     If the substring force appears in the value,  this  makes
14080                     the  list  be shown even if there is only one match. Nor‐
14081                     mally, the list would be shown only if there are at least
14082                     two matches.
14083
14084                     The   value   contains   the   substring  packed  if  the
14085                     LIST_PACKED option is set. If this substring is given for
14086                     all  matches  added  to a group, this group will show the
14087                     LIST_PACKED  behavior.  The  same   is   done   for   the
14088                     LIST_ROWS_FIRST option with the substring rows.
14089
14090                     Finally,  if  the value contains the string explanations,
14091                     only the explanation strings, if any, will be listed  and
14092                     if  it  contains  messages, only the messages (added with
14093                     the -x option of compadd) will be listed.  If it contains
14094                     both  explanations and messages both kinds of explanation
14095                     strings will be listed.  It will be set appropriately  on
14096                     entry to a completion widget and may be changed there.
14097
14098              list_lines
14099                     This gives the number of lines that are needed to display
14100                     the full list of completions.  Note that to calculate the
14101                     total number of lines to display you need to add the num‐
14102                     ber of lines needed for the command line to  this  value,
14103                     this is available as the value of the BUFFERLINES special
14104                     parameter.
14105
14106              list_max
14107                     Initially this is set to the value of the LISTMAX parame‐
14108                     ter.   It  may be set to any other value; when the widget
14109                     exits this value will be used in  the  same  way  as  the
14110                     value of LISTMAX.
14111
14112              nmatches
14113                     The  number of matches generated and accepted by the com‐
14114                     pletion code so far.
14115
14116              old_insert
14117                     On entry to the widget this will be set to the number  of
14118                     the match of an old list of completions that is currently
14119                     inserted into the command line. If no match has been  in‐
14120                     serted, this is unset.
14121
14122                     As with old_list, the value of this key will only be used
14123                     if it is the string keep. If it was set to this value  by
14124                     the  widget  and there was an old match inserted into the
14125                     command line, this match will be kept and if the value of
14126                     the insert key specifies that another match should be in‐
14127                     serted, this will be inserted after the old one.
14128
14129              old_list
14130                     This is set to yes if there is still a valid list of com‐
14131                     pletions  from a previous completion at the time the wid‐
14132                     get is invoked.  This will usually be  the  case  if  and
14133                     only  if  the previous editing operation was a completion
14134                     widget or one of the builtin  completion  functions.   If
14135                     there  is  a valid list and it is also currently shown on
14136                     the screen, the value of this key is shown.
14137
14138                     After the widget has exited the value of this key is only
14139                     used  if it was set to keep.  In this case the completion
14140                     code will continue to use this old list.  If  the  widget
14141                     generated new matches, they will not be used.
14142
14143              parameter
14144                     The  name of the parameter when completing in a subscript
14145                     or in the value of a parameter assignment.
14146
14147              pattern_insert
14148                     Normally this is set to menu, which specifies  that  menu
14149                     completion  will  be  used  whenever a set of matches was
14150                     generated using pattern matching.  If it is  set  to  any
14151                     other non-empty string by the user and menu completion is
14152                     not selected by other option settings, the code will  in‐
14153                     stead  insert any common prefix for the generated matches
14154                     as with normal completion.
14155
14156              pattern_match
14157                     Locally controls the behaviour given by the GLOB_COMPLETE
14158                     option.   Initially  it  is set to `*' if and only if the
14159                     option is set.  The completion widget may set it to  this
14160                     value,  to  an empty string (which has the same effect as
14161                     unsetting it), or to any other non-empty string.   If  it
14162                     is non-empty, unquoted metacharacters on the command line
14163                     will be treated as patterns; if it is `*', then addition‐
14164                     ally a wildcard `*' is assumed at the cursor position; if
14165                     it is empty or unset, metacharacters will be treated lit‐
14166                     erally.
14167
14168                     Note that the matcher specifications given to the compadd
14169                     builtin command  are  not  used  if  this  is  set  to  a
14170                     non-empty string.
14171
14172              quote  When  completing  inside quotes, this contains the quota‐
14173                     tion character (i.e. either  a  single  quote,  a  double
14174                     quote, or a backtick).  Otherwise it is unset.
14175
14176              quoting
14177                     When  completing inside single quotes, this is set to the
14178                     string single; inside double quotes, the  string  double;
14179                     inside  backticks,  the string backtick.  Otherwise it is
14180                     unset.
14181
14182              redirect
14183                     The redirection operator when completing in a redirection
14184                     position, i.e. one of <, >, etc.
14185
14186              restore
14187                     This  is  set to auto before a function is entered, which
14188                     forces the special  parameters  mentioned  above  (words,
14189                     CURRENT,  PREFIX, IPREFIX, SUFFIX, and ISUFFIX) to be re‐
14190                     stored to their previous values when the function  exits.
14191                     If  a  function unsets it or sets it to any other string,
14192                     they will not be restored.
14193
14194              to_end Specifies the occasions on which the cursor is  moved  to
14195                     the  end  of a string when a match is inserted.  On entry
14196                     to a widget function, it may be single if this will  hap‐
14197                     pen when a single unambiguous match was inserted or match
14198                     if it will happen any time a match is inserted (for exam‐
14199                     ple,  by menu completion; this is likely to be the effect
14200                     of the ALWAYS_TO_END option).
14201
14202                     On exit, it may be set to single as above.  It  may  also
14203                     be  set  to  always,  or to the empty string or unset; in
14204                     those cases the cursor will be moved to the  end  of  the
14205                     string always or never respectively.  Any other string is
14206                     treated as match.
14207
14208              unambiguous
14209                     This key is read-only and will always be set to the  com‐
14210                     mon  (unambiguous)  prefix the completion code has gener‐
14211                     ated for all matches added so far.
14212
14213              unambiguous_cursor
14214                     This gives the position the cursor would be placed at  if
14215                     the  common  prefix in the unambiguous key were inserted,
14216                     relative to the value of that key. The  cursor  would  be
14217                     placed  before the character whose index is given by this
14218                     key.
14219
14220              unambiguous_positions
14221                     This contains all positions where characters in the unam‐
14222                     biguous  string  are  missing  or where the character in‐
14223                     serted differs from at least one of the matches.  The po‐
14224                     sitions are given as indexes into the string given by the
14225                     value of the unambiguous key.
14226
14227              vared  If completion is called while editing a  line  using  the
14228                     vared  builtin,  the value of this key is set to the name
14229                     of the parameter given as an argument to vared.  This key
14230                     is only set while a vared command is active.
14231
14232       words  This  array  contains the words present on the command line cur‐
14233              rently being edited.
14234

COMPLETION BUILTIN COMMANDS

14236       compadd [ -akqQfenUl12C ] [ -F array ]
14237               [-P prefix ] [ -S suffix ]
14238               [-p hidden-prefix ] [ -s hidden-suffix ]
14239               [-i ignored-prefix ] [ -I ignored-suffix ]
14240               [-W file-prefix ] [ -d array ]
14241               [-J group-name ] [ -X explanation ] [ -x message ]
14242               [-V group-name ] [ -o [ order ] ]
14243               [-r remove-chars ] [ -R remove-func ]
14244               [-D array ] [ -O array ] [ -A array ]
14245               [-E number ]
14246               [-M match-spec ] [ -- ] [ words ... ]
14247
14248              This builtin command can be used to  add  matches  directly  and
14249              control all the information the completion code stores with each
14250              possible match. The return status is zero if at least one  match
14251              was added and non-zero if no matches were added.
14252
14253              The  completion  code  breaks  the string to complete into seven
14254              fields in the order:
14255
14256                     <ipre><apre><hpre><word><hsuf><asuf><isuf>
14257
14258              The first field is an ignored  prefix  taken  from  the  command
14259              line,  the  contents  of  the  IPREFIX parameter plus the string
14260              given with the -i option. With the -U option,  only  the  string
14261              from the -i option is used. The field <apre> is an optional pre‐
14262              fix string given with the -P option.   The  <hpre>  field  is  a
14263              string  that is considered part of the match but that should not
14264              be shown when listing completions, given with the -p option; for
14265              example,  functions  that do filename generation might specify a
14266              common path prefix this way.  <word> is the part  of  the  match
14267              that  should  appear in the list of completions, i.e. one of the
14268              words given at the end of the compadd command line. The suffixes
14269              <hsuf>,  <asuf>  and  <isuf>  correspond to the prefixes <hpre>,
14270              <apre> and <ipre> and are given by the options -s,  -S  and  -I,
14271              respectively.
14272
14273              The supported flags are:
14274
14275              -P prefix
14276                     This  gives  a  string  to  be  inserted before the given
14277                     words.  The string given is not considered as part of the
14278                     match  and  any  shell  metacharacters  in it will not be
14279                     quoted when the string is inserted.
14280
14281              -S suffix
14282                     Like -P, but gives a string  to  be  inserted  after  the
14283                     match.
14284
14285              -p hidden-prefix
14286                     This gives a string that should be inserted into the com‐
14287                     mand line before the match but that should not appear  in
14288                     the  list of matches. Unless the -U option is given, this
14289                     string must be matched as part of the string on the  com‐
14290                     mand line.
14291
14292              -s hidden-suffix
14293                     Like `-p', but gives a string to insert after the match.
14294
14295              -i ignored-prefix
14296                     This  gives a string to insert into the command line just
14297                     before any string given with the  `-P'  option.   Without
14298                     `-P'  the string is inserted before the string given with
14299                     `-p' or directly before the match.
14300
14301              -I ignored-suffix
14302                     Like -i, but gives an ignored suffix.
14303
14304              -a     With this flag the words are taken as names of arrays and
14305                     the possible matches are their values.  If only some ele‐
14306                     ments of the arrays are needed, the words may  also  con‐
14307                     tain subscripts, as in `foo[2,-1]'.
14308
14309              -k     With  this  flag the words are taken as names of associa‐
14310                     tive arrays and the possible matches are their keys.   As
14311                     for  -a,  the  words  may  also contain subscripts, as in
14312                     `foo[(R)*bar*]'.
14313
14314              -d array
14315                     This adds per-match display  strings.  The  array  should
14316                     contain  one  element per word given. The completion code
14317                     will then display the first element instead of the  first
14318                     word, and so on. The array may be given as the name of an
14319                     array parameter or directly as a space-separated list  of
14320                     words in parentheses.
14321
14322                     If  there are fewer display strings than words, the left‐
14323                     over words will be displayed unchanged and if  there  are
14324                     more  display  strings  than  words, the leftover display
14325                     strings will be silently ignored.
14326
14327              -l     This option only has an effect if used together with  the
14328                     -d option. If it is given, the display strings are listed
14329                     one per line, not arrayed in columns.
14330
14331              -o [ order ]
14332                     This controls the order in which matches are sorted.  or‐
14333                     der  is  a  comma-separated list comprising the following
14334                     possible values.  These  values  can  be  abbreviated  to
14335                     their initial two or three characters.  Note that the or‐
14336                     der forms part of the group name space  so  matches  with
14337                     different orderings will not be in the same group.
14338
14339                     match  If given, the order of the output is determined by
14340                            the match strings; otherwise it is  determined  by
14341                            the display strings (i.e. the strings given by the
14342                            -d option). This is the default if `-o' is  speci‐
14343                            fied but the order argument is omitted.
14344
14345                     nosort This specifies that the matches are pre-sorted and
14346                            their order should be preserved.  This value  only
14347                            makes  sense alone and cannot be combined with any
14348                            others.
14349
14350                     numeric
14351                            If the matches include numbers, sort them  numeri‐
14352                            cally rather than lexicographically.
14353
14354                     reverse
14355                            Arrange  the  matches  backwards  by reversing the
14356                            sort ordering.
14357
14358              -J group-name
14359                     Gives the name of the group of matches the  words  should
14360                     be stored in.
14361
14362              -V group-name
14363                     Like  -J  but  naming  an  unsorted group. This option is
14364                     identical to the combination of -J and -o nosort.
14365
14366              -1     If given together with the -V option, makes only consecu‐
14367                     tive duplicates in the group be removed. If combined with
14368                     the -J option, this has  no  visible  effect.  Note  that
14369                     groups  with  and without this flag are in different name
14370                     spaces.
14371
14372              -2     If given together with the -J or -V option, makes all du‐
14373                     plicates  be  kept.  Again,  groups with and without this
14374                     flag are in different name spaces.
14375
14376              -X explanation
14377                     The explanation string will be printed with the  list  of
14378                     matches, above the group currently selected.
14379
14380                     Within  the  explanation,  the following sequences may be
14381                     used to specify output attributes  as  described  in  the
14382                     section  EXPANSION  OF  PROMPT  SEQUENCES  in zshmisc(1):
14383                     `%B', `%S', `%U', `%F', `%K' and their lower  case  coun‐
14384                     terparts, as well as `%{...%}'.  `%F', `%K' and `%{...%}'
14385                     take arguments in the  same  form  as  prompt  expansion.
14386                     (Note  that  the sequence `%G' is not available; an argu‐
14387                     ment to `%{' should be used instead.)  The sequence  `%%'
14388                     produces a literal `%'.
14389
14390                     These  sequences  are  most  often employed by users when
14391                     customising the format  style  (see  zshcompsys(1)),  but
14392                     they must also be taken into account when writing comple‐
14393                     tion functions, as passing  descriptions  with  unescaped
14394                     `%'  characters  to  utility functions such as _arguments
14395                     and _message may produce unexpected results. If arbitrary
14396                     text  is to be passed in a description, it can be escaped
14397                     using e.g. ${my_str//\%/%%}.
14398
14399              -x message
14400                     Like -X, but the message will be printed  even  if  there
14401                     are no matches in the group.
14402
14403              -q     The suffix given with -S will be automatically removed if
14404                     the next character typed is a blank or  does  not  insert
14405                     anything, or if the suffix consists of only one character
14406                     and the next character typed is the same character.
14407
14408              -r remove-chars
14409                     This is a more versatile form of the -q option.  The suf‐
14410                     fix  given with -S or the slash automatically added after
14411                     completing directories will be automatically  removed  if
14412                     the  next  character  typed inserts one of the characters
14413                     given in the remove-chars.  This string is  parsed  as  a
14414                     characters  class and understands the backslash sequences
14415                     used by the print command.  For example, `-r "a-z\t"' re‐
14416                     moves  the  suffix  if the next character typed inserts a
14417                     lower case character or a TAB, and  `-r  "^0-9"'  removes
14418                     the  suffix  if the next character typed inserts anything
14419                     but a digit. One extra backslash sequence  is  understood
14420                     in  this  string: `\-' stands for all characters that in‐
14421                     sert nothing. Thus `-S "=" -q' is the same as `-S "="  -r
14422                     "= \t\n\-"'.
14423
14424                     This  option may also be used without the -S option; then
14425                     any automatically added space will be removed when one of
14426                     the characters in the list is typed.
14427
14428              -R remove-func
14429                     This  is another form of the -r option. When a suffix has
14430                     been inserted and the completion accepted,  the  function
14431                     remove-func  will  be  called  after  the  next character
14432                     typed.  It is passed the length of the suffix as an argu‐
14433                     ment  and can use the special parameters available in or‐
14434                     dinary (non-completion) zle widgets  (see  zshzle(1))  to
14435                     analyse and modify the command line.
14436
14437              -f     If  this  flag  is  given,  all of the matches built from
14438                     words are marked as being the names of files.   They  are
14439                     not required to be actual filenames, but if they are, and
14440                     the option LIST_TYPES is set, the  characters  describing
14441                     the  types  of  the files in the completion lists will be
14442                     shown. This also forces a slash to be added when the name
14443                     of a directory is completed.
14444
14445              -e     This  flag  can  be used to tell the completion code that
14446                     the matches added are parameter names for a parameter ex‐
14447                     pansion.   This   will   make  the  AUTO_PARAM_SLASH  and
14448                     AUTO_PARAM_KEYS options be used for the matches.
14449
14450              -W file-prefix
14451                     This string is a pathname that will be prepended to  each
14452                     of  the  matches  formed by the given words together with
14453                     any prefix specified by the -p option to form a  complete
14454                     filename  for  testing.   Hence it is only useful if com‐
14455                     bined with the -f flag, as the tests will  not  otherwise
14456                     be performed.
14457
14458              -F array
14459                     Specifies  an  array  containing patterns. Words matching
14460                     one of these patterns are ignored, i.e. not considered to
14461                     be possible matches.
14462
14463                     The array may be the name of an array parameter or a list
14464                     of literal patterns enclosed in parentheses  and  quoted,
14465                     as  in  `-F  "(*?.o  *?.h)"'.  If the name of an array is
14466                     given, the elements of the array are taken  as  the  pat‐
14467                     terns.
14468
14469              -Q     This  flag instructs the completion code not to quote any
14470                     metacharacters in the words when inserting them into  the
14471                     command line.
14472
14473              -M match-spec
14474                     This  gives local match specifications as described below
14475                     in the section `Completion Matching Control'. This option
14476                     may   be   given  more  than  once.   In  this  case  all
14477                     match-specs given are concatenated  with  spaces  between
14478                     them  to form the specification string to use.  Note that
14479                     they will only be used if the -U option is not given.
14480
14481              -n     Specifies that the words added are to be used as possible
14482                     matches, but are not to appear in the completion listing.
14483
14484              -U     If  this  flag is given, all words given will be accepted
14485                     and no matching will be done by the completion code. Nor‐
14486                     mally  this  is  used  in  functions that do the matching
14487                     themselves.
14488
14489              -O array
14490                     If this option is given, the words are not added  to  the
14491                     set  of  possible completions.  Instead, matching is done
14492                     as usual and all of the words  given  as  arguments  that
14493                     match  the  string  on the command line will be stored in
14494                     the array parameter whose name is given as array.
14495
14496              -A array
14497                     As the -O option, except that instead  of  those  of  the
14498                     words which match being stored in array, the strings gen‐
14499                     erated internally by the completion code are stored.  For
14500                     example,  with a matching specification of `-M "L:|no="',
14501                     the string `nof' on the command line and the string `foo'
14502                     as  one  of the words, this option stores the string `no‐
14503                     foo' in the array, whereas the -O option stores the `foo'
14504                     originally given.
14505
14506              -D array
14507                     As  with -O, the words are not added to the set of possi‐
14508                     ble completions.   Instead,  the  completion  code  tests
14509                     whether  each  word  in turn matches what is on the line.
14510                     If the nth word does not match, the nth  element  of  the
14511                     array  is  removed.  Elements for which the corresponding
14512                     word is matched are retained.
14513
14514              -C     This option adds a special match  which  expands  to  all
14515                     other  matches  when  inserted  into the line, even those
14516                     that are added after this option is used.  Together  with
14517                     the  -d  option  it  is possible to specify a string that
14518                     should be displayed in the list for this  special  match.
14519                     If  no string is given, it will be shown as a string con‐
14520                     taining the strings that would be inserted for the  other
14521                     matches, truncated to the width of the screen.
14522
14523              -E number
14524                     This  option  adds  number  empty matches after the words
14525                     have been added.  An empty match takes up space  in  com‐
14526                     pletion  listings  but will never be inserted in the line
14527                     and can't be selected with menu completion or menu selec‐
14528                     tion.   This  makes  empty  matches only useful to format
14529                     completion lists and to make explanatory string be  shown
14530                     in  completion  lists  (since  empty matches can be given
14531                     display strings with the -d option).  And because all but
14532                     one  empty string would otherwise be removed, this option
14533                     implies the -V and -2 options (even if an explicit -J op‐
14534                     tion  is given).  This can be important to note as it af‐
14535                     fects the name space into which matches are added.
14536
14537              -
14538              --     This flag ends the list of flags and options.  All  argu‐
14539                     ments  after  it  will  be  taken  as the words to use as
14540                     matches even if they begin with hyphens.
14541
14542              Except for the -M flag, if any of these flags is given more than
14543              once, the first one (and its argument) will be used.
14544
14545       compset -p number
14546       compset -P [ number ] pattern
14547       compset -s number
14548       compset -S [ number ] pattern
14549       compset -n begin [ end ]
14550       compset -N beg-pat [ end-pat ]
14551       compset -q
14552              This  command simplifies modification of the special parameters,
14553              while its return status allows tests on them to be carried out.
14554
14555              The options are:
14556
14557              -p number
14558                     If the value of the PREFIX parameter is at  least  number
14559                     characters  long, the first number characters are removed
14560                     from it and appended to the contents of the  IPREFIX  pa‐
14561                     rameter.
14562
14563              -P [ number ] pattern
14564                     If the value of the PREFIX parameter begins with anything
14565                     that matches the pattern, the matched portion is  removed
14566                     from PREFIX and appended to IPREFIX.
14567
14568                     Without  the optional number, the longest match is taken,
14569                     but if number is given, anything up to the numberth match
14570                     is  moved.  If the number is negative, the numberth long‐
14571                     est match is moved. For example, if PREFIX  contains  the
14572                     string  `a=b=c',  then  compset  -P  '*\='  will move the
14573                     string `a=b=' into the IPREFIX parameter, but compset  -P
14574                     1 '*\=' will move only the string `a='.
14575
14576              -s number
14577                     As  -p,  but transfer the last number characters from the
14578                     value of SUFFIX to the front of the value of ISUFFIX.
14579
14580              -S [ number ] pattern
14581                     As -P, but match the last portion of SUFFIX and  transfer
14582                     the matched portion to the front of the value of ISUFFIX.
14583
14584              -n begin [ end ]
14585                     If  the current word position as specified by the parame‐
14586                     ter CURRENT is greater than or equal to  begin,  anything
14587                     up  to  the  beginth word is removed from the words array
14588                     and the value of the parameter CURRENT is decremented  by
14589                     begin.
14590
14591                     If  the  optional  end is given, the modification is done
14592                     only if the current word position is also  less  than  or
14593                     equal  to  end. In this case, the words from position end
14594                     onwards are also removed from the words array.
14595
14596                     Both begin and end may be  negative  to  count  backwards
14597                     from the last element of the words array.
14598
14599              -N beg-pat [ end-pat ]
14600                     If  one of the elements of the words array before the one
14601                     at the index given by the value of the parameter  CURRENT
14602                     matches  the  pattern beg-pat, all elements up to and in‐
14603                     cluding the matching one are removed from the words array
14604                     and  the value of CURRENT is changed to point to the same
14605                     word in the changed array.
14606
14607                     If the optional pattern end-pat is also given, and  there
14608                     is  an  element in the words array matching this pattern,
14609                     the parameters are modified only if  the  index  of  this
14610                     word  is higher than the one given by the CURRENT parame‐
14611                     ter (so that the matching word has to be after  the  cur‐
14612                     sor).  In  this  case,  the  words  starting with the one
14613                     matching end-pat are also removed from the  words  array.
14614                     If  words  contains no word matching end-pat, the testing
14615                     and modification is performed as if it were not given.
14616
14617              -q     The word currently being completed  is  split  on  spaces
14618                     into  separate  words, respecting the usual shell quoting
14619                     conventions.  The resulting words are stored in the words
14620                     array,  and CURRENT, PREFIX, SUFFIX, QIPREFIX, and QISUF‐
14621                     FIX are modified to reflect the word part  that  is  com‐
14622                     pleted.
14623
14624              In  all  the  above  cases the return status is zero if the test
14625              succeeded and the parameters were modified and  non-zero  other‐
14626              wise. This allows one to use this builtin in tests such as:
14627
14628                     if compset -P '*\='; then ...
14629
14630              This  forces anything up to and including the last equal sign to
14631              be ignored by the completion code.
14632
14633       compcall [ -TD ]
14634              This allows the use of  completions  defined  with  the  compctl
14635              builtin  from  within  completion  widgets.  The list of matches
14636              will be generated as if one of the non-widget  completion  func‐
14637              tions  (complete-word,  etc.)  had been called, except that only
14638              compctls given for specific commands are used. To force the code
14639              to  try completions defined with the -T option of compctl and/or
14640              the default completion (whether defined by  compctl  -D  or  the
14641              builtin  default)  in  the  appropriate places, the -T and/or -D
14642              flags can be passed to compcall.
14643
14644              The return status can be used to test if a matching compctl def‐
14645              inition  was  found.  It  is non-zero if a compctl was found and
14646              zero otherwise.
14647
14648              Note that this builtin is defined by the zsh/compctl module.
14649

COMPLETION CONDITION CODES

14651       The following additional condition codes for use within the [[  ...  ]]
14652       construct  are available in completion widgets.  These work on the spe‐
14653       cial parameters.  All of these tests  can  also  be  performed  by  the
14654       compset builtin, but in the case of the condition codes the contents of
14655       the special parameters are not modified.
14656
14657       -prefix [ number ] pattern
14658              true if the test for the -P option of compset would succeed.
14659
14660       -suffix [ number ] pattern
14661              true if the test for the -S option of compset would succeed.
14662
14663       -after beg-pat
14664              true if the test of the -N option with only  the  beg-pat  given
14665              would succeed.
14666
14667       -between beg-pat end-pat
14668              true if the test for the -N option with both patterns would suc‐
14669              ceed.
14670

COMPLETION MATCHING CONTROL

14672       It is possible by use of the -M option of the compadd  builtin  command
14673       to  specify  how the characters in the string to be completed (referred
14674       to here as the command line) map onto the characters  in  the  list  of
14675       matches  produced by the completion code (referred to here as the trial
14676       completions). Note that this is not used if the command line contains a
14677       glob  pattern  and the GLOB_COMPLETE option is set or the pattern_match
14678       of the compstate special association is set to a non-empty string.
14679
14680       The match-spec given as the argument to the -M option (see  `Completion
14681       Builtin  Commands' above) consists of one or more matching descriptions
14682       separated by whitespace.  Each description consists of  a  letter  fol‐
14683       lowed  by  a colon and then the patterns describing which character se‐
14684       quences on the line match which character sequences in the  trial  com‐
14685       pletion.   Any  sequence of characters not handled in this fashion must
14686       match exactly, as usual.
14687
14688       The forms of match-spec understood are as follows. In  each  case,  the
14689       form  with  an  upper case initial character retains the string already
14690       typed on the command line as the final result of completion, while with
14691       a  lower  case  initial  character  the  string  on the command line is
14692       changed into the corresponding part of the trial completion.
14693
14694       m:lpat=tpat
14695       M:lpat=tpat
14696              Here, lpat is a pattern that matches on the command line, corre‐
14697              sponding to tpat which matches in the trial completion.
14698
14699       l:lanchor|lpat=tpat
14700       L:lanchor|lpat=tpat
14701       l:lanchor||ranchor=tpat
14702       L:lanchor||ranchor=tpat
14703       b:lpat=tpat
14704       B:lpat=tpat
14705              These letters are for patterns that are anchored by another pat‐
14706              tern on the left side. Matching for lpat and tpat is  as  for  m
14707              and  M, but the pattern lpat matched on the command line must be
14708              preceded by the pattern lanchor.  The lanchor can  be  blank  to
14709              anchor the match to the start of the command line string; other‐
14710              wise the anchor can occur anywhere, but must match in  both  the
14711              command line and trial completion strings.
14712
14713              If  no  lpat is given but a ranchor is, this matches the gap be‐
14714              tween substrings matched by lanchor and ranchor. Unlike lanchor,
14715              the ranchor only needs to match the trial completion string.
14716
14717              The  b  and B forms are similar to l and L with an empty anchor,
14718              but need to match only the beginning of the word on the  command
14719              line or trial completion, respectively.
14720
14721       r:lpat|ranchor=tpat
14722       R:lpat|ranchor=tpat
14723       r:lanchor||ranchor=tpat
14724       R:lanchor||ranchor=tpat
14725       e:lpat=tpat
14726       E:lpat=tpat
14727              As  l, L, b and B, with the difference that the command line and
14728              trial completion patterns are anchored on the right side.   Here
14729              an  empty  ranchor  and the e and E forms force the match to the
14730              end of the command line or trial completion string.
14731
14732       x:     This form is used to mark the end  of  matching  specifications:
14733              subsequent  specifications  are  ignored. In a single standalone
14734              list of specifications this has no use but where matching speci‐
14735              fications  are  accumulated, such as from nested function calls,
14736              it can allow one function to override another.
14737
14738       Each lpat, tpat or anchor is either an empty string or  consists  of  a
14739       sequence  of literal characters (which may be quoted with a backslash),
14740       question marks, character classes, and correspondence classes; ordinary
14741       shell patterns are not used.  Literal characters match only themselves,
14742       question marks match any character, and character classes are formed as
14743       for globbing and match any character in the given set.
14744
14745       Correspondence classes are defined like character classes, but with two
14746       differences: they are delimited  by  a  pair  of  braces,  and  negated
14747       classes  are  not  allowed,  so  the characters ! and ^ have no special
14748       meaning directly after the opening brace.  They indicate that  a  range
14749       of characters on the line match a range of characters in the trial com‐
14750       pletion, but (unlike ordinary character classes)  paired  according  to
14751       the  corresponding  position in the sequence.  For example, to make any
14752       ASCII lower case letter on the line match the corresponding upper  case
14753       letter  in  the trial completion, you can use `m:{a-z}={A-Z}' (however,
14754       see below for the recommended form for this).  More than  one  pair  of
14755       classes  can  occur,  in which case the first class before the = corre‐
14756       sponds to the first after it, and so on.  If one  side  has  more  such
14757       classes than the other side, the superfluous classes behave like normal
14758       character classes.  In anchor patterns correspondence classes also  be‐
14759       have like normal character classes.
14760
14761       The  standard  `[:name:]'  forms  described for standard shell patterns
14762       (see the section FILENAME GENERATION in zshexpn(1)) may appear in  cor‐
14763       respondence classes as well as normal character classes.  The only spe‐
14764       cial behaviour in correspondence classes is if the form on the left and
14765       the  form  on the right are each one of [:upper:], [:lower:].  In these
14766       cases the character in the word and the character on the line  must  be
14767       the  same  up  to  a  difference in case.  Hence to make any lower case
14768       character on the line match the corresponding upper case  character  in
14769       the trial completion you can use `m:{[:lower:]}={[:upper:]}'.  Although
14770       the matching system does not yet handle multibyte characters,  this  is
14771       likely to be a future extension, at which point this syntax will handle
14772       arbitrary alphabets; hence this form, rather than the use  of  explicit
14773       ranges,  is  the recommended form.  In other cases `[:name:]' forms are
14774       allowed.  If the two forms on the left and  right  are  the  same,  the
14775       characters  must  match exactly.  In remaining cases, the corresponding
14776       tests are applied to both characters, but they are not  otherwise  con‐
14777       strained;  any  matching  character  in  one set goes with any matching
14778       character in the other set:  this is equivalent to the behaviour of or‐
14779       dinary character classes.
14780
14781       The  pattern tpat may also be one or two stars, `*' or `**'. This means
14782       that the pattern on the command line can match any number of characters
14783       in  the trial completion. In this case the pattern must be anchored (on
14784       either side); in the case of a single star, the anchor then  determines
14785       how  much of the trial completion is to be included -- only the charac‐
14786       ters up to the next appearance of the anchor will be matched. With  two
14787       stars, substrings matched by the anchor can be matched, too.
14788
14789       Examples:
14790
14791       The keys of the options association defined by the parameter module are
14792       the option names in all-lower-case form, without underscores, and with‐
14793       out  the  optional  no at the beginning even though the builtins setopt
14794       and unsetopt understand option names with upper  case  letters,  under‐
14795       scores,  and  the optional no.  The following alters the matching rules
14796       so that the prefix no and any underscore are  ignored  when  trying  to
14797       match  the  trial  completions  generated and upper case letters on the
14798       line match the corresponding lower case letters in the words:
14799
14800              compadd -M 'L:|[nN][oO]= M:_= M:{[:upper:]}={[:lower:]}' - \
14801                ${(k)options}
14802
14803       The first part says that the pattern `[nN][oO]' at the  beginning  (the
14804       empty  anchor before the pipe symbol) of the string on the line matches
14805       the empty string in the list of words generated by  completion,  so  it
14806       will be ignored if present. The second part does the same for an under‐
14807       score anywhere in the command line string, and the third part uses cor‐
14808       respondence  classes  so that any upper case letter on the line matches
14809       the corresponding lower case letter in the word. The use of  the  upper
14810       case  forms  of  the specification characters (L and M) guarantees that
14811       what has already been typed on the command line (in particular the pre‐
14812       fix no) will not be deleted.
14813
14814       Note  that  the  use  of L in the first part means that it matches only
14815       when at the beginning of both the command line  string  and  the  trial
14816       completion.  I.e.,  the  string  `_NO_f'  would  not  be  completed  to
14817       `_NO_foo', nor would `NONO_f' be completed to `NONO_foo' because of the
14818       leading  underscore or the second `NO' on the line which makes the pat‐
14819       tern fail even though they are otherwise  ignored.  To  fix  this,  one
14820       would  use `B:[nN][oO]=' instead of the first part. As described above,
14821       this matches at the beginning of the trial completion,  independent  of
14822       other  characters  or  substrings  at the beginning of the command line
14823       word which are ignored by the same or other match-specs.
14824
14825       The second example makes completion case insensitive.  This is just the
14826       same  as in the option example, except here we wish to retain the char‐
14827       acters in the list of completions:
14828
14829              compadd -M 'm:{[:lower:]}={[:upper:]}' ...
14830
14831       This makes lower case letters match their upper case counterparts.   To
14832       make upper case letters match the lower case forms as well:
14833
14834              compadd -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' ...
14835
14836       A  nice  example  for the use of * patterns is partial word completion.
14837       Sometimes you would like to  make  strings  like  `c.s.u'  complete  to
14838       strings like `comp.source.unix', i.e. the word on the command line con‐
14839       sists of multiple parts, separated by a dot in this example, where each
14840       part  should  be  completed  separately -- note, however, that the case
14841       where each part of the word, i.e. `comp', `source' and `unix'  in  this
14842       example,  is to be completed from separate sets of matches is a differ‐
14843       ent problem to be solved by the implementation of the  completion  wid‐
14844       get.  The example can be handled by:
14845
14846              compadd -M 'r:|.=* r:|=*' \
14847                - comp.sources.unix comp.sources.misc ...
14848
14849       The  first  specification says that lpat is the empty string, while an‐
14850       chor is a dot; tpat is *, so this can match anything except for the `.'
14851       from  the  anchor  in  the  trial  completion word.  So in `c.s.u', the
14852       matcher sees `c', followed by the empty string, followed by the  anchor
14853       `.',  and  likewise  for the second dot, and replaces the empty strings
14854       before the anchors, giving `c[omp].s[ources].u[nix]',  where  the  last
14855       part of the completion is just as normal.
14856
14857       With  the  pattern shown above, the string `c.u' could not be completed
14858       to `comp.sources.unix' because  the  single  star  means  that  no  dot
14859       (matched  by  the  anchor)  can  be  skipped.  By using two stars as in
14860       `r:|.=**', however, `c.u' could be  completed  to  `comp.sources.unix'.
14861       This  also shows that in some cases, especially if the anchor is a real
14862       pattern, like a character class, the form with two stars may result  in
14863       more matches than one would like.
14864
14865       The second specification is needed to make this work when the cursor is
14866       in the middle of the string on the command line  and  the  option  COM‐
14867       PLETE_IN_WORD  is  set. In this case the completion code would normally
14868       try to match trial completions that end with the  string  as  typed  so
14869       far,  i.e.  it  will  only insert new characters at the cursor position
14870       rather than at the end.  However in our example we would like the  code
14871       to recognise matches which contain extra characters after the string on
14872       the line (the `nix' in the example).   Hence  we  say  that  the  empty
14873       string  at  the end of the string on the line matches any characters at
14874       the end of the trial completion.
14875
14876       More generally, the specification
14877
14878              compadd -M 'r:|[.,_-]=* r:|=*' ...
14879
14880       allows one to complete words with abbreviations before any of the char‐
14881       acters  in the square brackets.  For example, to complete veryverylong‐
14882       file.c rather than veryverylongheader.h with the above in  effect,  you
14883       can just type very.c before attempting completion.
14884
14885       The  specifications  with  both a left and a right anchor are useful to
14886       complete partial words whose parts are not separated  by  some  special
14887       character.  For  example,  in  some places strings have to be completed
14888       that are formed `LikeThis' (i.e. the separate parts are determined by a
14889       leading  upper  case  letter) or maybe one has to complete strings with
14890       trailing numbers. Here one could use the simple form with only one  an‐
14891       chor as in:
14892
14893              compadd -M 'r:|[[:upper:]0-9]=* r:|=*' LikeTHIS FooHoo 5foo123 5bar234
14894
14895       But with this, the string `H' would neither complete to `FooHoo' nor to
14896       `LikeTHIS' because in each case there is an upper  case  letter  before
14897       the `H' and that is matched by the anchor. Likewise, a `2' would not be
14898       completed. In both cases this could  be  changed  by  using  `r:|[[:up‐
14899       per:]0-9]=**',  but  then `H' completes to both `LikeTHIS' and `FooHoo'
14900       and a `2' matches the other strings because characters can be  inserted
14901       before every upper case letter and digit. To avoid this one would use:
14902
14903              compadd -M 'r:[^[:upper:]0-9]||[[:upper:]0-9]=** r:|=*' \
14904                  LikeTHIS FooHoo foo123 bar234
14905
14906       By using these two anchors, a `H' matches only upper case `H's that are
14907       immediately preceded by something matching  the  left  anchor  `[^[:up‐
14908       per:]0-9]'.  The effect is, of course, that `H' matches only the string
14909       `FooHoo', a `2' matches only `bar234' and so on.
14910
14911       When using the completion system (see zshcompsys(1)), users can  define
14912       match specifications that are to be used for specific contexts by using
14913       the matcher and matcher-list styles. The values for the latter will  be
14914       used everywhere.
14915

COMPLETION WIDGET EXAMPLE

14917       The first step is to define the widget:
14918
14919              zle -C complete complete-word complete-files
14920
14921       Then  the  widget  can be bound to a key using the bindkey builtin com‐
14922       mand:
14923
14924              bindkey '^X\t' complete
14925
14926       After that the shell function complete-files will be invoked after typ‐
14927       ing  control-X  and TAB. The function should then generate the matches,
14928       e.g.:
14929
14930              complete-files () { compadd - * }
14931
14932       This function will complete files in the current directory matching the
14933       current word.
14934
14935
14936
14937ZSHCOMPSYS(1)               General Commands Manual              ZSHCOMPSYS(1)
14938
14939
14940

NAME

14942       zshcompsys - zsh completion system
14943

DESCRIPTION

14945       This describes the shell code for the `new' completion system, referred
14946       to as compsys.  It is written in shell functions based on the  features
14947       described in zshcompwid(1).
14948
14949       The features are contextual, sensitive to the point at which completion
14950       is started.  Many completions are already provided.  For this reason, a
14951       user  can perform a great many tasks without knowing any details beyond
14952       how to initialize the system, which is described below  in  INITIALIZA‐
14953       TION.
14954
14955       The context that decides what completion is to be performed may be
14956       •      an  argument  or option position: these describe the position on
14957              the command line at which completion is requested.  For  example
14958              `first  argument  to rmdir, the word being completed names a di‐
14959              rectory';
14960
14961
14962       •      a special context, denoting an element in  the  shell's  syntax.
14963              For  example  `a  word  in  command  position' or `an array sub‐
14964              script'.
14965
14966
14967       A full context specification contains other elements, as we  shall  de‐
14968       scribe.
14969
14970       Besides  commands  names and contexts, the system employs two more con‐
14971       cepts, styles and tags.  These provide ways for the user  to  configure
14972       the system's behaviour.
14973
14974       Tags  play  a dual role.  They serve as a classification system for the
14975       matches, typically indicating a class of object that the user may  need
14976       to  distinguish.  For example, when completing arguments of the ls com‐
14977       mand the user may prefer to try files before directories,  so  both  of
14978       these are tags.  They also appear as the rightmost element in a context
14979       specification.
14980
14981       Styles modify various operations of the completion system, such as out‐
14982       put formatting, but also what kinds of completers are used (and in what
14983       order), or which tags are examined.  Styles may  accept  arguments  and
14984       are  manipulated  using  the  zstyle  command  described in see zshmod‐
14985       ules(1).
14986
14987       In summary, tags describe what the completion objects  are,  and  style
14988       how they are to be completed.  At various points of execution, the com‐
14989       pletion system checks what styles and/or tags are defined for the  cur‐
14990       rent  context, and uses that to modify its behavior.  The full descrip‐
14991       tion of context handling, which determines how tags and other  elements
14992       of the context influence the behaviour of styles, is described below in
14993       COMPLETION SYSTEM CONFIGURATION.
14994
14995       When a completion is requested, a dispatcher function  is  called;  see
14996       the  description of _main_complete in the list of control functions be‐
14997       low. This dispatcher decides which function should be called to produce
14998       the completions, and calls it. The result is passed to one or more com‐
14999       pleters, functions that  implement  individual  completion  strategies:
15000       simple  completion, error correction, completion with error correction,
15001       menu selection, etc.
15002
15003       More generally, the shell functions contained in the completion  system
15004       are of two types:
15005       •      those beginning `comp' are to be called directly; there are only
15006              a few of these;
15007
15008
15009       •      those beginning `_' are called  by  the  completion  code.   The
15010              shell  functions  of this set, which implement completion behav‐
15011              iour and may be bound to keystrokes, are referred  to  as  `wid‐
15012              gets'.  These proliferate as new completions are required.
15013
15014

INITIALIZATION

15016       If the system was installed completely, it should be enough to call the
15017       shell function compinit from your initialization  file;  see  the  next
15018       section.   However,  the  function  compinstall can be run by a user to
15019       configure various aspects of the completion system.
15020
15021       Usually, compinstall will insert code into .zshrc, although if that  is
15022       not  writable  it will save it in another file and tell you that file's
15023       location.  Note that it is up to you to make sure that the lines  added
15024       to  .zshrc are actually run; you may, for example, need to move them to
15025       an earlier place in the file if .zshrc usually returns early.  So  long
15026       as you keep them all together (including the comment lines at the start
15027       and finish), you can rerun compinstall and it will correctly locate and
15028       modify  these lines.  Note, however, that any code you add to this sec‐
15029       tion by hand is likely to be lost if you  rerun  compinstall,  although
15030       lines using the command `zstyle' should be gracefully handled.
15031
15032       The  new  code  will  take effect next time you start the shell, or run
15033       .zshrc by hand; there is also an option to make them take effect  imme‐
15034       diately.   However,  if  compinstall  has removed definitions, you will
15035       need to restart the shell to see the changes.
15036
15037       To run compinstall you will need to make sure it is in a directory men‐
15038       tioned in your fpath parameter, which should already be the case if zsh
15039       was properly configured as long as your startup files do not remove the
15040       appropriate  directories  from fpath.  Then it must be autoloaded (`au‐
15041       toload -U compinstall' is recommended).  You can abort the installation
15042       any  time  you are being prompted for information, and your .zshrc will
15043       not be altered at all; changes only take place right at the end,  where
15044       you are specifically asked for confirmation.
15045
15046   Use of compinit
15047       This section describes the use of compinit to initialize completion for
15048       the current session when called directly; if you have  run  compinstall
15049       it will be called automatically from your .zshrc.
15050
15051       To  initialize  the system, the function compinit should be in a direc‐
15052       tory mentioned in the fpath parameter, and should be  autoloaded  (`au‐
15053       toload -U compinit' is recommended), and then run simply as `compinit'.
15054       This will define a few utility functions, arrange for all the necessary
15055       shell  functions  to be autoloaded, and will then re-define all widgets
15056       that do completion to use the new system.  If you use  the  menu-select
15057       widget,  which is part of the zsh/complist module, you should make sure
15058       that that module is loaded before the call to  compinit  so  that  that
15059       widget is also re-defined.  If completion styles (see below) are set up
15060       to perform expansion as well as completion by default, and the TAB  key
15061       is  bound  to  expand-or-complete,  compinit  will  rebind  it  to com‐
15062       plete-word; this is necessary to use the correct form of expansion.
15063
15064       Should you need to use the original completion commands, you can  still
15065       bind  keys  to  the old widgets by putting a `.' in front of the widget
15066       name, e.g. `.expand-or-complete'.
15067
15068       To speed up the running of compinit, it can be made to produce a dumped
15069       configuration  that  will be read in on future invocations; this is the
15070       default, but can be turned off by calling compinit with the option  -D.
15071       The  dumped  file  is  .zcompdump  in the same directory as the startup
15072       files (i.e. $ZDOTDIR or $HOME); alternatively, an  explicit  file  name
15073       can  be  given  by  `compinit  -d  dumpfile'.   The  next invocation of
15074       compinit will read the dumped file instead of performing  a  full  ini‐
15075       tialization.
15076
15077       If the number of completion files changes, compinit will recognise this
15078       and produce a new dump file.  However, if the name of a function or the
15079       arguments in the first line of a #compdef function (as described below)
15080       change, it is easiest to delete the dump file by hand so that  compinit
15081       will  re-create it the next time it is run.  The check performed to see
15082       if there are new functions can be omitted by giving the option -C.   In
15083       this  case  the  dump  file will only be created if there isn't one al‐
15084       ready.
15085
15086       The dumping is actually done by another  function,  compdump,  but  you
15087       will  only  need  to  run this yourself if you change the configuration
15088       (e.g. using compdef) and then want to dump the new one.   The  name  of
15089       the old dumped file will be remembered for this purpose.
15090
15091       If the parameter _compdir is set, compinit uses it as a directory where
15092       completion functions can be found; this is only necessary if  they  are
15093       not already in the function search path.
15094
15095       For  security  reasons  compinit  also  checks if the completion system
15096       would use files not owned by root or by the current user, or  files  in
15097       directories  that are world- or group-writable or that are not owned by
15098       root or by the current user.  If such files or directories  are  found,
15099       compinit  will  ask if the completion system should really be used.  To
15100       avoid these tests and make all files found be used without asking,  use
15101       the  option -u, and to make compinit silently ignore all insecure files
15102       and directories use the option -i.  This security check is skipped  en‐
15103       tirely when the -C option is given.
15104
15105       The  security  check can be retried at any time by running the function
15106       compaudit.  This is the same check used by compinit, but when it is ex‐
15107       ecuted  directly any changes to fpath are made local to the function so
15108       they do not persist.  The directories to be checked may  be  passed  as
15109       arguments; if none are given, compaudit uses fpath and _compdir to find
15110       completion system directories, adding missing ones to fpath  as  neces‐
15111       sary.   To  force a check of exactly the directories currently named in
15112       fpath, set _compdir to an empty  string  before  calling  compaudit  or
15113       compinit.
15114
15115       The  function  bashcompinit provides compatibility with bash's program‐
15116       mable completion system.  When run it will define the functions,  comp‐
15117       gen  and  complete  which correspond to the bash builtins with the same
15118       names.  It will then be possible to use completion  specifications  and
15119       functions written for bash.
15120
15121   Autoloaded files
15122       The convention for autoloaded functions used in completion is that they
15123       start with an underscore; as already mentioned, the fpath/FPATH parame‐
15124       ter  must  contain  the directory in which they are stored.  If zsh was
15125       properly installed on your system, then fpath/FPATH automatically  con‐
15126       tains the required directories for the standard functions.
15127
15128       For  incomplete  installations,  if compinit does not find enough files
15129       beginning with an underscore (fewer than twenty) in the search path, it
15130       will  try  to  find more by adding the directory _compdir to the search
15131       path.  If that directory has a subdirectory named Base, all subdirecto‐
15132       ries  will be added to the path.  Furthermore, if the subdirectory Base
15133       has a subdirectory named Core, compinit will add all subdirectories  of
15134       the  subdirectories to the path: this allows the functions to be in the
15135       same format as in the zsh source distribution.
15136
15137       When compinit is  run,  it  searches  all  such  files  accessible  via
15138       fpath/FPATH and reads the first line of each of them.  This line should
15139       contain one of the tags described below.  Files whose first  line  does
15140       not  start  with one of these tags are not considered to be part of the
15141       completion system and will not be treated specially.
15142
15143       The tags are:
15144
15145       #compdef name ... [ -{p|P} pattern ... [ -N name ... ] ]
15146              The file will be made autoloadable and the function  defined  in
15147              it will be called when completing names, each of which is either
15148              the name of a command whose arguments are to be completed or one
15149              of  a number of special contexts in the form -context- described
15150              below.
15151
15152              Each name may also be of the form `cmd=service'.  When  complet‐
15153              ing  the  command  cmd, the function typically behaves as if the
15154              command (or special context) service  was  being  completed  in‐
15155              stead.   This  provides a way of altering the behaviour of func‐
15156              tions that can perform many different completions.  It is imple‐
15157              mented  by setting the parameter $service when calling the func‐
15158              tion; the function may choose to interpret this how  it  wishes,
15159              and simpler functions will probably ignore it.
15160
15161              If  the  #compdef line contains one of the options -p or -P, the
15162              words following are taken to be patterns.  The function will  be
15163              called  when  completion  is  attempted for a command or context
15164              that matches one of the patterns.  The options  -p  and  -P  are
15165              used  to specify patterns to be tried before or after other com‐
15166              pletions respectively.  Hence -P may be used to specify  default
15167              actions.
15168
15169              The option -N is used after a list following -p or -P; it speci‐
15170              fies that remaining words no longer define patterns.  It is pos‐
15171              sible  to toggle between the three options as many times as nec‐
15172              essary.
15173
15174       #compdef -k style key-sequence ...
15175              This option creates a widget behaving like  the  builtin  widget
15176              style  and  binds  it  to  the given key-sequences, if any.  The
15177              style must be one of the builtin widgets  that  perform  comple‐
15178              tion,  namely complete-word, delete-char-or-list, expand-or-com‐
15179              plete, expand-or-complete-prefix,  list-choices,  menu-complete,
15180              menu-expand-or-complete,   or   reverse-menu-complete.   If  the
15181              zsh/complist module is loaded  (see  zshmodules(1))  the  widget
15182              menu-select is also available.
15183
15184              When one of the key-sequences is typed, the function in the file
15185              will be invoked to generate the matches.  Note that a  key  will
15186              not  be  re-bound if it already was (that is, was bound to some‐
15187              thing other than undefined-key).  The  widget  created  has  the
15188              same  name  as the file and can be bound to any other keys using
15189              bindkey as usual.
15190
15191       #compdef -K widget-name style key-sequence [ name style seq ... ]
15192              This is similar to -k except that only one key-sequence argument
15193              may  be given for each widget-name style pair.  However, the en‐
15194              tire set of three arguments may be repeated with a different set
15195              of  arguments.   Note in particular that the widget-name must be
15196              distinct in each set.  If it does not begin with `_'  this  will
15197              be added.  The widget-name should not clash with the name of any
15198              existing widget: names based on the name  of  the  function  are
15199              most useful.  For example,
15200
15201                     #compdef -K _foo_complete complete-word "^X^C" \
15202                       _foo_list list-choices "^X^D"
15203
15204              (all on one line) defines a widget _foo_complete for completion,
15205              bound to `^X^C', and a widget _foo_list for  listing,  bound  to
15206              `^X^D'.
15207
15208       #autoload [ options ]
15209              Functions  with the #autoload tag are marked for autoloading but
15210              are not otherwise treated specially.  Typically they are  to  be
15211              called from within one of the completion functions.  Any options
15212              supplied will be passed to the autoload builtin; a  typical  use
15213              is +X to force the function to be loaded immediately.  Note that
15214              the -U and -z flags are always added implicitly.
15215
15216       The # is part of the tag name and no white space is allowed  after  it.
15217       The  #compdef  tags  use the compdef function described below; the main
15218       difference is that the name of the function is supplied implicitly.
15219
15220       The special contexts for which completion functions can be defined are:
15221
15222       -array-value-
15223              The right hand side of an array-assignment (`name=(...)')
15224
15225       -brace-parameter-
15226              The name of a parameter expansion within braces (`${...}')
15227
15228       -assign-parameter-
15229              The name of a parameter in an assignment, i.e. on the left  hand
15230              side of an `='
15231
15232       -command-
15233              A word in command position
15234
15235       -condition-
15236              A word inside a condition (`[[...]]')
15237
15238       -default-
15239              Any word for which no other completion is defined
15240
15241       -equal-
15242              A word beginning with an equals sign
15243
15244       -first-
15245              This  is  tried before any other completion function.  The func‐
15246              tion called may set the _compskip parameter to  one  of  various
15247              values:  all:  no further completion is attempted; a string con‐
15248              taining the substring patterns: no pattern completion  functions
15249              will  be  called;  a string containing default: the function for
15250              the `-default-' context will not be called,  but  functions  de‐
15251              fined for commands will be.
15252
15253       -math- Inside mathematical contexts, such as `((...))'
15254
15255       -parameter-
15256              The name of a parameter expansion (`$...')
15257
15258       -redirect-
15259              The word after a redirection operator.
15260
15261       -subscript-
15262              The contents of a parameter subscript.
15263
15264       -tilde-
15265              After  an initial tilde (`~'), but before the first slash in the
15266              word.
15267
15268       -value-
15269              On the right hand side of an assignment.
15270
15271       Default implementations are supplied for each of  these  contexts.   In
15272       most  cases  the  context  -context-  is implemented by a corresponding
15273       function _context, for example the context `-tilde-' and  the  function
15274       `_tilde').
15275
15276       The contexts -redirect- and -value- allow extra context-specific infor‐
15277       mation.  (Internally, this is handled by the functions for each context
15278       calling  the function _dispatch.)  The extra information is added sepa‐
15279       rated by commas.
15280
15281       For the -redirect- context, the extra information is in the form  `-re‐
15282       direct-,op,command',  where  op is the redirection operator and command
15283       is the name of the command on the line.  If there is no command on  the
15284       line yet, the command field will be empty.
15285
15286       For the -value- context, the form is `-value-,name,command', where name
15287       is the name of the parameter on the left hand side of  the  assignment.
15288       In  the  case  of  elements  of  an associative array, for example `as‐
15289       soc=(key <TAB>', name is expanded to `name-key'.   In  certain  special
15290       contexts,  such  as  completing  after `make CFLAGS=', the command part
15291       gives the name of the command, here make; otherwise it is empty.
15292
15293       It is not necessary to define fully specific completions as  the  func‐
15294       tions  provided  will  try to generate completions by progressively re‐
15295       placing the elements with `-default-'.  For  example,  when  completing
15296       after  `foo=<TAB>',  _value will try the names `-value-,foo,' (note the
15297       empty command part), `-value-,foo,-default-' and`-value-,-default-,-de‐
15298       fault-',  in  that  order, until it finds a function to handle the con‐
15299       text.
15300
15301       As an example:
15302
15303              compdef '_files -g "*.log"' '-redirect-,2>,-default-'
15304
15305       completes files matching `*.log' after `2> <TAB>' for any command  with
15306       no more specific handler defined.
15307
15308       Also:
15309
15310              compdef _foo -value-,-default-,-default-
15311
15312       specifies  that  _foo provides completions for the values of parameters
15313       for which no special function has been defined.  This is  usually  han‐
15314       dled by the function _value itself.
15315
15316       The same lookup rules are used when looking up styles (as described be‐
15317       low); for example
15318
15319              zstyle ':completion:*:*:-redirect-,2>,*:*' file-patterns '*.log'
15320
15321       is another way to make  completion  after  `2>  <TAB>'  complete  files
15322       matching `*.log'.
15323
15324   Functions
15325       The  following  function  is  defined by compinit and may be called di‐
15326       rectly.
15327
15328       compdef [ -ane ] function name ... [ -{p|P} pattern ... [ -N name ...]]
15329       compdef -d name ...
15330       compdef -k [ -an ] function style key-sequence [ key-sequence ... ]
15331       compdef -K [ -an ] function name style key-seq [ name style seq ... ]
15332              The first form defines the function to call  for  completion  in
15333              the given contexts as described for the #compdef tag above.
15334
15335              Alternatively,  all  the  arguments  may have the form `cmd=ser‐
15336              vice'.   Here  service  should  already  have  been  defined  by
15337              `cmd1=service' lines in #compdef files, as described above.  The
15338              argument for cmd will be completed in the same way as service.
15339
15340              The function argument may alternatively be a  string  containing
15341              almost  any  shell  code.  If the string contains an equal sign,
15342              the above will take precedence.  The option -e may  be  used  to
15343              specify the first argument is to be evaluated as shell code even
15344              if it contains an equal sign.  The string will be executed using
15345              the eval builtin command to generate completions.  This provides
15346              a way of avoiding having to define a  new  completion  function.
15347              For  example,  to  complete files ending in `.h' as arguments to
15348              the command foo:
15349
15350                     compdef '_files -g "*.h"' foo
15351
15352              The option -n prevents any completions already defined  for  the
15353              command or context from being overwritten.
15354
15355              The  option -d deletes any completion defined for the command or
15356              contexts listed.
15357
15358              The names may also contain -p, -P and -N  options  as  described
15359              for  the #compdef tag.  The effect on the argument list is iden‐
15360              tical, switching between  definitions  of  patterns  tried  ini‐
15361              tially,  patterns  tried  finally,  and normal commands and con‐
15362              texts.
15363
15364              The parameter $_compskip may be set by any function defined  for
15365              a  pattern context.  If it is set to a value containing the sub‐
15366              string `patterns' none of the pattern-functions will be  called;
15367              if it is set to a value containing the substring `all', no other
15368              function will be called.  Setting $_compskip in this  manner  is
15369              of particular utility when using the -p option, as otherwise the
15370              dispatcher will move on to additional functions (likely the  de‐
15371              fault one) after calling the pattern-context one, which can man‐
15372              gle the display of completion possibilities if not handled prop‐
15373              erly.
15374
15375              The  form  with  -k  defines  a widget with the same name as the
15376              function that will be called for each of the key-sequences; this
15377              is  like  the #compdef -k tag.  The function should generate the
15378              completions needed and will otherwise behave  like  the  builtin
15379              widget  whose  name is given as the style argument.  The widgets
15380              usable for this  are:  complete-word,  delete-char-or-list,  ex‐
15381              pand-or-complete,    expand-or-complete-prefix,    list-choices,
15382              menu-complete,  menu-expand-or-complete,  and  reverse-menu-com‐
15383              plete,  as  well  as  menu-select  if the zsh/complist module is
15384              loaded.  The option -n prevents the key being bound if it is al‐
15385              ready to bound to something other than undefined-key.
15386
15387              The  form  with -K is similar and defines multiple widgets based
15388              on the same function, each of which requires the  set  of  three
15389              arguments name, style and key-sequence, where the latter two are
15390              as for -k and the first must be a unique widget  name  beginning
15391              with an underscore.
15392
15393              Wherever  applicable, the -a option makes the function autoload‐
15394              able, equivalent to autoload -U function.
15395
15396       The function compdef can be used to associate existing completion func‐
15397       tions with new commands.  For example,
15398
15399              compdef _pids foo
15400
15401       uses the function _pids to complete process IDs for the command foo.
15402
15403       Note  also the _gnu_generic function described below, which can be used
15404       to complete options for commands that understand the `--help' option.
15405

COMPLETION SYSTEM CONFIGURATION

15407       This section gives a short overview of how the completion system works,
15408       and  then  more  detail on how users can configure how and when matches
15409       are generated.
15410
15411   Overview
15412       When completion is attempted somewhere on the command line the  comple‐
15413       tion system begins building the context.  The context represents every‐
15414       thing that the shell knows about the meaning of the  command  line  and
15415       the  significance of the cursor position.  This takes account of a num‐
15416       ber of things including the command word (such as `grep' or `zsh')  and
15417       options  to which the current word may be an argument (such as the `-o'
15418       option to zsh which takes a shell option as an argument).
15419
15420       The context starts out very generic ("we are beginning  a  completion")
15421       and becomes more specific as more is learned ("the current word is in a
15422       position that is usually a command name" or "the current word might  be
15423       a  variable  name"  and so on).  Therefore the context will vary during
15424       the same call to the completion system.
15425
15426       This context information is condensed into a string consisting of  mul‐
15427       tiple  fields  separated by colons, referred to simply as `the context'
15428       in the remainder of the documentation.  Note that a user of the comple‐
15429       tion  system rarely needs to compose a context string, unless for exam‐
15430       ple a new function is being written to perform  completion  for  a  new
15431       command.   What a user may need to do is compose a style pattern, which
15432       is matched against a context when needed to look  up  context-sensitive
15433       options that configure the completion system.
15434
15435       The  next  few  paragraphs explain how a context is composed within the
15436       completion function suite.  Following that is discussion of how  styles
15437       are  defined.  Styles determine such things as how the matches are gen‐
15438       erated, similarly to shell options but with much  more  control.   They
15439       are defined with the zstyle builtin command (see zshmodules(1)).
15440
15441       The  context string always consists of a fixed set of fields, separated
15442       by colons and with a leading colon before the first.  Fields which  are
15443       not yet known are left empty, but the surrounding colons appear anyway.
15444       The fields are always in the order  :completion:function:completer:com‐
15445       mand:argument:tag.  These have the following meaning:
15446
15447       •      The literal string completion, saying that this style is used by
15448              the completion system.   This  distinguishes  the  context  from
15449              those used by, for example, zle widgets and ZFTP functions.
15450
15451
15452       •      The function, if completion is called from a named widget rather
15453              than through the normal completion system.   Typically  this  is
15454              blank,  but  it is set by special widgets such as predict-on and
15455              the various functions in the Widget directory of  the  distribu‐
15456              tion to the name of that function, often in an abbreviated form.
15457
15458
15459       •      The completer currently active, the name of the function without
15460              the leading underscore and with other underscores  converted  to
15461              hyphens.   A `completer' is in overall control of how completion
15462              is to be performed; `complete' is the simplest, but  other  com‐
15463              pleters exist to perform related tasks such as correction, or to
15464              modify the behaviour of a  later  completer.   See  the  section
15465              `Control Functions' below for more information.
15466
15467
15468       •      The command or a special -context-, just at it appears following
15469              the #compdef tag or the compdef function.  Completion  functions
15470              for commands that have sub-commands usually modify this field to
15471              contain the name of the command followed by a minus sign and the
15472              sub-command.   For  example, the completion function for the cvs
15473              command sets this field to cvs-add when completing arguments  to
15474              the add subcommand.
15475
15476
15477       •      The  argument; this indicates which command line or option argu‐
15478              ment we are completing.  For command  arguments  this  generally
15479              takes  the  form  argument-n, where n is the number of the argu‐
15480              ment, and for arguments to options the form option-opt-n where n
15481              is  the  number of the argument to option opt.  However, this is
15482              only the case if  the  command  line  is  parsed  with  standard
15483              UNIX-style options and arguments, so many completions do not set
15484              this.
15485
15486
15487       •      The tag.  As described previously, tags are used to discriminate
15488              between  the types of matches a completion function can generate
15489              in a certain context.  Any completion function may use  any  tag
15490              name  it  likes, but a list of the more common ones is given be‐
15491              low.
15492
15493
15494       The context is gradually put together as the  functions  are  executed,
15495       starting  with  the  main  entry point, which adds :completion: and the
15496       function element if necessary.  The completer then adds  the  completer
15497       element.   The  contextual completion adds the command and argument op‐
15498       tions.  Finally, the tag is added when  the  types  of  completion  are
15499       known.  For example, the context name
15500
15501              :completion::complete:dvips:option-o-1:files
15502
15503       says  that normal completion was attempted as the first argument to the
15504       option -o of the command dvips:
15505
15506              dvips -o ...
15507
15508       and the completion function will generate filenames.
15509
15510       Usually completion will be tried for all  possible  tags  in  an  order
15511       given  by the completion function.  However, this can be altered by us‐
15512       ing the tag-order style.  Completion is then restricted to the list  of
15513       given tags in the given order.
15514
15515       The  _complete_help  bindable  command  shows all the contexts and tags
15516       available for completion at a particular point.  This provides an  easy
15517       way  of  finding information for tag-order and other styles.  It is de‐
15518       scribed in the section `Bindable Commands' below.
15519
15520       When looking up styles the completion system uses full  context  names,
15521       including  the tag.  Looking up the value of a style therefore consists
15522       of two things: the context, which is matched to the most specific (best
15523       fitting) style pattern, and the name of the style itself, which must be
15524       matched exactly.  The following examples demonstrate  that  style  pat‐
15525       terns  may  be  loosely  defined  for  styles that apply broadly, or as
15526       tightly defined as desired for styles that apply  in  narrower  circum‐
15527       stances.
15528
15529       For example, many completion functions can generate matches in a simple
15530       and a verbose form and use the  verbose  style  to  decide  which  form
15531       should be used.  To make all such functions use the verbose form, put
15532
15533              zstyle ':completion:*' verbose yes
15534
15535       in  a startup file (probably .zshrc).  This gives the verbose style the
15536       value yes in every context inside the completion  system,  unless  that
15537       context has a more specific definition.  It is best to avoid giving the
15538       context as `*' in case the style has some meaning outside  the  comple‐
15539       tion system.
15540
15541       Many  such general purpose styles can be configured simply by using the
15542       compinstall function.
15543
15544       A more specific example of the use of the verbose style is by the  com‐
15545       pletion  for  the kill builtin.  If the style is set, the builtin lists
15546       full job texts and process command lines; otherwise it shows  the  bare
15547       job numbers and PIDs.  To turn the style off for this use only:
15548
15549              zstyle ':completion:*:*:kill:*:*' verbose no
15550
15551       For  even  more  control,  the  style can use one of the tags `jobs' or
15552       `processes'.  To turn off verbose display only for jobs:
15553
15554              zstyle ':completion:*:*:kill:*:jobs' verbose no
15555
15556       The -e option to zstyle even allows completion function code to  appear
15557       as the argument to a style; this requires some understanding of the in‐
15558       ternals of completion functions (see see zshcompwid(1))).  For example,
15559
15560              zstyle -e ':completion:*' hosts 'reply=($myhosts)'
15561
15562       This forces the value of the hosts style to be read from  the  variable
15563       myhosts each time a host name is needed; this is useful if the value of
15564       myhosts can change dynamically.  For another useful  example,  see  the
15565       example in the description of the file-list style below.  This form can
15566       be slow and should be avoided for commonly examined styles such as menu
15567       and list-rows-first.
15568
15569       Note  that  the  order in which styles are defined does not matter; the
15570       style mechanism uses the most specific possible match for a  particular
15571       style to determine the set of values.  More precisely, strings are pre‐
15572       ferred over patterns  (for  example,  `:completion::complete:::foo'  is
15573       more  specific  than  `:completion::complete:::*'), and longer patterns
15574       are preferred over shorter patterns.
15575
15576       A good rule of thumb is that any completion style pattern that needs to
15577       include more than one wildcard (*) and that does not end in a tag name,
15578       should include all six  colons  (:),  possibly  surrounding  additional
15579       wildcards.
15580
15581       Style  names like those of tags are arbitrary and depend on the comple‐
15582       tion function.  However, the following two sections list  some  of  the
15583       most common tags and styles.
15584
15585   Standard Tags
15586       Some  of  the following are only used when looking up particular styles
15587       and do not refer to a type of match.
15588
15589       accounts
15590              used to look up the users-hosts style
15591
15592       all-expansions
15593              used by the _expand completer when adding the single string con‐
15594              taining all possible expansions
15595
15596       all-files
15597              for  the  names of all files (as distinct from a particular sub‐
15598              set, see the globbed-files tag).
15599
15600       arguments
15601              for arguments to a command
15602
15603       arrays for names of array parameters
15604
15605       association-keys
15606              for keys of associative arrays; used when  completing  inside  a
15607              subscript to a parameter of this type
15608
15609       bookmarks
15610              when  completing  bookmarks (e.g. for URLs and the zftp function
15611              suite)
15612
15613       builtins
15614              for names of builtin commands
15615
15616       characters
15617              for single characters in arguments of  commands  such  as  stty.
15618              Also  used  when  completing  character classes after an opening
15619              bracket
15620
15621       colormapids
15622              for X colormap ids
15623
15624       colors for color names
15625
15626       commands
15627              for names of external commands.  Also used by  complex  commands
15628              such as cvs when completing names subcommands.
15629
15630       contexts
15631              for contexts in arguments to the zstyle builtin command
15632
15633       corrections
15634              used  by  the  _approximate and _correct completers for possible
15635              corrections
15636
15637       cursors
15638              for cursor names used by X programs
15639
15640       default
15641              used in some contexts to provide a way of  supplying  a  default
15642              when  more  specific tags are also valid.  Note that this tag is
15643              used when only the function field of the context name is set
15644
15645       descriptions
15646              used when looking up the value of the format style  to  generate
15647              descriptions for types of matches
15648
15649       devices
15650              for names of device special files
15651
15652       directories
15653              for  names  of  directories -- local-directories is used instead
15654              when completing arguments of cd  and  related  builtin  commands
15655              when the cdpath array is set
15656
15657       directory-stack
15658              for entries in the directory stack
15659
15660       displays
15661              for X display names
15662
15663       domains
15664              for network domains
15665
15666       email-plugin
15667              for   email   addresses  from  the  `_email-plugin'  backend  of
15668              _email_addresses
15669
15670       expansions
15671              used by the _expand completer for individual words  (as  opposed
15672              to  the complete set of expansions) resulting from the expansion
15673              of a word on the command line
15674
15675       extensions
15676              for X server extensions
15677
15678       file-descriptors
15679              for numbers of open file descriptors
15680
15681       files  the generic file-matching tag used by functions completing file‐
15682              names
15683
15684       fonts  for X font names
15685
15686       fstypes
15687              for file system types (e.g. for the mount command)
15688
15689       functions
15690              names of functions -- normally shell functions, although certain
15691              commands may understand other kinds of function
15692
15693       globbed-files
15694              for filenames when the name has been generated by pattern match‐
15695              ing
15696
15697       groups for names of user groups
15698
15699       history-words
15700              for words from the history
15701
15702       hosts  for hostnames
15703
15704       indexes
15705              for array indexes
15706
15707       jobs   for jobs (as listed by the `jobs' builtin)
15708
15709       interfaces
15710              for network interfaces
15711
15712       keymaps
15713              for names of zsh keymaps
15714
15715       keysyms
15716              for names of X keysyms
15717
15718       libraries
15719              for names of system libraries
15720
15721       limits for system limits
15722
15723       local-directories
15724              for  names of directories that are subdirectories of the current
15725              working directory when completing arguments of  cd  and  related
15726              builtin  commands  (compare path-directories) -- when the cdpath
15727              array is unset, directories is used instead
15728
15729       manuals
15730              for names of manual pages
15731
15732       mailboxes
15733              for e-mail folders
15734
15735       maps   for map names (e.g. NIS maps)
15736
15737       messages
15738              used to look up the format style for messages
15739
15740       modifiers
15741              for names of X modifiers
15742
15743       modules
15744              for modules (e.g. zsh modules)
15745
15746       my-accounts
15747              used to look up the users-hosts style
15748
15749       named-directories
15750              for named directories (you wouldn't  have  guessed  that,  would
15751              you?)
15752
15753       names  for all kinds of names
15754
15755       newsgroups
15756              for USENET groups
15757
15758       nicknames
15759              for nicknames of NIS maps
15760
15761       options
15762              for command options
15763
15764       original
15765              used  by  the _approximate, _correct and _expand completers when
15766              offering the original string as a match
15767
15768       other-accounts
15769              used to look up the users-hosts style
15770
15771       other-files
15772              for the names of any non-directory files.  This is used  instead
15773              of all-files when the list-dirs-first style is in effect.
15774
15775       packages
15776              for packages (e.g. rpm or installed Debian packages)
15777
15778       parameters
15779              for names of parameters
15780
15781       path-directories
15782              for  names  of  directories  found by searching the cdpath array
15783              when completing arguments of cd  and  related  builtin  commands
15784              (compare local-directories)
15785
15786       paths  used  to  look  up  the values of the expand, ambiguous and spe‐
15787              cial-dirs styles
15788
15789       pods   for perl pods (documentation files)
15790
15791       ports  for communication ports
15792
15793       prefixes
15794              for prefixes (like those of a URL)
15795
15796       printers
15797              for print queue names
15798
15799       processes
15800              for process identifiers
15801
15802       processes-names
15803              used to look up the command style when generating the  names  of
15804              processes for killall
15805
15806       sequences
15807              for sequences (e.g. mh sequences)
15808
15809       sessions
15810              for sessions in the zftp function suite
15811
15812       signals
15813              for signal names
15814
15815       strings
15816              for  strings  (e.g.  the  replacement strings for the cd builtin
15817              command)
15818
15819       styles for styles used by the zstyle builtin command
15820
15821       suffixes
15822              for filename extensions
15823
15824       tags   for tags (e.g. rpm tags)
15825
15826       targets
15827              for makefile targets
15828
15829       time-zones
15830              for time zones (e.g. when setting the TZ parameter)
15831
15832       types  for types of whatever (e.g. address types for the xhost command)
15833
15834       urls   used to look up the urls and local styles when completing URLs
15835
15836       users  for usernames
15837
15838       values for one of a set of values in certain lists
15839
15840       variant
15841              used by _pick_variant to look up the command to run when  deter‐
15842              mining what program is installed for a particular command name.
15843
15844       visuals
15845              for X visuals
15846
15847       warnings
15848              used to look up the format style for warnings
15849
15850       widgets
15851              for zsh widget names
15852
15853       windows
15854              for IDs of X windows
15855
15856       zsh-options
15857              for shell options
15858
15859   Standard Styles
15860       Note  that the values of several of these styles represent boolean val‐
15861       ues.  Any of the strings `true', `on', `yes', and `1' can be  used  for
15862       the  value  `true' and any of the strings `false', `off', `no', and `0'
15863       for the value `false'.  The behavior for any other value  is  undefined
15864       except  where  explicitly  mentioned.   The default value may be either
15865       `true' or `false' if the style is not set.
15866
15867       Some of these styles are tested first for  every  possible  tag  corre‐
15868       sponding to a type of match, and if no style was found, for the default
15869       tag.  The most notable styles of this type are  menu,  list-colors  and
15870       styles   controlling   completion   listing  such  as  list-packed  and
15871       last-prompt.  When tested for the default tag, only the function  field
15872       of  the  context will be set so that a style using the default tag will
15873       normally be defined along the lines of:
15874
15875              zstyle ':completion:*:default' menu ...
15876
15877       accept-exact
15878              This is tested for the default tag in addition to the tags valid
15879              for  the current context.  If it is set to `true' and any of the
15880              trial matches is the same as the string  on  the  command  line,
15881              this match will immediately be accepted (even if it would other‐
15882              wise be considered ambiguous).
15883
15884              When completing pathnames (where the tag used is  `paths')  this
15885              style accepts any number of patterns as the value in addition to
15886              the boolean values.  Pathnames matching one  of  these  patterns
15887              will  be  accepted immediately even if the command line contains
15888              some more partially typed pathname components and these match no
15889              file under the directory accepted.
15890
15891              This  style  is  also used by the _expand completer to decide if
15892              words beginning with a tilde or parameter  expansion  should  be
15893              expanded.   For example, if there are parameters foo and foobar,
15894              the string `$foo' will only be expanded if accept-exact  is  set
15895              to  `true';  otherwise  the completion system will be allowed to
15896              complete $foo to $foobar. If the style  is  set  to  `continue',
15897              _expand  will  add  the  expansion as a match and the completion
15898              system will also be allowed to continue.
15899
15900       accept-exact-dirs
15901              This is used by filename completion.  Unlike accept-exact it  is
15902              a  boolean.  By default, filename completion examines all compo‐
15903              nents of a path to see if there are completions of  that  compo‐
15904              nent,  even if the component matches an existing directory.  For
15905              example, when completion after /usr/bin/, the function  examines
15906              possible completions to /usr.
15907
15908              When  this style is `true', any prefix of a path that matches an
15909              existing directory is accepted without any attempt  to  complete
15910              it  further.  Hence, in the given example, the path /usr/bin/ is
15911              accepted immediately and completion tried in that directory.
15912
15913              This style is also useful when completing after directories that
15914              magically  appear  when referenced, such as ZFS .zfs directories
15915              or NetApp .snapshot directories.  When  the  style  is  set  the
15916              shell  does  not check for the existence of the directory within
15917              the parent directory.
15918
15919              If  you  wish  to  inhibit  this  behaviour  entirely,  set  the
15920              path-completion style (see below) to `false'.
15921
15922       add-space
15923              This  style  is  used by the _expand completer.  If it is `true'
15924              (the default), a space will be inserted after all words  result‐
15925              ing  from  the  expansion,  or  a slash in the case of directory
15926              names.  If the value is `file', the completer will  only  add  a
15927              space  to  names  of existing files.  Either a boolean `true' or
15928              the value `file' may be combined with `subst', in which case the
15929              completer  will  not add a space to words generated from the ex‐
15930              pansion of a substitution of the form `$(...)' or `${...}'.
15931
15932              The _prefix completer uses this style as a simple boolean  value
15933              to decide if a space should be inserted before the suffix.
15934
15935       ambiguous
15936              This  applies  when  completing non-final components of filename
15937              paths, in other words those with a trailing  slash.   If  it  is
15938              set,  the  cursor  is  left after the first ambiguous component,
15939              even if menu completion is in use.  The style is  always  tested
15940              with the paths tag.
15941
15942       assign-list
15943              When completing after an equals sign that is being treated as an
15944              assignment, the completion system normally  completes  only  one
15945              filename.   In  some cases the value  may be a list of filenames
15946              separated by colons, as with PATH and similar parameters.   This
15947              style  can  be  set  to a list of patterns matching the names of
15948              such parameters.
15949
15950              The default is to complete lists when the word on the  line  al‐
15951              ready contains a colon.
15952
15953       auto-description
15954              If  set,  this style's value will be used as the description for
15955              options that are not described by the completion functions,  but
15956              that  have exactly one argument.  The sequence `%d' in the value
15957              will be replaced by the description for this argument.   Depend‐
15958              ing  on personal preferences, it may be useful to set this style
15959              to something like `specify: %d'.  Note that this  may  not  work
15960              for some commands.
15961
15962       avoid-completer
15963              This  is  used  by  the  _all_matches completer to decide if the
15964              string consisting of all matches should be  added  to  the  list
15965              currently being generated.  Its value is a list of names of com‐
15966              pleters.  If any of these is the name of the completer that gen‐
15967              erated  the  matches  in this completion, the string will not be
15968              added.
15969
15970              The default value for this style is `_expand _old_list  _correct
15971              _approximate',  i.e.  it  contains  the  completers  for which a
15972              string with all matches will almost never be wanted.
15973
15974       cache-path
15975              This style defines the path where  any  cache  files  containing
15976              dumped  completion  data  are  stored.   It  defaults to `$ZDOT‐
15977              DIR/.zcompcache', or `$HOME/.zcompcache' if $ZDOTDIR is not  de‐
15978              fined.   The  completion  cache  will  not  be  used  unless the
15979              use-cache style is set.
15980
15981       cache-policy
15982              This style defines the function that will be used  to  determine
15983              whether  a  cache  needs  rebuilding.   See  the  section on the
15984              _cache_invalid function below.
15985
15986       call-command
15987              This style is used in the function for commands such as make and
15988              ant  where calling the command directly to generate matches suf‐
15989              fers problems such as being slow or, as in the case of make  can
15990              potentially  cause actions in the makefile to be executed. If it
15991              is set to `true' the command is called to generate matches.  The
15992              default value of this style is `false'.
15993
15994       command
15995              In  many places, completion functions need to call external com‐
15996              mands to generate the list of completions.  This  style  can  be
15997              used  to override the command that is called in some such cases.
15998              The elements of the value are joined with spaces to form a  com‐
15999              mand  line  to execute.  The value can also start with a hyphen,
16000              in which case the usual command will be added to the  end;  this
16001              is  most  useful  for putting `builtin' or `command' in front to
16002              make sure the appropriate version of a command  is  called,  for
16003              example  to avoid calling a shell function with the same name as
16004              an external command.
16005
16006              As an example, the completion function for process IDs uses this
16007              style with the processes tag to generate the IDs to complete and
16008              the list of processes  to  display  (if  the  verbose  style  is
16009              `true').   The list produced by the command should look like the
16010              output of the ps command.  The first line is not displayed,  but
16011              is searched for the string `PID' (or `pid') to find the position
16012              of the process IDs in the following lines.  If the line does not
16013              contain  `PID', the first numbers in each of the other lines are
16014              taken as the process IDs to complete.
16015
16016              Note that the completion function  generally  has  to  call  the
16017              specified  command  for  each attempt to generate the completion
16018              list.  Hence care should be taken to specify only commands  that
16019              take  a  short  time to run, and in particular to avoid any that
16020              may never terminate.
16021
16022       command-path
16023              This is a list of directories to search  for  commands  to  com‐
16024              plete.   The  default for this style is the value of the special
16025              parameter path.
16026
16027       commands
16028              This is used by the function  completing  sub-commands  for  the
16029              system  initialisation scripts (residing in /etc/init.d or some‐
16030              where not too far away from that).  Its values give the  default
16031              commands to complete for those commands for which the completion
16032              function isn't able to find them out automatically.  The default
16033              for this style are the two strings `start' and `stop'.
16034
16035       complete
16036              This  is  used  by  the _expand_alias function when invoked as a
16037              bindable command.  If set to `true' and the word on the  command
16038              line  is  not the name of an alias, matching alias names will be
16039              completed.
16040
16041       complete-options
16042              This is used by the completer for  cd,  chdir  and  pushd.   For
16043              these  commands a - is used to introduce a directory stack entry
16044              and completion of these is far more common than  completing  op‐
16045              tions.   Hence  unless the value of this style is `true' options
16046              will not be completed, even  after  an  initial  -.   If  it  is
16047              `true',  options  will  be  completed  after an initial - unless
16048              there is a preceding -- on the command line.
16049
16050       completer
16051              The strings given as the value of this style provide  the  names
16052              of the completer functions to use. The available completer func‐
16053              tions are described in the section `Control Functions' below.
16054
16055              Each string may be either the name of a completer function or  a
16056              string  of the form `function:name'.  In the first case the com‐
16057              pleter field of the context will contain the name  of  the  com‐
16058              pleter  without the leading underscore and with all other under‐
16059              scores replaced by hyphens.  In the second case the function  is
16060              the  name of the completer to call, but the context will contain
16061              the user-defined name in the completer field of the context.  If
16062              the  name  starts with a hyphen, the string for the context will
16063              be build from the name of the completer function as in the first
16064              case with the name appended to it.  For example:
16065
16066                     zstyle ':completion:*' completer _complete _complete:-foo
16067
16068              Here,  completion  will call the _complete completer twice, once
16069              using `complete' and once using `complete-foo' in the  completer
16070              field  of  the context.  Normally, using the same completer more
16071              than once only makes sense when used with  the  `functions:name'
16072              form, because otherwise the context name will be the same in all
16073              calls to the completer; possible exceptions to this rule are the
16074              _ignored and _prefix completers.
16075
16076              The  default  value for this style is `_complete _ignored': only
16077              completion will be done, first using the ignored-patterns  style
16078              and the $fignore array and then without ignoring matches.
16079
16080       condition
16081              This  style is used by the _list completer function to decide if
16082              insertion of matches should be delayed unconditionally. The  de‐
16083              fault is `true'.
16084
16085       delimiters
16086              This  style is used when adding a delimiter for use with history
16087              modifiers or glob qualifiers that have delimited arguments.   It
16088              is an array of preferred delimiters to add.  Non-special charac‐
16089              ters are preferred as the completion system may otherwise become
16090              confused.   The  default list is :, +, /, -, %.  The list may be
16091              empty to force a delimiter to be typed.
16092
16093       disabled
16094              If this is set to `true', the _expand_alias completer and  bind‐
16095              able  command will try to expand disabled aliases, too.  The de‐
16096              fault is `false'.
16097
16098       domains
16099              A list of names of network domains for completion.  If  this  is
16100              not  set,  domain  names  will  be  taken from the file /etc/re‐
16101              solv.conf.
16102
16103       environ
16104              The environ style is used when completing for `sudo'.  It is set
16105              to  an  array of `VAR=value' assignments to be exported into the
16106              local environment before the completion for the  target  command
16107              is invoked.
16108              zstyle ':completion:*:sudo::' environ \
16109                PATH="/sbin:/usr/sbin:$PATH" HOME="/root"
16110
16111       expand This  style is used when completing strings consisting of multi‐
16112              ple parts, such as path names.
16113
16114              If one of its values is the string `prefix', the partially typed
16115              word  from  the line will be expanded as far as possible even if
16116              trailing parts cannot be completed.
16117
16118              If one of its values is the string `suffix', matching names  for
16119              components  after  the  first  ambiguous one will also be added.
16120              This means that the resulting string is the longest  unambiguous
16121              string  possible.  However, menu completion can be used to cycle
16122              through all matches.
16123
16124       fake   This style may be set for any completion context.  It  specifies
16125              additional  strings  that  will always be completed in that con‐
16126              text.  The form of each string is `value:description'; the colon
16127              and  description may be omitted, but any literal colons in value
16128              must be quoted with a backslash.  Any  description  provided  is
16129              shown alongside the value in completion listings.
16130
16131              It  is  important to use a sufficiently restrictive context when
16132              specifying fake strings.  Note that the  styles  fake-files  and
16133              fake-parameters  provide  additional  features  when  completing
16134              files or parameters.
16135
16136       fake-always
16137              This works identically to the fake style  except  that  the  ig‐
16138              nored-patterns style is not applied to it.  This makes it possi‐
16139              ble to override a set of matches completely by setting  the  ig‐
16140              nored patterns to `*'.
16141
16142              The  following  shows  a way of supplementing any tag with arbi‐
16143              trary data, but having it behave for  display  purposes  like  a
16144              separate  tag.   In  this  example  we  use  the features of the
16145              tag-order style to divide the  named-directories  tag  into  two
16146              when  performing completion with the standard completer complete
16147              for arguments of cd.  The tag  named-directories-normal  behaves
16148              as  normal,  but the tag named-directories-mine contains a fixed
16149              set of directories.  This has the effect  of  adding  the  match
16150              group `extra directories' with the given completions.
16151
16152                     zstyle ':completion::complete:cd:*' tag-order \
16153                       'named-directories:-mine:extra\ directories
16154                       named-directories:-normal:named\ directories *'
16155                     zstyle ':completion::complete:cd:*:named-directories-mine' \
16156                       fake-always mydir1 mydir2
16157                     zstyle ':completion::complete:cd:*:named-directories-mine' \
16158                       ignored-patterns '*'
16159
16160       fake-files
16161              This style is used when completing files and looked up without a
16162              tag.  Its values are of the form `dir:names...'.  This will  add
16163              the names (strings separated by spaces) as possible matches when
16164              completing in the directory dir, even if no  such  files  really
16165              exist.   The  dir may be a pattern; pattern characters or colons
16166              in dir should be quoted with a backslash to  be  treated  liter‐
16167              ally.
16168
16169              This  can be useful on systems that support special file systems
16170              whose top-level pathnames can not be listed  or  generated  with
16171              glob  patterns (but see accept-exact-dirs for a more general way
16172              of dealing with this problem).  It can also be used for directo‐
16173              ries for which one does not have read permission.
16174
16175              The  pattern  form can be used to add a certain `magic' entry to
16176              all directories on a particular file system.
16177
16178       fake-parameters
16179              This is used by the completion  function  for  parameter  names.
16180              Its values are names of parameters that might not yet be set but
16181              should be completed nonetheless.  Each name may also be followed
16182              by  a  colon  and  a string specifying the type of the parameter
16183              (like `scalar', `array' or `integer').  If the  type  is  given,
16184              the  name  will only be completed if parameters of that type are
16185              required in the particular context.  Names for which no type  is
16186              specified will always be completed.
16187
16188       file-list
16189              This  style  controls whether files completed using the standard
16190              builtin mechanism are to be listed with a long list  similar  to
16191              ls  -l.   Note  that this feature uses the shell module zsh/stat
16192              for file information; this loads the builtin stat which will re‐
16193              place any external stat executable.  To avoid this the following
16194              code can be included in an initialization file:
16195
16196                     zmodload -i zsh/stat
16197                     disable stat
16198
16199              The style may either be set to a `true' value (or `all'), or one
16200              of  the  values `insert' or `list', indicating that files are to
16201              be listed in long format in all circumstances, or when  attempt‐
16202              ing  to  insert  a file name, or when listing file names without
16203              attempting to insert one.
16204
16205              More generally, the value may be an array of any  of  the  above
16206              values, optionally followed by =num.  If num is present it gives
16207              the maximum number of matches for which long listing style  will
16208              be used.  For example,
16209
16210                     zstyle ':completion:*' file-list list=20 insert=10
16211
16212              specifies  that  long  format will be used when listing up to 20
16213              files or inserting a file with up  to  10  matches  (assuming  a
16214              listing  is to be shown at all, for example on an ambiguous com‐
16215              pletion), else short format will be used.
16216
16217                     zstyle -e ':completion:*' file-list \
16218                            '(( ${+NUMERIC} )) && reply=(true)'
16219
16220              specifies that long format will be used any time a numeric argu‐
16221              ment is supplied, else short format.
16222
16223       file-patterns
16224              This  is used by the standard function for completing filenames,
16225              _files.  If the style is unset up to  three  tags  are  offered,
16226              `globbed-files',`directories'  and `all-files', depending on the
16227              types of files  expected by the caller of _files.  The first two
16228              (`globbed-files'  and  `directories')  are  normally offered to‐
16229              gether to make it easier to complete files in sub-directories.
16230
16231              The file-patterns style provides  alternatives  to  the  default
16232              tags, which are not used.  Its value consists of elements of the
16233              form `pattern:tag'; each string may contain any number  of  such
16234              specifications separated by spaces.
16235
16236              The  pattern  is  a pattern that is to be used to generate file‐
16237              names.  Any occurrence of the sequence `%p' is replaced  by  any
16238              pattern(s) passed by the function calling _files.  Colons in the
16239              pattern must be preceded by a backslash  to  make  them  distin‐
16240              guishable  from the colon before the tag.  If more than one pat‐
16241              tern is needed, the patterns can be given inside  braces,  sepa‐
16242              rated by commas.
16243
16244              The  tags  of all strings in the value will be offered by _files
16245              and used when looking up other styles.  Any  tags  in  the  same
16246              word  will  be  offered at the same time and before later words.
16247              If no `:tag' is given the `files' tag will be used.
16248
16249              The tag may also be followed by an optional second colon  and  a
16250              description, which will be used for the `%d' in the value of the
16251              format style (if that is set) instead of the default description
16252              supplied  by  the completion function.  If the description given
16253              here contains itself a `%d', that is replaced with the  descrip‐
16254              tion supplied by the completion function.
16255
16256              For example, to make the rm command first complete only names of
16257              object files and then the names of all  files  if  there  is  no
16258              matching object file:
16259
16260                     zstyle ':completion:*:*:rm:*:*' file-patterns \
16261                         '*.o:object-files' '%p:all-files'
16262
16263              To alter the default behaviour of file completion -- offer files
16264              matching a pattern and directories on the  first  attempt,  then
16265              all  files -- to offer only matching files on the first attempt,
16266              then directories, and finally all files:
16267
16268                     zstyle ':completion:*' file-patterns \
16269                         '%p:globbed-files' '*(-/):directories' '*:all-files'
16270
16271              This works even  where  there  is  no  special  pattern:  _files
16272              matches  all  files  using the pattern `*' at the first step and
16273              stops when it sees this pattern.  Note also it will never try  a
16274              pattern more than once for a single completion attempt.
16275
16276              During  the execution of completion functions, the EXTENDED_GLOB
16277              option is in effect, so the characters `#',  `~'  and  `^'  have
16278              special meanings in the patterns.
16279
16280       file-sort
16281              The  standard filename completion function uses this style with‐
16282              out a tag to determine  in  which  order  the  names  should  be
16283              listed;  menu completion will cycle through them in the same or‐
16284              der.  The possible values are: `size' to sort by the size of the
16285              file; `links' to sort by the number of links to the file; `modi‐
16286              fication' (or `time' or `date') to sort by the last modification
16287              time;  `access' to sort by the last access time; and `inode' (or
16288              `change') to sort by the last inode change time.  If  the  style
16289              is set to any other value, or is unset, files will be sorted al‐
16290              phabetically by name.  If the value  contains  the  string  `re‐
16291              verse',  sorting  is  done  in the opposite order.  If the value
16292              contains the string `follow', timestamps are associated with the
16293              targets  of symbolic links; the default is to use the timestamps
16294              of the links themselves.
16295
16296       file-split-chars
16297              A set of characters that will cause all file completions for the
16298              given  context to be split at the point where any of the charac‐
16299              ters occurs.  A typical use is to set the style to :;  then  ev‐
16300              erything  up to and including the last : in the string so far is
16301              ignored when completing files.  As this is  quite  heavy-handed,
16302              it is usually preferable to update completion functions for con‐
16303              texts where this behaviour is useful.
16304
16305       filter The ldap plugin of  email  address  completion  (see  _email_ad‐
16306              dresses)  uses  this  style  to  specify the attributes to match
16307              against when filtering entries.  So for example, if the style is
16308              set  to  `sn', matching is done against surnames.  Standard LDAP
16309              filtering is used so normal completion matching is bypassed.  If
16310              this style is not set, the LDAP plugin is skipped.  You may also
16311              need to set the command style to specify how to connect to  your
16312              LDAP server.
16313
16314       force-list
16315              This forces a list of completions to be shown at any point where
16316              listing is done, even in cases where the list would  usually  be
16317              suppressed.   For  example,  normally  the list is only shown if
16318              there are at least two different matches.  By setting this style
16319              to  `always',  the  list  will always be shown, even if there is
16320              only a single match that  will  immediately  be  accepted.   The
16321              style  may  also be set to a number.  In this case the list will
16322              be shown if there are at least that many matches, even  if  they
16323              would all insert the same string.
16324
16325              This style is tested for the default tag as well as for each tag
16326              valid for the current completion.   Hence  the  listing  can  be
16327              forced only for certain types of match.
16328
16329       format If  this is set for the descriptions tag, its value is used as a
16330              string to display above matches in completion  lists.   The  se‐
16331              quence  `%d'  in  this  string will be replaced with a short de‐
16332              scription of what these matches are.  This string may also  con‐
16333              tain  the  output  attribute  sequences understood by compadd -X
16334              (see zshcompwid(1)).
16335
16336              The style is tested with each tag valid for the current  comple‐
16337              tion  before  it is tested for the descriptions tag.  Hence dif‐
16338              ferent format strings can be  defined  for  different  types  of
16339              match.
16340
16341              Note  also  that  some  completer  functions  define  additional
16342              `%'-sequences.  These are described for the completer  functions
16343              that make use of them.
16344
16345              Some  completion  functions  display  messages  that may be cus‐
16346              tomised by setting this style for the messages tag.   Here,  the
16347              `%d'  is  replaced  with a message given by the completion func‐
16348              tion.
16349
16350              Finally, the format string is looked up with the  warnings  tag,
16351              for use when no matches could be generated at all.  In this case
16352              the `%d' is replaced with the descriptions for the matches  that
16353              were  expected  separated  by  spaces.  The sequence `%D' is re‐
16354              placed with the same descriptions separated by newlines.
16355
16356              It is possible to use printf-style field width  specifiers  with
16357              `%d' and similar escape sequences.  This is handled by the zfor‐
16358              mat builtin command  from  the  zsh/zutil  module,  see  zshmod‐
16359              ules(1).
16360
16361       glob   This  is  used by the _expand completer.  If it is set to `true'
16362              (the default), globbing will be attempted on the words resulting
16363              from  a previous substitution (see the substitute style) or else
16364              the original string from the line.
16365
16366       global If this is set to `true' (the default), the  _expand_alias  com‐
16367              pleter and bindable command will try to expand global aliases.
16368
16369       group-name
16370              The  completion  system  can  group  different types of matches,
16371              which appear in separate lists.  This style can be used to  give
16372              the  names  of groups for particular tags.  For example, in com‐
16373              mand position the completion system generates names  of  builtin
16374              and external commands, names of aliases, shell functions and pa‐
16375              rameters and reserved words as possible  completions.   To  have
16376              the external commands and shell functions listed separately:
16377
16378                     zstyle ':completion:*:*:-command-:*:commands' \
16379                            group-name commands
16380                     zstyle ':completion:*:*:-command-:*:functions' \
16381                            group-name functions
16382
16383              As  a consequence, any match with the same tag will be displayed
16384              in the same group.
16385
16386              If the name given is the empty string the name of  the  tag  for
16387              the  matches will be used as the name of the group.  So, to have
16388              all different types of matches  displayed  separately,  one  can
16389              just set:
16390
16391                     zstyle ':completion:*' group-name ''
16392
16393              All  matches for which no group name is defined will be put in a
16394              group named -default-.
16395
16396       group-order
16397              This style is additional to the group-name style to specify  the
16398              order  for  display of the groups defined by that style (compare
16399              tag-order, which determines which completions  appear  at  all).
16400              The  groups named are shown in the given order; any other groups
16401              are shown in the order defined by the completion function.
16402
16403              For example, to have names of builtin commands, shell  functions
16404              and  external  commands  appear in that order when completing in
16405              command position:
16406
16407                     zstyle ':completion:*:*:-command-:*:*' group-order \
16408                            builtins functions commands
16409
16410       groups A list of names of UNIX groups.  If this is not set, group names
16411              are taken from the YP database or the file `/etc/group'.
16412
16413       hidden If this is set to `true', matches for the given context will not
16414              be listed, although any description for the matches set with the
16415              format style will be shown.  If it is set to `all', not even the
16416              description will be displayed.
16417
16418              Note that the matches will still be completed; they are just not
16419              shown in the list.  To avoid having matches considered as possi‐
16420              ble completions at all, the tag-order style can be  modified  as
16421              described below.
16422
16423       hosts  A  list  of names of hosts that should be completed.  If this is
16424              not set, hostnames are taken from the file `/etc/hosts'.
16425
16426       hosts-ports
16427              This style is used by commands that need or accept hostnames and
16428              network  ports.   The strings in the value should be of the form
16429              `host:port'.  Valid ports are  determined  by  the  presence  of
16430              hostnames; multiple ports for the same host may appear.
16431
16432       ignore-line
16433              This  is  tested  for each tag valid for the current completion.
16434              If it is set to `true', none of the words that  are  already  on
16435              the  line  will be considered as possible completions.  If it is
16436              set to `current', the word the cursor is on will not be  consid‐
16437              ered  as  a  possible  completion.  The value `current-shown' is
16438              similar but only applies if the list of completions is currently
16439              shown  on  the screen.  Finally, if the style is set to `other',
16440              all words on the line except for the current  one  will  be  ex‐
16441              cluded from the possible completions.
16442
16443              The  values `current' and `current-shown' are a bit like the op‐
16444              posite of the accept-exact style:   only  strings  with  missing
16445              characters will be completed.
16446
16447              Note  that you almost certainly don't want to set this to `true'
16448              or `other' for a general context such as `:completion:*'.   This
16449              is because it would disallow completion of, for example, options
16450              multiple times even if the command in question accepts  the  op‐
16451              tion more than once.
16452
16453       ignore-parents
16454              The  style  is  tested  without a tag by the function completing
16455              pathnames in order to determine whether to ignore the  names  of
16456              directories  already  mentioned in the current word, or the name
16457              of the current working directory.  The value must include one or
16458              both of the following strings:
16459
16460              parent The name of any directory whose path is already contained
16461                     in the word on the line is ignored.   For  example,  when
16462                     completing  after  foo/../, the directory foo will not be
16463                     considered a valid completion.
16464
16465              pwd    The name of the current working  directory  will  not  be
16466                     completed;  hence, for example, completion after ../ will
16467                     not use the name of the current directory.
16468
16469              In addition, the value may include one or both of:
16470
16471              ..     Ignore the specified directories only when  the  word  on
16472                     the line contains the substring `../'.
16473
16474              directory
16475                     Ignore  the  specified directories only when names of di‐
16476                     rectories are completed, not  when  completing  names  of
16477                     files.
16478
16479              Excluded  values  act  in a similar fashion to values of the ig‐
16480              nored-patterns style, so they can be restored  to  consideration
16481              by the _ignored completer.
16482
16483       extra-verbose
16484              If  set, the completion listing is more verbose at the cost of a
16485              probable decrease in completion speed.   Completion  performance
16486              will suffer if this style is set to `true'.
16487
16488       ignored-patterns
16489              A  list  of  patterns;  any trial completion matching one of the
16490              patterns will be excluded from consideration.  The _ignored com‐
16491              pleter  can  appear in the list of completers to restore the ig‐
16492              nored matches.  This is a more configurable version of the shell
16493              parameter $fignore.
16494
16495              Note  that  the EXTENDED_GLOB option is set during the execution
16496              of completion functions, so the characters `#', `~' and `^' have
16497              special meanings in the patterns.
16498
16499       insert This  style  is  used  by  the  _all_matches completer to decide
16500              whether to insert the list of all  matches  unconditionally  in‐
16501              stead of adding the list as another match.
16502
16503       insert-ids
16504              When  completing  process  IDs,  for example as arguments to the
16505              kill and wait builtins the name of a command may be converted to
16506              the  appropriate  process ID.  A problem arises when the process
16507              name typed is not unique.  By default (or if this style  is  set
16508              explicitly  to `menu') the name will be converted immediately to
16509              a set of possible IDs, and menu completion will  be  started  to
16510              cycle through them.
16511
16512              If the value of the style is `single', the shell will wait until
16513              the user has typed enough to make the command unique before con‐
16514              verting the name to an ID; attempts at completion will be unsuc‐
16515              cessful until that point.  If the value  is  any  other  string,
16516              menu  completion  will  be  started when the string typed by the
16517              user is longer than the common prefix to the corresponding IDs.
16518
16519       insert-tab
16520              If this is set to `true', the completion system  will  insert  a
16521              TAB  character  (assuming that was used to start completion) in‐
16522              stead of performing completion when there is no non-blank  char‐
16523              acter  to the left of the cursor.  If it is set to `false', com‐
16524              pletion will be done even there.
16525
16526              The value may also contain the substrings  `pending'  or  `pend‐
16527              ing=val'.   In  this  case, the typed character will be inserted
16528              instead of starting completion when there is  unprocessed  input
16529              pending.   If  a  val  is  given, completion will not be done if
16530              there are at least that many characters  of  unprocessed  input.
16531              This  is  often  useful when pasting characters into a terminal.
16532              Note however, that it relies on the $PENDING  special  parameter
16533              from  the zsh/zle module being set properly which is not guaran‐
16534              teed on all platforms.
16535
16536              The default value of this style is `true' except for  completion
16537              within vared builtin command where it is `false'.
16538
16539       insert-unambiguous
16540              This  is  used by the _match and _approximate completers.  These
16541              completers are often used with menu completion  since  the  word
16542              typed may bear little resemblance to the final completion.  How‐
16543              ever, if this style is `true', the  completer  will  start  menu
16544              completion  only  if it could find no unambiguous initial string
16545              at least as long as the original string typed by the user.
16546
16547              In the case of the _approximate completer, the  completer  field
16548              in  the context will already have been set to one of correct-num
16549              or approximate-num, where num is the number of errors that  were
16550              accepted.
16551
16552              In  the  case of the _match completer, the style may also be set
16553              to the string `pattern'.  Then the pattern on the line  is  left
16554              unchanged if it does not match unambiguously.
16555
16556       gain-privileges
16557              If set to true, this style enables the use of commands like sudo
16558              or doas to gain extra privileges when retrieving information for
16559              completion.  This  is  only done when a command such as sudo ap‐
16560              pears on the command-line. To force the use of, e.g. sudo or  to
16561              override  any prefix that might be added due to gain-privileges,
16562              the command style can be used with a value that  begins  with  a
16563              hyphen.
16564
16565       keep-prefix
16566              This  style  is used by the _expand completer.  If it is `true',
16567              the completer will try to keep a prefix containing  a  tilde  or
16568              parameter  expansion.   Hence,  for  example,  the string `~/f*'
16569              would be expanded to `~/foo' instead  of  `/home/user/foo'.   If
16570              the  style  is  set  to `changed' (the default), the prefix will
16571              only be left unchanged if there were other changes  between  the
16572              expanded words and the original word from the command line.  Any
16573              other value forces the prefix to be expanded unconditionally.
16574
16575              The behaviour of _expand when this style is `true' is  to  cause
16576              _expand  to  give  up  when a single expansion with the restored
16577              prefix is the same as the original;  hence  any  remaining  com‐
16578              pleters may be called.
16579
16580       last-prompt
16581              This  is  a more flexible form of the ALWAYS_LAST_PROMPT option.
16582              If it is `true', the completion system will try  to  return  the
16583              cursor  to  the previous command line after displaying a comple‐
16584              tion list.  It is tested for all tags valid for the current com‐
16585              pletion, then the default tag.  The cursor will be moved back to
16586              the previous line if this style  is  `true'  for  all  types  of
16587              match.   Note  that unlike the ALWAYS_LAST_PROMPT option this is
16588              independent of the numeric argument.
16589
16590       known-hosts-files
16591              This style should contain a list of files  to  search  for  host
16592              names  and (if the use-ip style is set) IP addresses in a format
16593              compatible with ssh known_hosts files.  If it is  not  set,  the
16594              files /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts are used.
16595
16596       list   This  style  is used by the _history_complete_word bindable com‐
16597              mand.  If it is set to `true' it has no effect.  If it is set to
16598              `false'  matches will not be listed.  This overrides the setting
16599              of the options  controlling  listing  behaviour,  in  particular
16600              AUTO_LIST.   The  context  always  starts with `:completion:his‐
16601              tory-words'.
16602
16603       list-colors
16604              If the zsh/complist module is loaded, this style can be used  to
16605              set  color  specifications.   This mechanism replaces the use of
16606              the ZLS_COLORS and ZLS_COLOURS parameters described in the  sec‐
16607              tion  `The zsh/complist Module' in zshmodules(1), but the syntax
16608              is the same.
16609
16610              If this style is set for the default tag,  the  strings  in  the
16611              value  are  taken  as  specifications that are to be used every‐
16612              where.  If it is set for other tags, the specifications are used
16613              only  for matches of the type described by the tag.  For this to
16614              work best, the group-name style must be set to an empty string.
16615
16616              In addition to setting styles for specific tags, it is also pos‐
16617              sible  to use group names specified explicitly by the group-name
16618              tag together with the `(group)' syntax allowed by the ZLS_COLORS
16619              and ZLS_COLOURS parameters and simply using the default tag.
16620
16621              It  is  possible  to use any color specifications already set up
16622              for the GNU version of the ls command:
16623
16624                     zstyle ':completion:*:default' list-colors \
16625                            ${(s.:.)LS_COLORS}
16626
16627              The default colors are the same as for the GNU  ls  command  and
16628              can  be  obtained  by setting the style to an empty string (i.e.
16629              '').
16630
16631       list-dirs-first
16632              This is used by file completion.  If set, directories to be com‐
16633              pleted  are  listed  separately  from  and before completion for
16634              other files, regardless of tag ordering.  In addition,  the  tag
16635              other-files  is  used  in  place  of all-files for the remaining
16636              files, to indicate that no directories are presented  with  that
16637              tag.
16638
16639       list-grouped
16640              If  this  style  is  `true' (the default), the completion system
16641              will try to make certain completion  listings  more  compact  by
16642              grouping  matches.   For example, options for commands that have
16643              the same description (shown when the verbose  style  is  set  to
16644              `true')  will appear as a single entry.  However, menu selection
16645              can be used to cycle through all the matches.
16646
16647       list-packed
16648              This is tested for each tag valid in the current context as well
16649              as  the  default tag.  If it is set to `true', the corresponding
16650              matches appear in listings as if  the  LIST_PACKED  option  were
16651              set.  If it is set to `false', they are listed normally.
16652
16653       list-prompt
16654              If  this style is set for the default tag, completion lists that
16655              don't fit on the screen can be scrolled (see the description  of
16656              the  zsh/complist  module  in zshmodules(1)).  The value, if not
16657              the empty string, will be displayed after  every  screenful  and
16658              the  shell  will  prompt for a key press; if the style is set to
16659              the empty string, a default prompt will be used.
16660
16661              The value may contain the escape sequences: `%l' or `%L',  which
16662              will  be  replaced  by the number of the last line displayed and
16663              the total number of lines; `%m' or `%M', the number of the  last
16664              match  shown and the total number of matches; and `%p' and `%P',
16665              `Top' when at the beginning of the list, `Bottom'  when  at  the
16666              end  and  the position shown as a percentage of the total length
16667              otherwise.  In each case the form with the uppercase letter will
16668              be  replaced  by  a  string of fixed width, padded to the  right
16669              with spaces, while the lowercase form  will  be  replaced  by  a
16670              variable  width  string.  As in other prompt strings, the escape
16671              sequences `%S', `%s', `%B', `%b', `%U', `%u'  for  entering  and
16672              leaving  the  display  modes  standout,  bold and underline, and
16673              `%F', `%f', `%K', `%k' for changing  the  foreground  background
16674              colour, are also available, as is the form `%{...%}' for enclos‐
16675              ing escape sequences which display with zero (or, with a numeric
16676              argument, some other) width.
16677
16678              After deleting this prompt the variable LISTPROMPT should be un‐
16679              set for the removal to take effect.
16680
16681       list-rows-first
16682              This style is tested in the same way as  the  list-packed  style
16683              and  determines whether matches are to be listed in a rows-first
16684              fashion as if the LIST_ROWS_FIRST option were set.
16685
16686       list-suffixes
16687              This style is used by the function that completes filenames.  If
16688              it is `true', and completion is attempted on a string containing
16689              multiple partially typed pathname components, all ambiguous com‐
16690              ponents will be shown.  Otherwise, completion stops at the first
16691              ambiguous component.
16692
16693       list-separator
16694              The value of this style is used in completion listing  to  sepa‐
16695              rate  the  string  to  complete from a description when possible
16696              (e.g. when completing options).  It defaults to  `--'  (two  hy‐
16697              phens).
16698
16699       local  This  is for use with functions that complete URLs for which the
16700              corresponding files are available directly from the file system.
16701              Its  value should consist of three strings: a hostname, the path
16702              to the default web pages for the server, and the directory  name
16703              used by a user placing web pages within their home area.
16704
16705              For example:
16706
16707                     zstyle ':completion:*' local toast \
16708                         /var/http/public/toast public_html
16709
16710              Completion  after  `http://toast/stuff/'  will look for files in
16711              the directory  /var/http/public/toast/stuff,   while  completion
16712              after  `http://toast/~yousir/' will look for files in the direc‐
16713              tory ~yousir/public_html.
16714
16715       mail-directory
16716              If set, zsh will assume that mailbox files can be found  in  the
16717              directory specified.  It defaults to `~/Mail'.
16718
16719       match-original
16720              This  is  used  by  the _match completer.  If it is set to only,
16721              _match will try to generate matches without inserting a  `*'  at
16722              the  cursor  position.   If set to any other non-empty value, it
16723              will first try to generate matches without inserting the `*' and
16724              if  that  yields  no matches, it will try again with the `*' in‐
16725              serted.  If it is unset or set to  the  empty  string,  matching
16726              will only be performed with the `*' inserted.
16727
16728       matcher
16729              This  style  is tested separately for each tag valid in the cur‐
16730              rent context.  Its value is placed before any  match  specifica‐
16731              tions  given  by the matcher-list style so can override them via
16732              the use of an x: specification.  The value should be in the form
16733              described  in  the section `Completion Matching Control' in zsh‐
16734              compwid(1).  For examples of this, see the  description  of  the
16735              tag-order style.
16736
16737              For  notes comparing the use of this and the matcher-list style,
16738              see under the description of the tag-order style.
16739
16740       matcher-list
16741              This style can be set to a list of match specifications that are
16742              to  be applied everywhere. Match specifications are described in
16743              the section `Completion Matching Control' in zshcompwid(1).  The
16744              completion  system will try them one after another for each com‐
16745              pleter selected.  For example, to try  first  simple  completion
16746              and, if that generates no matches, case-insensitive completion:
16747
16748                     zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
16749
16750              By  default  each  specification replaces the previous one; how‐
16751              ever, if a specification is prefixed with +, it is added to  the
16752              existing list.  Hence it is possible to create increasingly gen‐
16753              eral specifications without repetition:
16754
16755                     zstyle ':completion:*' matcher-list \
16756                            '' '+m:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
16757
16758              It is possible to create match specifications valid for particu‐
16759              lar  completers  by  using the third field of the context.  This
16760              applies  only   to   completers   that   override   the   global
16761              matcher-list, which as of this writing includes only _prefix and
16762              _ignored.  For example, to  use  the  completers  _complete  and
16763              _prefix  but  allow  case-insensitive completion only with _com‐
16764              plete:
16765
16766                     zstyle ':completion:*' completer _complete _prefix
16767                     zstyle ':completion:*:complete:*:*:*' matcher-list \
16768                            '' 'm:{a-zA-Z}={A-Za-z}'
16769
16770              User-defined names, as explained for the  completer  style,  are
16771              available.   This  makes  it  possible to try the same completer
16772              more than once with different match  specifications  each  time.
16773              For example, to try normal completion without a match specifica‐
16774              tion, then normal  completion  with  case-insensitive  matching,
16775              then correction, and finally partial-word completion:
16776
16777                     zstyle ':completion:*' completer \
16778                         _complete _correct _complete:foo
16779                     zstyle ':completion:*:complete:*:*:*' matcher-list \
16780                         '' 'm:{a-zA-Z}={A-Za-z}'
16781                     zstyle ':completion:*:foo:*:*:*' matcher-list \
16782                         'm:{a-zA-Z}={A-Za-z} r:|[-_./]=* r:|=*'
16783
16784              If  the  style is unset in any context no match specification is
16785              applied.  Note also that some completers such  as  _correct  and
16786              _approximate  do not use the match specifications at all, though
16787              these completers will only ever  be  called  once  even  if  the
16788              matcher-list contains more than one element.
16789
16790              Where  multiple  specifications are useful, note that the entire
16791              completion is done for each element of matcher-list,  which  can
16792              quickly  reduce  the  shell's  performance.   As a rough rule of
16793              thumb, one to three strings will  give  acceptable  performance.
16794              On  the other hand, putting multiple space-separated values into
16795              the same string does not have an appreciable impact  on  perfor‐
16796              mance.
16797
16798              If  there  is  no current matcher or it is empty, and the option
16799              NO_CASE_GLOB is in effect, the matching for files  is  performed
16800              case-insensitively  in  any case.  However, any matcher must ex‐
16801              plicitly specify case-insensitive matching if that is required.
16802
16803              For notes comparing the use of this and the matcher  style,  see
16804              under the description of the tag-order style.
16805
16806       max-errors
16807              This  is  used  by the _approximate and _correct completer func‐
16808              tions to determine the maximum number of errors to  allow.   The
16809              completer will try to generate completions by first allowing one
16810              error, then two errors, and so  on,  until  either  a  match  or
16811              matches were found or the maximum number of errors given by this
16812              style has been reached.
16813
16814              If the value for this style contains the string  `numeric',  the
16815              completer function will take any numeric argument as the maximum
16816              number of errors allowed. For example, with
16817
16818                     zstyle ':completion:*:approximate:::' max-errors 2 numeric
16819
16820              two errors are allowed if no numeric argument is given, but with
16821              a  numeric argument of six (as in `ESC-6 TAB'), up to six errors
16822              are accepted.  Hence with a value of `0 numeric', no  correcting
16823              completion will be attempted unless a numeric argument is given.
16824
16825              If  the  value  contains the string `not-numeric', the completer
16826              will not try to generate corrected completions when given a  nu‐
16827              meric  argument,  so  in  this  case  the number given should be
16828              greater than zero.  For example, `2 not-numeric' specifies  that
16829              correcting completion with two errors will usually be performed,
16830              but if a numeric argument is given, correcting  completion  will
16831              not be performed.
16832
16833              The default value for this style is `2 numeric'.
16834
16835       max-matches-width
16836              This  style is used to determine the trade off between the width
16837              of the display used for matches and the width used for their de‐
16838              scriptions when the verbose style is in effect.  The value gives
16839              the number of display columns to reserve for the  matches.   The
16840              default is half the width of the screen.
16841
16842              This  has the most impact when several matches have the same de‐
16843              scription and so will be grouped together.  Increasing the style
16844              will  allow  more  matches to be grouped together; decreasing it
16845              will allow more of the description to be visible.
16846
16847       menu   If this is `true' in the context of any of the tags defined  for
16848              the  current completion menu completion will be used.  The value
16849              for a specific tag will take precedence over that for  the  `de‐
16850              fault' tag.
16851
16852              If  none  of the values found in this way is `true' but at least
16853              one is set to `auto', the shell behaves as if the AUTO_MENU  op‐
16854              tion is set.
16855
16856              If  one of the values is explicitly set to `false', menu comple‐
16857              tion will be explicitly turned off, overriding the MENU_COMPLETE
16858              option and other settings.
16859
16860              In the form `yes=num', where `yes' may be any of the `true' val‐
16861              ues (`yes', `true', `on'  and  `1'),  menu  completion  will  be
16862              turned  on  if  there  are  at  least  num matches.  In the form
16863              `yes=long', menu completion will be turned on if the  list  does
16864              not  fit  on the screen.  This does not activate menu completion
16865              if the widget normally only lists completions, but menu  comple‐
16866              tion   can   be   activated   in   that   case  with  the  value
16867              `yes=long-list' (Typically,  the  value  `select=long-list'  de‐
16868              scribed  later  is  more  useful  as  it  provides  control over
16869              scrolling.)
16870
16871              Similarly, with any of the `false' values (as in `no=10'),  menu
16872              completion will not be used if there are num or more matches.
16873
16874              The value of this widget also controls menu selection, as imple‐
16875              mented by the zsh/complist module.  The following values may ap‐
16876              pear either alongside or instead of the values above.
16877
16878              If  the  value contains the string `select', menu selection will
16879              be started unconditionally.
16880
16881              In the form `select=num', menu selection will only be started if
16882              there are at least num matches.  If the values for more than one
16883              tag provide a number, the smallest number is taken.
16884
16885              Menu selection can be turned off explicitly by defining a  value
16886              containing the string`no-select'.
16887
16888              It  is also possible to start menu selection only if the list of
16889              matches does not fit on the  screen  by  using  the  value  `se‐
16890              lect=long'.   To start menu selection even if the current widget
16891              only performs listing, use the value `select=long-list'.
16892
16893              To turn on menu completion or menu selection when  there  are  a
16894              certain number of matches or the list of matches does not fit on
16895              the screen, both of `yes=' and `select='  may  be  given  twice,
16896              once with a number and once with `long' or `long-list'.
16897
16898              Finally,  it  is  possible to activate two special modes of menu
16899              selection.  The word `interactive' in the value causes  interac‐
16900              tive  mode  to  be  entered  immediately  when menu selection is
16901              started; see the description of the zsh/complist module in  zsh‐
16902              modules(1) for a description of interactive mode.  Including the
16903              string `search' does the same for incremental search  mode.   To
16904              select   backward   incremental   search,   include  the  string
16905              `search-backward'.
16906
16907       muttrc If set, gives the location of the mutt configuration  file.   It
16908              defaults to `~/.muttrc'.
16909
16910       numbers
16911              This is used with the jobs tag.  If it is `true', the shell will
16912              complete job numbers instead of the shortest unambiguous  prefix
16913              of  the job command text.  If the value is a number, job numbers
16914              will only be used if that many words from the  job  descriptions
16915              are  required to resolve ambiguities.  For example, if the value
16916              is `1', strings will only be used if  all  jobs  differ  in  the
16917              first word on their command lines.
16918
16919       old-list
16920              This  is  used  by the _oldlist completer.  If it is set to `al‐
16921              ways', then standard widgets which perform listing  will  retain
16922              the  current  list of matches, however they were generated; this
16923              can be turned off explicitly with the value `never', giving  the
16924              behaviour  without  the _oldlist completer.  If the style is un‐
16925              set, or any other value, then the existing list  of  completions
16926              is  displayed if it is not already; otherwise, the standard com‐
16927              pletion list is generated; this  is  the  default  behaviour  of
16928              _oldlist.   However, if there is an old list and this style con‐
16929              tains the name of the  completer  function  that  generated  the
16930              list, then the old list will be used even if it was generated by
16931              a widget which does not do listing.
16932
16933              For example, suppose you type ^Xc to use the _correct_word  wid‐
16934              get,  which  generates  a list of corrections for the word under
16935              the cursor.  Usually, typing ^D would generate a  standard  list
16936              of  completions for the word on the command line, and show that.
16937              With _oldlist, it will instead show the list of corrections  al‐
16938              ready generated.
16939
16940              As  another  example consider the _match completer: with the in‐
16941              sert-unambiguous style set to `true' it inserts  only  a  common
16942              prefix  string, if there is any.  However, this may remove parts
16943              of the original pattern, so that further completion  could  pro‐
16944              duce  more  matches  than  on  the  first attempt.  By using the
16945              _oldlist completer and setting this style to _match, the list of
16946              matches generated on the first attempt will be used again.
16947
16948       old-matches
16949              This  is  used by the _all_matches completer to decide if an old
16950              list of matches should be used if one exists.  This is  selected
16951              by  one  of  the  `true' values or by the string `only'.  If the
16952              value is `only', _all_matches will only  use  an  old  list  and
16953              won't  have  any  effect  on the list of matches currently being
16954              generated.
16955
16956              If this style  is  set  it  is  generally  unwise  to  call  the
16957              _all_matches completer unconditionally.  One possible use is for
16958              either this style or the completer style to be defined with  the
16959              -e option to zstyle to make the style conditional.
16960
16961       old-menu
16962              This  is  used  by the _oldlist completer.  It controls how menu
16963              completion behaves when a completion has already  been  inserted
16964              and  the  user types a standard completion key such as TAB.  The
16965              default behaviour of _oldlist is  that  menu  completion  always
16966              continues  with the existing list of completions.  If this style
16967              is set to `false', however, a new completion is started  if  the
16968              old  list  was generated by a different completion command; this
16969              is the behaviour without the _oldlist completer.
16970
16971              For example, suppose you type ^Xc to generate a list of  correc‐
16972              tions,  and menu completion is started in one of the usual ways.
16973              Usually, or with this style set to `false', typing TAB  at  this
16974              point would start trying to complete the line as it now appears.
16975              With _oldlist, it instead continues to cycle through the list of
16976              corrections.
16977
16978       original
16979              This  is used by the _approximate and _correct completers to de‐
16980              cide if the original string should be added as a  possible  com‐
16981              pletion.   Normally, this is done only if there are at least two
16982              possible corrections, but if this style is set to `true', it  is
16983              always  added.   Note  that  the style will be examined with the
16984              completer field in the context name set to  correct-num  or  ap‐
16985              proximate-num,  where  num is the number of errors that were ac‐
16986              cepted.
16987
16988       packageset
16989              This style is used  when  completing  arguments  of  the  Debian
16990              `dpkg' program.  It contains an override for the default package
16991              set for a given context.  For example,
16992
16993                     zstyle ':completion:*:complete:dpkg:option--status-1:*' \
16994                                    packageset avail
16995
16996              causes available packages, rather than only installed  packages,
16997              to be completed for `dpkg --status'.
16998
16999       path   The function that completes color names uses this style with the
17000              colors tag.  The value should be the pathname of a file contain‐
17001              ing  color  names  in the format of an X11 rgb.txt file.  If the
17002              style is not set but this file is found in one of various  stan‐
17003              dard locations it will be used as the default.
17004
17005       path-completion
17006              This  is used by filename completion.  By default, filename com‐
17007              pletion examines all components of a path to see  if  there  are
17008              completions  of that component.  For example, /u/b/z can be com‐
17009              pleted  to  /usr/bin/zsh.   Explicitly  setting  this  style  to
17010              `false'  inhibits this behaviour for path components up to the /
17011              before the cursor; this  overrides  the  setting  of  accept-ex‐
17012              act-dirs.
17013
17014              Even with the style set to `false', it is still possible to com‐
17015              plete multiple paths by setting the option COMPLETE_IN_WORD  and
17016              moving  the cursor back to the first component in the path to be
17017              completed.  For example, /u/b/z can be completed to /usr/bin/zsh
17018              if the cursor is after the /u.
17019
17020       pine-directory
17021              If  set,  specifies the directory containing PINE mailbox files.
17022              There is no default, since recursively searching this  directory
17023              is inconvenient for anyone who doesn't use PINE.
17024
17025       ports  A  list  of  Internet service names (network ports) to complete.
17026              If this is not set,  service  names  are  taken  from  the  file
17027              `/etc/services'.
17028
17029       prefix-hidden
17030              This  is  used for certain completions which share a common pre‐
17031              fix, for example command options beginning with dashes.   If  it
17032              is `true', the prefix will not be shown in the list of matches.
17033
17034              The default value for this style is `false'.
17035
17036       prefix-needed
17037              This  style  is  also relevant for matches with a common prefix.
17038              If it is set to `true' this common prefix must be typed  by  the
17039              user to generate the matches.
17040
17041              The  style  is  applicable  to the options, signals, jobs, func‐
17042              tions, and parameters completion tags.
17043
17044              For command options, this means that the initial  `-',  `+',  or
17045              `--'  must  be typed explicitly before option names will be com‐
17046              pleted.
17047
17048              For signals, an initial `-' is required before signal names will
17049              be completed.
17050
17051              For  jobs,  an  initial `%' is required before job names will be
17052              completed.
17053
17054              For function and parameter names, an initial `_' or `.'  is  re‐
17055              quired  before  function  or parameter names starting with those
17056              characters will be completed.
17057
17058              The default value for this style is `false' for function and pa‐
17059              rameter completions, and  `true' otherwise.
17060
17061       preserve-prefix
17062              This style is used when completing path names.  Its value should
17063              be a pattern matching an initial prefix of the word to  complete
17064              that  should be left unchanged under all circumstances.  For ex‐
17065              ample, on some Unices an initial `//' (double slash) has a  spe‐
17066              cial  meaning;  setting  this style to the string `//' will pre‐
17067              serve it.  As another example, setting this style to `?:/' under
17068              Cygwin would allow completion after `a:/...' and so on.
17069
17070       range  This  is  used  by  the _history completer and the _history_com‐
17071              plete_word bindable command to decide which words should be com‐
17072              pleted.
17073
17074              If it is a single number, only the last N words from the history
17075              will be completed.
17076
17077              If it is a range of the form `max:slice', the last  slice  words
17078              will  be  completed;  then  if that yields no matches, the slice
17079              words before those will be tried and so on.  This process  stops
17080              either when at least one match has been found, or max words have
17081              been tried.
17082
17083              The default is to complete all words from the history at once.
17084
17085       recursive-files
17086              If this style is set, its value is an array of  patterns  to  be
17087              tested  against  `$PWD/':  note the trailing slash, which allows
17088              directories in the pattern to be delimited unambiguously by  in‐
17089              cluding  slashes  on both sides.  If an ordinary file completion
17090              fails and the word on the command line does not yet have  a  di‐
17091              rectory  part to its name, the style is retrieved using the same
17092              tag as for the completion  just  attempted,  then  the  elements
17093              tested  against  $PWD/  in turn.  If one matches, then the shell
17094              reattempts completion by prepending the word on the command line
17095              with  each directory in the expansion of **/*(/) in turn.  Typi‐
17096              cally the elements of the style will be set to restrict the num‐
17097              ber  of directories beneath the current one to a manageable num‐
17098              ber, for example `*/.git/*'.
17099
17100              For example,
17101
17102                     zstyle ':completion:*' recursive-files '*/zsh/*'
17103
17104              If the current directory is  /home/pws/zsh/Src,  then  zle_trTAB
17105              can be completed to Zle/zle_tricky.c.
17106
17107       regular
17108              This  style  is used by the _expand_alias completer and bindable
17109              command.  If set to `true' (the default), regular  aliases  will
17110              be  expanded  but  only  in  command  position.  If it is set to
17111              `false', regular aliases will never be expanded.   If it is  set
17112              to  `always',  regular  aliases  will be expanded even if not in
17113              command position.
17114
17115       rehash If this is set when completing external commands,  the  internal
17116              list (hash) of commands will be updated for each search by issu‐
17117              ing the rehash command.  There is a speed penalty for this which
17118              is  only  likely  to  be noticeable when directories in the path
17119              have slow file access.
17120
17121       remote-access
17122              If set to `false', certain commands will be prevented from  mak‐
17123              ing  Internet  connections to retrieve remote information.  This
17124              includes the completion for the CVS command.
17125
17126              It is not always possible to know if connections are in fact  to
17127              a remote site, so some may be prevented unnecessarily.
17128
17129       remove-all-dups
17130              The  _history_complete_word  bindable  command  and the _history
17131              completer use this to decide if all duplicate matches should  be
17132              removed, rather than just consecutive duplicates.
17133
17134       select-prompt
17135              If  this is set for the default tag, its value will be displayed
17136              during menu selection (see the menu style above) when  the  com‐
17137              pletion  list  does  not fit on the screen as a whole.  The same
17138              escapes as for the list-prompt style are understood, except that
17139              the  numbers  refer  to the match or line the mark is on.  A de‐
17140              fault prompt is used when the value is the empty string.
17141
17142       select-scroll
17143              This style is tested for the default tag and  determines  how  a
17144              completion  list  is  scrolled  during a menu selection (see the
17145              menu style above) when the completion list does not fit  on  the
17146              screen  as  a  whole.   If  the value is `0' (zero), the list is
17147              scrolled by half-screenfuls; if it is a  positive  integer,  the
17148              list  is scrolled by the given number of lines; if it is a nega‐
17149              tive number, the list is scrolled by a screenful minus the abso‐
17150              lute  value  of  the  given  number of lines.  The default is to
17151              scroll by single lines.
17152
17153       separate-sections
17154              This style is used with the manuals tag when completing names of
17155              manual  pages.   If it is `true', entries for different sections
17156              are added separately using tag names  of  the  form  `manual.X',
17157              where  X  is  the  section number.  When the group-name style is
17158              also in effect, pages from different sections will appear  sepa‐
17159              rately.   This style is also used similarly with the words style
17160              when completing words for the dict command. It allows words from
17161              different  dictionary databases to be added separately.  The de‐
17162              fault for this style is `false'.
17163
17164       show-ambiguity
17165              If the zsh/complist module is loaded, this style can be used  to
17166              highlight the first ambiguous character in completion lists. The
17167              value is either a color indication such as  those  supported  by
17168              the  list-colors  style or, with a value of `true', a default of
17169              underlining is selected. The highlighting is only applied if the
17170              completion display strings correspond to the actual matches.
17171
17172       show-completer
17173              Tested  whenever a new completer is tried.  If it is `true', the
17174              completion system outputs a progress message in the listing area
17175              showing  what  completer  is  being  tried.  The message will be
17176              overwritten by any output when completions are found and is  re‐
17177              moved after completion is finished.
17178
17179       single-ignored
17180              This  is  used  by the _ignored completer when there is only one
17181              match.  If its value is `show', the single match  will  be  dis‐
17182              played  but not inserted.  If the value is `menu', then the sin‐
17183              gle match and the original string are both added as matches  and
17184              menu  completion  is started, making it easy to select either of
17185              them.
17186
17187       sort   This allows the standard ordering of matches to be overridden.
17188
17189              If its value is `true' or `false', sorting is  enabled  or  dis‐
17190              abled.   Additionally the values associated with the `-o' option
17191              to compadd can also be listed: match, nosort, numeric,  reverse.
17192              If  it is not set for the context, the standard behaviour of the
17193              calling widget is used.
17194
17195              The style is tested first against the full context including the
17196              tag,  and  if  that fails to produce a value against the context
17197              without the tag.
17198
17199              In many cases where a calling widget explicitly selects  a  par‐
17200              ticular  ordering  in  lieu of the default, a value of `true' is
17201              not honoured.  An example of where this is not the case  is  for
17202              command history where the default of sorting matches chronologi‐
17203              cally may be overridden by setting the style to `true'.
17204
17205              In the _expand completer, if it is set to `true', the expansions
17206              generated  will  always be sorted.  If it is set to `menu', then
17207              the expansions are only sorted when they are offered  as  single
17208              strings  but  not  in  the string containing all possible expan‐
17209              sions.
17210
17211       special-dirs
17212              Normally, the completion code will  not  produce  the  directory
17213              names  `.'  and  `..' as possible completions.  If this style is
17214              set to `true', it will add both `.' and `..' as possible comple‐
17215              tions; if it is set to `..', only `..' will be added.
17216
17217              The following example sets special-dirs to `..' when the current
17218              prefix is empty, is a single `.', or consists only of a path be‐
17219              ginning with `../'.  Otherwise the value is `false'.
17220
17221                     zstyle -e ':completion:*' special-dirs \
17222                        '[[ $PREFIX = (../)#(|.|..) ]] && reply=(..)'
17223
17224       squeeze-slashes
17225              If  set  to  `true', sequences of slashes in filename paths (for
17226              example in `foo//bar') will be treated as a single slash.   This
17227              is  the  usual behaviour of UNIX paths.  However, by default the
17228              file completion function behaves as if there were a `*'  between
17229              the slashes.
17230
17231       stop   If  set  to  `true', the _history_complete_word bindable command
17232              will stop once when reaching the beginning or end  of  the  his‐
17233              tory.   Invoking _history_complete_word will then wrap around to
17234              the opposite end of the  history.   If  this  style  is  set  to
17235              `false'  (the default), _history_complete_word will loop immedi‐
17236              ately as in a menu completion.
17237
17238       strip-comments
17239              If set to `true', this style causes non-essential  comment  text
17240              to  be  removed  from  completion matches.  Currently it is only
17241              used when completing e-mail addresses where it removes any  dis‐
17242              play  name  from  the  addresses,  cutting  them  down  to plain
17243              user@host form.
17244
17245       subst-globs-only
17246              This is used by the _expand completer.  If it is set to  `true',
17247              the  expansion  will  only be used if it resulted from globbing;
17248              hence, if expansions resulted from the  use  of  the  substitute
17249              style  described  below,  but  these were not further changed by
17250              globbing, the expansions will be rejected.
17251
17252              The default for this style is `false'.
17253
17254       substitute
17255              This boolean style controls whether the _expand  completer  will
17256              first  try  to  expand  all substitutions in the string (such as
17257              `$(...)' and `${...}').
17258
17259              The default is `true'.
17260
17261       suffix This is used by the _expand completer if the word starts with  a
17262              tilde  or  contains  a  parameter  expansion.   If  it is set to
17263              `true', the word will only be expanded if it doesn't have a suf‐
17264              fix,  i.e.  if it is something like `~foo' or `$foo' rather than
17265              `~foo/' or `$foo/bar', unless that suffix itself contains  char‐
17266              acters  eligible  for  expansion.  The default for this style is
17267              `true'.
17268
17269       tag-order
17270              This provides a mechanism for sorting how the tags available  in
17271              a particular context will be used.
17272
17273              The  values  for  the style are sets of space-separated lists of
17274              tags.  The tags in each value will be tried at the same time; if
17275              no  match  is found, the next value is used.  (See the file-pat‐
17276              terns style for an exception to this behavior.)
17277
17278              For example:
17279
17280                     zstyle ':completion:*:complete:-command-:*:*' tag-order \
17281                         'commands functions'
17282
17283              specifies that completion in command position first  offers  ex‐
17284              ternal  commands  and  shell  functions.  Remaining tags will be
17285              tried if no completions are found.
17286
17287              In addition to tag names, each string in the value may take  one
17288              of the following forms:
17289
17290              -      If  any  value  consists  of only a hyphen, then only the
17291                     tags specified in the other values are  generated.   Nor‐
17292                     mally  all tags not explicitly selected are tried last if
17293                     the specified tags fail to generate  any  matches.   This
17294                     means that a single value consisting only of a single hy‐
17295                     phen turns off completion.
17296
17297              ! tags...
17298                     A string starting  with  an  exclamation  mark  specifies
17299                     names of tags that are not to be used.  The effect is the
17300                     same as if all other possible tags for  the  context  had
17301                     been listed.
17302
17303              tag:label ...
17304                     Here, tag is one of the standard tags and label is an ar‐
17305                     bitrary name.  Matches are generated as  normal  but  the
17306                     name  label  is used in contexts instead of tag.  This is
17307                     not useful in words starting with !.
17308
17309                     If the label starts with a hyphen, the tag  is  prepended
17310                     to  the label to form the name used for lookup.  This can
17311                     be used to make the completion system try a  certain  tag
17312                     more  than  once,  supplying different style settings for
17313                     each attempt; see below for an example.
17314
17315              tag:label:description
17316                     As before, but description will replace the `%d'  in  the
17317                     value of the format style instead of the default descrip‐
17318                     tion supplied by the completion function.  Spaces in  the
17319                     description  must be quoted with a backslash.  A `%d' ap‐
17320                     pearing in description is replaced with  the  description
17321                     given by the completion function.
17322
17323              In  any  of  the forms above the tag may be a pattern or several
17324              patterns in the form `{pat1,pat2...}'.  In this case all  match‐
17325              ing  tags  will  be  used except for any given explicitly in the
17326              same string.
17327
17328              One use of these features is to try one tag more than once, set‐
17329              ting  other styles differently on each attempt, but still to use
17330              all the other tags without having to repeat them all.  For exam‐
17331              ple,  to  make  completion of function names in command position
17332              ignore all the completion functions starting with an  underscore
17333              the first time completion is tried:
17334
17335                     zstyle ':completion:*:*:-command-:*:*' tag-order \
17336                         'functions:-non-comp *' functions
17337                     zstyle ':completion:*:functions-non-comp' \
17338                         ignored-patterns '_*'
17339
17340              On the first attempt, all tags will be offered but the functions
17341              tag will be replaced by  functions-non-comp.   The  ignored-pat‐
17342              terns  style  is  set for this tag to exclude functions starting
17343              with an underscore.  If there are no matches, the  second  value
17344              of  the  tag-order style is used which completes functions using
17345              the default tag, this time  presumably  including  all  function
17346              names.
17347
17348              The matches for one tag can be split into different groups.  For
17349              example:
17350
17351                     zstyle ':completion:*' tag-order \
17352                         'options:-long:long\ options
17353                          options:-short:short\ options
17354                          options:-single-letter:single\ letter\ options'
17355                     zstyle ':completion:*:options-long' \
17356                          ignored-patterns '[-+](|-|[^-]*)'
17357                     zstyle ':completion:*:options-short' \
17358                          ignored-patterns '--*' '[-+]?'
17359                     zstyle ':completion:*:options-single-letter' \
17360                          ignored-patterns '???*'
17361
17362              With the group-names style set, options beginning with `--', op‐
17363              tions beginning with a single `-' or `+' but containing multiple
17364              characters, and single-letter options will be displayed in sepa‐
17365              rate groups with different descriptions.
17366
17367              Another  use of patterns is to try multiple match specifications
17368              one after another.  The matcher-list style offers something sim‐
17369              ilar,  but  it is tested very early in the completion system and
17370              hence can't be set for single commands  nor  for  more  specific
17371              contexts.   Here  is  how  to  try normal completion without any
17372              match specification and, if that generates no matches, try again
17373              with  case-insensitive matching, restricting the effect to argu‐
17374              ments of the command foo:
17375
17376                     zstyle ':completion:*:*:foo:*:*' tag-order '*' '*:-case'
17377                     zstyle ':completion:*-case' matcher 'm:{a-z}={A-Z}'
17378
17379              First, all the tags offered when completing after foo are  tried
17380              using  the  normal  tag name.  If that generates no matches, the
17381              second value of tag-order is used, which tries  all  tags  again
17382              except  that  this  time each has -case appended to its name for
17383              lookup of styles.  Hence this time the  value  for  the  matcher
17384              style  from  the second call to zstyle in the example is used to
17385              make completion case-insensitive.
17386
17387              It is possible to use the -e option of the zstyle  builtin  com‐
17388              mand  to specify conditions for the use of particular tags.  For
17389              example:
17390
17391                     zstyle -e '*:-command-:*' tag-order '
17392                         if [[ -n $PREFIX$SUFFIX ]]; then
17393                           reply=( )
17394                         else
17395                           reply=( - )
17396                         fi'
17397
17398              Completion in command position will be  attempted  only  if  the
17399              string typed so far is not empty.  This is tested using the PRE‐
17400              FIX special parameter; see zshcompwid for a description  of  pa‐
17401              rameters  which  are special inside completion widgets.  Setting
17402              reply to an empty array provides the default behaviour of trying
17403              all  tags  at once; setting it to an array containing only a hy‐
17404              phen disables the use of all tags and hence of all completions.
17405
17406              If no tag-order style  has  been  defined  for  a  context,  the
17407              strings  `(|*-)argument-*  (|*-)option-*  values'  and `options'
17408              plus all tags offered by the completion function will be used to
17409              provide  a  sensible  default  behavior  that  causes  arguments
17410              (whether normal command arguments or arguments of options) to be
17411              completed before option names for most commands.
17412
17413       urls   This  is used together with the urls tag by functions completing
17414              URLs.
17415
17416              If the value consists of more than one string, or  if  the  only
17417              string  does  not name a file or directory, the strings are used
17418              as the URLs to complete.
17419
17420              If the value contains only one string which is  the  name  of  a
17421              normal  file  the  URLs are taken from that file (where the URLs
17422              may be separated by white space or newlines).
17423
17424              Finally, if the only string in the value names a directory,  the
17425              directory  hierarchy  rooted at this directory gives the comple‐
17426              tions.  The top  level  directory  should  be  the  file  access
17427              method,  such  as  `http', `ftp', `bookmark' and so on.  In many
17428              cases the next level of directories will be a filename.  The di‐
17429              rectory hierarchy can descend as deep as necessary.
17430
17431              For example,
17432
17433                     zstyle ':completion:*' urls ~/.urls
17434                     mkdir -p ~/.urls/ftp/ftp.zsh.org/pub
17435
17436              allows   completion   of   all   the   components   of  the  URL
17437              ftp://ftp.zsh.org/pub after suitable commands such as `netscape'
17438              or  `lynx'.   Note,  however,  that access methods and files are
17439              completed separately, so if the hosts style is set hosts can  be
17440              completed without reference to the urls style.
17441
17442              See the description in the function _urls itself for more infor‐
17443              mation (e.g. `more $^fpath/_urls(N)').
17444
17445       use-cache
17446              If this is set, the completion caching layer  is  activated  for
17447              any  completions  which  use  it  (via  the  _store_cache,  _re‐
17448              trieve_cache, and _cache_invalid functions).  The directory con‐
17449              taining  the  cache  files  can  be  changed with the cache-path
17450              style.
17451
17452       use-compctl
17453              If this style is set to a string not equal to false, 0, no,  and
17454              off, the completion system may use any completion specifications
17455              defined with the compctl builtin command.  If the style  is  un‐
17456              set, this is done only if the zsh/compctl module is loaded.  The
17457              string may also contain the substring `first' to use completions
17458              defined  with  `compctl  -T', and the substring `default' to use
17459              the completion defined with `compctl -D'.
17460
17461              Note that this is only intended to smooth  the  transition  from
17462              compctl  to  the  new completion system and may disappear in the
17463              future.
17464
17465              Note also that the definitions from compctl will only be used if
17466              there  is  no  specific  completion  function for the command in
17467              question.  For example, if there is a function _foo to  complete
17468              arguments  to the command foo, compctl will never be invoked for
17469              foo.  However, the compctl version will be  tried  if  foo  only
17470              uses default completion.
17471
17472       use-ip By default, the function _hosts that completes host names strips
17473              IP addresses from entries read from host databases such  as  NIS
17474              and  ssh  files.   If this style is `true', the corresponding IP
17475              addresses can be completed as well.  This style is  not  use  in
17476              any  context  where the hosts style is set; note also it must be
17477              set before the cache of host names is generated  (typically  the
17478              first completion attempt).
17479
17480       users  This  may  be set to a list of usernames to be completed.  If it
17481              is not set all usernames will be completed.  Note that if it  is
17482              set  only  that list of users will be completed; this is because
17483              on some systems querying all users can take a prohibitive amount
17484              of time.
17485
17486       users-hosts
17487              The  values  of  this style should be of the form `user@host' or
17488              `user:host'. It is used for commands that need  pairs  of  user-
17489              and hostnames.  These commands will complete usernames from this
17490              style (only), and will restrict subsequent  hostname  completion
17491              to  hosts  paired  with  that  user  in one of the values of the
17492              style.
17493
17494              It is possible to group values for sets of commands which  allow
17495              a remote login, such as rlogin and ssh, by using the my-accounts
17496              tag.  Similarly, values for sets of commands which usually refer
17497              to the accounts of other people, such as talk and finger, can be
17498              grouped by using the other-accounts tag.  More  ambivalent  com‐
17499              mands may use the accounts tag.
17500
17501       users-hosts-ports
17502              Like  users-hosts but used for commands like telnet and contain‐
17503              ing strings of the form `user@host:port'.
17504
17505       verbose
17506              If set, as it is by default, the completion listing is more ver‐
17507              bose.  In particular many commands show descriptions for options
17508              if this style is `true'.
17509
17510       word   This is used by the _list completer, which prevents  the  inser‐
17511              tion  of  completions until a second completion attempt when the
17512              line has not changed.  The normal way of finding out if the line
17513              has  changed  is  to compare its entire contents between the two
17514              occasions.  If this style is `true', the comparison  is  instead
17515              performed only on the current word.  Hence if completion is per‐
17516              formed on another word with the same contents,  completion  will
17517              not be delayed.
17518

CONTROL FUNCTIONS

17520       The initialization script compinit redefines all the widgets which per‐
17521       form completion to call the supplied  widget  function  _main_complete.
17522       This function acts as a wrapper calling the so-called `completer' func‐
17523       tions that generate matches.  If _main_complete is  called  with  argu‐
17524       ments, these are taken as the names of completer functions to be called
17525       in the order given.  If no arguments are given, the set of functions to
17526       try is taken from the completer style.  For example, to use normal com‐
17527       pletion and correction if that doesn't generate any matches:
17528
17529              zstyle ':completion:*' completer _complete _correct
17530
17531       after calling compinit. The default value for this style is  `_complete
17532       _ignored',  i.e. normally only ordinary completion is tried, first with
17533       the effect of the ignored-patterns style  and  then  without  it.   The
17534       _main_complete  function  uses the return status of the completer func‐
17535       tions to decide if other completers should be called.   If  the  return
17536       status  is  zero,  no other completers are tried and the _main_complete
17537       function returns.
17538
17539       If the first argument to _main_complete is a single hyphen,  the  argu‐
17540       ments  will  not  be taken as names of completers.  Instead, the second
17541       argument gives a name to use in the completer field of the context  and
17542       the other arguments give a command name and arguments to call to gener‐
17543       ate the matches.
17544
17545       The following completer functions are contained  in  the  distribution,
17546       although  users may write their own.  Note that in contexts the leading
17547       underscore is stripped, for example basic completion  is  performed  in
17548       the context `:completion::complete:...'.
17549
17550       _all_matches
17551              This  completer  can  be  used to add a string consisting of all
17552              other matches.  As it influences later completers it must appear
17553              as  the first completer in the list.  The list of all matches is
17554              affected by the avoid-completer and old-matches styles described
17555              above.
17556
17557              It may be useful to use the _generic function described below to
17558              bind _all_matches to its own keystroke, for example:
17559
17560                     zle -C all-matches complete-word _generic
17561                     bindkey '^Xa' all-matches
17562                     zstyle ':completion:all-matches:*' old-matches only
17563                     zstyle ':completion:all-matches::::' completer _all_matches
17564
17565              Note that this does not generate completions by  itself:   first
17566              use  any  of  the  standard ways of generating a list of comple‐
17567              tions, then use ^Xa to show all matches.  It is possible instead
17568              to  add  a  standard  completer to the list and request that the
17569              list of all matches should be directly inserted:
17570
17571                     zstyle ':completion:all-matches::::' completer \
17572                            _all_matches _complete
17573                     zstyle ':completion:all-matches:*' insert true
17574
17575              In this case the old-matches style should not be set.
17576
17577       _approximate
17578              This is similar to the basic _complete completer but allows  the
17579              completions  to  undergo corrections.  The maximum number of er‐
17580              rors can be specified by the max-errors style; see the  descrip‐
17581              tion  of  approximate  matching in zshexpn(1) for how errors are
17582              counted.  Normally this completer will only be tried  after  the
17583              normal _complete completer:
17584
17585                     zstyle ':completion:*' completer _complete _approximate
17586
17587              This  will give correcting completion if and only if normal com‐
17588              pletion yields no possible completions.  When corrected  comple‐
17589              tions  are found, the completer will normally start menu comple‐
17590              tion allowing you to cycle through these strings.
17591
17592              This completer uses the tags corrections and original when  gen‐
17593              erating  the  possible corrections and the original string.  The
17594              format style for the former may contain the additional sequences
17595              `%e' and `%o' which will be replaced by the number of errors ac‐
17596              cepted to generate the corrections and the original string,  re‐
17597              spectively.
17598
17599              The  completer  progressively increases the number of errors al‐
17600              lowed up to the limit by the max-errors style, hence if  a  com‐
17601              pletion  is found with one error, no completions with two errors
17602              will be shown, and so on.  It modifies the completer name in the
17603              context  to  indicate  the  number of errors being tried: on the
17604              first try the completer field contains `approximate-1',  on  the
17605              second try `approximate-2', and so on.
17606
17607              When _approximate is called from another function, the number of
17608              errors to accept may be passed with the -a option.  The argument
17609              is  in  the  same  format  as  the  max-errors style, all in one
17610              string.
17611
17612              Note that this completer (and the _correct  completer  mentioned
17613              below)  can  be quite expensive to call, especially when a large
17614              number of errors are allowed.  One way to avoid this is  to  set
17615              up  the  completer  style  using the -e option to zstyle so that
17616              some completers are only used when  completion  is  attempted  a
17617              second time on the same string, e.g.:
17618
17619                     zstyle -e ':completion:*' completer '
17620                       if [[ $_last_try != "$HISTNO$BUFFER$CURSOR" ]]; then
17621                         _last_try="$HISTNO$BUFFER$CURSOR"
17622                         reply=(_complete _match _prefix)
17623                       else
17624                         reply=(_ignored _correct _approximate)
17625                       fi'
17626
17627              This uses the HISTNO parameter and the BUFFER and CURSOR special
17628              parameters that are available inside zle and completion  widgets
17629              to  find  out  if the command line hasn't changed since the last
17630              time completion was tried.  Only then are the _ignored, _correct
17631              and _approximate completers called.
17632
17633       _canonical_paths  [ -A var ] [ -N ] [ -MJV12nfX ] tag descr [ paths ...
17634       ]
17635              This completion function completes all paths given  to  it,  and
17636              also  tries to offer completions which point to the same file as
17637              one of the paths given (relative path when an absolute  path  is
17638              given,  and  vice versa; when ..'s are present in the word to be
17639              completed; and some paths got from symlinks).
17640
17641              -A, if specified, takes the paths from the array variable speci‐
17642              fied.  Paths  can also be specified on the command line as shown
17643              above.  -N, if  specified,  prevents  canonicalizing  the  paths
17644              given before using them for completion, in case they are already
17645              so. The options -M, -J, -V, -1, -2, -n, -F,  -X  are  passed  to
17646              compadd.
17647
17648              See _description for a description of tag and descr.
17649
17650       _cmdambivalent
17651              Completes the remaining positional arguments as an external com‐
17652              mand.  The external command and its arguments are  completed  as
17653              separate  arguments  (in  a  manner  appropriate  for completing
17654              /usr/bin/env) if there are two or more remaining positional  ar‐
17655              guments  on the command line, and as a quoted command string (in
17656              the manner of system(...)) otherwise.  See also  _cmdstring  and
17657              _precommand.
17658
17659              This function takes no arguments.
17660
17661       _cmdstring
17662              Completes  an external command as a single argument, as for sys‐
17663              tem(...).
17664
17665       _complete
17666              This completer generates all  possible  completions  in  a  con‐
17667              text-sensitive  manner, i.e. using the settings defined with the
17668              compdef function explained above and the current settings of all
17669              special parameters.  This gives the normal completion behaviour.
17670
17671              To  complete  arguments  of commands, _complete uses the utility
17672              function _normal, which is in turn responsible for  finding  the
17673              particular function; it is described below.  Various contexts of
17674              the form -context- are handled specifically. These are all  men‐
17675              tioned above as possible arguments to the #compdef tag.
17676
17677              Before  trying  to find a function for a specific context, _com‐
17678              plete checks if the  parameter  `compcontext'  is  set.  Setting
17679              `compcontext'  allows  the  usual  completion  dispatching to be
17680              overridden which is useful in places such  as  a  function  that
17681              uses vared for input. If it is set to an array, the elements are
17682              taken to be the possible matches which will be  completed  using
17683              the tag `values' and the description `value'. If it is set to an
17684              associative array, the keys are used as the possible completions
17685              and  the  values (if non-empty) are used as descriptions for the
17686              matches.  If `compcontext' is set to a string containing colons,
17687              it  should  be of the form `tag:descr:action'.  In this case the
17688              tag and descr give the tag and description to use and the action
17689              indicates  what should be completed in one of the forms accepted
17690              by the _arguments utility function described below.
17691
17692              Finally, if `compcontext' is set to a string without colons, the
17693              value  is  taken as the name of the context to use and the func‐
17694              tion defined for that context will be called.  For this purpose,
17695              there  is  a special context named -command-line- that completes
17696              whole command lines (commands and their arguments).  This is not
17697              used  by the completion system itself but is nonetheless handled
17698              when explicitly called.
17699
17700       _correct
17701              Generate corrections, but not completions, for the current word;
17702              this is similar to _approximate but will not allow any number of
17703              extra characters at the cursor as that completer does.  The  ef‐
17704              fect is similar to spell-checking.  It is based on _approximate,
17705              but the completer field in the context name is correct.
17706
17707              For example, with:
17708
17709                     zstyle ':completion:::::' completer \
17710                            _complete _correct _approximate
17711                     zstyle ':completion:*:correct:::' max-errors 2 not-numeric
17712                     zstyle ':completion:*:approximate:::' max-errors 3 numeric
17713
17714              correction will accept up to two errors.  If a numeric  argument
17715              is  given, correction will not be performed, but correcting com‐
17716              pletion will be, and will accept as many errors as given by  the
17717              numeric  argument.  Without a numeric argument, first correction
17718              and then correcting completion will be tried, with the first one
17719              accepting two errors and the second one accepting three errors.
17720
17721              When  _correct  is called as a function, the number of errors to
17722              accept may be given following the -a option.  The argument is in
17723              the same form a values to the accept style, all in one string.
17724
17725              This  completer function is intended to be used without the _ap‐
17726              proximate completer or, as in the example, just before it.   Us‐
17727              ing  it  after  the _approximate completer is useless since _ap‐
17728              proximate will at least generate the corrected strings generated
17729              by the _correct completer -- and probably more.
17730
17731       _expand
17732              This  completer function does not really perform completion, but
17733              instead checks if the word on the command line is  eligible  for
17734              expansion  and,  if  it is, gives detailed control over how this
17735              expansion is done.  For this to happen,  the  completion  system
17736              needs  to  be invoked with complete-word, not expand-or-complete
17737              (the default binding for TAB), as otherwise the string  will  be
17738              expanded by the shell's internal mechanism before the completion
17739              system is started.  Note also this completer  should  be  called
17740              before the _complete completer function.
17741
17742              The  tags used when generating expansions are all-expansions for
17743              the string containing all possible expansions,  expansions  when
17744              adding  the  possible  expansions as single matches and original
17745              when adding the original string from the  line.   The  order  in
17746              which  these strings are generated, if at all, can be controlled
17747              by the group-order and tag-order styles, as usual.
17748
17749              The format string for all-expansions and for expansions may con‐
17750              tain  the  sequence  `%o' which will be replaced by the original
17751              string from the line.
17752
17753              The kind of expansion to be tried is controlled by  the  substi‐
17754              tute, glob and subst-globs-only styles.
17755
17756              It is also possible to call _expand as a function, in which case
17757              the different modes may be selected with options: -s for substi‐
17758              tute, -g for glob and -o for subst-globs-only.
17759
17760       _expand_alias
17761              If  the word the cursor is on is an alias, it is expanded and no
17762              other completers are called.  The types of aliases which are  to
17763              be  expanded  can  be controlled with the styles regular, global
17764              and disabled.
17765
17766              This function is also a bindable command, see the section `Bind‐
17767              able Commands' below.
17768
17769       _extensions
17770              If  the  cursor follows the string `*.', filename extensions are
17771              completed. The extensions are taken from files in current direc‐
17772              tory  or  a  directory specified at the beginning of the current
17773              word. For exact matches, completion  continues  to  allow  other
17774              completers  such  as _expand to expand the pattern. The standard
17775              add-space and prefix-hidden styles are observed.
17776
17777       _external_pwds
17778              Completes current directories of other zsh  processes  belonging
17779              to the current user.
17780
17781              This  is intended to be used via _generic, bound to a custom key
17782              combination. Note that pattern matching is enabled  so  matching
17783              is performed similar to how it works with the _match completer.
17784
17785       _history
17786              Complete  words  from  the  shell's command  history.  This com‐
17787              pleter can be controlled by the remove-all-dups, and sort styles
17788              as for the _history_complete_word bindable command, see the sec‐
17789              tion `Bindable Commands' below and the section `Completion  Sys‐
17790              tem Configuration' above.
17791
17792       _ignored
17793              The  ignored-patterns  style  can  be  set to a list of patterns
17794              which are compared against possible completions;  matching  ones
17795              are  removed.   With  this  completer those matches can be rein‐
17796              stated, as if no ignored-patterns style were set.  The completer
17797              actually generates its own list of matches; which completers are
17798              invoked is determined in the same way as for  the  _prefix  com‐
17799              pleter.  The single-ignored style is also available as described
17800              above.
17801
17802       _list  This completer allows the insertion of matches to be delayed un‐
17803              til  completion  is  attempted a second time without the word on
17804              the line being changed.  On the first attempt, only the list  of
17805              matches  will  be shown.  It is affected by the styles condition
17806              and word, see  the  section  `Completion  System  Configuration'
17807              above.
17808
17809       _match This  completer  is intended to be used after the _complete com‐
17810              pleter.  It behaves similarly but the string on the command line
17811              may be a pattern to match against trial completions.  This gives
17812              the effect of the GLOB_COMPLETE option.
17813
17814              Normally completion will be performed by taking the pattern from
17815              the  line,  inserting a `*' at the cursor position and comparing
17816              the resulting pattern with the possible  completions  generated.
17817              This  can  be  modified  with the match-original style described
17818              above.
17819
17820              The generated matches will be offered in a menu  completion  un‐
17821              less  the insert-unambiguous style is set to `true'; see the de‐
17822              scription above for other options for this style.
17823
17824              Note that matcher specifications defined globally or used by the
17825              completion  functions (the styles matcher-list and matcher) will
17826              not be used.
17827
17828       _menu  This completer was written as simple example  function  to  show
17829              how  menu  completion  can be enabled in shell code. However, it
17830              has the notable effect of disabling menu selection which can  be
17831              useful  with  _generic  based  widgets. It should be used as the
17832              first completer in the list.  Note that this is  independent  of
17833              the  setting  of the MENU_COMPLETE option and does not work with
17834              the other menu completion widgets such as reverse-menu-complete,
17835              or accept-and-menu-complete.
17836
17837       _oldlist
17838              This  completer controls how the standard completion widgets be‐
17839              have when there is an existing list  of  completions  which  may
17840              have  been  generated  by  a  special  completion  (i.e. a sepa‐
17841              rately-bound completion command).  It allows the  ordinary  com‐
17842              pletion  keys  to  continue  to use the list of completions thus
17843              generated, instead of producing a new list of  ordinary  contex‐
17844              tual  completions.   It  should appear in the list of completers
17845              before any of the widgets which generate matches.  It  uses  two
17846              styles:  old-list and old-menu, see the section `Completion Sys‐
17847              tem Configuration' above.
17848
17849       _precommand
17850              Complete an external command in word-separated arguments, as for
17851              exec and /usr/bin/env.
17852
17853       _prefix
17854              This  completer  can  be  used to try completion with the suffix
17855              (everything after the cursor) ignored.  In other words, the suf‐
17856              fix  will  not be considered to be part of the word to complete.
17857              The effect is similar to the expand-or-complete-prefix command.
17858
17859              The completer style is used to decide which other completers are
17860              to  be  called to generate matches.  If this style is unset, the
17861              list of completers set for the current context is  used  --  ex‐
17862              cept,  of course, the _prefix completer itself.  Furthermore, if
17863              this completer appears more than once in the list of  completers
17864              only  those  completers not already tried by the last invocation
17865              of _prefix will be called.
17866
17867              For example, consider this global completer style:
17868
17869                     zstyle ':completion:*' completer \
17870                         _complete _prefix _correct _prefix:foo
17871
17872              Here, the _prefix completer tries normal completion but ignoring
17873              the  suffix.   If that doesn't generate any matches, and neither
17874              does the call to the _correct completer after it,  _prefix  will
17875              be called a second time and, now only trying correction with the
17876              suffix ignored.  On the second invocation the completer part  of
17877              the context appears as `foo'.
17878
17879              To use _prefix as the last resort and try only normal completion
17880              when it is invoked:
17881
17882                     zstyle ':completion:*' completer _complete ... _prefix
17883                     zstyle ':completion::prefix:*' completer _complete
17884
17885              The add-space style is also respected.  If it is set  to  `true'
17886              then  _prefix  will insert a space between the matches generated
17887              (if any) and the suffix.
17888
17889              Note that this completer is only useful if the  COMPLETE_IN_WORD
17890              option is set; otherwise, the cursor will be moved to the end of
17891              the current word before the completion code is called and  hence
17892              there will be no suffix.
17893
17894       _user_expand
17895              This  completer  behaves  similarly to the _expand completer but
17896              instead  performs  expansions  defined  by  users.   The  styles
17897              add-space  and sort styles specific to the _expand completer are
17898              usable with _user_expand in addition  to  other  styles  handled
17899              more generally by the completion system.  The tag all-expansions
17900              is also available.
17901
17902              The expansion depends on the array style user-expand  being  de‐
17903              fined  for  the  current  context; remember that the context for
17904              completers is less specific than that for contextual  completion
17905              as  the  full  context has not yet been determined.  Elements of
17906              the array may have one of the following forms:
17907
17908              $hash
17909
17910                     hash is the name of an associative array.  Note  this  is
17911                     not  a  full  parameter  expression, merely a $, suitably
17912                     quoted to prevent immediate expansion,  followed  by  the
17913                     name  of  an  associative  array.  If the trial expansion
17914                     word matches a key in hash, the  resulting  expansion  is
17915                     the corresponding value.
17916              _func
17917
17918                     _func is the name of a shell function whose name must be‐
17919                     gin with _ but is not otherwise special to the completion
17920                     system.  The function is called with the trial word as an
17921                     argument.  If the word is to be  expanded,  the  function
17922                     should  set the array reply to a list of expansions.  Op‐
17923                     tionally, it can set REPLY to a word that will be used as
17924                     a description for the set of expansions.  The return sta‐
17925                     tus of the function is irrelevant.

BINDABLE COMMANDS

17927       In addition to the context-dependent completions  provided,  which  are
17928       expected to work in an intuitively obvious way, there are a few widgets
17929       implementing special behaviour which can be bound separately  to  keys.
17930       The following is a list of these and their default bindings.
17931
17932       _bash_completions
17933              This  function  is  used by two widgets, _bash_complete-word and
17934              _bash_list-choices.  It exists  to  provide  compatibility  with
17935              completion  bindings in bash.  The last character of the binding
17936              determines what is completed: `!', command names; `$',  environ‐
17937              ment  variables;  `@',  host  names;  `/',  file names; `~' user
17938              names.  In bash, the binding preceded by `\e' gives  completion,
17939              and  preceded  by `^X' lists options.  As some of these bindings
17940              clash with standard zsh bindings, only `\e~' and `^X~' are bound
17941              by  default.   To add the rest, the following should be added to
17942              .zshrc after compinit has been run:
17943
17944                     for key in '!' '$' '@' '/' '~'; do
17945                       bindkey "\e$key" _bash_complete-word
17946                       bindkey "^X$key" _bash_list-choices
17947                     done
17948
17949              This includes the bindings for `~' in  case  they  were  already
17950              bound  to  something else; the completion code does not override
17951              user bindings.
17952
17953       _correct_filename (^XC)
17954              Correct the filename path at the cursor position.  Allows up  to
17955              six  errors in the name.  Can also be called with an argument to
17956              correct a filename path, independently of zle; the correction is
17957              printed on standard output.
17958
17959       _correct_word (^Xc)
17960              Performs correction of the current argument using the usual con‐
17961              textual completions as possible choices. This stores the  string
17962              `correct-word'  in  the  function  field of the context name and
17963              then calls the _correct completer.
17964
17965       _expand_alias (^Xa)
17966              This function can be used as a completer and as a bindable  com‐
17967              mand.   It  expands the word the cursor is on if it is an alias.
17968              The types of alias expanded can be controlled  with  the  styles
17969              regular, global and disabled.
17970
17971              When  used as a bindable command there is one additional feature
17972              that can be selected by setting the complete  style  to  `true'.
17973              In  this  case,  if  the  word is not the name of an alias, _ex‐
17974              pand_alias tries to complete the word to a full alias name with‐
17975              out  expanding it.  It leaves the cursor directly after the com‐
17976              pleted word so that invoking _expand_alias once more will expand
17977              the now-complete alias name.
17978
17979       _expand_word (^Xe)
17980              Performs expansion on the current word:  equivalent to the stan‐
17981              dard expand-word command, but using the _expand completer.   Be‐
17982              fore  calling  it,  the  function field of the context is set to
17983              `expand-word'.
17984
17985       _generic
17986              This function is not defined as a widget and not  bound  by  de‐
17987              fault.  However, it can be used to define a widget and will then
17988              store the name of the widget in the function field of  the  con‐
17989              text and call the completion system.  This allows custom comple‐
17990              tion widgets with their own set of style settings to be  defined
17991              easily.   For  example,  to define a widget that performs normal
17992              completion and starts menu selection:
17993
17994                     zle -C foo complete-word _generic
17995                     bindkey '...' foo
17996                     zstyle ':completion:foo:*' menu yes select=1
17997
17998              Note in particular that the completer style may be set  for  the
17999              context in order to change the set of functions used to generate
18000              possible matches.  If _generic is called with  arguments,  those
18001              are  passed  through to _main_complete as the list of completers
18002              in place of those defined by the completer style.
18003
18004       _history_complete_word (\e/)
18005              Complete words from the shell's command history. This  uses  the
18006              list, remove-all-dups, sort, and stop styles.
18007
18008       _most_recent_file (^Xm)
18009              Complete  the  name  of the most recently modified file matching
18010              the pattern on the command line (which may be blank).  If  given
18011              a  numeric  argument  N, complete the Nth most recently modified
18012              file.  Note the completion, if any, is always unique.
18013
18014       _next_tags (^Xn)
18015              This command alters the set of matches used to that for the next
18016              tag,  or  set of tags, either as given by the tag-order style or
18017              as set by default; these matches would otherwise not  be  avail‐
18018              able.   Successive  invocations of the command cycle through all
18019              possible sets of tags.
18020
18021       _read_comp (^X^R)
18022              Prompt the user for a string, and use that to perform completion
18023              on  the  current  word.   There  are  two  possibilities for the
18024              string.  First, it can be a set of words beginning `_', for  ex‐
18025              ample `_files -/', in which case the function with any arguments
18026              will be called to generate the completions.   Unambiguous  parts
18027              of  the  function  name  will be completed automatically (normal
18028              completion is not available at this  point)  until  a  space  is
18029              typed.
18030
18031              Second, any other string will be passed as a set of arguments to
18032              compadd and should hence be an expression specifying what should
18033              be completed.
18034
18035              A  very  restricted  set  of  editing commands is available when
18036              reading the string:  `DEL' and `^H' delete the  last  character;
18037              `^U'  deletes  the  line,  and `^C' and `^G' abort the function,
18038              while `RET' accepts the completion.  Note  the  string  is  used
18039              verbatim  as  a command line, so arguments must be quoted in ac‐
18040              cordance with standard shell rules.
18041
18042              Once a string has been read, the next call  to  _read_comp  will
18043              use  the existing string instead of reading a new one.  To force
18044              a new string to be read, call _read_comp with  a  numeric  argu‐
18045              ment.
18046
18047       _complete_debug (^X?)
18048              This widget performs ordinary completion, but captures in a tem‐
18049              porary file a trace of the shell commands executed by  the  com‐
18050              pletion  system.   Each completion attempt gets its own file.  A
18051              command to view each of these files is pushed  onto  the  editor
18052              buffer stack.
18053
18054       _complete_help (^Xh)
18055              This  widget  displays  information about the context names, the
18056              tags, and the completion functions used when completing  at  the
18057              current  cursor position. If given a numeric argument other than
18058              1 (as in `ESC-2 ^Xh'), then the styles used and the contexts for
18059              which they are used will be shown, too.
18060
18061              Note that the information about styles may be incomplete; it de‐
18062              pends on the information available from the completion functions
18063              called, which in turn is determined by the user's own styles and
18064              other settings.
18065
18066       _complete_help_generic
18067              Unlike other commands listed here, this must  be  created  as  a
18068              normal ZLE widget rather than a completion widget (i.e. with zle
18069              -N).  It is used for generating help with a widget bound to  the
18070              _generic widget that is described above.
18071
18072              If  this widget is created using the name of the function, as it
18073              is by default, then when executed it will read a  key  sequence.
18074              This  is expected to be bound to a call to a completion function
18075              that uses the _generic widget.  That widget  will  be  executed,
18076              and  information  provided  in  the  same  format that the _com‐
18077              plete_help widget displays for contextual completion.
18078
18079              If the widget's name contains debug, for example if it  is  cre‐
18080              ated as `zle -N _complete_debug_generic _complete_help_generic',
18081              it will read and execute the keystring for a generic  widget  as
18082              before, but then generate debugging information as done by _com‐
18083              plete_debug for contextual completion.
18084
18085              If the widget's  name  contains  noread,  it  will  not  read  a
18086              keystring  but  instead  arrange  that the next use of a generic
18087              widget run in the same shell will have the effect  as  described
18088              above.
18089
18090              The    widget    works    by   setting   the   shell   parameter
18091              ZSH_TRACE_GENERIC_WIDGET which is read by  _generic.   Unsetting
18092              the parameter cancels any pending effect of the noread form.
18093
18094              For example, after executing the following:
18095
18096                     zle -N _complete_debug_generic _complete_help_generic
18097                     bindkey '^x:' _complete_debug_generic
18098
18099              typing `C-x :' followed by the key sequence for a generic widget
18100              will cause trace output for that widget to be saved to a file.
18101
18102       _complete_tag (^Xt)
18103              This widget completes symbol tags created by the etags or  ctags
18104              programmes (note there is no connection with the completion sys‐
18105              tem's tags) stored in a file TAGS, in the format used by  etags,
18106              or  tags,  in the format created by ctags.  It will look back up
18107              the path hierarchy for the first occurrence of either  file;  if
18108              both  exist,  the  file  TAGS is preferred.  You can specify the
18109              full path to a TAGS or tags file by setting the parameter $TAGS‐
18110              FILE  or  $tagsfile  respectively.  The corresponding completion
18111              tags used are etags and vtags, after emacs and vi respectively.
18112

UTILITY FUNCTIONS

18114       Descriptions follow for utility functions that may be useful when writ‐
18115       ing  completion  functions.   If functions are installed in subdirecto‐
18116       ries, most of these reside in the Base subdirectory.  Like the  example
18117       functions  for commands in the distribution, the utility functions gen‐
18118       erating matches all follow the convention of returning status  zero  if
18119       they  generated  completions  and  non-zero  if no matching completions
18120       could be added.
18121
18122       _absolute_command_paths
18123              This function completes external commands as absolute paths (un‐
18124              like  _command_names  -e  which  completes their basenames).  It
18125              takes no arguments.
18126
18127       _all_labels [ -x ] [ -12VJ ] tag name descr [ command arg ... ]
18128              This is a convenient interface to the _next_label  function  be‐
18129              low,  implementing  the  loop  shown in the _next_label example.
18130              The command  and  its  arguments  are  called  to  generate  the
18131              matches.  The options stored in the parameter name will automat‐
18132              ically be inserted into the args passed to  the  command.   Nor‐
18133              mally,  they  are  put directly after the command, but if one of
18134              the args is a single hyphen, they are inserted  directly  before
18135              that.   If  the  hyphen is the last argument, it will be removed
18136              from the argument list before the command is called.   This  al‐
18137              lows  _all_labels  to  be  used  in  almost  all cases where the
18138              matches can be generated by a single call to the compadd builtin
18139              command or by a call to one of the utility functions.
18140
18141              For example:
18142
18143                     local expl
18144                     ...
18145                     if _requested foo; then
18146                       ...
18147                       _all_labels foo expl '...' compadd ... - $matches
18148                     fi
18149
18150              Will complete the strings from the matches parameter, using com‐
18151              padd with additional options which  will  take  precedence  over
18152              those generated by _all_labels.
18153
18154       _alternative [ -O name ] [ -C name ] spec ...
18155              This  function is useful in simple cases where multiple tags are
18156              available.  Essentially it implements a loop like  the  one  de‐
18157              scribed for the _tags function below.
18158
18159              The  tags to use and the action to perform if a tag is requested
18160              are described using the specs which are of  the  form:  `tag:de‐
18161              scr:action'.  The tags are offered using _tags and if the tag is
18162              requested, the action is executed with the given description de‐
18163              scr.   The actions are those accepted by the _arguments function
18164              (described below), excluding the `->state' and `=...' forms.
18165
18166              For example, the action may be a simple function call:
18167
18168                     _alternative \
18169                         'users:user:_users' \
18170                         'hosts:host:_hosts'
18171
18172              offers usernames and hostnames as possible matches, generated by
18173              the _users and _hosts functions respectively.
18174
18175              Like  _arguments,  this function uses _all_labels to execute the
18176              actions, which will loop over all sets of  tags.   Special  han‐
18177              dling  is only required if there is an additional valid tag, for
18178              example inside a function called from _alternative.
18179
18180              The option `-O name' is used in the same way as  by  the  _argu‐
18181              ments  function.  In other words, the elements of the name array
18182              will be passed to compadd when executing an action.
18183
18184              Like _tags this function supports the -C option to give  a  dif‐
18185              ferent name for the argument context field.
18186
18187
18188       _arguments [ -nswWCRS ] [ -A pat ] [ -O name ] [ -M matchspec ]
18189                  [ : ] spec ...
18190       _arguments [ opt ... ] -- [ -l ] [ -i pats ] [ -s pair ]
18191                  [ helpspec ...]
18192              This  function  can be used to give a complete specification for
18193              completion for a command whose arguments  follow  standard  UNIX
18194              option and argument conventions.
18195
18196              Options Overview
18197
18198              Options  to _arguments itself must be in separate words, i.e. -s
18199              -w, not -sw.  The options are followed by  specs  that  describe
18200              options and arguments of the analyzed command.  To avoid ambigu‐
18201              ity, all options to _arguments itself may be separated from  the
18202              spec forms by a single colon.
18203
18204              The  `--' form is used to intuit spec forms from the help output
18205              of the command being analyzed, and is described in detail below.
18206              The opts for the `--' form are otherwise the same options as the
18207              first form.  Note that `-s' following `--' has a distinct  mean‐
18208              ing from `-s' preceding `--', and both may appear.
18209
18210              The option switches -s, -S, -A, -w, and -W affect how _arguments
18211              parses the analyzed command line's options.  These switches  are
18212              useful for commands with standard argument parsing.
18213
18214              The options of _arguments have the following meanings:
18215
18216              -n     With  this  option, _arguments sets the parameter NORMARG
18217                     to the position of  the  first  normal  argument  in  the
18218                     $words  array, i.e. the position after the end of the op‐
18219                     tions.  If that argument has not been reached, NORMARG is
18220                     set  to  -1.  The caller should declare `integer NORMARG'
18221                     if the -n option is passed; otherwise  the  parameter  is
18222                     not used.
18223
18224              -s     Enable option stacking for single-letter options, whereby
18225                     multiple single-letter options may  be  combined  into  a
18226                     single  word.  For example, the two options `-x' and `-y'
18227                     may be combined into a single word  `-xy'.   By  default,
18228                     every  word corresponds to a single option name (`-xy' is
18229                     a single option named `xy').
18230
18231                     Options beginning with a single hyphen or plus  sign  are
18232                     eligible  for  stacking; words beginning with two hyphens
18233                     are not.
18234
18235                     Note that -s after -- has a different meaning,  which  is
18236                     documented  in  the segment entitled `Deriving spec forms
18237                     from the help output'.
18238
18239              -w     In combination with -s, allow option stacking even if one
18240                     or  more  of the options take arguments.  For example, if
18241                     -x takes an argument, with no -s, `-xy' is considered  as
18242                     a  single  (unhandled)  option; with -s, -xy is an option
18243                     with the argument `y'; with both -s and -w,  -xy  is  the
18244                     option  -x and the option -y with arguments to -x (and to
18245                     -y, if it takes arguments) still to  come  in  subsequent
18246                     words.
18247
18248              -W     This  option takes -w a stage further:  it is possible to
18249                     complete single-letter options  even  after  an  argument
18250                     that occurs in the same word.  However, it depends on the
18251                     action performed whether options will really be completed
18252                     at  this point.  For more control, use a utility function
18253                     like _guard as part of the action.
18254
18255              -C     Modify the curcontext parameter for an action of the form
18256                     `->state'.  This is discussed in detail below.
18257
18258              -R     Return  status 300 instead of zero when a $state is to be
18259                     handled, in the `->string' syntax.
18260
18261              -S     Do not complete options after a  `--'  appearing  on  the
18262                     line,  and ignore the `--'.  For example, with -S, in the
18263                     line
18264
18265                            foobar -x -- -y
18266
18267                     the `-x' is considered an option, the `-y' is  considered
18268                     an argument, and the `--' is considered to be neither.
18269
18270              -A pat Do  not complete options after the first non-option argu‐
18271                     ment on the line.  pat is a pattern matching all  strings
18272                     which  are not to be taken as arguments.  For example, to
18273                     make _arguments stop completing options after  the  first
18274                     normal argument, but ignoring all strings starting with a
18275                     hyphen even if they are not described by one of the  opt‐
18276                     specs, the form is `-A "-*"'.
18277
18278              -O name
18279                     Pass the elements of the array name as arguments to func‐
18280                     tions called to execute actions.  This  is  discussed  in
18281                     detail below.
18282
18283              -M matchspec
18284                     Use  the match specification matchspec for completing op‐
18285                     tion names and values.  The default matchspec allows par‐
18286                     tial  word completion after `_' and `-', such as complet‐
18287                     ing `-f-b' to `-foo-bar'.  The default matchspec is:
18288                     r:|[_-]=* r:|=*
18289
18290              specs: overview
18291
18292              Each of the following forms is a spec describing individual sets
18293              of options or arguments on the command line being analyzed.
18294
18295              n:message:action
18296              n::message:action
18297                     This  describes  the  n'th  normal argument.  The message
18298                     will be printed above the matches generated and  the  ac‐
18299                     tion  indicates  what  can  be completed in this position
18300                     (see below).  If there are two colons before the  message
18301                     the  argument  is optional.  If the message contains only
18302                     white space, nothing will be printed  above  the  matches
18303                     unless the action adds an explanation string itself.
18304
18305              :message:action
18306              ::message:action
18307                     Similar, but describes the next argument, whatever number
18308                     that happens to be.  If all arguments  are  specified  in
18309                     this  form  in the correct order the numbers are unneces‐
18310                     sary.
18311
18312              *:message:action
18313              *::message:action
18314              *:::message:action
18315                     This describes how arguments  (usually  non-option  argu‐
18316                     ments,  those  not  beginning with - or +) are to be com‐
18317                     pleted when neither of the first two forms was  provided.
18318                     Any number of arguments can be completed in this fashion.
18319
18320                     With two colons before the message, the words special ar‐
18321                     ray and the CURRENT special parameter are modified to re‐
18322                     fer  only to the normal arguments when the action is exe‐
18323                     cuted or evaluated.  With three colons before the message
18324                     they  are  modified to refer only to the normal arguments
18325                     covered by this description.
18326
18327              optspec
18328              optspec:...
18329                     This describes an option.  The colon  indicates  handling
18330                     for  one  or  more  arguments to the option; if it is not
18331                     present, the option is assumed to take no arguments.
18332
18333                     The following forms are available for  the  initial  opt‐
18334                     spec, whether or not the option has arguments.
18335
18336                     *optspec
18337                            Here  optspec is one of the remaining forms below.
18338                            This indicates the following optspec  may  be  re‐
18339                            peated.   Otherwise if the corresponding option is
18340                            already present on the command line to the left of
18341                            the cursor it will not be offered again.
18342
18343                     -optname
18344                     +optname
18345                            In  the  simplest form the optspec is just the op‐
18346                            tion name beginning with a minus or a  plus  sign,
18347                            such as `-foo'.  The first argument for the option
18348                            (if any) must follow as a separate  word  directly
18349                            after the option.
18350
18351                            Either  of `-+optname' and `+-optname' can be used
18352                            to specify that -optname  and  +optname  are  both
18353                            valid.
18354
18355                            In all the remaining forms, the leading `-' may be
18356                            replaced by or paired with `+' in this way.
18357
18358                     -optname-
18359                            The first argument of the  option  must  come  di‐
18360                            rectly  after  the  option  name in the same word.
18361                            For example, `-foo-:...' specifies that  the  com‐
18362                            pleted   option   and   argument  will  look  like
18363                            `-fooarg'.
18364
18365                     -optname+
18366                            The first argument may  appear  immediately  after
18367                            optname in the same word, or may appear as a sepa‐
18368                            rate  word  after  the   option.    For   example,
18369                            `-foo+:...'  specifies  that  the completed option
18370                            and argument will look like  either  `-fooarg'  or
18371                            `-foo arg'.
18372
18373                     -optname=
18374                            The  argument  may  appear as the next word, or in
18375                            same word as the option name provided that  it  is
18376                            separated  from  it by an equals sign, for example
18377                            `-foo=arg' or `-foo arg'.
18378
18379                     -optname=-
18380                            The argument to the option must  appear  after  an
18381                            equals sign in the same word, and may not be given
18382                            in the next argument.
18383
18384                     optspec[explanation]
18385                            An explanation string may be appended  to  any  of
18386                            the  preceding forms of optspec by enclosing it in
18387                            brackets, as in `-q[query operation]'.
18388
18389                            The verbose style is used to  decide  whether  the
18390                            explanation  strings are displayed with the option
18391                            in a completion listing.
18392
18393                            If no bracketed explanation string  is  given  but
18394                            the auto-description style is set and only one ar‐
18395                            gument is described for this optspec, the value of
18396                            the style is displayed, with any appearance of the
18397                            sequence `%d' in it replaced by the message of the
18398                            first optarg that follows the optspec; see below.
18399
18400                     It  is  possible for options with a literal `+' or `=' to
18401                     appear, but that character must be  quoted,  for  example
18402                     `-\+'.
18403
18404                     Each  optarg  following  an  optspec must take one of the
18405                     following forms:
18406
18407                     :message:action
18408                     ::message:action
18409                            An argument to the option; message and action  are
18410                            treated  as  for ordinary arguments.  In the first
18411                            form, the argument is mandatory, and in the second
18412                            form it is optional.
18413
18414                            This  group may be repeated for options which take
18415                            multiple arguments.  In other words, :message1:ac‐
18416                            tion1:message2:action2  specifies  that the option
18417                            takes two arguments.
18418
18419                     :*pattern:message:action
18420                     :*pattern::message:action
18421                     :*pattern:::message:action
18422                            This describes multiple arguments.  Only the  last
18423                            optarg for an option taking multiple arguments may
18424                            be given in this form.  If the  pattern  is  empty
18425                            (i.e.  :*:),  all  the remaining words on the line
18426                            are to be completed as described  by  the  action;
18427                            otherwise,  all  the  words  up to and including a
18428                            word matching the pattern are to be completed  us‐
18429                            ing the action.
18430
18431                            Multiple  colons  are  treated  as for the `*:...'
18432                            forms for ordinary arguments:  when the message is
18433                            preceded  by  two  colons, the words special array
18434                            and the CURRENT  special  parameter  are  modified
18435                            during  the  execution or evaluation of the action
18436                            to refer only to the words after the option.  When
18437                            preceded by three colons, they are modified to re‐
18438                            fer only to the words covered by this description.
18439
18440              Any literal colon in an optname, message, or action must be pre‐
18441              ceded by a backslash, `\:'.
18442
18443              Each of the forms above may be preceded by a list in parentheses
18444              of option names and argument numbers.  If the given option is on
18445              the  command line, the options and arguments indicated in paren‐
18446              theses  will  not  be  offered.   For  example,  `(-two   -three
18447              1)-one:...'  completes the option `-one'; if this appears on the
18448              command line, the options -two and -three and the first ordinary
18449              argument will not be completed after it.  `(-foo):...' specifies
18450              an ordinary argument completion; -foo will not be  completed  if
18451              that argument is already present.
18452
18453              Other  items may appear in the list of excluded options to indi‐
18454              cate various other items that should not  be  applied  when  the
18455              current specification is matched: a single star (*) for the rest
18456              arguments (i.e. a specification of the form  `*:...');  a  colon
18457              (:) for all normal (non-option-) arguments; and a hyphen (-) for
18458              all options.  For example, if `(*)' appears before an option and
18459              the  option  appears  on the command line, the list of remaining
18460              arguments (those shown in the above table beginning  with  `*:')
18461              will not be completed.
18462
18463              To aid in reuse of specifications, it is possible to precede any
18464              of the forms above with `!'; then the form  will  no  longer  be
18465              completed,  although  if  the  option or argument appears on the
18466              command line they will be skipped as normal.  The main  use  for
18467              this is when the arguments are given by an array, and _arguments
18468              is called repeatedly for more specific contexts:  on  the  first
18469              call  `_arguments  $global_options'  is  used, and on subsequent
18470              calls `_arguments !$^global_options'.
18471
18472              specs: actions
18473
18474              In each of the forms above the action determines how completions
18475              should  be generated.  Except for the `->string' form below, the
18476              action will be executed by calling the _all_labels  function  to
18477              process  all  tag labels.  No special handling of tags is needed
18478              unless a function call introduces a new one.
18479
18480              The functions called to execute actions will be called with  the
18481              elements  of  the  array  named by the `-O name' option as argu‐
18482              ments.  This can be used, for example, to pass the same  set  of
18483              options for the compadd builtin to all actions.
18484
18485              The forms for action are as follows.
18486
18487               (single unquoted space)
18488                     This  is  useful  where an argument is required but it is
18489                     not possible or desirable to  generate  matches  for  it.
18490                     The  message will be displayed but no completions listed.
18491                     Note that even in this case the colon at the end  of  the
18492                     message  is needed; it may only be omitted when neither a
18493                     message nor an action is given.
18494
18495              (item1 item2 ...)
18496                     One of a list of possible matches, for example:
18497
18498                            :foo:(foo bar baz)
18499
18500              ((item1\:desc1 ...))
18501                     Similar to the above, but with descriptions for each pos‐
18502                     sible  match.   Note the backslash before the colon.  For
18503                     example,
18504
18505                            :foo:((a\:bar b\:baz))
18506
18507                     The matches will be listed together with  their  descrip‐
18508                     tions if the description style is set with the values tag
18509                     in the context.
18510
18511              ->string
18512                     In this form, _arguments processes the arguments and  op‐
18513                     tions  and  then  returns control to the calling function
18514                     with parameters set to indicate the state of  processing;
18515                     the  calling function then makes its own arrangements for
18516                     generating completions.  For example, functions that  im‐
18517                     plement a state machine can use this type of action.
18518
18519                     Where _arguments encounters action in the `->string' for‐
18520                     mat, it will strip all leading  and  trailing  whitespace
18521                     from  string  and  set  the array state to the set of all
18522                     strings for which an action is to be performed.  The ele‐
18523                     ments  of  the  array state_descr are assigned the corre‐
18524                     sponding message field from each optarg  containing  such
18525                     an action.
18526
18527                     By default and in common with all other well behaved com‐
18528                     pletion functions, _arguments returns status zero  if  it
18529                     was  able to add matches and non-zero otherwise. However,
18530                     if the -R option is given, _arguments will instead return
18531                     a status of 300 to indicate that $state is to be handled.
18532
18533                     In  addition  to $state and $state_descr, _arguments also
18534                     sets  the  global  parameters   `context',   `line'   and
18535                     `opt_args'  as  described  below,  and does not reset any
18536                     changes made to the special parameters such as PREFIX and
18537                     words.  This gives the calling function the choice of re‐
18538                     setting these parameters or propagating changes in them.
18539
18540                     A function calling _arguments with at  least  one  action
18541                     containing  a `->string' must therefore declare appropri‐
18542                     ate local parameters:
18543
18544                            local context state state_descr line
18545                            typeset -A opt_args
18546
18547                     to prevent _arguments from altering the  global  environ‐
18548                     ment.
18549
18550              {eval-string}
18551                     A string in braces is evaluated as shell code to generate
18552                     matches.  If the eval-string itself does not  begin  with
18553                     an opening parenthesis or brace it is split into separate
18554                     words before execution.
18555
18556              = action
18557                     If the action starts with `= ' (an equals  sign  followed
18558                     by  a  space), _arguments will insert the contents of the
18559                     argument field of the current context as  the  new  first
18560                     element  in  the  words  special  array and increment the
18561                     value of the CURRENT special parameter.  This has the ef‐
18562                     fect  of  inserting a dummy word onto the completion com‐
18563                     mand line while not changing the point at  which  comple‐
18564                     tion is taking place.
18565
18566                     This  is  most useful with one of the specifiers that re‐
18567                     strict the words on the command line on which the  action
18568                     is  to  operate  (the  two- and three-colon forms above).
18569                     One particular use is when an action itself causes _argu‐
18570                     ments  on a restricted range; it is necessary to use this
18571                     trick to insert an  appropriate  command  name  into  the
18572                     range  for  the  second  call to _arguments to be able to
18573                     parse the line.
18574
18575               word...
18576              word...
18577                     This covers all forms other than those above.  If the ac‐
18578                     tion  starts  with  a  space, the remaining list of words
18579                     will be invoked unchanged.
18580
18581                     Otherwise it will be  invoked  with  some  extra  strings
18582                     placed  after the first word; these are to be passed down
18583                     as options to the compadd builtin.  They ensure that  the
18584                     state specified by _arguments, in particular the descrip‐
18585                     tions of options and arguments, is  correctly  passed  to
18586                     the  completion  command.  These additional arguments are
18587                     taken from the array parameter `expl'; this will  be  set
18588                     up  before executing the action and hence may be referred
18589                     to inside it, typically  in  an  expansion  of  the  form
18590                     `$expl[@]' which preserves empty elements of the array.
18591
18592              During  the  performance  of the action the array `line' will be
18593              set to the normal arguments from  the  command  line,  i.e.  the
18594              words from the command line after the command name excluding all
18595              options and their arguments.  Options are stored in the associa‐
18596              tive  array `opt_args' with option names as keys and their argu‐
18597              ments as the values.  For options that have more than one  argu‐
18598              ment  these  are  given as one string, separated by colons.  All
18599              colons and backslashes in the original  arguments  are  preceded
18600              with backslashes.
18601
18602              The  parameter  `context'  is  set when returning to the calling
18603              function to perform an action of the form `->string'.  It is set
18604              to an array of elements corresponding to the elements of $state.
18605              Each element is a suitable name for the argument  field  of  the
18606              context: either a string of the form `option-opt-n' for the n'th
18607              argument of the option -opt, or a  string  of  the  form  `argu‐
18608              ment-n'  for  the  n'th argument.  For `rest' arguments, that is
18609              those in the list at the end not handled by position, n  is  the
18610              string `rest'.  For example, when completing the argument of the
18611              -o option, the name is `option-o-1', while for the second normal
18612              (non-option-) argument it is `argument-2'.
18613
18614              Furthermore,  during  the  evaluation  of the action the context
18615              name in the curcontext parameter is altered to append  the  same
18616              string that is stored in the context parameter.
18617
18618              The  option -C tells _arguments to modify the curcontext parame‐
18619              ter for an action of the form `->state'.  This is  the  standard
18620              parameter  used  to  keep track of the current context.  Here it
18621              (and not the context array) should be made local to the  calling
18622              function  to avoid passing back the modified value and should be
18623              initialised to the current value at the start of the function:
18624
18625                     local curcontext="$curcontext"
18626
18627              This is useful where it is not possible for multiple  states  to
18628              be valid together.
18629
18630              Grouping Options
18631
18632              Options  can  be grouped to simplify exclusion lists. A group is
18633              introduced with `+' followed by a name for the group in the sub‐
18634              sequent  word.  Whole groups can then be referenced in an exclu‐
18635              sion list or a group name can be used  to  disambiguate  between
18636              two forms of the same option. For example:
18637
18638                     _arguments \
18639                         '(group2--x)-a' \
18640                       + group1 \
18641                         -m \
18642                         '(group2)-n' \
18643                       + group2 \
18644                         -x -y
18645
18646              If  the  name  of a group is specified in the form `(name)' then
18647              only one value from that group will ever be completed; more for‐
18648              mally,  all  specifications  are mutually exclusive to all other
18649              specifications in that group. This is useful  for  defining  op‐
18650              tions that are aliases for each other. For example:
18651
18652                     _arguments \
18653                         -a -b \
18654                       + '(operation)' \
18655                         {-c,--compress}'[compress]' \
18656                         {-d,--decompress}'[decompress]' \
18657                         {-l,--list}'[list]'
18658
18659              If  an  option  in  a  group  appears on the command line, it is
18660              stored in the associative array `opt_args'  with  'group-option'
18661              as a key.  In the example above, a key `operation--c' is used if
18662              the option `-c' is present on the command line.
18663
18664              Specifying Multiple Sets of Arguments
18665
18666              It is possible to specify multiple sets of options and arguments
18667              with  the  sets  separated  by single hyphens. This differs from
18668              groups in that sets are considered to be mutually  exclusive  of
18669              each other.
18670
18671              Specifications  before the first set and from any group are com‐
18672              mon to all sets. For example:
18673
18674                     _arguments \
18675                         -a \
18676                       - set1 \
18677                         -c \
18678                       - set2 \
18679                         -d \
18680                         ':arg:(x2 y2)'
18681
18682              This defines two sets.  When the command line contains  the  op‐
18683              tion  `-c', the `-d' option and the argument will not be consid‐
18684              ered possible completions.  When it contains `-d'  or  an  argu‐
18685              ment,  the  option  `-c' will not be considered.  However, after
18686              `-a' both sets will still be considered valid.
18687
18688              As for groups, the name of a set may appear in exclusion  lists,
18689              either alone or preceding a normal option or argument specifica‐
18690              tion.
18691
18692              The completion code has to parse the command line separately for
18693              each set. This can be slow so sets should only be used when nec‐
18694              essary.  A useful alternative is often an  option  specification
18695              with  rest-arguments  (as in `-foo:*:...'); here the option -foo
18696              swallows up all remaining arguments as described by  the  optarg
18697              definitions.
18698
18699              Deriving spec forms from the help output
18700
18701              The  option `--' allows _arguments to work out the names of long
18702              options that support the `--help' option which  is  standard  in
18703              many GNU commands.  The command word is called with the argument
18704              `--help' and the output examined for option names.  Clearly,  it
18705              can  be dangerous to pass this to commands which may not support
18706              this option as the behaviour of the command is unspecified.
18707
18708              In addition to options, `_arguments --' will try to  deduce  the
18709              types   of   arguments  available  for  options  when  the  form
18710              `--opt=val' is valid.  It is also possible to provide  hints  by
18711              examining  the  help  text of the command and adding helpspec of
18712              the form `pattern:message:action'; note  that  other  _arguments
18713              spec  forms  are  not  used.  The pattern is matched against the
18714              help text for an option, and if it matches the message  and  ac‐
18715              tion  are  used  as  for other argument specifiers.  The special
18716              case of `*:' means both message and action are empty, which  has
18717              the  effect of causing options having no description in the help
18718              output to be ordered in listings ahead of options  that  have  a
18719              description.
18720
18721              For example:
18722
18723                     _arguments -- '*\*:toggle:(yes no)' \
18724                                   '*=FILE*:file:_files' \
18725                                   '*=DIR*:directory:_files -/' \
18726                                   '*=PATH*:directory:_files -/'
18727
18728              Here,  `yes'  and  `no' will be completed as the argument of op‐
18729              tions whose description ends in a star; file names will be  com‐
18730              pleted for options that contain the substring `=FILE' in the de‐
18731              scription; and directories will be completed for  options  whose
18732              description  contains  `=DIR' or `=PATH'.  The last three are in
18733              fact the default and so need not be given  explicitly,  although
18734              it is possible to override the use of these patterns.  A typical
18735              help text which uses this feature is:
18736
18737                       -C, --directory=DIR          change to directory DIR
18738
18739              so that the above specifications will cause  directories  to  be
18740              completed after `--directory', though not after `-C'.
18741
18742              Note also that _arguments tries to find out automatically if the
18743              argument for an option is optional.  This can be  specified  ex‐
18744              plicitly by doubling the colon before the message.
18745
18746              If the pattern ends in `(-)', this will be removed from the pat‐
18747              tern and the action will be used only directly  after  the  `=',
18748              not  in the next word.  This is the behaviour of a normal speci‐
18749              fication defined with the form `=-'.
18750
18751              By default, the command (with the option `--help') is run  after
18752              resetting  all  the  locale  categories (except for LC_CTYPE) to
18753              `C'.  If the localized help output is known to work, the  option
18754              `-l' can be specified after the `_arguments --' so that the com‐
18755              mand is run in the current locale.
18756
18757              The `_arguments --' can be followed by the option `-i  patterns'
18758              to give patterns for options which are not to be completed.  The
18759              patterns can be given as the name of an array parameter or as  a
18760              literal list in parentheses.  For example,
18761
18762                     _arguments -- -i \
18763                         "(--(en|dis)able-FEATURE*)"
18764
18765              will  cause  completion to ignore the options `--enable-FEATURE'
18766              and `--disable-FEATURE' (this example is useful with GNU config‐
18767              ure).
18768
18769              The  `_arguments --' form can also be followed by the option `-s
18770              pair' to describe option aliases.  The pair consists of  a  list
18771              of alternating patterns and corresponding replacements, enclosed
18772              in parens and quoted so that it forms a single argument word  in
18773              the _arguments call.
18774
18775              For example, some configure-script help output describes options
18776              only as `--enable-foo', but the script also accepts the  negated
18777              form `--disable-foo'.  To allow completion of the second form:
18778
18779                     _arguments -- -s "((#s)--enable- --disable-)"
18780
18781              Miscellaneous notes
18782
18783              Finally,  note  that _arguments generally expects to be the pri‐
18784              mary function handling any completion for which it is used.   It
18785              may  have side effects which change the treatment of any matches
18786              added by other functions called after it.  To combine _arguments
18787              with  other  functions,  those functions should be called either
18788              before _arguments, as an action within a spec,  or  in  handlers
18789              for `->state' actions.
18790
18791              Here is a more general example of the use of _arguments:
18792
18793                     _arguments '-l+:left border:' \
18794                                '-format:paper size:(letter A4)' \
18795                                '*-copy:output file:_files::resolution:(300 600)' \
18796                                ':postscript file:_files -g \*.\(ps\|eps\)' \
18797                                '*:page number:'
18798
18799              This describes three options: `-l', `-format', and `-copy'.  The
18800              first takes one argument described as `left border' for which no
18801              completion will be offered because of the empty action.  Its ar‐
18802              gument may come directly after the `-l' or it may  be  given  as
18803              the next word on the line.
18804
18805              The  `-format'  option  takes one argument in the next word, de‐
18806              scribed as `paper size' for which only the strings `letter'  and
18807              `A4' will be completed.
18808
18809              The `-copy' option may appear more than once on the command line
18810              and takes two arguments.  The first is  mandatory  and  will  be
18811              completed as a filename.  The second is optional (because of the
18812              second colon before the description `resolution')  and  will  be
18813              completed from the strings `300' and `600'.
18814
18815              The  last two descriptions say what should be completed as argu‐
18816              ments.  The first describes the first argument as a  `postscript
18817              file' and makes files ending in `ps' or `eps' be completed.  The
18818              last description gives all other arguments the description `page
18819              numbers' but does not offer completions.
18820
18821       _cache_invalid cache_identifier
18822              This  function returns status zero if the completions cache cor‐
18823              responding to the given cache identifier needs  rebuilding.   It
18824              determines  this  by  looking  up the cache-policy style for the
18825              current context.  This should provide a function name  which  is
18826              run  with  the  full path to the relevant cache file as the only
18827              argument.
18828
18829              Example:
18830
18831                     _example_caching_policy () {
18832                         # rebuild if cache is more than a week old
18833                         local -a oldp
18834                         oldp=( "$1"(Nm+7) )
18835                         (( $#oldp ))
18836                     }
18837
18838       _call_function return name [ arg ... ]
18839              If a function name exists, it is called with the arguments args.
18840              The  return  argument gives the name of a parameter in which the
18841              return status from the function name should be stored; if return
18842              is empty or a single hyphen it is ignored.
18843
18844              The  return status of _call_function itself is zero if the func‐
18845              tion name exists and was called and non-zero otherwise.
18846
18847       _call_program [ -l ] [ -p ] tag string ...
18848              This function provides a mechanism for the user to override  the
18849              use  of an external command.  It looks up the command style with
18850              the supplied tag.  If the style is set, its value is used as the
18851              command to execute.  The strings from the call to _call_program,
18852              or from the style if set, are concatenated with  spaces  between
18853              them  and  the resulting string is evaluated.  The return status
18854              is the return status of the command called.
18855
18856              By default, the command is run in an environment where  all  the
18857              locale  categories  (except  for  LC_CTYPE)  are reset to `C' by
18858              calling the utility function _comp_locale (see  below).  If  the
18859              option  `-l'  is  given, the command is run with the current lo‐
18860              cale.
18861
18862              If the option `-p' is supplied it  indicates  that  the  command
18863              output  is  influenced by the permissions it is run with. If the
18864              gain-privileges style is set to true,  _call_program  will  make
18865              use of commands such as sudo, if present on the command-line, to
18866              match the permissions to whatever the final command is likely to
18867              run  under.  When  looking  up  the  gain-privileges and command
18868              styles, the command component of the  zstyle  context  will  end
18869              with a slash (`/') followed by the command that would be used to
18870              gain privileges.
18871
18872       _combination [ -s pattern ] tag style spec ... field opts ...
18873              This function is used to complete combinations of  values,   for
18874              example  pairs  of  hostnames and usernames.  The style argument
18875              gives the style which defines the pairs; it is looked  up  in  a
18876              context with the tag specified.
18877
18878              The style name consists of field names separated by hyphens, for
18879              example `users-hosts-ports'.  For each field for a value is  al‐
18880              ready  known,  a spec of the form `field=pattern' is given.  For
18881              example, if the command line so far specifies a user `pws',  the
18882              argument `users=pws' should appear.
18883
18884              The  next  argument  with no equals sign is taken as the name of
18885              the field for which completions should be generated  (presumably
18886              not one of the fields for which the value is known).
18887
18888              The matches generated will be taken from the value of the style.
18889              These should contain the possible values for the combinations in
18890              the  appropriate  order  (users,  hosts,  ports  in  the example
18891              above).  The values for the different fields  are  separated  by
18892              colons.   This can be altered with the option -s to _combination
18893              which specifies a pattern.  Typically this is a character class,
18894              as for example `-s "[:@]"' in the case of the users-hosts style.
18895              Each `field=pattern'  specification  restricts  the  completions
18896              which apply to elements of the style with appropriately matching
18897              fields.
18898
18899              If no style with the given name is defined for the given tag, or
18900              if  none  of  the strings in style's value match, but a function
18901              name of the required field preceded by an underscore is defined,
18902              that function will be called to generate the matches.  For exam‐
18903              ple, if there is no `users-hosts-ports' or no matching  hostname
18904              when  a  host  is required, the function `_hosts' will automati‐
18905              cally be called.
18906
18907              If the same name is used for more than one field,  in  both  the
18908              `field=pattern'  and  the  argument  that  gives the name of the
18909              field to be completed, the number of the  field  (starting  with
18910              one)  may  be  given after the fieldname, separated from it by a
18911              colon.
18912
18913              All arguments after the required field name are passed  to  com‐
18914              padd  when  generating  matches  from the style value, or to the
18915              functions for the fields if they are called.
18916
18917       _command_names [ -e | - ]
18918              This function completes words that are valid  at  command  posi‐
18919              tion:  names  of  aliases, builtins, hashed commands, functions,
18920              and so on.  With the -e flag,  only  hashed  commands  are  com‐
18921              pleted.  The - flag is ignored.
18922
18923       _comp_locale
18924              This  function  resets  all  the  locale  categories  other than
18925              LC_CTYPE to `C' so that the output from external commands can be
18926              easily  analyzed  by the completion system. LC_CTYPE retains the
18927              current value (taking LC_ALL and LANG  into  account),  ensuring
18928              that  non-ASCII characters in file names are still handled prop‐
18929              erly.
18930
18931              This function should normally be run only in a subshell, because
18932              the  new  locale  is  exported to the environment. Typical usage
18933              would be `$(_comp_locale; command ...)'.
18934
18935       _completers [ -p ]
18936              This function completes names of completers.
18937
18938              -p     Include the leading underscore (`_') in the matches.
18939
18940
18941       _describe [-12JVx] [ -oO | -t tag ] descr name1 [ name2 ] [ opt ... ]
18942                 [ -- name1 [ name2 ] [ opt ... ] ... ]
18943              This function associates completions with descriptions.   Multi‐
18944              ple  groups  separated  by  -- can be supplied, potentially with
18945              different completion options opts.
18946
18947              The descr is taken as a string to display above the  matches  if
18948              the  format style for the descriptions tag is set.  This is fol‐
18949              lowed by one or two names of arrays followed by options to  pass
18950              to  compadd.   The array name1 contains the possible completions
18951              with their descriptions in  the  form  `completion:description'.
18952              Any  literal  colons  in  completion must be quoted with a back‐
18953              slash.  If a name2 is given, it should have the same  number  of
18954              elements  as  name1; in this case the corresponding elements are
18955              added as possible completions instead of the completion  strings
18956              from  name1.   The  completion list will retain the descriptions
18957              from name1.  Finally, a set of completion options can appear.
18958
18959              If the option  `-o'  appears  before  the  first  argument,  the
18960              matches  added will be treated as names of command options (N.B.
18961              not shell options), typically following a `-', `--'  or  `+'  on
18962              the  command  line.  In this case _describe uses the prefix-hid‐
18963              den, prefix-needed and verbose styles to find out if the strings
18964              should be added as completions and if the descriptions should be
18965              shown.  Without the `-o' option, only the verbose style is  used
18966              to  decide  how descriptions are shown.  If `-O' is used instead
18967              of `-o', command options are completed as  above  but  _describe
18968              will not handle the prefix-needed style.
18969
18970              With the -t option a tag can be specified.  The default is `val‐
18971              ues' or, if the -o option is given, `options'.
18972
18973              The options -1, -2, -J, -V, -x are passed to _next_label.
18974
18975              If selected by the list-grouped style, strings with the same de‐
18976              scription will appear together in the list.
18977
18978              _describe uses the _all_labels function to generate the matches,
18979              so it does not need to appear inside a loop over tag labels.
18980
18981       _description [ -x ] [ -12VJ ] tag name descr [ spec ... ]
18982              This function is not to be confused with the previous one; it is
18983              used  as  a helper function for creating options to compadd.  It
18984              is buried inside many of the higher level  completion  functions
18985              and so often does not need to be called directly.
18986
18987              The  styles listed below are tested in the current context using
18988              the given tag.  The resulting options for compadd are  put  into
18989              the  array  named  name  (this is traditionally `expl', but this
18990              convention is not enforced).  The  description  for  the  corre‐
18991              sponding set of matches is passed to the function in descr.
18992
18993              The styles tested are: format, hidden, matcher, ignore-line, ig‐
18994              nored-patterns, group-name and sort.  The format style is  first
18995              tested for the given tag and then for the descriptions tag if no
18996              value was found, while the remainder are only tested for the tag
18997              given  as  the  first  argument.  The function also calls _setup
18998              which tests some more styles.
18999
19000              The string returned by the format style (if any) will  be  modi‐
19001              fied so that the sequence `%d' is replaced by the descr given as
19002              the third argument without any leading or trailing white  space.
19003              If,  after  removing  the  white  space,  the descr is the empty
19004              string, the format style will not be used and  the  options  put
19005              into the name array will not contain an explanation string to be
19006              displayed above the matches.
19007
19008              If _description is called with more than  three  arguments,  the
19009              additional specs should be of the form `char:str'.  These supply
19010              escape sequence replacements for the format style: every appear‐
19011              ance of `%char' will be replaced by string.
19012
19013              If  the  -x  option  is given, the description will be passed to
19014              compadd using the -x option instead of  the  default  -X.   This
19015              means  that  the description will be displayed even if there are
19016              no corresponding matches.
19017
19018              The options placed  in  the  array  name  take  account  of  the
19019              group-name  style,  so  matches  are  placed in a separate group
19020              where necessary.  The group normally has its elements sorted (by
19021              passing  the  option  -J  to compadd), but if an option starting
19022              with `-V', `-J', `-1', or `-2' is passed to  _description,  that
19023              option  will be included in the array.  Hence it is possible for
19024              the completion group to be unsorted by giving the  option  `-V',
19025              `-1V', or `-2V'.
19026
19027              In most cases, the function will be used like this:
19028
19029                     local expl
19030                     _description files expl file
19031                     compadd "$expl[@]" - "$files[@]"
19032
19033              Note  the use of the parameter expl, the hyphen, and the list of
19034              matches.  Almost all calls to compadd within the completion sys‐
19035              tem  use  a  similar  format;  this  ensures that user-specified
19036              styles are correctly passed down to the builtins which implement
19037              the internals of completion.
19038
19039       _dir_list [ -s sep ] [ -S ]
19040              Complete a list of directory names separated by colons (the same
19041              format as $PATH).
19042
19043              -s sep Use sep as separator between items.  sep  defaults  to  a
19044                     colon (`:').
19045
19046              -S     Add  sep instead of slash (`/') as an autoremoveable suf‐
19047                     fix.
19048
19049       _dispatch context string ...
19050              This sets the current context to context and looks  for  comple‐
19051              tion  functions  to  handle  this context by hunting through the
19052              list of command names or special contexts  (as  described  above
19053              for compdef) given as strings.  The first completion function to
19054              be defined for one of the contexts in the list is used to gener‐
19055              ate  matches.   Typically, the last string is -default- to cause
19056              the function for default completion to be used as a fallback.
19057
19058              The function sets the parameter $service  to  the  string  being
19059              tried,  and  sets  the context/command field (the fourth) of the
19060              $curcontext parameter to the context given as  the  first  argu‐
19061              ment.
19062
19063       _email_addresses [ -c ] [ -n plugin ]
19064              Complete email addresses.  Addresses are provided by plugins.
19065
19066              -c     Complete  bare  localhost@domain.tld addresses, without a
19067                     name part or a  comment.   Without  this  option,  RFC822
19068                     `Firstname Lastname <address>' strings are completed.
19069
19070              -n plugin
19071                     Complete aliases from plugin.
19072
19073              The following plugins are available by default: _email-ldap (see
19074              the filter style), _email-local  (completes  user@hostname  Unix
19075              addresses),  _email-mail  (completes  aliases  from  ~/.mailrc),
19076              _email-mush, _email-mutt, and _email-pine.
19077
19078              Addresses from the _email-foo plugin are  added  under  the  tag
19079              `email-foo'.
19080
19081              Writing plugins
19082
19083              Plugins  are  written  as separate functions with names starting
19084              with `_email-'.  They are invoked with the -c option and compadd
19085              options.   They should either do their own completion or set the
19086              $reply array to a list of `alias:address'  elements  and  return
19087              300.  New plugins will be picked up and run automatically.
19088
19089       _files The function _files is a wrapper around _path_files. It supports
19090              all of the same functionality, with  some  enhancements  --  no‐
19091              tably,  it  respects  the  list-dirs-first  style, and it allows
19092              users to override the behaviour of the -g and  -/  options  with
19093              the  file-patterns  style.  _files should therefore be preferred
19094              over _path_files in most cases.
19095
19096              This function  accepts  the  full  set  of  options  allowed  by
19097              _path_files, described below.
19098
19099       _gnu_generic
19100              This function is a simple wrapper around the _arguments function
19101              described above.  It can be used to determine automatically  the
19102              long  options  understood  by  commands that produce a list when
19103              passed the option `--help'.  It is intended  to  be  used  as  a
19104              top-level completion function in its own right.  For example, to
19105              enable option completion for the commands foo and bar, use
19106
19107                     compdef _gnu_generic foo bar
19108
19109              after the call to compinit.
19110
19111              The completion system as supplied is conservative in its use  of
19112              this  function, since it is important to be sure the command un‐
19113              derstands the option `--help'.
19114
19115       _guard [ options ] pattern descr
19116              This function displays descr if pattern matches the string to be
19117              completed.   It  is  intended  to  be used in the action for the
19118              specifications passed to _arguments and similar functions.
19119
19120              The return status is zero if the message was displayed  and  the
19121              word to complete is not empty, and non-zero otherwise.
19122
19123              The  pattern may be preceded by any of the options understood by
19124              compadd that are passed down from _description, namely  -M,  -J,
19125              -V,  -1,  -2,  -n,  -F and -X.  All of these options will be ig‐
19126              nored.  This fits in conveniently with the argument-passing con‐
19127              ventions of actions for _arguments.
19128
19129              As  an  example,  consider  a  command taking the options -n and
19130              -none, where -n must be followed by a numeric value in the  same
19131              word.  By using:
19132
19133                     _arguments '-n-: :_guard "[0-9]#" "numeric value"' '-none'
19134
19135              _arguments  can  be  made  to  both display the message `numeric
19136              value' and complete options after `-n<TAB>'.  If the `-n' is al‐
19137              ready  followed  by  one  or  more digits (the pattern passed to
19138              _guard) only the message will be displayed; if the `-n' is  fol‐
19139              lowed by another character, only options are completed.
19140
19141       _message [ -r12 ] [ -VJ group ] descr
19142       _message -e [ tag ] descr
19143              The  descr  is used in the same way as the third argument to the
19144              _description function, except that the resulting string will al‐
19145              ways  be  shown  whether or not matches were generated.  This is
19146              useful for displaying a help message in places where no  comple‐
19147              tions can be generated.
19148
19149              The  format  style  is  examined with the messages tag to find a
19150              message; the usual tag, descriptions, is used only if the  style
19151              is not set with the former.
19152
19153              If  the -r option is given, no style is used; the descr is taken
19154              literally as the string to display.  This is  most  useful  when
19155              the descr comes from a pre-processed argument list which already
19156              contains an expanded description.  Note that  this  option  does
19157              not disable the `%'-sequence parsing done by compadd.
19158
19159              The  -12VJ options and the group are passed to compadd and hence
19160              determine the group the message string is added to.
19161
19162              The second -e form gives a description for completions with  the
19163              tag  tag  to be shown even if there are no matches for that tag.
19164              This form is called by _arguments in the event that there is  no
19165              action  for an option specification.  The tag can be omitted and
19166              if so the tag is taken from the parameter $curtag; this is main‐
19167              tained by the completion system and so is usually correct.  Note
19168              that if there are no  matches  at  the  time  this  function  is
19169              called, compstate[insert] is cleared, so additional matches gen‐
19170              erated later are not inserted on the command line.
19171
19172       _multi_parts [ -i ] sep array
19173              The argument sep is a separator character.  The array may be ei‐
19174              ther  the  name  of an array parameter or a literal array in the
19175              form `(foo bar)', a parenthesised list  of  words  separated  by
19176              whitespace.   The  possible completions are the strings from the
19177              array.  However, each chunk delimited by sep will  be  completed
19178              separately.  For example, the _tar function uses `_multi_parts /
19179              patharray' to complete partial file paths from the  given  array
19180              of complete file paths.
19181
19182              The  -i option causes _multi_parts to insert a unique match even
19183              if that requires multiple separators to be  inserted.   This  is
19184              not  usually  the expected behaviour with filenames, but certain
19185              other types of completion, for example those with a fixed set of
19186              possibilities, may be more suited to this form.
19187
19188              Like  other  utility  functions, this function accepts the `-V',
19189              `-J', `-1', `-2', `-n', `-f',  `-X',  `-M',  `-P',  `-S',  `-r',
19190              `-R', and `-q' options and passes them to the compadd builtin.
19191
19192       _next_label [ -x ] [ -12VJ ] tag name descr [ option ... ]
19193              This  function  is used to implement the loop over different tag
19194              labels for a particular tag as described above for the tag-order
19195              style.   On each call it checks to see if there are any more tag
19196              labels; if there is it returns status zero, otherwise  non-zero.
19197              As  this  function requires a current tag to be set, it must al‐
19198              ways follow a call to _tags or _requested.
19199
19200              The -x12VJ options and the first three arguments are  passed  to
19201              the  _description  function.   Where appropriate the tag will be
19202              replaced by a tag label in this call.  Any description given  in
19203              the  tag-order  style  is  preferred  to  the  descr  passed  to
19204              _next_label.
19205
19206              The options given after the descr are set in the parameter given
19207              by name, and hence are to be passed to compadd or whatever func‐
19208              tion is called to add the matches.
19209
19210              Here is a typical use of this function for  the  tag  foo.   The
19211              call to _requested determines if tag foo is required at all; the
19212              loop over _next_label handles any labels defined for the tag  in
19213              the tag-order style.
19214
19215                     local expl ret=1
19216                     ...
19217                     if _requested foo; then
19218                       ...
19219                       while _next_label foo expl '...'; do
19220                         compadd "$expl[@]" ... && ret=0
19221                       done
19222                       ...
19223                     fi
19224                     return ret
19225
19226       _normal [ -P | -p precommand ]
19227              This  is  the standard function called to handle completion out‐
19228              side any special -context-.  It is called both to  complete  the
19229              command  word and also the arguments for a command.  In the sec‐
19230              ond case, _normal looks for a special completion for  that  com‐
19231              mand,  and  if there is none it uses the completion for the -de‐
19232              fault- context.
19233
19234              A second use is to reexamine the command line specified  by  the
19235              $words  array  and  the $CURRENT parameter after those have been
19236              modified.  For example, the  function  _precommand,  which  com‐
19237              pletes  after  precommand  specifiers such as nohup, removes the
19238              first word from the words array, decrements the CURRENT  parame‐
19239              ter,  then calls `_normal -p $service'.  The effect is that `no‐
19240              hup cmd ...' is treated in the same way as `cmd ...'.
19241
19242              -P     Reset the list of precommands. This option should be used
19243                     if  completing  a command line which allows internal com‐
19244                     mands (e.g. builtins and functions) regardless  of  prior
19245                     precommands (e.g. `zsh -c').
19246
19247              -p precommand
19248                     Append precommand to the list of precommands. This option
19249                     should be used in nearly all cases in which -P is not ap‐
19250                     plicable.
19251
19252              If  the command name matches one of the patterns given by one of
19253              the options -p or -P to compdef,  the  corresponding  completion
19254              function  is called and then the parameter _compskip is checked.
19255              If it is set completion is terminated at that point even  if  no
19256              matches  have  been  found.   This  is the same effect as in the
19257              -first- context.
19258
19259       _options
19260              This can be used to complete the names  of  shell  options.   It
19261              provides  a  matcher  specification that ignores a leading `no',
19262              ignores underscores and allows upper-case letters to match their
19263              lower-case   counterparts   (for   example,   `glob',  `noglob',
19264              `NO_GLOB' are all completed).  Any arguments are  propagated  to
19265              the compadd builtin.
19266
19267       _options_set and _options_unset
19268              These  functions  complete  only  set or unset options, with the
19269              same matching specification used in the _options function.
19270
19271              Note that you need to uncomment a few lines  in  the  _main_com‐
19272              plete  function for these functions to work properly.  The lines
19273              in question are used to store the option settings in effect  be‐
19274              fore  the  completion  widget locally sets the options it needs.
19275              Hence these functions are not generally used by  the  completion
19276              system.
19277
19278       _parameters
19279              This is used to complete the names of shell parameters.
19280
19281              The  option  `-g  pattern'  limits  the completion to parameters
19282              whose type matches the pattern.  The type of a parameter is that
19283              shown by `print ${(t)param}', hence judicious use of `*' in pat‐
19284              tern is probably necessary.
19285
19286              All other arguments are passed to the compadd builtin.
19287
19288       _path_files
19289              This function is used throughout the completion system  to  com‐
19290              plete  filenames.   It  allows completion of partial paths.  For
19291              example, the string `/u/i/s/sig' may be completed  to  `/usr/in‐
19292              clude/sys/signal.h'.
19293
19294              The options accepted by both _path_files and _files are:
19295
19296              -f     Complete all filenames.  This is the default.
19297
19298              -/     Specifies that only directories should be completed.
19299
19300              -g pattern
19301                     Specifies  that only files matching the pattern should be
19302                     completed.
19303
19304              -W paths
19305                     Specifies path prefixes that are to be prepended  to  the
19306                     string  from  the  command line to generate the filenames
19307                     but that should not be inserted as completions nor  shown
19308                     in  completion  listings.  Here, paths may be the name of
19309                     an array parameter, a literal list of paths  enclosed  in
19310                     parentheses or an absolute pathname.
19311
19312              -F ignored-files
19313                     This  behaves as for the corresponding option to the com‐
19314                     padd builtin.  It gives direct control over  which  file‐
19315                     names  should  be ignored.  If the option is not present,
19316                     the ignored-patterns style is used.
19317
19318              Both _path_files and _files also accept  the  following  options
19319              which are passed to compadd: `-J', `-V', `-1', `-2', `-n', `-X',
19320              `-M', `-P', `-S', `-q', `-r', and `-R'.
19321
19322              Finally, the _path_files function  uses the styles  expand,  am‐
19323              biguous,  special-dirs,  list-suffixes  and  file-sort described
19324              above.
19325
19326
19327       _pick_variant [ -b builtin-label ] [ -c command ] [ -r name ]
19328                     label=pattern ... label [ arg ... ]
19329              This function is used to resolve situations where a single  com‐
19330              mand  name  requires  more than one type of handling, either be‐
19331              cause it has more than one variant or because there  is  a  name
19332              clash between two different commands.
19333
19334              The  command to run is taken from the first element of the array
19335              words unless this is overridden by the option -c.  This  command
19336              is  run  and  its  output is compared with a series of patterns.
19337              Arguments to be passed to the command can be  specified  at  the
19338              end after all the other arguments.  The patterns to try in order
19339              are given by the arguments label=pattern; if the output of `com‐
19340              mand  arg  ...'  contains pattern, then label is selected as the
19341              label for the command variant.  If none of the  patterns  match,
19342              the final command label is selected and status 1 is returned.
19343
19344              If the `-b builtin-label' is given, the command is tested to see
19345              if it is provided as a shell builtin,  possibly  autoloaded;  if
19346              so,  the  label  builtin-label  is selected as the label for the
19347              variant.
19348
19349              If the `-r name' is given, the label picked is stored in the pa‐
19350              rameter named name.
19351
19352              The  results are also cached in the _cmd_variant associative ar‐
19353              ray indexed by the name of the command run.
19354
19355       _regex_arguments name spec ...
19356              This function generates a completion function name which matches
19357              the  specifications  specs,  a set of regular expressions as de‐
19358              scribed below.  After  running  _regex_arguments,  the  function
19359              name should be called as a normal completion function.  The pat‐
19360              tern to be matched is given by the contents of the  words  array
19361              up  to  the  current  cursor  position joined together with null
19362              characters; no quotation is applied.
19363
19364              The arguments are grouped as sets of alternatives  separated  by
19365              `|',  which  are  tried  one  after the other until one matches.
19366              Each alternative consists of a one or more specifications  which
19367              are  tried  left  to  right,  with  each  pattern  matched being
19368              stripped in turn from the command line being tested,  until  all
19369              of  the  group  succeeds or until one fails; in the latter case,
19370              the next alternative is tried.  This structure can  be  repeated
19371              to  arbitrary depth by using parentheses; matching proceeds from
19372              inside to outside.
19373
19374              A special procedure is applied if no test succeeds but  the  re‐
19375              maining command line string contains no null character (implying
19376              the remaining word is the one for which completions  are  to  be
19377              generated).   The completion target is restricted to the remain‐
19378              ing word and any actions for the corresponding patterns are exe‐
19379              cuted.   In this case, nothing is stripped from the command line
19380              string.  The order of evaluation of the actions  can  be  deter‐
19381              mined  by  the tag-order style; the various formats supported by
19382              _alternative can be used in action.  The descr is used for  set‐
19383              ting up the array parameter expl.
19384
19385              Specification  arguments  take  one of following forms, in which
19386              metacharacters such as `(', `)', `#' and `|' should be quoted.
19387
19388              /pattern/ [%lookahead%] [-guard] [:tag:descr:action]
19389                     This is a single primitive component.  The function tests
19390                     whether   the  combined  pattern  `(#b)((#B)pattern)look‐
19391                     ahead*' matches the command line string.  If so,  `guard'
19392                     is  evaluated and its return status is examined to deter‐
19393                     mine if the test has succeeded.  The pattern string  `[]'
19394                     is  guaranteed  never  to  match.   The  lookahead is not
19395                     stripped from the command line before the next pattern is
19396                     examined.
19397
19398                     The  argument  starting with : is used in the same manner
19399                     as an argument to _alternative.
19400
19401                     A component is used as follows: pattern is tested to  see
19402                     if  the component already exists on the command line.  If
19403                     it does, any following  specifications  are  examined  to
19404                     find  something  to  complete.  If a component is reached
19405                     but no such pattern exists yet on the command  line,  the
19406                     string  containing the action is used to generate matches
19407                     to insert at that point.
19408
19409              /pattern/+ [%lookahead%] [-guard] [:tag:descr:action]
19410                     This is similar to `/pattern/ ...' but the left  part  of
19411                     the command line string (i.e. the part already matched by
19412                     previous patterns) is also considered part of the comple‐
19413                     tion target.
19414
19415              /pattern/- [%lookahead%] [-guard] [:tag:descr:action]
19416                     This is similar to `/pattern/ ...' but the actions of the
19417                     current and previously matched patterns are ignored  even
19418                     if the following `pattern' matches the empty string.
19419
19420              ( spec )
19421                     Parentheses may be used to groups specs; note each paren‐
19422                     thesis is a single argument to _regex_arguments.
19423
19424              spec # This allows any number of repetitions of spec.
19425
19426              spec spec
19427                     The two specs are to be matched one after  the  other  as
19428                     described above.
19429
19430              spec | spec
19431                     Either of the two specs can be matched.
19432
19433              The  function  _regex_words  can be used as a helper function to
19434              generate matches for a set of alternative  words  possibly  with
19435              their own arguments as a command line argument.
19436
19437              Examples:
19438
19439                     _regex_arguments _tst /$'[^\0]#\0'/ \
19440                         /$'[^\0]#\0'/ :'compadd aaa'
19441
19442              This  generates  a  function _tst that completes aaa as its only
19443              argument.  The tag and description  for  the  action  have  been
19444              omitted for brevity (this works but is not recommended in normal
19445              use).  The first component matches the command  word,  which  is
19446              arbitrary; the second matches  any argument.  As the argument is
19447              also arbitrary, any following component would not depend on  aaa
19448              being present.
19449
19450                     _regex_arguments _tst /$'[^\0]#\0'/ \
19451                         /$'aaa\0'/ :'compadd aaa'
19452
19453              This  is  a  more  typical use; it is similar, but any following
19454              patterns would only match if aaa was present as the first  argu‐
19455              ment.
19456
19457                     _regex_arguments _tst /$'[^\0]#\0'/ \( \
19458                         /$'aaa\0'/ :'compadd aaa' \
19459                         /$'bbb\0'/ :'compadd bbb' \) \#
19460
19461              In  this  example, an indefinite number of command arguments may
19462              be completed.  Odd arguments are completed as aaa and even argu‐
19463              ments  as  bbb.   Completion fails unless the set of aaa and bbb
19464              arguments before the current one is matched correctly.
19465
19466                     _regex_arguments _tst /$'[^\0]#\0'/ \
19467                         \( /$'aaa\0'/ :'compadd aaa' \| \
19468                         /$'bbb\0'/ :'compadd bbb' \) \#
19469
19470              This is similar, but either aaa or bbb may be completed for  any
19471              argument.  In this case _regex_words could be used to generate a
19472              suitable expression for the arguments.
19473
19474       _regex_words tag description spec ...
19475              This  function  can  be  used  to  generate  arguments  for  the
19476              _regex_arguments  command  which  may  be  inserted at any point
19477              where a set of rules is expected.  The tag and description  give
19478              a  standard  tag  and description pertaining to the current con‐
19479              text.  Each spec contains two or three arguments separated by  a
19480              colon: note that there is no leading colon in this case.
19481
19482              Each  spec  gives one of a set of words that may be completed at
19483              this point, together with arguments.  It is thus roughly equiva‐
19484              lent  to the _arguments function when used in normal (non-regex)
19485              completion.
19486
19487              The part of the spec before the first colon is the  word  to  be
19488              completed.   This  may  contain a *; the entire word, before and
19489              after the * is completed, but only the text before the * is  re‐
19490              quired  for the context to be matched, so that further arguments
19491              may be completed after the abbreviated form.
19492
19493              The second part of spec is a description for the word being com‐
19494              pleted.
19495
19496              The  optional third part of the spec describes how words follow‐
19497              ing the one being completed are themselves to be completed.   It
19498              will be evaluated in order to avoid problems with quoting.  This
19499              means that typically it contains a reference to  an  array  con‐
19500              taining previously generated regex arguments.
19501
19502              The  option  -t term specifies a terminator for the word instead
19503              of the usual space.  This is handled as an auto-removable suffix
19504              in the manner of the option -s sep to _values.
19505
19506              The  result  of  the processing by _regex_words is placed in the
19507              array reply, which should be made local to the calling function.
19508              If the set of words and arguments may be matched repeatedly, a #
19509              should be appended to the generated array at that point.
19510
19511              For example:
19512
19513                     local -a reply
19514                     _regex_words mydb-commands 'mydb commands' \
19515                       'add:add an entry to mydb:$mydb_add_cmds' \
19516                       'show:show entries in mydb'
19517                     _regex_arguments _mydb "$reply[@]"
19518                     _mydb "$@"
19519
19520              This shows a completion function for a command mydb which  takes
19521              two  command  arguments, add and show.  show takes no arguments,
19522              while the arguments for add have already been prepared in an ar‐
19523              ray   mydb_add_cmds,  quite  possibly  by  a  previous  call  to
19524              _regex_words.
19525
19526       _requested [ -x ] [ -12VJ ] tag [ name descr [ command [ arg ... ] ]
19527              This function is called to decide whether a tag  already  regis‐
19528              tered  by  a call to _tags (see below) has been requested by the
19529              user and hence completion should be performed for  it.   It  re‐
19530              turns  status  zero  if the tag is requested and non-zero other‐
19531              wise.  The function is typically used as part  of  a  loop  over
19532              different tags as follows:
19533
19534                     _tags foo bar baz
19535                     while _tags; do
19536                       if _requested foo; then
19537                         ... # perform completion for foo
19538                       fi
19539                       ... # test the tags bar and baz in the same way
19540                       ... # exit loop if matches were generated
19541                     done
19542
19543              Note  that  the  test  for whether matches were generated is not
19544              performed until the end of the _tags loop.  This is so that  the
19545              user  can set the tag-order style to specify a set of tags to be
19546              completed at the same time.
19547
19548              If name and descr are given, _requested calls  the  _description
19549              function  with  these arguments together with the options passed
19550              to _requested.
19551
19552              If command is given, the _all_labels function will be called im‐
19553              mediately  with  the same arguments.  In simple cases this makes
19554              it possible to perform the test for the tag and the matching  in
19555              one go.  For example:
19556
19557                     local expl ret=1
19558                     _tags foo bar baz
19559                     while _tags; do
19560                       _requested foo expl 'description' \
19561                           compadd foobar foobaz && ret=0
19562                       ...
19563                       (( ret )) || break
19564                     done
19565
19566              If  the command is not compadd, it must nevertheless be prepared
19567              to handle the same options.
19568
19569       _retrieve_cache cache_identifier
19570              This function retrieves completion  information  from  the  file
19571              given  by  cache_identifier,  stored in a directory specified by
19572              the cache-path style which defaults to ~/.zcompcache.   The  re‐
19573              turn  status  is zero if retrieval was successful.  It will only
19574              attempt retrieval if the use-cache style is set, so you can call
19575              this  function without worrying about whether the user wanted to
19576              use the caching layer.
19577
19578              See _store_cache below for more details.
19579
19580       _sep_parts
19581              This function is passed alternating arrays and separators as ar‐
19582              guments.  The arrays specify completions for parts of strings to
19583              be separated by the separators.  The arrays may be the names  of
19584              array  parameters or a quoted list of words in parentheses.  For
19585              example, with the array `hosts=(ftp news)' the call  `_sep_parts
19586              '(foo  bar)' @ hosts' will complete the string  `f' to `foo' and
19587              the string `b@n' to `bar@news'.
19588
19589              This function accepts the  compadd  options  `-V',  `-J',  `-1',
19590              `-2',  `-n',  `-X',  `-M',  `-P', `-S', `-r', `-R', and `-q' and
19591              passes them on to the compadd builtin used to add the matches.
19592
19593       _sequence [ -s sep ] [ -n max ] [ -d ] function [ - ] ...
19594              This function is a wrapper to  other  functions  for  completing
19595              items in a separated list. The same function is used to complete
19596              each item in the list. The separator is specified  with  the  -s
19597              option.  If  -s is omitted it will use `,'. Duplicate values are
19598              not matched unless -d is specified. If there is a fixed or maxi‐
19599              mum  number of items in the list, this can be specified with the
19600              -n option.
19601
19602              Common compadd options are passed on to the function. It is pos‐
19603              sible to use compadd directly with _sequence, though _values may
19604              be more appropriate in this situation.
19605
19606       _setup tag [ group ]
19607              This function sets up the special parameters used by the comple‐
19608              tion  system  appropriately for the tag given as the first argu‐
19609              ment.    It   uses   the   styles   list-colors,    list-packed,
19610              list-rows-first, last-prompt, accept-exact, menu and force-list.
19611
19612              The  optional  group supplies the name of the group in which the
19613              matches will be placed.  If it is not given, the tag is used  as
19614              the group name.
19615
19616              This  function  is  called  automatically  from _description and
19617              hence is not normally called explicitly.
19618
19619       _store_cache cache_identifier param ...
19620              This function, together with _retrieve_cache and _cache_invalid,
19621              implements  a  caching layer which can be used in any completion
19622              function.  Data obtained by costly operations are stored in  pa‐
19623              rameters;  this  function then dumps the values of those parame‐
19624              ters to a file.  The data can then  be  retrieved  quickly  from
19625              that  file  via  _retrieve_cache, even in different instances of
19626              the shell.
19627
19628              The cache_identifier specifies the file which the data should be
19629              dumped  to.   The file is stored in a directory specified by the
19630              cache-path style which defaults to ~/.zcompcache.  The remaining
19631              params arguments are the parameters to dump to the file.
19632
19633              The  return status is zero if storage was successful.  The func‐
19634              tion will only attempt storage if the use-cache style is set, so
19635              you  can  call  this function without worrying about whether the
19636              user wanted to use the caching layer.
19637
19638              The completion function may avoid calling  _retrieve_cache  when
19639              it  already  has  the  completion  data available as parameters.
19640              However, in that case it should  call  _cache_invalid  to  check
19641              whether  the  data  in the parameters and in the cache are still
19642              valid.
19643
19644              See the _perl_modules completion function for a  simple  example
19645              of the usage of the caching layer.
19646
19647       _tags [ [ -C name ] tag ... ]
19648              If  called  with  arguments,  these are taken to be the names of
19649              tags valid for completions in the current context.   These  tags
19650              are stored internally and sorted by using the tag-order style.
19651
19652              Next, _tags is called repeatedly without arguments from the same
19653              completion function.  This successively selects the first,  sec‐
19654              ond,  etc. set of tags requested by the user.  The return status
19655              is zero if at least one of the tags is  requested  and  non-zero
19656              otherwise.  To test if a particular tag is to be tried, the _re‐
19657              quested function should be called (see above).
19658
19659              If `-C name' is given, name is temporarily stored in  the  argu‐
19660              ment  field (the fifth) of the context in the curcontext parame‐
19661              ter during the call to _tags; the field  is  restored  on  exit.
19662              This  allows _tags to use a more specific context without having
19663              to change and reset the curcontext parameter (which has the same
19664              effect).
19665
19666       _tilde_files
19667              Like  _files,  but resolve leading tildes according to the rules
19668              of filename expansion, so the suggested completions don't  start
19669              with a `~' even if the filename on the command-line does.
19670
19671       _values [ -O name ] [ -s sep ] [ -S sep ] [ -wC ] desc spec ...
19672              This  is  used to complete arbitrary keywords (values) and their
19673              arguments, or lists of such combinations.
19674
19675              If the first argument is the option `-O name', it will  be  used
19676              in  the same way as by the _arguments function.  In other words,
19677              the elements of the name array will be passed  to  compadd  when
19678              executing an action.
19679
19680              If the first argument (or the first argument after `-O name') is
19681              `-s', the next argument is used as the character that  separates
19682              multiple  values.   This  character is automatically added after
19683              each value in an auto-removable fashion (see below); all  values
19684              completed by `_values -s' appear in the same word on the command
19685              line, unlike completion using _arguments.  If this option is not
19686              present, only a single value will be completed per word.
19687
19688              Normally,  _values  will  only use the current word to determine
19689              which values are already present on the command line  and  hence
19690              are not to be completed again.  If the -w option is given, other
19691              arguments are examined as well.
19692
19693              The first non-option argument, desc, is  used  as  a  string  to
19694              print as a description before listing the values.
19695
19696              All other arguments describe the possible values and their argu‐
19697              ments in the same format used for the description of options  by
19698              the  _arguments  function (see above).  The only differences are
19699              that no minus or plus sign is required at the beginning,  values
19700              can  have  only  one argument, and the forms of action beginning
19701              with an equal sign are not supported.
19702
19703              The character separating a value from its argument  can  be  set
19704              using  the  option -S (like -s, followed by the character to use
19705              as the separator in the next argument).  By default  the  equals
19706              sign will be used as the separator between values and arguments.
19707
19708              Example:
19709
19710                     _values -s , 'description' \
19711                             '*foo[bar]' \
19712                             '(two)*one[number]:first count:' \
19713                             'two[another number]::second count:(1 2 3)'
19714
19715              This  describes  three possible values: `foo', `one', and `two'.
19716              The first is described as `bar', takes no argument and  may  ap‐
19717              pear  more  than once.  The second is described as `number', may
19718              appear more than once, and  takes  one  mandatory  argument  de‐
19719              scribed as `first count'; no action is specified, so it will not
19720              be completed.  The `(two)' at the beginning  says  that  if  the
19721              value  `one'  is  on the line, the value `two' will no longer be
19722              considered a  possible  completion.   Finally,  the  last  value
19723              (`two')  is  described as `another number' and takes an optional
19724              argument described as `second count' for which  the  completions
19725              (to  appear  after  an  `=') are `1', `2', and `3'.  The _values
19726              function will complete lists of these values separated  by  com‐
19727              mas.
19728
19729              Like  _arguments, this function temporarily adds another context
19730              name component to the arguments element (the fifth) of the  cur‐
19731              rent context while executing the action.  Here this name is just
19732              the name of the value for which the argument is completed.
19733
19734              The style verbose is used to decide if the descriptions for  the
19735              values (but not those for the arguments) should be printed.
19736
19737              The  associative  array  val_args  is  used to report values and
19738              their arguments; this works similarly to the  opt_args  associa‐
19739              tive array used by _arguments.  Hence the function calling _val‐
19740              ues should declare  the  local  parameters  state,  state_descr,
19741              line, context and val_args:
19742
19743                     local context state state_descr line
19744                     typeset -A val_args
19745
19746              when using an action of the form `->string'.  With this function
19747              the context parameter will be set to the name of the value whose
19748              argument  is  to be completed.  Note that for _values, the state
19749              and state_descr are scalars rather than arrays.  Only  a  single
19750              matching state is returned.
19751
19752              Note  also  that _values normally adds the character used as the
19753              separator between values as an auto-removable suffix (similar to
19754              a  `/'  after a directory).  However, this is not possible for a
19755              `->string' action as the matches for the argument are  generated
19756              by  the calling function.  To get the usual behaviour, the call‐
19757              ing function can add the separator x as a suffix by passing  the
19758              options `-qS x' either directly or indirectly to compadd.
19759
19760              The option -C is treated in the same way as it is by _arguments.
19761              In that case the parameter curcontext should be made  local  in‐
19762              stead of context (as described above).
19763
19764       _wanted [ -x ] [ -C name ]  [ -12VJ ] tag name descr command [ arg ...]
19765              In  many  contexts,  completion can only generate one particular
19766              set of matches, usually corresponding to a single tag.  However,
19767              it  is  still  necessary  to  decide  whether  the user requires
19768              matches of this type.  This function is useful in such a case.
19769
19770              The arguments to _wanted are the same as  those  to  _requested,
19771              i.e.  arguments  to be passed to _description.  However, in this
19772              case the command is not optional;  all the processing  of  tags,
19773              including the loop over both tags and tag labels and the genera‐
19774              tion of matches, is carried out automatically by _wanted.
19775
19776              Hence to offer only one tag and immediately add the  correspond‐
19777              ing matches with the given description:
19778
19779                     local expl
19780                     _wanted tag expl 'description' \
19781                         compadd matches...
19782
19783              Note that, as for _requested, the command must be able to accept
19784              options to be passed down to compadd.
19785
19786              Like _tags this function supports the -C option to give  a  dif‐
19787              ferent  name  for the argument context field.  The -x option has
19788              the same meaning as for _description.
19789
19790       _widgets [ -g pattern ]
19791              This function completes names of zle widgets  (see  the  section
19792              `Widgets'  in  zshzle(1)).   The pattern, if present, is matched
19793              against values of the $widgets special parameter, documented  in
19794              the section `The zsh/zleparameter Module' in zshmodules(1).
19795

COMPLETION SYSTEM VARIABLES

19797       There  are  some  standard variables, initialised by the _main_complete
19798       function and then used from other functions.
19799
19800       The standard variables are:
19801
19802       _comp_caller_options
19803              The completion system uses setopt to set a  number  of  options.
19804              This allows functions to be written without concern for compati‐
19805              bility with every possible combination of user options. However,
19806              sometimes  completion needs to know what the user's option pref‐
19807              erences are. These are saved in the  _comp_caller_options  asso‐
19808              ciative array. Option names, spelled in lowercase without under‐
19809              scores, are mapped to one or  other  of  the  strings  `on'  and
19810              `off'.
19811
19812              _comp_priv_prefix
19813                     Completion   functions   such   as   _sudo  can  set  the
19814                     _comp_priv_prefix array to a command prefix that may then
19815                     be  used  by  _call_program  to match the privileges when
19816                     calling programs to generate matches.
19817
19818              Two more features are offered by  the  _main_complete  function.
19819              The  arrays  compprefuncs and comppostfuncs may contain names of
19820              functions that are to be called immediately before or after com‐
19821              pletion has been tried.  A function will only be called once un‐
19822              less it explicitly reinserts itself into the array.
19823

COMPLETION DIRECTORIES

19825       In the source distribution, the files are contained in  various  subdi‐
19826       rectories of the Completion directory.  They may have been installed in
19827       the same structure, or into one single function directory.  The follow‐
19828       ing  is  a  description  of  the  files found in the original directory
19829       structure.  If you wish to alter an installed file, you  will  need  to
19830       copy  it to some directory which appears earlier in your fpath than the
19831       standard directory where it appears.
19832
19833       Base   The core functions and special completion widgets  automatically
19834              bound  to  keys.   You will certainly need most of these, though
19835              will probably not need to alter them.  Many of these  are  docu‐
19836              mented above.
19837
19838       Zsh    Functions for completing arguments of shell builtin commands and
19839              utility functions for this.  Some of  these  are  also  used  by
19840              functions from the Unix directory.
19841
19842       Unix   Functions  for  completing  arguments  of  external commands and
19843              suites of commands.  They may need modifying  for  your  system,
19844              although in many cases some attempt is made to decide which ver‐
19845              sion of a command is present.  For example, completion  for  the
19846              mount  command  tries  to determine the system it is running on,
19847              while completion for many other utilities try to decide  whether
19848              the  GNU version of the command is in use, and hence whether the
19849              --help option is supported.
19850
19851       X, AIX, BSD, ...
19852              Completion and utility function for commands available  only  on
19853              some  systems.   These  are not arranged hierarchically, so, for
19854              example, both the Linux and Debian directories, as well as the X
19855              directory, may be useful on your system.
19856
19857
19858
19859ZSHCOMPCTL(1)               General Commands Manual              ZSHCOMPCTL(1)
19860
19861
19862

NAME

19864       zshcompctl - zsh programmable completion
19865

DESCRIPTION

19867       This  version  of zsh has two ways of performing completion of words on
19868       the command line.  New users of the shell may prefer to use  the  newer
19869       and more powerful system based on shell functions; this is described in
19870       zshcompsys(1), and the basic shell mechanisms which support it are  de‐
19871       scribed  in  zshcompwid(1).  This manual entry describes the older com‐
19872       pctl command.
19873
19874       compctl [ -CDT ] options [ command ... ]
19875       compctl [ -CDT ] options [ -x pattern options - ... -- ]
19876               [ + options [ -x ... -- ] ... [+] ] [ command ... ]
19877       compctl -M match-specs ...
19878       compctl -L [ -CDTM ] [ command ... ]
19879       compctl + command ...
19880
19881       Control the editor's completion behavior according to the supplied  set
19882       of options.  Various editing commands, notably expand-or-complete-word,
19883       usually bound to tab, will attempt to complete  a  word  typed  by  the
19884       user, while others, notably delete-char-or-list, usually bound to ^D in
19885       EMACS editing mode, list the possibilities; compctl controls what those
19886       possibilities  are.  They may for example be filenames (the most common
19887       case, and  hence  the  default),  shell  variables,  or  words  from  a
19888       user-specified list.
19889

COMMAND FLAGS

19891       Completion of the arguments of a command may be different for each com‐
19892       mand or may use the default.  The behavior when completing the  command
19893       word  itself may also be separately specified.  These correspond to the
19894       following flags and arguments, all of which (except for -L) may be com‐
19895       bined with any combination of the options described subsequently in the
19896       section `Option Flags':
19897
19898       command ...
19899              controls completion for the named commands, which must be listed
19900              last on the command line.  If completion is attempted for a com‐
19901              mand with a pathname containing slashes and no completion  defi‐
19902              nition  is  found,  the search is retried with the last pathname
19903              component. If the command starts with a =, completion  is  tried
19904              with the pathname of the command.
19905
19906              Any  of the command strings may be patterns of the form normally
19907              used for filename generation.  These should be quoted to protect
19908              them  from  immediate  expansion; for example the command string
19909              'foo*' arranges for completion of the words of any  command  be‐
19910              ginning  with  foo.   When  completion is attempted, all pattern
19911              completions are tried in the reverse order of  their  definition
19912              until one matches.  By default, completion then proceeds as nor‐
19913              mal, i.e. the shell will try to generate more  matches  for  the
19914              specific  command on the command line; this can be overridden by
19915              including -tn in the flags for the pattern completion.
19916
19917              Note that aliases are expanded before the command name is deter‐
19918              mined  unless  the COMPLETE_ALIASES option is set.  Commands may
19919              not be combined with the -C, -D or -T flags.
19920
19921       -C     controls completion when the command word itself is  being  com‐
19922              pleted.  If no compctl -C command has been issued,  the names of
19923              any executable command (whether in the path or specific  to  the
19924              shell, such as aliases or functions) are completed.
19925
19926       -D     controls  default  completion behavior for the arguments of com‐
19927              mands not assigned any special behavior.  If no compctl -D  com‐
19928              mand has been issued, filenames are completed.
19929
19930       -T     supplies completion flags to be used before any other processing
19931              is done, even before processing for compctls  defined  for  spe‐
19932              cific  commands.   This  is especially useful when combined with
19933              extended completion (the -x flag, see the section `Extended Com‐
19934              pletion'  below).  Using this flag you can define default behav‐
19935              ior which will apply to all commands without exception,  or  you
19936              can  alter the standard behavior for all commands.  For example,
19937              if your access to the user database is too slow and/or  it  con‐
19938              tains  too  many users (so that completion after `~' is too slow
19939              to be usable), you can use
19940
19941                     compctl -T -x 's[~] C[0,[^/]#]' -k friends -S/ -tn
19942
19943              to complete the strings in the array friends after a  `~'.   The
19944              C[...]  argument  is necessary so that this form of ~-completion
19945              is not tried after the directory name is finished.
19946
19947       -L     lists the existing completion behavior in a manner suitable  for
19948              putting  into  a  start-up  script; the existing behavior is not
19949              changed.  Any combination of the above forms,  or  the  -M  flag
19950              (which must follow the -L flag), may be specified, otherwise all
19951              defined completions are listed.  Any other  flags  supplied  are
19952              ignored.
19953
19954       no argument
19955              If  no  argument is given, compctl lists all defined completions
19956              in an abbreviated form;  with a list of options, all completions
19957              with  those  flags  set  (not  counting extended completion) are
19958              listed.
19959
19960       If the + flag is alone and followed immediately by  the  command  list,
19961       the  completion  behavior  for all the commands in the list is reset to
19962       the default.  In other words, completion will subsequently use the  op‐
19963       tions specified by the -D flag.
19964
19965       The  form  with -M as the first and only option defines global matching
19966       specifications (see zshcompwid). The match specifications given will be
19967       used  for  every  completion attempt (only when using compctl, not with
19968       the new completion system) and are tried in the order in which they are
19969       defined until one generates at least one match. E.g.:
19970
19971              compctl -M '' 'm:{a-zA-Z}={A-Za-z}'
19972
19973       This  will first try completion without any global match specifications
19974       (the empty string) and, if that generates no matches, will try case in‐
19975       sensitive completion.
19976

OPTION FLAGS

19978       [ -fcFBdeaRGovNAIOPZEnbjrzu/12 ]
19979       [ -k array ] [ -g globstring ] [ -s subststring ]
19980       [ -K function ]
19981       [ -Q ] [ -P prefix ] [ -S suffix ]
19982       [ -W file-prefix ] [ -H num pattern ]
19983       [ -q ] [ -X explanation ] [ -Y explanation ]
19984       [ -y func-or-var ] [ -l cmd ] [ -h cmd ] [ -U ]
19985       [ -t continue ] [ -J name ] [ -V name ]
19986       [ -M match-spec ]
19987
19988       The remaining options specify the type of command arguments to look for
19989       during completion.  Any combination of these flags  may  be  specified;
19990       the  result is a sorted list of all the possibilities.  The options are
19991       as follows.
19992
19993   Simple Flags
19994       These produce completion lists made up by the shell itself:
19995
19996       -f     Filenames and file system paths.
19997
19998       -/     Just file system paths.
19999
20000       -c     Command names, including aliases, shell functions, builtins  and
20001              reserved words.
20002
20003       -F     Function names.
20004
20005       -B     Names of builtin commands.
20006
20007       -m     Names of external commands.
20008
20009       -w     Reserved words.
20010
20011       -a     Alias names.
20012
20013       -R     Names of regular (non-global) aliases.
20014
20015       -G     Names of global aliases.
20016
20017       -d     This can be combined with -F, -B, -w, -a, -R and -G to get names
20018              of disabled functions, builtins, reserved words or aliases.
20019
20020       -e     This option (to show enabled commands) is in effect by  default,
20021              but may be combined with -d; -de in combination with -F, -B, -w,
20022              -a, -R and -G will complete names of  functions,  builtins,  re‐
20023              served words or aliases whether or not they are disabled.
20024
20025       -o     Names of shell options (see zshoptions(1)).
20026
20027       -v     Names of any variable defined in the shell.
20028
20029       -N     Names of scalar (non-array) parameters.
20030
20031       -A     Array names.
20032
20033       -I     Names of integer variables.
20034
20035       -O     Names of read-only variables.
20036
20037       -p     Names of parameters used by the shell (including special parame‐
20038              ters).
20039
20040       -Z     Names of shell special parameters.
20041
20042       -E     Names of environment variables.
20043
20044       -n     Named directories.
20045
20046       -b     Key binding names.
20047
20048       -j     Job names:  the first word of the  job  leader's  command  line.
20049              This is useful with the kill builtin.
20050
20051       -r     Names of running jobs.
20052
20053       -z     Names of suspended jobs.
20054
20055       -u     User names.
20056
20057   Flags with Arguments
20058       These have user supplied arguments to determine how the list of comple‐
20059       tions is to be made up:
20060
20061       -k array
20062              Names taken from the elements of $array (note that the `$'  does
20063              not  appear  on  the command line).  Alternatively, the argument
20064              array itself may be a set of space- or comma-separated values in
20065              parentheses,  in which any delimiter may be escaped with a back‐
20066              slash; in this case the argument should be quoted.  For example,
20067
20068                     compctl -k "(cputime filesize datasize stacksize
20069                                 coredumpsize resident descriptors)" limit
20070
20071       -g globstring
20072              The globstring is expanded using filename globbing; it should be
20073              quoted  to  protect  it  from immediate expansion. The resulting
20074              filenames are taken as the possible completions.  Use `*(/)' in‐
20075              stead of `*/' for directories.  The fignore special parameter is
20076              not applied to the resulting files.  More than one  pattern  may
20077              be  given separated by blanks. (Note that brace expansion is not
20078              part of globbing.  Use the syntax `(either|or)' to match  alter‐
20079              natives.)
20080
20081       -s subststring
20082              The subststring is split into words and these words are than ex‐
20083              panded using all shell expansion  mechanisms  (see  zshexpn(1)).
20084              The resulting words are taken as possible completions.  The fig‐
20085              nore special parameter is not applied to  the  resulting  files.
20086              Note that -g is faster for filenames.
20087
20088       -K function
20089              Call the given function to get the completions.  Unless the name
20090              starts with an underscore, the function is passed two arguments:
20091              the  prefix and the suffix of the word on which completion is to
20092              be attempted, in other words those characters before the  cursor
20093              position, and those from the cursor position onwards.  The whole
20094              command line can be accessed with the -c and  -l  flags  of  the
20095              read  builtin.  The function should set the variable reply to an
20096              array containing the completions (one completion  per  element);
20097              note  that reply should not be made local to the function.  From
20098              such a function the command line can be accessed with the -c and
20099              -l flags to the read builtin.  For example,
20100
20101                     function whoson { reply=(`users`); }
20102                     compctl -K whoson talk
20103
20104              completes only logged-on users after `talk'.  Note that `whoson'
20105              must return an array, so `reply=`users`' would be incorrect.
20106
20107       -H num pattern
20108              The possible completions are taken from  the  last  num  history
20109              lines.   Only  words matching pattern are taken.  If num is zero
20110              or negative the whole history is searched and if pattern is  the
20111              empty  string  all words are taken (as with `*').  A typical use
20112              is
20113
20114                     compctl -D -f + -H 0 ''
20115
20116              which forces completion to look back in the history list  for  a
20117              word if no filename matches.
20118
20119   Control Flags
20120       These do not directly specify types of name to be completed, but manip‐
20121       ulate the options that do:
20122
20123       -Q     This instructs the shell not to quote any metacharacters in  the
20124              possible  completions.  Normally the results of a completion are
20125              inserted into the command line with any metacharacters quoted so
20126              that  they are interpreted as normal characters.  This is appro‐
20127              priate for filenames and ordinary strings.  However, for special
20128              effects,  such  as inserting a backquoted expression from a com‐
20129              pletion array (-k) so that the expression will not be  evaluated
20130              until the complete line is executed, this option must be used.
20131
20132       -P prefix
20133              The  prefix  is  inserted  just before the completed string; any
20134              initial part already typed will be completed and the whole  pre‐
20135              fix ignored for completion purposes.  For example,
20136
20137                     compctl -j -P "%" kill
20138
20139              inserts  a  `%'  after  the  kill command and then completes job
20140              names.
20141
20142       -S suffix
20143              When a completion is found the suffix is inserted after the com‐
20144              pleted string.  In the case of menu completion the suffix is in‐
20145              serted immediately, but it is still possible  to  cycle  through
20146              the list of completions by repeatedly hitting the same key.
20147
20148       -W file-prefix
20149              With  directory  file-prefix:   for command, file, directory and
20150              globbing completion (options -c, -f, -/, -g), the file prefix is
20151              implicitly added in front of the completion.  For example,
20152
20153                     compctl -/ -W ~/Mail maildirs
20154
20155              completes  any subdirectories to any depth beneath the directory
20156              ~/Mail, although that prefix does  not  appear  on  the  command
20157              line.   The  file-prefix may also be of the form accepted by the
20158              -k flag, i.e. the name of an array or a literal list  in  paren‐
20159              thesis.  In  this  case  all the directories in the list will be
20160              searched for possible completions.
20161
20162       -q     If used with a suffix as specified by the -S option, this causes
20163              the  suffix to be removed if the next character typed is a blank
20164              or does not insert anything or if the suffix  consists  of  only
20165              one  character  and the next character typed is the same charac‐
20166              ter; this the same rule used for the  AUTO_REMOVE_SLASH  option.
20167              The  option  is  most  useful for list separators (comma, colon,
20168              etc.).
20169
20170       -l cmd This option restricts the range of command line words  that  are
20171              considered  to  be  arguments.   If combined with one of the ex‐
20172              tended completion patterns `p[...]', `r[...]', or `R[...]'  (see
20173              the section `Extended Completion' below) the range is restricted
20174              to the range of arguments specified in the brackets.  Completion
20175              is then performed as if these had been given as arguments to the
20176              cmd supplied with the option. If the cmd  string  is  empty  the
20177              first  word  in  the range is instead taken as the command name,
20178              and command name completion performed on the first word  in  the
20179              range.  For example,
20180
20181                     compctl -x 'r[-exec,;]' -l '' -- find
20182
20183              completes  arguments  between  `-exec' and the following `;' (or
20184              the end of the command line if there is no such  string)  as  if
20185              they were a separate command line.
20186
20187       -h cmd Normally  zsh completes quoted strings as a whole. With this op‐
20188              tion, completion can be done separately on  different  parts  of
20189              such  strings. It works like the -l option but makes the comple‐
20190              tion code work on the parts of the current word that  are  sepa‐
20191              rated by spaces. These parts are completed as if they were argu‐
20192              ments to the given cmd. If cmd is the empty  string,  the  first
20193              part is completed as a command name, as with -l.
20194
20195       -U     Use  the whole list of possible completions, whether or not they
20196              actually match the word on the command line.  The word typed  so
20197              far will be deleted.  This is most useful with a function (given
20198              by the -K option) which can examine the word  components  passed
20199              to  it  (or  via the read builtin's -c and -l flags) and use its
20200              own criteria to decide what matches.  If there is no completion,
20201              the original word is retained.  Since the produced possible com‐
20202              pletions seldom have interesting common prefixes  and  suffixes,
20203              menu  completion  is started immediately if AUTO_MENU is set and
20204              this flag is used.
20205
20206       -y func-or-var
20207              The list provided by func-or-var is  displayed  instead  of  the
20208              list  of  completions whenever a listing is required; the actual
20209              completions to be inserted are not affected.  It can be provided
20210              in  two ways. Firstly, if func-or-var begins with a $ it defines
20211              a variable, or if it begins with a left  parenthesis  a  literal
20212              array, which contains the list.  A variable may have been set by
20213              a call to a function using the -K option.  Otherwise it contains
20214              the  name  of  a  function  which will be executed to create the
20215              list.  The function will be  passed  as  an  argument  list  all
20216              matching  completions,  including prefixes and suffixes expanded
20217              in full, and should set the array reply to the result.  In  both
20218              cases,  the display list will only be retrieved after a complete
20219              list of matches has been created.
20220
20221              Note that the returned list does not have to correspond, even in
20222              length,  to  the original set of matches, and may be passed as a
20223              scalar instead of an array.  No special formatting of characters
20224              is performed on the output in this case; in particular, newlines
20225              are printed literally and if they appear output  in  columns  is
20226              suppressed.
20227
20228       -X explanation
20229              Print  explanation  when trying completion on the current set of
20230              options. A `%n' in this string is  replaced  by  the  number  of
20231              matches that were added for this explanation string.  The expla‐
20232              nation only appears if completion was tried  and  there  was  no
20233              unique  match,  or when listing completions. Explanation strings
20234              will be listed together with the matches of the group  specified
20235              together  with the -X option (using the -J or -V option). If the
20236              same explanation string is given to  multiple  -X  options,  the
20237              string  appears  only  once  (for  each group) and the number of
20238              matches shown for the `%n' is the total number  of  all  matches
20239              for each of these uses. In any case, the explanation string will
20240              only be shown if there was at least one match added for the  ex‐
20241              planation string.
20242
20243              The  sequences  %B,  %b,  %S,  %s, %U, and %u specify output at‐
20244              tributes (bold, standout, and underline), %F, %f, %K, %k specify
20245              foreground  and  background  colours, and %{...%} can be used to
20246              include literal escape sequences as in prompts.
20247
20248       -Y explanation
20249              Identical to -X, except that the explanation first undergoes ex‐
20250              pansion  following the usual rules for strings in double quotes.
20251              The expansion will be carried out after any functions are called
20252              for the -K or -y options, allowing them to set variables.
20253
20254       -t continue
20255              The  continue-string  contains  a character that specifies which
20256              set of completion flags should be used next.  It is useful:
20257
20258              (i) With -T, or when trying a list of pattern completions,  when
20259              compctl  would  usually  continue with ordinary processing after
20260              finding matches; this can be suppressed with `-tn'.
20261
20262              (ii) With a list of alternatives separated by  +,  when  compctl
20263              would  normally  stop  when  one  of  the alternatives generates
20264              matches.  It can be forced to consider the next set  of  comple‐
20265              tions by adding `-t+' to the flags of the alternative before the
20266              `+'.
20267
20268              (iii) In an extended completion list (see below),  when  compctl
20269              would  normally  continue  until  a set of conditions succeeded,
20270              then use only the immediately following flags.  With `-t-', com‐
20271              pctl  will  continue  trying extended completions after the next
20272              `-'; with `-tx' it will  attempt  completion  with  the  default
20273              flags, in other words those before the `-x'.
20274
20275       -J name
20276              This  gives  the  name of the group the matches should be placed
20277              in. Groups are listed and sorted separately; likewise, menu com‐
20278              pletion  will  offer  the  matches in the groups in the order in
20279              which the groups were defined. If no group  name  is  explicitly
20280              given,  the  matches  are  stored  in a group named default. The
20281              first time a group name is encountered, a group with  that  name
20282              is  created. After that all matches with the same group name are
20283              stored in that group.
20284
20285              This can be useful with non-exclusive  alternative  completions.
20286              For example, in
20287
20288                     compctl -f -J files -t+ + -v -J variables foo
20289
20290              both  files  and  variables are possible completions, as the -t+
20291              forces both sets of alternatives before and after the  +  to  be
20292              considered  at  once.   Because  of the -J options, however, all
20293              files are listed before all variables.
20294
20295       -V name
20296              Like -J, but matches within the group  will  not  be  sorted  in
20297              listings  nor in menu completion. These unsorted groups are in a
20298              different name space from the sorted ones, so groups defined  as
20299              -J files and -V files are distinct.
20300
20301       -1     If given together with the -V option, makes only consecutive du‐
20302              plicates in the group be removed.  Note  that  groups  with  and
20303              without this flag are in different name spaces.
20304
20305       -2     If given together with the -J or -V option, makes all duplicates
20306              be kept. Again, groups with and without this flag are in differ‐
20307              ent name spaces.
20308
20309       -M match-spec
20310              This  defines  additional  matching  control specifications that
20311              should be used only when testing words for  the  list  of  flags
20312              this flag appears in. The format of the match-spec string is de‐
20313              scribed in zshcompwid.
20314

ALTERNATIVE COMPLETION

20316       compctl [ -CDT ] options + options [ + ... ] [ + ] command ...
20317
20318       The form with `+' specifies alternative options.  Completion  is  tried
20319       with the options before the first `+'. If this produces no matches com‐
20320       pletion is tried with the flags after the `+' and so on. If  there  are
20321       no  flags  after the last `+' and a match has not been found up to that
20322       point, default completion is tried.  If the list of flags contains a -t
20323       with  a + character, the next list of flags is used even if the current
20324       list produced matches.
20325
20326       Additional options are available that restrict completion to some  part
20327       of the command line; this is referred to as `extended completion'.
20328

EXTENDED COMPLETION

20330       compctl [ -CDT ] options -x pattern options - ... --
20331               [ command ... ]
20332       compctl [ -CDT ] options [ -x pattern options - ... -- ]
20333               [ + options [ -x ... -- ] ... [+] ] [ command ... ]
20334
20335       The  form  with  `-x'  specifies  extended  completion for the commands
20336       given; as shown, it may be combined with alternative  completion  using
20337       `+'.  Each pattern is examined in turn; when a match is found, the cor‐
20338       responding options, as described in the section `Option  Flags'  above,
20339       are  used to generate possible completions.  If no pattern matches, the
20340       options given before the -x are used.
20341
20342       Note that each pattern should be supplied  as  a  single  argument  and
20343       should be quoted to prevent expansion of metacharacters by the shell.
20344
20345       A  pattern  is built of sub-patterns separated by commas; it matches if
20346       at least one of these sub-patterns matches  (they  are  `or'ed).  These
20347       sub-patterns  are  in  turn composed of other sub-patterns separated by
20348       white spaces which match if all of the  sub-patterns  match  (they  are
20349       `and'ed).  An element of the sub-patterns is of the form `c[...][...]',
20350       where the pairs of brackets may be repeated as often as necessary,  and
20351       matches  if  any  of the sets of brackets match (an `or').  The example
20352       below makes this clearer.
20353
20354       The elements may be any of the following:
20355
20356       s[string]...
20357              Matches if the current word on the command line starts with  one
20358              of the strings given in brackets.  The string is not removed and
20359              is not part of the completion.
20360
20361       S[string]...
20362              Like s[string] except that the string is part of the completion.
20363
20364       p[from,to]...
20365              Matches if the number of the current word is between one of  the
20366              from  and  to pairs inclusive. The comma and to are optional; to
20367              defaults to the same value as from.  The numbers  may  be  nega‐
20368              tive: -n refers to the n'th last word on the line.
20369
20370       c[offset,string]...
20371              Matches if the string matches the word offset by offset from the
20372              current word position.  Usually offset will be negative.
20373
20374       C[offset,pattern]...
20375              Like c but using pattern matching instead.
20376
20377       w[index,string]...
20378              Matches if the word in position index is  equal  to  the  corre‐
20379              sponding  string.   Note  that  the word count is made after any
20380              alias expansion.
20381
20382       W[index,pattern]...
20383              Like w but using pattern matching instead.
20384
20385       n[index,string]...
20386              Matches if the current word contains string.  Anything up to and
20387              including the indexth occurrence of this string will not be con‐
20388              sidered part of the completion, but the rest will.  index may be
20389              negative  to  count from the end: in most cases, index will be 1
20390              or -1.  For example,
20391
20392                     compctl -s '`users`' -x 'n[1,@]' -k hosts -- talk
20393
20394              will usually complete usernames, but if you insert  an  @  after
20395              the  name,  names from the array hosts (assumed to contain host‐
20396              names, though you must make the array  yourself)  will  be  com‐
20397              pleted.  Other commands such as rcp can be handled similarly.
20398
20399       N[index,string]...
20400              Like  n  except  that  the  string  will be taken as a character
20401              class.  Anything up to and including the indexth  occurrence  of
20402              any  of  the characters in string will not be considered part of
20403              the completion.
20404
20405       m[min,max]...
20406              Matches if the total number of words lies between  min  and  max
20407              inclusive.
20408
20409       r[str1,str2]...
20410              Matches  if  the  cursor  is  after a word with prefix str1.  If
20411              there is also a word with prefix str2 on the command line  after
20412              the  one matched by str1 it matches only if the cursor is before
20413              this word. If the comma and str2 are omitted, it matches if  the
20414              cursor is after a word with prefix str1.
20415
20416       R[str1,str2]...
20417              Like r but using pattern matching instead.
20418
20419       q[str]...
20420              Matches  the  word currently being completed is in single quotes
20421              and the str begins with the letter `s', or if completion is done
20422              in  double quotes and str starts with the letter `d', or if com‐
20423              pletion is done in backticks and str starts with a `b'.
20424

EXAMPLE

20426              compctl -u -x 's[+] c[-1,-f],s[-f+]' \
20427                -g '~/Mail/*(:t)' - 's[-f],c[-1,-f]' -f -- mail
20428
20429       This is to be interpreted as follows:
20430
20431       If the current command is mail, then
20432
20433              if ((the current word begins with + and the previous word is -f)
20434              or (the current word begins with -f+)), then complete the
20435              non-directory part (the `:t' glob modifier) of files in the directory
20436              ~/Mail; else
20437
20438              if the current word begins with -f or the previous word was -f, then
20439              complete any file; else
20440
20441              complete user names.
20442
20443
20444
20445
20446ZSHMODULES(1)               General Commands Manual              ZSHMODULES(1)
20447
20448
20449

NAME

20451       zshmodules - zsh loadable modules
20452

DESCRIPTION

20454       Some optional parts of zsh are in modules, separate from  the  core  of
20455       the  shell.   Each  of  these  modules may be linked in to the shell at
20456       build time, or can be dynamically linked while the shell is running  if
20457       the  installation supports this feature.  Modules are linked at runtime
20458       with the zmodload command, see zshbuiltins(1).
20459
20460       The modules that are bundled with the zsh distribution are:
20461
20462       zsh/attr
20463              Builtins for manipulating extended attributes (xattr).
20464
20465       zsh/cap
20466              Builtins for manipulating POSIX.1e (POSIX.6) capability  (privi‐
20467              lege) sets.
20468
20469       zsh/clone
20470              A builtin that can clone a running shell onto another terminal.
20471
20472       zsh/compctl
20473              The compctl builtin for controlling completion.
20474
20475       zsh/complete
20476              The basic completion code.
20477
20478       zsh/complist
20479              Completion listing extensions.
20480
20481       zsh/computil
20482              A  module  with  utility  builtins needed for the shell function
20483              based completion system.
20484
20485       zsh/curses
20486              curses windowing commands
20487
20488       zsh/datetime
20489              Some date/time commands and parameters.
20490
20491       zsh/db/gdbm
20492              Builtins for managing associative array parameters tied to  GDBM
20493              databases.
20494
20495       zsh/deltochar
20496              A ZLE function duplicating EMACS' zap-to-char.
20497
20498       zsh/example
20499              An example of how to write a module.
20500
20501       zsh/files
20502              Some basic file manipulation commands as builtins.
20503
20504       zsh/langinfo
20505              Interface to locale information.
20506
20507       zsh/mapfile
20508              Access to external files via a special associative array.
20509
20510       zsh/mathfunc
20511              Standard  scientific  functions  for use in mathematical evalua‐
20512              tions.
20513
20514       zsh/nearcolor
20515              Map colours to the nearest colour in the available palette.
20516
20517       zsh/newuser
20518              Arrange for files for new users to be installed.
20519
20520       zsh/parameter
20521              Access to internal hash tables via special associative arrays.
20522
20523       zsh/pcre
20524              Interface to the PCRE library.
20525
20526       zsh/param/private
20527              Builtins for managing private-scoped parameters in function con‐
20528              text.
20529
20530       zsh/regex
20531              Interface to the POSIX regex library.
20532
20533       zsh/sched
20534              A  builtin  that  provides a timed execution facility within the
20535              shell.
20536
20537       zsh/net/socket
20538              Manipulation of Unix domain sockets
20539
20540       zsh/stat
20541              A builtin command interface to the stat system call.
20542
20543       zsh/system
20544              A builtin interface to various low-level system features.
20545
20546       zsh/net/tcp
20547              Manipulation of TCP sockets
20548
20549       zsh/termcap
20550              Interface to the termcap database.
20551
20552       zsh/terminfo
20553              Interface to the terminfo database.
20554
20555       zsh/zftp
20556              A builtin FTP client.
20557
20558       zsh/zle
20559              The Zsh Line Editor, including the bindkey and vared builtins.
20560
20561       zsh/zleparameter
20562              Access to internals of the Zsh Line Editor via parameters.
20563
20564       zsh/zprof
20565              A module allowing profiling for shell functions.
20566
20567       zsh/zpty
20568              A builtin for starting a command in a pseudo-terminal.
20569
20570       zsh/zselect
20571              Block and return when file descriptors are ready.
20572
20573       zsh/zutil
20574              Some utility builtins, e.g. the one for supporting configuration
20575              via styles.
20576

THE ZSH/ATTR MODULE

20578       The  zsh/attr module is used for manipulating extended attributes.  The
20579       -h option causes all commands to operate on symbolic links  instead  of
20580       their targets.  The builtins in this module are:
20581
20582       zgetattr [ -h ] filename attribute [ parameter ]
20583              Get  the  extended  attribute attribute from the specified file‐
20584              name. If the optional argument parameter is given, the attribute
20585              is set on that parameter instead of being printed to stdout.
20586
20587       zsetattr [ -h ] filename attribute value
20588              Set  the  extended attribute attribute on the specified filename
20589              to value.
20590
20591       zdelattr [ -h ] filename attribute
20592              Remove the extended attribute attribute from the specified file‐
20593              name.
20594
20595       zlistattr [ -h ] filename [ parameter ]
20596              List  the  extended  attributes  currently  set on the specified
20597              filename. If the optional argument parameter is given, the  list
20598              of  attributes is set on that parameter instead of being printed
20599              to stdout.
20600
20601       zgetattr and zlistattr allocate memory dynamically.  If  the  attribute
20602       or  list of attributes grows between the allocation and the call to get
20603       them, they return 2.  On all other errors, 1 is returned.  This  allows
20604       the calling function to check for this case and retry.
20605

THE ZSH/CAP MODULE

20607       The zsh/cap module is used for manipulating POSIX.1e (POSIX.6) capabil‐
20608       ity sets.  If the operating system does not support this interface, the
20609       builtins  defined by this module will do nothing.  The builtins in this
20610       module are:
20611
20612       cap [ capabilities ]
20613              Change the shell's process capability sets to the specified  ca‐
20614              pabilities, otherwise display the shell's current capabilities.
20615
20616       getcap filename ...
20617              This is a built-in implementation of the POSIX standard utility.
20618              It displays the capability sets on each specified filename.
20619
20620       setcap capabilities filename ...
20621              This is a built-in implementation of the POSIX standard utility.
20622              It  sets  the  capability sets on each specified filename to the
20623              specified capabilities.
20624

THE ZSH/CLONE MODULE

20626       The zsh/clone module makes available one builtin command:
20627
20628       clone tty
20629              Creates a forked instance of the current shell, attached to  the
20630              specified  tty.  In the new shell, the PID, PPID and TTY special
20631              parameters are changed appropriately.  $! is set to zero in  the
20632              new shell, and to the new shell's PID in the original shell.
20633
20634              The  return status of the builtin is zero in both shells if suc‐
20635              cessful, and non-zero on error.
20636
20637              The target of clone should be an unused terminal, such as an un‐
20638              used virtual console or a virtual terminal created by
20639
20640                     xterm -e sh -c 'trap : INT QUIT TSTP; tty;
20641                             while :; do sleep 100000000; done'
20642
20643              Some  words  of  explanation are warranted about this long xterm
20644              command line: when doing clone on a pseudo-terminal, some  other
20645              session ("session" meant as a unix session group, or SID) is al‐
20646              ready owning the terminal. Hence the cloned zsh  cannot  acquire
20647              the pseudo-terminal as a controlling tty. That means two things:
20648
20649              •      the    job    control    signals    will    go   to   the
20650                     sh-started-by-xterm process group (that's why we  disable
20651                     INT  QUIT  and  TSTP  with trap; otherwise the while loop
20652                     could get suspended or killed)
20653
20654              •      the cloned shell will have job control disabled, and  the
20655                     job  control  keys  (control-C,  control-\ and control-Z)
20656                     will not work.
20657
20658              This does not apply when cloning to an unused vc.
20659
20660              Cloning to a used (and unprepared) terminal will result  in  two
20661              processes  reading  simultaneously  from the same terminal, with
20662              input bytes going randomly to either process.
20663
20664              clone is mostly useful  as  a  shell  built-in  replacement  for
20665              openvt.
20666

THE ZSH/COMPCTL MODULE

20668       The  zsh/compctl  module makes available two builtin commands. compctl,
20669       is the old, deprecated way to control completions for ZLE.  See zshcom‐
20670       pctl(1).   The  other builtin command, compcall can be used in user-de‐
20671       fined completion widgets, see zshcompwid(1).
20672

THE ZSH/COMPLETE MODULE

20674       The zsh/complete module makes available several builtin commands  which
20675       can be used in user-defined completion widgets, see zshcompwid(1).
20676

THE ZSH/COMPLIST MODULE

20678       The zsh/complist module offers three extensions to completion listings:
20679       the ability to highlight matches in such a list, the ability to  scroll
20680       through long lists and a different style of menu completion.
20681
20682   Colored completion listings
20683       Whenever one of the parameters ZLS_COLORS or ZLS_COLOURS is set and the
20684       zsh/complist module is loaded or  linked  into  the  shell,  completion
20685       lists will be colored.  Note, however, that complist will not automati‐
20686       cally be loaded if it is not linked in:  on systems with dynamic  load‐
20687       ing, `zmodload zsh/complist' is required.
20688
20689       The  parameters  ZLS_COLORS  and  ZLS_COLOURS  describe how matches are
20690       highlighted.  To turn on highlighting an empty value suffices, in which
20691       case  all  the  default values given below will be used.  The format of
20692       the value of these parameters is the same as used by the GNU version of
20693       the  ls  command:  a colon-separated list of specifications of the form
20694       `name=value'.  The name may be one of the following  strings,  most  of
20695       which specify file types for which the value will be used.  The strings
20696       and their default values are:
20697
20698       no 0   for normal text (i.e. when displaying  something  other  than  a
20699              matched file)
20700
20701       fi 0   for regular files
20702
20703       di 32  for directories
20704
20705       ln 36  for  symbolic links.  If this has the special value target, sym‐
20706              bolic links are dereferenced and the target file used to  deter‐
20707              mine the display format.
20708
20709       pi 31  for named pipes (FIFOs)
20710
20711       so 33  for sockets
20712
20713       bd 44;37
20714              for block devices
20715
20716       cd 44;37
20717              for character devices
20718
20719       or none
20720              for  a symlink to nonexistent file (default is the value defined
20721              for ln)
20722
20723       mi none
20724              for a non-existent file (default is the value defined  for  fi);
20725              this code is currently not used
20726
20727       su 37;41
20728              for files with setuid bit set
20729
20730       sg 30;43
20731              for files with setgid bit set
20732
20733       tw 30;42
20734              for world writable directories with sticky bit set
20735
20736       ow 34;43
20737              for world writable directories without sticky bit set
20738
20739       sa none
20740              for  files  with an associated suffix alias; this is only tested
20741              after specific suffixes, as described below
20742
20743       st 37;44
20744              for directories with sticky bit set but not world writable
20745
20746       ex 35  for executable files
20747
20748       lc \e[ for the left code (see below)
20749
20750       rc m   for the right code
20751
20752       tc 0   for the character indicating the file type  printed after  file‐
20753              names if the LIST_TYPES option is set
20754
20755       sp 0   for the spaces printed after matches to align the next column
20756
20757       ec none
20758              for the end code
20759
20760       Apart  from  these strings, the name may also be an asterisk (`*') fol‐
20761       lowed by any string. The value given for such a string will be used for
20762       all  files  whose  name  ends with the string.  The name may also be an
20763       equals sign (`=') followed by a pattern; the EXTENDED_GLOB option  will
20764       be  turned  on for evaluation of the pattern.  The value given for this
20765       pattern will be used for all matches (not just filenames) whose display
20766       string  are  matched by the pattern.  Definitions for the form with the
20767       leading equal sign take precedence over the  values  defined  for  file
20768       types, which in turn take precedence over the form with the leading as‐
20769       terisk (file extensions).
20770
20771       The leading-equals form also allows different parts  of  the  displayed
20772       strings  to  be  colored differently.  For this, the pattern has to use
20773       the `(#b)' globbing flag and pairs of parentheses surrounding the parts
20774       of  the  strings  that are to be colored differently.  In this case the
20775       value may consist of more than one color code separated by equal signs.
20776       The first code will be used for all parts for which no explicit code is
20777       specified and the following codes will be used for the parts matched by
20778       the  sub-patterns  in  parentheses.   For  example,  the  specification
20779       `=(#b)(?)*(?)=0=3=7' will be used for all matches which  are  at  least
20780       two  characters long and will use the code `3' for the first character,
20781       `7' for the last character and `0' for the rest.
20782
20783       All three forms of name may be preceded by a  pattern  in  parentheses.
20784       If  this  is  given,  the value will be used only for matches in groups
20785       whose names are matched by the pattern given in the  parentheses.   For
20786       example,  `(g*)m*=43'  highlights  all  matches  beginning  with `m' in
20787       groups whose names  begin with `g' using the color code `43'.  In  case
20788       of the `lc', `rc', and `ec' codes, the group pattern is ignored.
20789
20790       Note also that all patterns are tried in the order in which they appear
20791       in the parameter value until the first one matches which is then  used.
20792       Patterns  may  be  matched  against completions, descriptions (possibly
20793       with spaces appended for padding), or lines consisting of a  completion
20794       followed by a description.  For consistent coloring it may be necessary
20795       to use more than one pattern or a pattern with backreferences.
20796
20797       When printing a match, the code prints the value of lc, the  value  for
20798       the  file-type or the last matching specification with a `*', the value
20799       of rc, the string to display for the match itself, and then  the  value
20800       of  ec  if that is defined or the values of lc, no, and rc if ec is not
20801       defined.
20802
20803       The default values are ISO 6429 (ANSI) compliant and  can  be  used  on
20804       vt100 compatible terminals such as xterms.  On monochrome terminals the
20805       default values will have no visible effect.  The colors  function  from
20806       the  contribution  can be used to get associative arrays containing the
20807       codes for ANSI terminals (see the section `Other Functions' in  zshcon‐
20808       trib(1)).    For   example,   after   loading  colors,  one  could  use
20809       `$color[red]'  to  get  the  code  for   foreground   color   red   and
20810       `$color[bg-green]' for the code for background color green.
20811
20812       If  the completion system invoked by compinit is used, these parameters
20813       should not be set directly because the  system  controls  them  itself.
20814       Instead, the list-colors style should be used (see the section `Comple‐
20815       tion System Configuration' in zshcompsys(1)).
20816
20817   Scrolling in completion listings
20818       To enable scrolling through a completion list, the LISTPROMPT parameter
20819       must  be set.  Its value will be used as the prompt; if it is the empty
20820       string, a default prompt will be used.  The value may  contain  escapes
20821       of  the  form  `%x'.   It  supports the escapes `%B', `%b', `%S', `%s',
20822       `%U', `%u', `%F', `%f', `%K', `%k' and `%{...%}'  used  also  in  shell
20823       prompts  as well as three pairs of additional sequences: a `%l' or `%L'
20824       is replaced by the number of the last line shown and the  total  number
20825       of  lines  in  the form `number/total'; a `%m' or `%M' is replaced with
20826       the number of the last match shown and the total number of matches; and
20827       `%p'  or  `%P'  is replaced with `Top', `Bottom' or the position of the
20828       first line shown in percent of the total number of lines, respectively.
20829       In  each  of these cases the form with the uppercase letter will be re‐
20830       placed with a string of fixed width, padded to the right  with  spaces,
20831       while the lowercase form will not be padded.
20832
20833       If the parameter LISTPROMPT is set, the completion code will not ask if
20834       the list should be shown.  Instead it immediately starts displaying the
20835       list,  stopping  after  the  first screenful, showing the prompt at the
20836       bottom, waiting for a  keypress  after  temporarily  switching  to  the
20837       listscroll  keymap.   Some  of the zle functions have a special meaning
20838       while scrolling lists:
20839
20840       send-break
20841              stops listing discarding the key pressed
20842
20843       accept-line, down-history, down-line-or-history
20844       down-line-or-search, vi-down-line-or-history
20845              scrolls forward one line
20846
20847       complete-word, menu-complete, expand-or-complete
20848       expand-or-complete-prefix, menu-complete-or-expand
20849              scrolls forward one screenful
20850
20851       accept-search
20852              stop listing but take no other action
20853
20854       Every other character stops listing and immediately processes  the  key
20855       as  usual.   Any key that is not bound in the listscroll keymap or that
20856       is bound to undefined-key is looked up  in  the  keymap  currently  se‐
20857       lected.
20858
20859       As for the ZLS_COLORS and ZLS_COLOURS parameters, LISTPROMPT should not
20860       be set directly when using the shell function based completion  system.
20861       Instead, the list-prompt style should be used.
20862
20863   Menu selection
20864       The  zsh/complist  module also offers an alternative style of selecting
20865       matches from a list, called menu selection, which can be  used  if  the
20866       shell is set up to return to the last prompt after showing a completion
20867       list (see the ALWAYS_LAST_PROMPT option in zshoptions(1)).
20868
20869       Menu selection can be invoked directly by the  widget  menu-select  de‐
20870       fined  by this module.  This is a standard ZLE widget that can be bound
20871       to a key in the usual way as described in zshzle(1).
20872
20873       Alternatively, the parameter MENUSELECT can be set to an integer, which
20874       gives  the  minimum  number of matches that must be present before menu
20875       selection is automatically turned on.  This second method requires that
20876       menu  completion  be  started,  either  directly  from a widget such as
20877       menu-complete, or due to one of the options MENU_COMPLETE or  AUTO_MENU
20878       being  set.  If MENUSELECT is set, but is 0, 1 or empty, menu selection
20879       will always be started during an ambiguous menu completion.
20880
20881       When using the completion system based on shell functions, the  MENUSE‐
20882       LECT  parameter should not be used (like the ZLS_COLORS and ZLS_COLOURS
20883       parameters described above).  Instead, the menu style  should  be  used
20884       with the select=... keyword.
20885
20886       After  menu  selection is started, the matches will be listed. If there
20887       are more matches than fit on the screen, only the  first  screenful  is
20888       shown.   The  matches  to  insert into the command line can be selected
20889       from this list.  In the list one match is highlighted using  the  value
20890       for ma from the ZLS_COLORS or ZLS_COLOURS parameter.  The default value
20891       for this is `7' which forces the selected match to be highlighted using
20892       standout  mode  on  a vt100-compatible terminal.  If neither ZLS_COLORS
20893       nor ZLS_COLOURS is set, the same terminal control sequence as  for  the
20894       `%S' escape in prompts is used.
20895
20896       If  there  are  more  matches  than fit on the screen and the parameter
20897       MENUPROMPT is set, its value will be shown below the matches.  It  sup‐
20898       ports  the  same  escape sequences as LISTPROMPT, but the number of the
20899       match or line shown will be that of the one where the mark  is  placed.
20900       If its value is the empty string, a default prompt will be used.
20901
20902       The  MENUSCROLL  parameter  can  be  used  to  specify  how the list is
20903       scrolled.  If the parameter is unset, this is done line by line, if  it
20904       is  set to `0' (zero), the list will scroll half the number of lines of
20905       the screen.  If the value is positive, it gives the number of lines  to
20906       scroll  and  if it is negative, the list will be scrolled the number of
20907       lines of the screen minus the (absolute) value.
20908
20909       As for the ZLS_COLORS, ZLS_COLOURS and LISTPROMPT  parameters,  neither
20910       MENUPROMPT  nor  MENUSCROLL should be set directly when using the shell
20911       function based completion system.  Instead, the select-prompt  and  se‐
20912       lect-scroll styles should be used.
20913
20914       The completion code sometimes decides not to show all of the matches in
20915       the list.  These hidden matches are either matches for which  the  com‐
20916       pletion  function  which  added them explicitly requested that they not
20917       appear in the list (using the -n option of the compadd builtin command)
20918       or  they  are matches which duplicate a string already in the list (be‐
20919       cause they differ only in things like prefixes or suffixes that are not
20920       displayed).   In  the list used for menu selection, however, even these
20921       matches are shown so that it is possible to select them.  To  highlight
20922       such  matches  the  hi  and  du  capabilities  in  the  ZLS_COLORS  and
20923       ZLS_COLOURS parameters are supported for hidden matches  of  the  first
20924       and second kind, respectively.
20925
20926       Selecting matches is done by moving the mark around using the zle move‐
20927       ment functions.  When not all matches can be shown on the screen at the
20928       same  time,  the  list will scroll up and down when crossing the top or
20929       bottom line.  The following zle functions have special  meaning  during
20930       menu  selection.   Note that the following always perform the same task
20931       within the menu selection map and cannot be replaced  by  user  defined
20932       widgets, nor can the set of functions be extended:
20933
20934       accept-line, accept-search
20935              accept  the  current  match and leave menu selection (but do not
20936              cause the command line to be accepted)
20937
20938       send-break
20939              leaves menu selection and restores the previous contents of  the
20940              command line
20941
20942       redisplay, clear-screen
20943              execute their normal function without leaving menu selection
20944
20945       accept-and-hold, accept-and-menu-complete
20946              accept  the  currently inserted match and continue selection al‐
20947              lowing to select the next match to insert into the line
20948
20949       accept-and-infer-next-history
20950              accepts the current match and then tries  completion  with  menu
20951              selection again;  in the case of files this allows one to select
20952              a directory and immediately attempt to complete files in it;  if
20953              there are no matches, a message is shown and one can use undo to
20954              go back to completion on the previous  level,  every  other  key
20955              leaves  menu  selection (including the other zle functions which
20956              are otherwise special during menu selection)
20957
20958       undo   removes matches inserted during the menu selection by one of the
20959              three functions before
20960
20961       down-history, down-line-or-history
20962       vi-down-line-or-history,  down-line-or-search
20963              moves the mark one line down
20964
20965       up-history, up-line-or-history
20966       vi-up-line-or-history, up-line-or-search
20967              moves the mark one line up
20968
20969       forward-char, vi-forward-char
20970              moves the mark one column right
20971
20972       backward-char, vi-backward-char
20973              moves the mark one column left
20974
20975       forward-word, vi-forward-word
20976       vi-forward-word-end, emacs-forward-word
20977              moves the mark one screenful down
20978
20979       backward-word, vi-backward-word, emacs-backward-word
20980              moves the mark one screenful up
20981
20982       vi-forward-blank-word, vi-forward-blank-word-end
20983              moves the mark to the first line of the next group of matches
20984
20985       vi-backward-blank-word
20986              moves the mark to the last line of the previous group of matches
20987
20988       beginning-of-history
20989              moves the mark to the first line
20990
20991       end-of-history
20992              moves the mark to the last line
20993
20994       beginning-of-buffer-or-history, beginning-of-line
20995       beginning-of-line-hist, vi-beginning-of-line
20996              moves the mark to the leftmost column
20997
20998       end-of-buffer-or-history, end-of-line
20999       end-of-line-hist, vi-end-of-line
21000              moves the mark to the rightmost column
21001
21002       complete-word, menu-complete, expand-or-complete
21003       expand-or-complete-prefix, menu-expand-or-complete
21004              moves the mark to the next match
21005
21006       reverse-menu-complete
21007              moves the mark to the previous match
21008
21009       vi-insert
21010              this toggles between normal and interactive mode; in interactive
21011              mode the keys bound to self-insert and self-insert-unmeta insert
21012              into  the  command  line  as  in normal editing mode but without
21013              leaving menu selection; after each character completion is tried
21014              again  and the list changes to contain only the new matches; the
21015              completion widgets make the longest unambiguous  string  be  in‐
21016              serted  in the command line and undo and backward-delete-char go
21017              back to the previous set of matches
21018
21019       history-incremental-search-forward
21020       history-incremental-search-backward
21021              this starts incremental searches in the list of completions dis‐
21022              played;  in  this  mode,  accept-line  only  leaves  incremental
21023              search, going back to the normal menu selection mode
21024
21025       All movement functions wrap around at the edges; any other zle function
21026       not  listed  leaves  menu  selection and executes that function.  It is
21027       possible to make widgets in the above list do the  same  by  using  the
21028       form  of the widget with a `.' in front.  For example, the widget `.ac‐
21029       cept-line' has the effect of leaving menu selection and  accepting  the
21030       entire command line.
21031
21032       During  this  selection the widget uses the keymap menuselect.  Any key
21033       that is not defined in this keymap or that is bound to undefined-key is
21034       looked  up  in  the  keymap currently selected.  This is used to ensure
21035       that the most important keys used during selection (namely  the  cursor
21036       keys,  return,  and  TAB) have sensible defaults.  However, keys in the
21037       menuselect keymap can be modified directly using  the  bindkey  builtin
21038       command  (see zshmodules(1)). For example, to make the return key leave
21039       menu selection without accepting the match currently selected one could
21040       call
21041
21042              bindkey -M menuselect '^M' send-break
21043
21044       after loading the zsh/complist module.
21045

THE ZSH/COMPUTIL MODULE

21047       The  zsh/computil module adds several builtin commands that are used by
21048       some of the completion functions in  the  completion  system  based  on
21049       shell  functions  (see  zshcompsys(1)  ).   Except  for compquote these
21050       builtin commands are very specialised and  thus  not  very  interesting
21051       when  writing your own completion functions.  In summary, these builtin
21052       commands are:
21053
21054       comparguments
21055              This is used by the _arguments function to do the  argument  and
21056              command  line parsing.  Like compdescribe it has an option -i to
21057              do the parsing and initialize some internal  state  and  various
21058              options to access the state information to decide what should be
21059              completed.
21060
21061       compdescribe
21062              This is used by the _describe function to build the displays for
21063              the  matches and to get the strings to add as matches with their
21064              options.  On the first call one of the options -i or  -I  should
21065              be  supplied  as the first argument.  In the first case, display
21066              strings without the descriptions will be generated, in the  sec‐
21067              ond case, the string used to separate the matches from their de‐
21068              scriptions must be given as the second argument and the descrip‐
21069              tions  (if any) will be shown.  All other arguments are like the
21070              definition arguments to _describe itself.
21071
21072              Once compdescribe has been called with either the -i or  the  -I
21073              option,  it  can be repeatedly called with the -g option and the
21074              names of four parameters  as  its  arguments.   This  will  step
21075              through  the  different  sets  of matches and store the value of
21076              compstate[list] in the first scalar, the options for compadd  in
21077              the  second  array,  the  matches  in  the  third array, and the
21078              strings to be displayed in the completion listing in the  fourth
21079              array.  The arrays may then be directly given to compadd to reg‐
21080              ister the matches with the completion code.
21081
21082       compfiles
21083              Used by the _path_files function to optimize  complex  recursive
21084              filename generation (globbing).  It does three things.  With the
21085              -p and -P options it builds the glob patterns to use,  including
21086              the  paths  already  handled and trying to optimize the patterns
21087              with respect to the prefix and suffix  from  the  line  and  the
21088              match  specification currently used.  The -i option does the di‐
21089              rectory tests for the ignore-parents style  and  the  -r  option
21090              tests  if  a  component for some of the matches are equal to the
21091              string on the line and removes all  other  matches  if  that  is
21092              true.
21093
21094       compgroups
21095              Used  by  the  _tags  function to implement the internals of the
21096              group-order style.  This only takes its arguments  as  names  of
21097              completion  groups and creates the groups for it (all six types:
21098              sorted and unsorted, both without removing duplicates, with  re‐
21099              moving all duplicates and with removing consecutive duplicates).
21100
21101       compquote [ -p ] names ...
21102              There  may be reasons to write completion functions that have to
21103              add the matches using the -Q option to compadd and perform quot‐
21104              ing  themselves.  Instead of interpreting the first character of
21105              the all_quotes key of the compstate special association and  us‐
21106              ing  the  q  flag  for  parameter  expansions,  one can use this
21107              builtin command.  The arguments are the names of scalar or array
21108              parameters  and  the  values  of  these parameters are quoted as
21109              needed for the innermost quoting level.  If  the  -p  option  is
21110              given,  quoting  is  done  as if there is some prefix before the
21111              values of the parameters, so that a leading equal sign will  not
21112              be quoted.
21113
21114              The  return status is non-zero in case of an error and zero oth‐
21115              erwise.
21116
21117       comptags
21118       comptry
21119              These implement the internals of the tags mechanism.
21120
21121       compvalues
21122              Like comparguments, but for the _values function.
21123

THE ZSH/CURSES MODULE

21125       The zsh/curses module makes available one builtin command  and  various
21126       parameters.
21127
21128   Builtin
21129       zcurses init
21130       zcurses end
21131       zcurses addwin targetwin nlines ncols begin_y begin_x [ parentwin ]
21132       zcurses delwin targetwin
21133       zcurses refresh [ targetwin ... ]
21134       zcurses touch targetwin ...
21135       zcurses move targetwin new_y new_x
21136       zcurses clear targetwin [ redraw | eol | bot ]
21137       zcurses position targetwin array
21138       zcurses char targetwin character
21139       zcurses string targetwin string
21140       zcurses border targetwin border
21141       zcurses attr targetwin [ [+|-]attribute | fg_col/bg_col ] [...]
21142       zcurses bg targetwin [ [+|-]attribute | fg_col/bg_col | @char ] [...]
21143       zcurses scroll targetwin [ on | off | [+|-]lines ]
21144       zcurses input targetwin [ param [ kparam [ mparam ] ] ]
21145       zcurses mouse [ delay num | [+|-]motion ]
21146       zcurses timeout targetwin intval
21147       zcurses querychar targetwin [ param ]
21148       zcurses resize height width [ endwin | nosave | endwin_nosave ]
21149              Manipulate  curses  windows.  All uses of this command should be
21150              bracketed by `zcurses init' to initialise  use  of  curses,  and
21151              `zcurses  end'  to  end it; omitting `zcurses end' can cause the
21152              terminal to be in an unwanted state.
21153
21154              The subcommand addwin creates a window  with  nlines  lines  and
21155              ncols  columns.  Its upper left corner will be placed at row be‐
21156              gin_y and column begin_x of the screen.  targetwin is  a  string
21157              and  refers  to  the  name of a window that is not currently as‐
21158              signed.  Note in particular the curses convention that  vertical
21159              values appear before horizontal values.
21160
21161              If addwin is given an existing window as the final argument, the
21162              new window is created as a subwindow of parentwin.  This differs
21163              from  an  ordinary  new  window in that the memory of the window
21164              contents is shared with the parent's memory.  Subwindows must be
21165              deleted  before their parent.  Note that the coordinates of sub‐
21166              windows are relative to the screen,  not  the  parent,  as  with
21167              other windows.
21168
21169              Use  the  subcommand  delwin to delete a window created with ad‐
21170              dwin.  Note that end does not  implicitly  delete  windows,  and
21171              that delwin does not erase the screen image of the window.
21172
21173              The  window  corresponding  to the full visible screen is called
21174              stdscr; it always exists after  `zcurses  init'  and  cannot  be
21175              delete with delwin.
21176
21177              The  subcommand  refresh  will refresh window targetwin; this is
21178              necessary to make any pending changes (such  as  characters  you
21179              have  prepared for output with char) visible on the screen.  re‐
21180              fresh without an argument causes the screen to  be  cleared  and
21181              redrawn.   If  multiple windows are given, the screen is updated
21182              once at the end.
21183
21184              The subcommand touch marks the  targetwins  listed  as  changed.
21185              This is necessary before refreshing windows if a window that was
21186              in front of another window (which may be stdscr) is deleted.
21187
21188              The subcommand move moves the cursor position  in  targetwin  to
21189              new  coordinates  new_y  and  new_x.   Note  that the subcommand
21190              string (but not the subcommand char) advances the  cursor  posi‐
21191              tion over the characters added.
21192
21193              The subcommand clear erases the contents of targetwin.  One (and
21194              no more than one) of three options may be specified.   With  the
21195              option  redraw,  in  addition the next refresh of targetwin will
21196              cause the screen to be cleared and repainted.  With  the  option
21197              eol,  targetwin is only cleared to the end of the current cursor
21198              line.  With the option bot, targetwin is cleared to the  end  of
21199              the  window, i.e everything to the right and below the cursor is
21200              cleared.
21201
21202              The subcommand position writes various positions associated with
21203              targetwin into the array named array.  These are, in order:
21204              -      The y and x coordinates of the cursor relative to the top
21205                     left of targetwin
21206              -      The y and x coordinates of the top left of  targetwin  on
21207                     the screen
21208              -      The size of targetwin in y and x dimensions.
21209
21210              Outputting  characters  and  strings  are  achieved  by char and
21211              string respectively.
21212
21213              To draw a border around window targetwin, use border.  Note that
21214              the  border  is  not  subsequently  handled specially:  in other
21215              words, the border is simply a set of characters  output  at  the
21216              edge of the window.  Hence it can be overwritten, can scroll off
21217              the window, etc.
21218
21219              The subcommand attr will set  targetwin's  attributes  or  fore‐
21220              ground/background  color  pair for any successive character out‐
21221              put.  Each attribute given on the line may be prepended by  a  +
21222              to  set  or a - to unset that attribute; + is assumed if absent.
21223              The attributes supported are blink, bold, dim,  reverse,  stand‐
21224              out, and underline.
21225
21226              Each  fg_col/bg_col attribute (to be read as `fg_col on bg_col')
21227              sets the foreground and background color for  character  output.
21228              The  color  default is sometimes available (in particular if the
21229              library is ncurses), specifying  the  foreground  or  background
21230              color  with  which  the  terminal  started.   The color pair de‐
21231              fault/default is always available. To use more than the 8  named
21232              colors  (red,  green,  etc.)  construct  the fg_col/bg_col pairs
21233              where fg_col and bg_col are decimal integers, e.g 128/200.   The
21234              maximum color value is 254 if the terminal supports 256 colors.
21235
21236              bg overrides the color and other attributes of all characters in
21237              the window.  Its usual use is to set the  background  initially,
21238              but  it  will  overwrite the attributes of any characters at the
21239              time when it is called.  In addition to  the  arguments  allowed
21240              with  attr,  an argument @char specifies a character to be shown
21241              in otherwise blank areas of the window.  Owing to limitations of
21242              curses  this cannot be a multibyte character (use of ASCII char‐
21243              acters only is recommended).  As the specified set of attributes
21244              override  the existing background, turning attributes off in the
21245              arguments is not useful, though this does not cause an error.
21246
21247              The subcommand scroll can be used with on or off to  enabled  or
21248              disable  scrolling  of  a window when the cursor would otherwise
21249              move below the window due to typing or output.  It can  also  be
21250              used with a positive or negative integer to scroll the window up
21251              or down the given number of lines without changing  the  current
21252              cursor position (which therefore appears to move in the opposite
21253              direction relative to the  window).   In  the  second  case,  if
21254              scrolling is off it is temporarily turned on to allow the window
21255              to be scrolled.
21256
21257              The subcommand input reads a single character  from  the  window
21258              without  echoing it back.  If param is supplied the character is
21259              assigned to the parameter param, else it is assigned to the  pa‐
21260              rameter REPLY.
21261
21262              If  both param and kparam are supplied, the key is read in `key‐
21263              pad' mode.  In this mode special keys such as function keys  and
21264              arrow  keys  return the name of the key in the parameter kparam.
21265              The key  names  are  the  macros  defined  in  the  curses.h  or
21266              ncurses.h  with the prefix `KEY_' removed; see also the descrip‐
21267              tion of the parameter zcurses_keycodes below.  Other keys  cause
21268              a  value  to  be set in param as before.  On a successful return
21269              only one of param or kparam contains  a  non-empty  string;  the
21270              other is set to an empty string.
21271
21272              If  mparam  is also supplied, input attempts to handle mouse in‐
21273              put.  This is only available with  the  ncurses  library;  mouse
21274              handling  can  be  detected  by  checking for the exit status of
21275              `zcurses mouse' with no arguments.  If a mouse button is clicked
21276              (or  double-  or  triple-clicked,  or pressed or released with a
21277              configurable delay from being clicked) then kparam is set to the
21278              string  MOUSE,  and  mparam is set to an array consisting of the
21279              following elements:
21280              -      An identifier to discriminate  different  input  devices;
21281                     this is only rarely useful.
21282              -      The x, y and z coordinates of the mouse click relative to
21283                     the full screen, as three elements in  that  order  (i.e.
21284                     the  y coordinate is, unusually, after the x coordinate).
21285                     The z coordinate is only available for a few unusual  in‐
21286                     put devices and is otherwise set to zero.
21287              -      Any events that occurred as separate items; usually there
21288                     will be just one.  An  event  consists  of  PRESSED,  RE‐
21289                     LEASED,  CLICKED,  DOUBLE_CLICKED  or TRIPLE_CLICKED fol‐
21290                     lowed immediately (in the same element) by the number  of
21291                     the button.
21292              -      If the shift key was pressed, the string SHIFT.
21293              -      If the control key was pressed, the string CTRL.
21294              -      If the alt key was pressed, the string ALT.
21295
21296              Not  all mouse events may be passed through to the terminal win‐
21297              dow; most terminal emulators  handle  some  mouse  events  them‐
21298              selves.   Note  that the ncurses manual implies that using input
21299              both with and without mouse handling may cause the mouse  cursor
21300              to appear and disappear.
21301
21302              The  subcommand  mouse  can  be used to configure the use of the
21303              mouse.  There is no window argument; mouse options  are  global.
21304              `zcurses mouse' with no arguments returns status 0 if mouse han‐
21305              dling is possible, else status 1.  Otherwise, the possible argu‐
21306              ments  (which  may  be combined on the same command line) are as
21307              follows.  delay num sets the maximum delay in  milliseconds  be‐
21308              tween  press and release events to be considered as a click; the
21309              value 0 disables click resolution, and the default is one  sixth
21310              of  a second.  motion proceeded by an optional `+' (the default)
21311              or - turns on or off reporting of mouse motion  in  addition  to
21312              clicks,  presses  and releases, which are always reported.  How‐
21313              ever, it appears reports for mouse motion are not currently  im‐
21314              plemented.
21315
21316              The  subcommand timeout specifies a timeout value for input from
21317              targetwin.  If intval is negative, `zcurses input' waits indefi‐
21318              nitely  for  a  character  to be typed; this is the default.  If
21319              intval is zero, `zcurses input' returns immediately; if there is
21320              typeahead  it is returned, else no input is done and status 1 is
21321              returned.  If intval is positive, `zcurses input'  waits  intval
21322              milliseconds  for  input and if there is none at the end of that
21323              period returns status 1.
21324
21325              The subcommand querychar queries the character  at  the  current
21326              cursor  position.   The  return  values  are stored in the array
21327              named param if supplied, else in the  array  reply.   The  first
21328              value  is  the  character (which may be a multibyte character if
21329              the system supports them); the second is the color pair  in  the
21330              usual  fg_col/bg_col  notation,  or 0 if color is not supported.
21331              Any attributes other than color that apply to the character,  as
21332              set with the subcommand attr, appear as additional elements.
21333
21334              The  subcommand  resize  resizes stdscr and all windows to given
21335              dimensions (windows that stick out from the new  dimensions  are
21336              resized  down).  The  underlying  curses  extension (resize_term
21337              call) can be unavailable. To verify,  zeroes  can  be  used  for
21338              height  and  width.  If  the  result of the subcommand is 0, re‐
21339              size_term is available (2 otherwise). Tests show  that  resizing
21340              can  be normally accomplished by calling zcurses end and zcurses
21341              refresh. The resize subcommand is provided for versatility. Mul‐
21342              tiple  system  configurations  have been checked and zcurses end
21343              and zcurses refresh are still needed for correct terminal  state
21344              after  resize.  To invoke them with resize, use endwin argument.
21345              Using nosave argument will cause new terminal state  to  not  be
21346              saved internally by zcurses. This is also provided for versatil‐
21347              ity and should normally be not needed.
21348
21349   Parameters
21350       ZCURSES_COLORS
21351              Readonly integer.  The maximum number  of  colors  the  terminal
21352              supports.   This  value is initialised by the curses library and
21353              is not available until the first time zcurses init is run.
21354
21355       ZCURSES_COLOR_PAIRS
21356              Readonly  integer.   The   maximum   number   of   color   pairs
21357              fg_col/bg_col  that  may  be defined in `zcurses attr' commands;
21358              note this limit applies to all color pairs that have  been  used
21359              whether  or  not  they are currently active.  This value is ini‐
21360              tialised by the curses library and is not  available  until  the
21361              first time zcurses init is run.
21362
21363       zcurses_attrs
21364              Readonly  array.  The attributes supported by zsh/curses; avail‐
21365              able as soon as the module is loaded.
21366
21367       zcurses_colors
21368              Readonly array.  The colors supported by  zsh/curses;  available
21369              as soon as the module is loaded.
21370
21371       zcurses_keycodes
21372              Readonly  array.   The values that may be returned in the second
21373              parameter supplied to `zcurses input' in the order in which they
21374              are  defined  internally  by  curses.  Not all function keys are
21375              listed, only F0; curses reserves space for F0 up to F63.
21376
21377       zcurses_windows
21378              Readonly array.  The current list of windows, i.e.  all  windows
21379              that  have  been  created  with `zcurses addwin' and not removed
21380              with `zcurses delwin'.
21381

THE ZSH/DATETIME MODULE

21383       The zsh/datetime module makes available one builtin command:
21384
21385       strftime [ -s scalar ] format [ epochtime [ nanoseconds ] ]
21386       strftime -r [ -q ] [ -s scalar ] format timestring
21387              Output the date in the format specified.  With no epochtime, the
21388              current  system  date/time is used; optionally, epochtime may be
21389              used to specify the number  of  seconds  since  the  epoch,  and
21390              nanoseconds  may  additionally  be used to specify the number of
21391              nanoseconds past the second (otherwise that number is assumed to
21392              be  0).   See  strftime(3)  for details.  The zsh extensions de‐
21393              scribed in the section EXPANSION OF  PROMPT  SEQUENCES  in  zsh‐
21394              misc(1) are also available.
21395
21396              -q     Run  quietly; suppress printing of all error messages de‐
21397                     scribed below.  Errors for invalid epochtime  values  are
21398                     always printed.
21399
21400              -r     With the option -r (reverse), use format to parse the in‐
21401                     put string timestring and output the  number  of  seconds
21402                     since  the epoch at which the time occurred.  The parsing
21403                     is implemented by the system function strptime; see strp‐
21404                     time(3).   This  means that zsh format extensions are not
21405                     available, but for reverse lookup they are not required.
21406
21407                     In most implementations of strftime any timezone  in  the
21408                     timestring  is ignored and the local timezone declared by
21409                     the TZ environment variable is used; other parameters are
21410                     set to zero if not present.
21411
21412                     If  timestring  does not match format the command returns
21413                     status 1 and prints  an  error  message.   If  timestring
21414                     matches  format but not all characters in timestring were
21415                     used, the conversion succeeds but also  prints  an  error
21416                     message.
21417
21418                     If  either  of the system functions strptime or mktime is
21419                     not available, status 2 is returned and an error  message
21420                     is printed.
21421
21422              -s scalar
21423                     Assign the date string (or epoch time in seconds if -r is
21424                     given) to scalar instead of printing it.
21425
21426              Note that depending on the system's declared integral time type,
21427              strftime  may  produce incorrect results for epoch times greater
21428              than 2147483647 which corresponds to 2038-01-19 03:14:07 +0000.
21429
21430       The zsh/datetime module makes available  several  parameters;  all  are
21431       readonly:
21432
21433       EPOCHREALTIME
21434              A  floating point value representing the number of seconds since
21435              the epoch.  The notional  accuracy  is  to  nanoseconds  if  the
21436              clock_gettime  call  is available and to microseconds otherwise,
21437              but in practice the range of double precision floating point and
21438              shell scheduling latencies may be significant effects.
21439
21440       EPOCHSECONDS
21441              An  integer  value  representing the number of seconds since the
21442              epoch.
21443
21444       epochtime
21445              An array value containing the number of seconds since the  epoch
21446              in  the  first  element  and the remainder of the time since the
21447              epoch in nanoseconds in the second element.  To ensure  the  two
21448              elements  are consistent the array should be copied or otherwise
21449              referenced as a single substitution before the values are  used.
21450              The following idiom may be used:
21451
21452                     for secs nsecs in $epochtime; do
21453                       ...
21454                     done
21455

THE ZSH/DB/GDBM MODULE

21457       The zsh/db/gdbm module is used to create "tied" associative arrays that
21458       interface to database files.  If the GDBM interface is  not  available,
21459       the  builtins defined by this module will report an error.  This module
21460       is also intended as a prototype for creating additional database inter‐
21461       faces, so the ztie builtin may move to a more generic module in the fu‐
21462       ture.
21463
21464       The builtins in this module are:
21465
21466       ztie -d db/gdbm -f filename [ -r ] arrayname
21467              Open the GDBM database identified by filename and,  if  success‐
21468              ful,  create the associative array arrayname linked to the file.
21469              To create a local tied array, the parameter must  first  be  de‐
21470              clared,  so  commands similar to the following would be executed
21471              inside a function scope:
21472
21473                     local -A sampledb
21474                     ztie -d db/gdbm -f sample.gdbm sampledb
21475
21476              The -r option opens the database file for reading only, creating
21477              a  parameter  with the readonly attribute.  Without this option,
21478              using `ztie' on a file for which the user does  not  have  write
21479              permission  is  an  error.   If writable, the database is opened
21480              synchronously so fields changed  in  arrayname  are  immediately
21481              written to filename.
21482
21483              Changes  to  the file modes filename after it has been opened do
21484              not alter the state of arrayname,  but  `typeset  -r  arrayname'
21485              works as expected.
21486
21487       zuntie [ -u ] arrayname ...
21488              Close  the GDBM database associated with each arrayname and then
21489              unset the parameter.  The -u option forces an unset  of  parame‐
21490              ters made readonly with `ztie -r'.
21491
21492              This  happens automatically if the parameter is explicitly unset
21493              or its local scope (function) ends.  Note that a readonly param‐
21494              eter  may  not  be  explicitly unset, so the only way to unset a
21495              global parameter created with `ztie -r' is to use `zuntie -u'.
21496
21497       zgdbmpath parametername
21498              Put path to database file assigned to parametername  into  REPLY
21499              scalar.
21500
21501       zgdbm_tied
21502              Array holding names of all tied parameters.
21503
21504       The  fields of an associative array tied to GDBM are neither cached nor
21505       otherwise stored in memory, they are read from or written to the  data‐
21506       base  on  each  reference.  Thus, for example, the values in a readonly
21507       array may be changed by a second writer of the same database file.
21508

THE ZSH/DELTOCHAR MODULE

21510       The zsh/deltochar module makes available two ZLE functions:
21511
21512       delete-to-char
21513              Read a character from the keyboard, and delete from  the  cursor
21514              position  up to and including the next (or, with repeat count n,
21515              the nth) instance of that  character.   Negative  repeat  counts
21516              mean delete backwards.
21517
21518       zap-to-char
21519              This  behaves  like delete-to-char, except that the final occur‐
21520              rence of the character itself is not deleted.
21521

THE ZSH/EXAMPLE MODULE

21523       The zsh/example module makes available one builtin command:
21524
21525       example [ -flags ] [ args ... ]
21526              Displays the flags and arguments it is invoked with.
21527
21528       The purpose of the module is to serve as an example of how to  write  a
21529       module.
21530

THE ZSH/FILES MODULE

21532       The  zsh/files module makes available some common commands for file ma‐
21533       nipulation as builtins; these commands are probably not needed for many
21534       normal  situations  but  can be useful in emergency recovery situations
21535       with constrained resources.  The commands do not implement all features
21536       now required by relevant standards committees.
21537
21538       For  all commands, a variant beginning zf_ is also available and loaded
21539       automatically.  Using the features capability of zmodload will let  you
21540       load  only  those names you want.  Note that it's possible to load only
21541       the builtins with zsh-specific names using the following command:
21542
21543              zmodload -m -F zsh/files b:zf_\*
21544
21545       The commands loaded by default are:
21546
21547       chgrp [ -hRs ] group filename ...
21548              Changes group of files specified.  This is equivalent  to  chown
21549              with a user-spec argument of `:group'.
21550
21551       chmod [ -Rs ] mode filename ...
21552              Changes mode of files specified.
21553
21554              The specified mode must be in octal.
21555
21556              The  -R option causes chmod to recursively descend into directo‐
21557              ries, changing the mode of all  files  in  the  directory  after
21558              changing the mode of the directory itself.
21559
21560              The -s option is a zsh extension to chmod functionality.  It en‐
21561              ables paranoid behaviour, intended to  avoid  security  problems
21562              involving  a chmod being tricked into affecting files other than
21563              the ones intended.  It will refuse to follow symbolic links,  so
21564              that  (for example) ``chmod 600 /tmp/foo/passwd'' can't acciden‐
21565              tally chmod /etc/passwd if /tmp/foo happens  to  be  a  link  to
21566              /etc.  It will also check where it is after leaving directories,
21567              so that a recursive chmod of a deep directory tree can't end  up
21568              recursively chmoding /usr as a result of directories being moved
21569              up the tree.
21570
21571       chown [ -hRs ] user-spec filename ...
21572              Changes ownership and group of files specified.
21573
21574              The user-spec can be in four forms:
21575
21576              user   change owner to user; do not change group
21577              user:: change owner to user; do not change group
21578              user:  change owner to user;  change  group  to  user's  primary
21579                     group
21580              user:group
21581                     change owner to user; change group to group
21582              :group do not change owner; change group to group
21583
21584              In each case, the `:' may instead be a `.'.  The rule is that if
21585              there is a `:' then the separator is `:', otherwise if there  is
21586              a  `.'  then the separator is `.', otherwise there is no separa‐
21587              tor.
21588
21589              Each of user and group may be either a username (or group  name,
21590              as appropriate) or a decimal user ID (group ID).  Interpretation
21591              as a name takes precedence, if there is an all-numeric  username
21592              (or group name).
21593
21594              If  the target is a symbolic link, the -h option causes chown to
21595              set the ownership of the link instead of its target.
21596
21597              The -R option causes chown to recursively descend into  directo‐
21598              ries, changing the ownership of all files in the directory after
21599              changing the ownership of the directory itself.
21600
21601              The -s option is a zsh extension to chown functionality.  It en‐
21602              ables  paranoid  behaviour,  intended to avoid security problems
21603              involving a chown being tricked into affecting files other  than
21604              the  ones intended.  It will refuse to follow symbolic links, so
21605              that (for example) ``chown luser /tmp/foo/passwd''  can't  acci‐
21606              dentally  chown  /etc/passwd if /tmp/foo happens to be a link to
21607              /etc.  It will also check where it is after leaving directories,
21608              so  that a recursive chown of a deep directory tree can't end up
21609              recursively chowning /usr as a result of directories being moved
21610              up the tree.
21611
21612       ln [ -dfhins ] filename dest
21613       ln [ -dfhins ] filename ... dir
21614              Creates  hard (or, with -s, symbolic) links.  In the first form,
21615              the specified destination is created, as a link to the specified
21616              filename.  In the second form, each of the filenames is taken in
21617              turn, and linked to a pathname in the specified  directory  that
21618              has the same last pathname component.
21619
21620              Normally,  ln  will not attempt to create hard links to directo‐
21621              ries.  This check can be overridden using the -d option.   Typi‐
21622              cally  only the super-user can actually succeed in creating hard
21623              links to directories.  This does not apply to symbolic links  in
21624              any case.
21625
21626              By  default, existing files cannot be replaced by links.  The -i
21627              option causes the user to be queried  about  replacing  existing
21628              files.   The  -f  option  causes  existing  files to be silently
21629              deleted, without querying.  -f takes precedence.
21630
21631              The -h and -n options are identical and both exist for  compati‐
21632              bility;  either  one  indicates  that if the target is a symlink
21633              then it should not be dereferenced.  Typically this is  used  in
21634              combination with -sf so that if an existing link points to a di‐
21635              rectory then it will be removed, instead of followed.   If  this
21636              option  is used with multiple filenames and the target is a sym‐
21637              bolic link pointing to a directory then the result is an error.
21638
21639       mkdir [ -p ] [ -m mode ] dir ...
21640              Creates directories.  With the -p  option,  non-existing  parent
21641              directories are first created if necessary, and there will be no
21642              complaint if the directory already exists.  The -m option can be
21643              used  to  specify  (in  octal) a set of file permissions for the
21644              created directories, otherwise mode 777 modified by the  current
21645              umask (see umask(2)) is used.
21646
21647       mv [ -fi ] filename dest
21648       mv [ -fi ] filename ... dir
21649              Moves files.  In the first form, the specified filename is moved
21650              to the specified destination.  In the second form, each  of  the
21651              filenames is taken in turn, and moved to a pathname in the spec‐
21652              ified directory that has the same last pathname component.
21653
21654              By default, the user will be queried before replacing  any  file
21655              that  the  user  cannot  write  to,  but  writable files will be
21656              silently removed.  The -i option causes the user to  be  queried
21657              about  replacing  any  existing files.  The -f option causes any
21658              existing files to be silently  deleted,  without  querying.   -f
21659              takes precedence.
21660
21661              Note  that this mv will not move files across devices.  Histori‐
21662              cal versions of mv, when actual  renaming  is  impossible,  fall
21663              back  on  copying  and  removing files; if this behaviour is de‐
21664              sired, use cp and rm manually.  This may change in a future ver‐
21665              sion.
21666
21667       rm [ -dfiRrs ] filename ...
21668              Removes files and directories specified.
21669
21670              Normally,  rm will not remove directories (except with the -R or
21671              -r options).  The -d option causes rm to try  removing  directo‐
21672              ries  with  unlink  (see  unlink(2)),  the  same method used for
21673              files.  Typically only the super-user can  actually  succeed  in
21674              unlinking  directories in this way.  -d takes precedence over -R
21675              and -r.
21676
21677              By default, the user will be queried before  removing  any  file
21678              that  the  user  cannot  write  to,  but  writable files will be
21679              silently removed.  The -i option causes the user to  be  queried
21680              about  removing  any  files.   The  -f option causes files to be
21681              silently deleted, without querying, and suppresses all error in‐
21682              dications.  -f takes precedence.
21683
21684              The  -R  and -r options cause rm to recursively descend into di‐
21685              rectories, deleting all files in the directory  before  removing
21686              the directory with the rmdir system call (see rmdir(2)).
21687
21688              The  -s  option  is a zsh extension to rm functionality.  It en‐
21689              ables paranoid behaviour,  intended  to  avoid  common  security
21690              problems  involving  a  root-run  rm being tricked into removing
21691              files other than the ones intended.  It will  refuse  to  follow
21692              symbolic  links,  so  that  (for example) ``rm /tmp/foo/passwd''
21693              can't accidentally remove /etc/passwd if /tmp/foo happens to  be
21694              a  link  to  /etc.  It will also check where it is after leaving
21695              directories, so that a recursive removal  of  a  deep  directory
21696              tree  can't  end up recursively removing /usr as a result of di‐
21697              rectories being moved up the tree.
21698
21699       rmdir dir ...
21700              Removes empty directories specified.
21701
21702       sync   Calls the system call of the  same  name  (see  sync(2)),  which
21703              flushes  dirty  buffers to disk.  It might return before the I/O
21704              has actually been completed.
21705

THE ZSH/LANGINFO MODULE

21707       The zsh/langinfo module makes available one parameter:
21708
21709       langinfo
21710              An associative array that maps langinfo elements to  their  val‐
21711              ues.
21712
21713              Your implementation may support a number of the following keys:
21714
21715              CODESET, D_T_FMT, D_FMT, T_FMT, RADIXCHAR, THOUSEP, YESEXPR, NO‐
21716              EXPR,   CRNCYSTR,   ABDAY_{1..7},   DAY_{1..7},   ABMON_{1..12},
21717              MON_{1..12},   T_FMT_AMPM,   AM_STR,   PM_STR,  ERA,  ERA_D_FMT,
21718              ERA_D_T_FMT, ERA_T_FMT, ALT_DIGITS
21719

THE ZSH/MAPFILE MODULE

21721       The zsh/mapfile module provides one special associative array parameter
21722       of the same name.
21723
21724       mapfile
21725              This associative array takes as keys the names of files; the re‐
21726              sulting value is the content of the file.  The value is  treated
21727              identically  to  any  other  text  coming from a parameter.  The
21728              value may also be assigned to, in which case the file  in  ques‐
21729              tion  is  written  (whether or not it originally existed); or an
21730              element may be unset, which will delete the  file  in  question.
21731              For  example, `vared mapfile[myfile]' works as expected, editing
21732              the file `myfile'.
21733
21734              When the array is accessed as a whole, the keys are the names of
21735              files  in  the  current  directory, and the values are empty (to
21736              save a huge overhead in memory).   Thus  ${(k)mapfile}  has  the
21737              same  effect  as  the  glob operator *(D), since files beginning
21738              with a dot are not special.  Care must be taken with expressions
21739              such  as  rm  ${(k)mapfile}, which will delete every file in the
21740              current directory without the usual `rm *' test.
21741
21742              The parameter mapfile may be made read-only; in that case, files
21743              referenced may not be written or deleted.
21744
21745              A  file  may  conveniently be read into an array as one line per
21746              element with the form `array=("${(f@)mapfile[filename]}")'.  The
21747              double  quotes  and the `@' are necessary to prevent empty lines
21748              from being removed.  Note that if the file ends with a  newline,
21749              the  shell  will split on the final newline, generating an addi‐
21750              tional empty  field;  this  can  be  suppressed  by  using  `ar‐
21751              ray=("${(f@)${mapfile[filename]%$'\n'}}")'.
21752
21753   Limitations
21754       Although  reading  and  writing  of the file in question is efficiently
21755       handled, zsh's internal memory management may be  arbitrarily  baroque;
21756       however,  mapfile is usually very much more efficient than anything in‐
21757       volving a loop.  Note in particular that the whole contents of the file
21758       will  always reside physically in memory when accessed (possibly multi‐
21759       ple times, due to standard parameter substitution operations).  In par‐
21760       ticular,  this  means handling of sufficiently long files (greater than
21761       the machine's swap space, or than the range of the pointer  type)  will
21762       be incorrect.
21763
21764       No  errors  are printed or flagged for non-existent, unreadable, or un‐
21765       writable files, as the parameter mechanism is too low in the shell exe‐
21766       cution hierarchy to make this convenient.
21767
21768       It  is  unfortunate that the mechanism for loading modules does not yet
21769       allow the user to specify the name of the shell parameter to  be  given
21770       the special behaviour.
21771

THE ZSH/MATHFUNC MODULE

21773       The  zsh/mathfunc  module  provides standard mathematical functions for
21774       use when evaluating mathematical formulae.  The syntax agrees with nor‐
21775       mal C and FORTRAN conventions, for example,
21776
21777              (( f = sin(0.3) ))
21778
21779       assigns the sine of 0.3 to the parameter f.
21780
21781       Most  functions  take  floating  point  arguments and return a floating
21782       point value.  However, any necessary conversions  from  or  to  integer
21783       type  will  be  performed  automatically by the shell.  Apart from atan
21784       with a second argument and the abs, int and float functions, all  func‐
21785       tions  behave as noted in the manual page for the corresponding C func‐
21786       tion, except that any arguments out of range for the function in  ques‐
21787       tion will be detected by the shell and an error reported.
21788
21789       The  following  functions  take a single floating point argument: acos,
21790       acosh, asin, asinh, atan, atanh, cbrt, ceil, cos, cosh, erf, erfc, exp,
21791       expm1,  fabs,  floor,  gamma,  j0, j1, lgamma, log, log10, log1p, log2,
21792       logb, sin, sinh, sqrt, tan, tanh, y0, y1.  The atan  function  can  op‐
21793       tionally  take  a  second argument, in which case it behaves like the C
21794       function atan2.  The ilogb function takes a single floating point argu‐
21795       ment, but returns an integer.
21796
21797       The  function signgam takes no arguments, and returns an integer, which
21798       is the C variable of the same name, as  described  in  gamma(3).   Note
21799       that  it  is therefore only useful immediately after a call to gamma or
21800       lgamma.  Note also that `signgam()' and `signgam' are distinct  expres‐
21801       sions.
21802
21803       The  functions  min, max, and sum are defined not in this module but in
21804       the zmathfunc autoloadable function, described in the  section  `Mathe‐
21805       matical Functions' in zshcontrib(1).
21806
21807       The  following  functions  take two floating point arguments: copysign,
21808       fmod, hypot, nextafter.
21809
21810       The following take an integer first argument and a floating point  sec‐
21811       ond argument: jn, yn.
21812
21813       The  following take a floating point first argument and an integer sec‐
21814       ond argument: ldexp, scalb.
21815
21816       The function abs does not convert the type of its single  argument;  it
21817       returns  the absolute value of either a floating point number or an in‐
21818       teger.  The functions float and int  convert  their  arguments  into  a
21819       floating point or integer value (by truncation) respectively.
21820
21821       Note  that  the C pow function is available in ordinary math evaluation
21822       as the `**' operator and is not provided here.
21823
21824       The function rand48 is available if your system's mathematical  library
21825       has the function erand48(3).  It returns a pseudo-random floating point
21826       number between 0 and 1.  It takes a single string optional argument.
21827
21828       If the argument is not present, the random number seed  is  initialised
21829       by  three calls to the rand(3) function --- this produces the same ran‐
21830       dom numbers as the next three values of $RANDOM.
21831
21832       If the argument is present, it gives the name  of  a  scalar  parameter
21833       where  the  current  random  number  seed will be stored.  On the first
21834       call, the value must contain at least twelve  hexadecimal  digits  (the
21835       remainder of the string is ignored), or the seed will be initialised in
21836       the same manner as for a call to rand48 with no  argument.   Subsequent
21837       calls  to  rand48(param)  will  then maintain the seed in the parameter
21838       param as a string of twelve hexadecimal digits, with no base signifier.
21839       The random number sequences for different parameters are completely in‐
21840       dependent, and are also independent from that used by calls  to  rand48
21841       with no argument.
21842
21843       For example, consider
21844
21845              print $(( rand48(seed) ))
21846              print $(( rand48() ))
21847              print $(( rand48(seed) ))
21848
21849       Assuming  $seed  does  not  exist,  it will be initialised by the first
21850       call.  In the second call, the default seed is initialised; note,  how‐
21851       ever,  that  because of the properties of rand() there is a correlation
21852       between the seeds used for the two initialisations, so for more  secure
21853       uses,  you  should  generate your own 12-byte seed.  The third call re‐
21854       turns to the same sequence of random numbers used in  the  first  call,
21855       unaffected by the intervening rand48().
21856

THE ZSH/NEARCOLOR MODULE

21858       The  zsh/nearcolor  module  replaces  colours specified as hex triplets
21859       with the nearest colour in the 88  or  256  colour  palettes  that  are
21860       widely  used by terminal emulators.  By default, 24-bit true colour es‐
21861       cape codes are generated when colours are specified using hex triplets.
21862       These  are  not supported by all terminals.  The purpose of this module
21863       is to make it easier to define colour preferences in a  form  that  can
21864       work across a range of terminal emulators.
21865
21866       Aside  from  the  default colour, the ANSI standard for terminal escape
21867       codes provides for eight colours. The bright attribute brings  this  to
21868       sixteen. These basic colours are commonly used in terminal applications
21869       due to being widely supported. Expanded 88 and 256 colour palettes  are
21870       also  common and, while the first sixteen colours vary somewhat between
21871       terminals and configurations, these add a generally consistent and pre‐
21872       dictable set of colours.
21873
21874       In  order  to use the zsh/nearcolor module, it only needs to be loaded.
21875       Thereafter, whenever a colour is specified using a hex triplet, it will
21876       be  compared against each of the available colours and the closest will
21877       be selected. The first  sixteen  colours  are  never  matched  in  this
21878       process due to being unpredictable.
21879
21880       It  isn't  possible  to  reliably detect support for true colour in the
21881       terminal emulator. It is therefore recommended to be selective in load‐
21882       ing  the  zsh/nearcolor  module.  For example, the following checks the
21883       COLORTERM environment variable:
21884
21885              [[ $COLORTERM = *(24bit|truecolor)* ]] || zmodload zsh/nearcolor
21886
21887       Note that some terminals accept the true color  escape  codes  but  map
21888       them  internally  to  a more limited palette in a similar manner to the
21889       zsh/nearcolor module.
21890

THE ZSH/NEWUSER MODULE

21892       The zsh/newuser module is loaded at boot if it is  available,  the  RCS
21893       option is set, and the PRIVILEGED option is not set (all three are true
21894       by default).  This takes place immediately after commands in the global
21895       zshenv  file  (typically  /etc/zshenv), if any, have been executed.  If
21896       the module is not available it is silently ignored by  the  shell;  the
21897       module  may safely be removed from $MODULE_PATH by the administrator if
21898       it is not required.
21899
21900       On loading, the module tests if any  of  the  start-up  files  .zshenv,
21901       .zprofile,  .zshrc or .zlogin exist in the directory given by the envi‐
21902       ronment variable ZDOTDIR, or the user's home directory if that  is  not
21903       set.   The test is not performed and the module halts processing if the
21904       shell was in an emulation mode (i.e. had been  invoked  as  some  other
21905       shell than zsh).
21906
21907       If none of the start-up files were found, the module then looks for the
21908       file newuser first in a sitewide directory, usually the  parent  direc‐
21909       tory of the site-functions directory, and if that is not found the mod‐
21910       ule searches in a version-specific directory, usually the parent of the
21911       functions  directory containing version-specific functions.  (These di‐
21912       rectories  can  be  configured  when  zsh  is  built  using  the  --en‐
21913       able-site-scriptdir=dir  and --enable-scriptdir=dir flags to configure,
21914       respectively;   the   defaults   are    prefix/share/zsh    and    pre‐
21915       fix/share/zsh/$ZSH_VERSION where the default prefix is /usr/local.)
21916
21917       If  the file newuser is found, it is then sourced in the same manner as
21918       a start-up file.  The file is  expected  to  contain  code  to  install
21919       start-up  files for the user, however any valid shell code will be exe‐
21920       cuted.
21921
21922       The zsh/newuser module is then unconditionally unloaded.
21923
21924       Note that it is possible to achieve exactly  the  same  effect  as  the
21925       zsh/newuser  module  by  adding code to /etc/zshenv.  The module exists
21926       simply to allow the shell to make arrangements for  new  users  without
21927       the need for intervention by package maintainers and system administra‐
21928       tors.
21929
21930       The  script  supplied  with  the  module  invokes  the  shell  function
21931       zsh-newuser-install.   This may be invoked directly by the user even if
21932       the zsh/newuser module is disabled.  Note, however, that if the  module
21933       is  not installed the function will not be installed either.  The func‐
21934       tion is documented in the section User Configuration Functions in  zsh‐
21935       contrib(1).
21936

THE ZSH/PARAMETER MODULE

21938       The  zsh/parameter module gives access to some of the internal hash ta‐
21939       bles used by the shell by defining some special parameters.
21940
21941       options
21942              The keys for this associative array are the names of the options
21943              that  can  be  set  and  unset  using  the  setopt  and unsetopt
21944              builtins. The value of each key is either the string on  if  the
21945              option  is currently set, or the string off if the option is un‐
21946              set.  Setting a key to one of these strings is like  setting  or
21947              unsetting  the option, respectively. Unsetting a key in this ar‐
21948              ray is like setting it to the value off.
21949
21950       commands
21951              This array gives access to the command hash table. The keys  are
21952              the  names of external commands, the values are the pathnames of
21953              the files that would be executed when the command would  be  in‐
21954              voked.  Setting  a key in this array defines a new entry in this
21955              table in the same way as with the hash builtin. Unsetting a  key
21956              as  in  `unset  "commands[foo]"' removes the entry for the given
21957              key from the command hash table.
21958
21959       functions
21960              This associative array maps names of enabled functions to  their
21961              definitions.  Setting  a  key  in it is like defining a function
21962              with the name given by the key and the body given by the  value.
21963              Unsetting a key removes the definition for the function named by
21964              the key.
21965
21966       dis_functions
21967              Like functions but for disabled functions.
21968
21969       functions_source
21970              This readonly associative array maps names of enabled  functions
21971              to the name of the file containing the source of the function.
21972
21973              For  an  autoloaded  function  that  has already been loaded, or
21974              marked for autoload with an absolute path, or that has  had  its
21975              path  resolved  with  `functions -r', this is the file found for
21976              autoloading, resolved to an absolute path.
21977
21978              For a function defined within the body of a  script  or  sourced
21979              file,  this is the name of that file.  In this case, this is the
21980              exact path originally used to that file, which may be a relative
21981              path.
21982
21983              For  any other function, including any defined at an interactive
21984              prompt or an autoload function whose path has not yet  been  re‐
21985              solved,  this is the empty string.  However, the hash element is
21986              reported as defined just so long as  the  function  is  present:
21987              the keys to this hash are the same as those to $functions.
21988
21989       dis_functions_source
21990              Like functions_source but for disabled functions.
21991
21992       builtins
21993              This  associative array gives information about the builtin com‐
21994              mands currently enabled. The keys are the names of  the  builtin
21995              commands  and the values are either `undefined' for builtin com‐
21996              mands that will automatically be loaded from a module if invoked
21997              or `defined' for builtin commands that are already loaded.
21998
21999       dis_builtins
22000              Like builtins but for disabled builtin commands.
22001
22002       reswords
22003              This array contains the enabled reserved words.
22004
22005       dis_reswords
22006              Like reswords but for disabled reserved words.
22007
22008       patchars
22009              This array contains the enabled pattern characters.
22010
22011       dis_patchars
22012              Like patchars but for disabled pattern characters.
22013
22014       aliases
22015              This  maps the names of the regular aliases currently enabled to
22016              their expansions.
22017
22018       dis_aliases
22019              Like aliases but for disabled regular aliases.
22020
22021       galiases
22022              Like aliases, but for global aliases.
22023
22024       dis_galiases
22025              Like galiases but for disabled global aliases.
22026
22027       saliases
22028              Like raliases, but for suffix aliases.
22029
22030       dis_saliases
22031              Like saliases but for disabled suffix aliases.
22032
22033       parameters
22034              The keys in this associative array are the names of the  parame‐
22035              ters  currently  defined.  The values are strings describing the
22036              type of the parameter, in the same format used by the t  parame‐
22037              ter  flag,  see  zshexpn(1) .  Setting or unsetting keys in this
22038              array is not possible.
22039
22040       modules
22041              An associative array giving information about modules. The  keys
22042              are  the  names  of  the  modules  loaded,  registered to be au‐
22043              toloaded, or aliased. The value says which state the named  mod‐
22044              ule  is  in and is one of the strings `loaded', `autoloaded', or
22045              `alias:name', where name is the name the module is aliased to.
22046
22047              Setting or unsetting keys in this array is not possible.
22048
22049       dirstack
22050              A normal array holding the elements of the directory stack. Note
22051              that  the  output  of the dirs builtin command includes one more
22052              directory, the current working directory.
22053
22054       history
22055              This associative array maps history event numbers  to  the  full
22056              history  lines.   Although it is presented as an associative ar‐
22057              ray, the array of all values (${history[@]}) is guaranteed to be
22058              returned in order from most recent to oldest history event, that
22059              is, by decreasing history event number.
22060
22061       historywords
22062              A special array containing the  words  stored  in  the  history.
22063              These also appear in most to least recent order.
22064
22065       jobdirs
22066              This  associative array maps job numbers to the directories from
22067              which the job was started (which may not be the  current  direc‐
22068              tory of the job).
22069
22070              The  keys  of  the associative arrays are usually valid job num‐
22071              bers, and  these  are  the  values  output  with,  for  example,
22072              ${(k)jobdirs}.   Non-numeric  job  references  may  be used when
22073              looking up a value; for example, ${jobdirs[%+]}  refers  to  the
22074              current job.
22075
22076       jobtexts
22077              This associative array maps job numbers to the texts of the com‐
22078              mand lines that were used to start the jobs.
22079
22080              Handling of the keys of the associative array  is  as  described
22081              for jobdirs above.
22082
22083       jobstates
22084              This associative array gives information about the states of the
22085              jobs currently known. The keys are the job numbers and the  val‐
22086              ues  are  strings of the form `job-state:mark:pid=state...'. The
22087              job-state gives the state the whole job is currently in, one  of
22088              `running',  `suspended', or `done'. The mark is `+' for the cur‐
22089              rent job, `-' for the previous job and empty otherwise. This  is
22090              followed  by  one `:pid=state' for every process in the job. The
22091              pids are, of course, the process IDs and the state describes the
22092              state of that process.
22093
22094              Handling  of  the  keys of the associative array is as described
22095              for jobdirs above.
22096
22097       nameddirs
22098              This associative array maps the names of  named  directories  to
22099              the pathnames they stand for.
22100
22101       userdirs
22102              This associative array maps user names to the pathnames of their
22103              home directories.
22104
22105       usergroups
22106              This associative array maps names of system groups of which  the
22107              current user is a member to the corresponding group identifiers.
22108              The contents are the same as the groups output by  the  id  com‐
22109              mand.
22110
22111       funcfiletrace
22112              This  array contains the absolute line numbers and corresponding
22113              file names for the point where  the  current  function,  sourced
22114              file,  or  (if EVAL_LINENO is set) eval command was called.  The
22115              array is of the same length as  funcsourcetrace  and  functrace,
22116              but  differs  from funcsourcetrace in that the line and file are
22117              the point of call, not the point of definition, and differs from
22118              functrace in that all values are absolute line numbers in files,
22119              rather than relative to the start of a function, if any.
22120
22121       funcsourcetrace
22122              This array contains the file  names  and  line  numbers  of  the
22123              points  where  the functions, sourced files, and (if EVAL_LINENO
22124              is set) eval commands currently  being  executed  were  defined.
22125              The  line  number is the line where the `function name' or `name
22126              ()' started.  In the case of an autoloaded  function   the  line
22127              number is reported as zero.  The format of each element is file‐
22128              name:lineno.
22129
22130              For functions autoloaded from a file in native zsh format, where
22131              only  the  body of the function occurs in the file, or for files
22132              that have been executed by the source or `.' builtins, the trace
22133              information is shown as filename:0, since the entire file is the
22134              definition.  The source file name is  resolved  to  an  absolute
22135              path when the function is loaded or the path to it otherwise re‐
22136              solved.
22137
22138              Most users will be interested in the information  in  the  func‐
22139              filetrace array instead.
22140
22141       funcstack
22142              This  array  contains the names of the functions, sourced files,
22143              and (if EVAL_LINENO is set) eval commands. currently being  exe‐
22144              cuted.  The  first element is the name of the function using the
22145              parameter.
22146
22147              The standard shell array zsh_eval_context can be used to  deter‐
22148              mine  the  type of shell construct being executed at each depth:
22149              note, however, that is in the opposite order, with the most  re‐
22150              cent  item  last, and it is more detailed, for example including
22151              an entry for toplevel, the main shell code being executed either
22152              interactively  or  from a script, which is not present in $func‐
22153              stack.
22154
22155       functrace
22156              This array contains the names and line numbers  of  the  callers
22157              corresponding  to  the  functions currently being executed.  The
22158              format of each element is name:lineno.  Callers are  also  shown
22159              for  sourced  files; the caller is the point where the source or
22160              `.' command was executed.
22161

THE ZSH/PCRE MODULE

22163       The zsh/pcre module makes some commands available as builtins:
22164
22165       pcre_compile [ -aimxs ] PCRE
22166              Compiles a perl-compatible regular expression.
22167
22168              Option -a will force the pattern to be anchored.  Option -i will
22169              compile  a  case-insensitive  pattern.  Option -m will compile a
22170              multi-line pattern; that is, ^ and $ will match newlines  within
22171              the  pattern.   Option  -x  will  compile  an  extended pattern,
22172              wherein whitespace and # comments are ignored.  Option -s  makes
22173              the dot metacharacter match all characters, including those that
22174              indicate newline.
22175
22176       pcre_study
22177              Studies the previously-compiled PCRE which may result in  faster
22178              matching.
22179
22180       pcre_match [ -v var ] [ -a arr ] [ -n offset ] [ -b ] string
22181              Returns  successfully  if string matches the previously-compiled
22182              PCRE.
22183
22184              Upon successful match, if  the  expression  captures  substrings
22185              within parentheses, pcre_match will set the array match to those
22186              substrings, unless the -a option is given, in which case it will
22187              set the array arr.  Similarly, the variable MATCH will be set to
22188              the entire matched portion of the string, unless the  -v  option
22189              is  given, in which case the variable var will be set.  No vari‐
22190              ables are altered if there is no successful match.  A -n  option
22191              starts  searching  for  a match from the byte offset position in
22192              string.  If the -b option is given, the variable  ZPCRE_OP  will
22193              be  set  to  an offset pair string, representing the byte offset
22194              positions of the entire matched portion within the string.   For
22195              example,  a  ZPCRE_OP  set to "32 45" indicates that the matched
22196              portion began on byte offset 32 and ended  on  byte  offset  44.
22197              Here, byte offset position 45 is the position directly after the
22198              matched portion.  Keep in mind that the byte position isn't nec‐
22199              essarily  the  same as the character position when UTF-8 charac‐
22200              ters are involved.  Consequently, the byte offset positions  are
22201              only to be relied on in the context of using them for subsequent
22202              searches on string, using an offset position as an  argument  to
22203              the  -n  option.  This is mostly used to implement the "find all
22204              non-overlapping matches" functionality.
22205
22206              A simple example of "find all non-overlapping matches":
22207
22208                     string="The following zip codes: 78884 90210 99513"
22209                     pcre_compile -m "\d{5}"
22210                     accum=()
22211                     pcre_match -b -- $string
22212                     while [[ $? -eq 0 ]] do
22213                         b=($=ZPCRE_OP)
22214                         accum+=$MATCH
22215                         pcre_match -b -n $b[2] -- $string
22216                     done
22217                     print -l $accum
22218
22219       The zsh/pcre module makes available the following test condition:
22220
22221       expr -pcre-match pcre
22222              Matches a string against a perl-compatible regular expression.
22223
22224              For example,
22225
22226                     [[ "$text" -pcre-match ^d+$ ]] &&
22227                     print text variable contains only "d's".
22228
22229              If the REMATCH_PCRE option is set, the =~ operator is equivalent
22230              to  -pcre-match, and the NO_CASE_MATCH option may be used.  Note
22231              that NO_CASE_MATCH never applies to the pcre_match builtin,  in‐
22232              stead use the -i switch of pcre_compile.
22233

THE ZSH/PARAM/PRIVATE MODULE

22235       The  zsh/param/private  module is used to create parameters whose scope
22236       is limited to the current function body, and  not  to  other  functions
22237       called by the current function.
22238
22239       This module provides a single autoloaded builtin:
22240
22241       private [ {+|-}AHUahlprtux ] [ {+|-}EFLRZi [ n ] ] [ name[=value] ... ]
22242              The  private  builtin accepts all the same options and arguments
22243              as local (zshbuiltins(1)) except for the `-T' option.  Tied  pa‐
22244              rameters may not be made private.
22245
22246              If  used  at  the  top level (outside a function scope), private
22247              creates a normal parameter in the  same  manner  as  declare  or
22248              typeset.   A warning about this is printed if WARN_CREATE_GLOBAL
22249              is set (zshoptions(1)).  Used inside a function  scope,  private
22250              creates  a  local  parameter similar to one declared with local,
22251              except having special properties noted below.
22252
22253              Special parameters which expose  or  manipulate  internal  shell
22254              state,  such  as  ARGC,  argv,  COLUMNS,  LINES, UID, EUID, IFS,
22255              PROMPT, RANDOM, SECONDS, etc., cannot be made private unless the
22256              `-h'  option  is used to hide the special meaning of the parame‐
22257              ter.  This may change in the future.
22258
22259       As with other typeset equivalents, private is both a builtin and a  re‐
22260       served  word,  so  arrays  may be assigned with parenthesized word list
22261       name=(value...) syntax.  However, the reserved word  `private'  is  not
22262       available until zsh/param/private is loaded, so care must be taken with
22263       order of execution and parsing for function definitions which use  pri‐
22264       vate.   To compensate for this, the module also adds the option `-P' to
22265       the `local' builtin to declare private parameters.
22266
22267       For example, this construction fails if zsh/param/private has  not  yet
22268       been loaded when `bad_declaration' is defined:
22269              bad_declaration() {
22270                zmodload zsh/param/private
22271                private array=( one two three )
22272              }
22273
22274       This  construction  works  because  local is already a keyword, and the
22275       module is loaded before the statement is executed:
22276              good_declaration() {
22277                zmodload zsh/param/private
22278                local -P array=( one two three )
22279              }
22280
22281       The following is usable in scripts but may have trouble with autoload:
22282              zmodload zsh/param/private
22283              iffy_declaration() {
22284                private array=( one two three )
22285              }
22286
22287       The private builtin may always be used with scalar assignments and  for
22288       declarations without assignments.
22289
22290       Parameters declared with private have the following properties:
22291
22292       •      Within the function body where it is declared, the parameter be‐
22293              haves as a local, except as noted above for tied or special  pa‐
22294              rameters.
22295
22296       •      The  type  of  a parameter declared private cannot be changed in
22297              the scope where it was declared, even if the parameter is unset.
22298              Thus an array cannot be assigned to a private scalar, etc.
22299
22300       •      Within  any other function called by the declaring function, the
22301              private parameter does NOT hide other  parameters  of  the  same
22302              name, so for example a global parameter of the same name is vis‐
22303              ible and may be assigned  or  unset.   This  includes  calls  to
22304              anonymous  functions,  although  that may also change in the fu‐
22305              ture.
22306
22307       •      An exported private remains in the environment of  inner  scopes
22308              but appears unset for the current shell in those scopes.  Gener‐
22309              ally, exporting private parameters should be avoided.
22310
22311       Note that this differs from the static scope defined by  compiled  lan‐
22312       guages derived from C, in that the a new call to the same function cre‐
22313       ates a new scope, i.e., the parameter is still associated with the call
22314       stack  rather  than  with the function definition.  It differs from ksh
22315       `typeset -S' because the syntax used to  define  the  function  has  no
22316       bearing on whether the parameter scope is respected.
22317

THE ZSH/REGEX MODULE

22319       The zsh/regex module makes available the following test condition:
22320
22321       expr -regex-match regex
22322              Matches  a  string  against a POSIX extended regular expression.
22323              On successful match, matched portion of the string will normally
22324              be  placed  in  the  MATCH variable.  If there are any capturing
22325              parentheses within the regex, then the match array variable will
22326              contain  those.   If the match is not successful, then the vari‐
22327              ables will not be altered.
22328
22329              For example,
22330
22331                     [[ alphabetical -regex-match ^a([^a]+)a([^a]+)a ]] &&
22332                     print -l $MATCH X $match
22333
22334              If the option REMATCH_PCRE is not set, then the =~ operator will
22335              automatically  load  this  module  as needed and will invoke the
22336              -regex-match operator.
22337
22338              If BASH_REMATCH is set, then the array BASH_REMATCH will be  set
22339              instead of MATCH and match.
22340

THE ZSH/SCHED MODULE

22342       The zsh/sched module makes available one builtin command and one param‐
22343       eter.
22344
22345       sched [-o] [+]hh:mm[:ss] command ...
22346       sched [-o] [+]seconds command ...
22347       sched [ -item ]
22348              Make an entry in the scheduled list of commands to execute.  The
22349              time  may  be specified in either absolute or relative time, and
22350              either as hours, minutes and (optionally) seconds separated by a
22351              colon,  or  seconds  alone.  An absolute number of seconds indi‐
22352              cates the time since the epoch (1970/01/01 00:00); this is  use‐
22353              ful in combination with the features in the zsh/datetime module,
22354              see the zsh/datetime module entry in zshmodules(1).
22355
22356              With no arguments, prints the list of  scheduled  commands.   If
22357              the  scheduled command has the -o flag set, this is shown at the
22358              start of the command.
22359
22360              With the argument `-item', removes the given item from the list.
22361              The  numbering of the list is continuous and entries are in time
22362              order, so the numbering can change when  entries  are  added  or
22363              deleted.
22364
22365              Commands  are  executed  either  immediately before a prompt, or
22366              while the shell's line editor is waiting for input.  In the lat‐
22367              ter case it is useful to be able to produce output that does not
22368              interfere with the line being edited.  Providing the  option  -o
22369              causes  the shell to clear the command line before the event and
22370              redraw it afterwards.  This should be used  with  any  scheduled
22371              event  that  produces  visible output to the terminal; it is not
22372              needed, for example, with output that updates a terminal  emula‐
22373              tor's title bar.
22374
22375              To  effect  changes to the editor buffer when an event executes,
22376              use the `zle' command with no arguments to test whether the edi‐
22377              tor is active, and if it is, then use `zle widget' to access the
22378              editor via the named widget.
22379
22380              The sched builtin is not made  available  by  default  when  the
22381              shell  starts in a mode emulating another shell.  It can be made
22382              available with the command `zmodload -F zsh/sched b:sched'.
22383
22384       zsh_scheduled_events
22385              A readonly array corresponding to the events  scheduled  by  the
22386              sched  builtin.  The indices of the array correspond to the num‐
22387              bers shown when sched is run with no  arguments  (provided  that
22388              the  KSH_ARRAYS option is not set).  The value of the array con‐
22389              sists of the scheduled time in seconds since the epoch (see  the
22390              section  `The zsh/datetime Module' for facilities for using this
22391              number), followed by a colon, followed by any options (which may
22392              be empty but will be preceded by a `-' otherwise), followed by a
22393              colon, followed by the command to be executed.
22394
22395              The sched builtin should be used for  manipulating  the  events.
22396              Note  that this will have an immediate effect on the contents of
22397              the array, so that indices may become invalid.
22398

THE ZSH/NET/SOCKET MODULE

22400       The zsh/net/socket module makes available one builtin command:
22401
22402       zsocket [ -altv ] [ -d fd ] [ args ]
22403              zsocket is implemented as a builtin to allow full use  of  shell
22404              command line editing, file I/O, and job control mechanisms.
22405
22406   Outbound Connections
22407       zsocket [ -v ] [ -d fd ] filename
22408              Open a new Unix domain connection to filename.  The shell param‐
22409              eter REPLY will be set to the file  descriptor  associated  with
22410              that  connection.   Currently,  only stream connections are sup‐
22411              ported.
22412
22413              If -d is specified, its argument will be  taken  as  the  target
22414              file descriptor for the connection.
22415
22416              In order to elicit more verbose output, use -v.
22417
22418              File  descriptors can be closed with normal shell syntax when no
22419              longer needed, for example:
22420
22421                     exec {REPLY}>&-
22422
22423   Inbound Connections
22424       zsocket -l [ -v ] [ -d fd ] filename
22425              zsocket -l will open a socket listening on filename.  The  shell
22426              parameter  REPLY  will  be set to the file descriptor associated
22427              with that listener.  The file descriptor remains  open  in  sub‐
22428              shells and forked external executables.
22429
22430              If  -d  is  specified,  its argument will be taken as the target
22431              file descriptor for the connection.
22432
22433              In order to elicit more verbose output, use -v.
22434
22435       zsocket -a [ -tv ] [ -d targetfd ] listenfd
22436              zsocket -a will accept an incoming connection to the socket  as‐
22437              sociated  with  listenfd.  The shell parameter REPLY will be set
22438              to the file descriptor associated with the  inbound  connection.
22439              The  file descriptor remains open in subshells and forked exter‐
22440              nal executables.
22441
22442              If -d is specified, its argument will be  taken  as  the  target
22443              file descriptor for the connection.
22444
22445              If  -t  is specified, zsocket will return if no incoming connec‐
22446              tion is pending.  Otherwise it will wait for one.
22447
22448              In order to elicit more verbose output, use -v.
22449

THE ZSH/STAT MODULE

22451       The zsh/stat module makes available one builtin command under two  pos‐
22452       sible names:
22453
22454       zstat [ -gnNolLtTrs ] [ -f fd ] [ -H hash ] [ -A array ] [ -F fmt ]
22455             [ +element ] [ file ... ]
22456       stat ...
22457              The  command  acts  as  a front end to the stat system call (see
22458              stat(2)).  The same command is provided with two names;  as  the
22459              name stat is often used by an external command it is recommended
22460              that only the zstat form of the command is used.   This  can  be
22461              arranged  by  loading  the  module with the command `zmodload -F
22462              zsh/stat b:zstat'.
22463
22464              If the stat call fails, the  appropriate  system  error  message
22465              printed  and  status  1  is returned.  The fields of struct stat
22466              give information about the files provided as  arguments  to  the
22467              command.   In addition to those available from the stat call, an
22468              extra element `link' is provided.  These elements are:
22469
22470              device The number of the device on which the file resides.
22471
22472              inode  The unique number of the file  on  this  device  (`inode'
22473                     number).
22474
22475              mode   The mode of the file; that is, the file's type and access
22476                     permissions.  With the -s option, this will  be  returned
22477                     as a string corresponding to the first column in the dis‐
22478                     play of the ls -l command.
22479
22480              nlink  The number of hard links to the file.
22481
22482              uid    The user ID of the owner of the file.  With  the  -s  op‐
22483                     tion, this is displayed as a user name.
22484
22485              gid    The  group  ID  of the file.  With the -s option, this is
22486                     displayed as a group name.
22487
22488              rdev   The raw device number.  This is only useful  for  special
22489                     devices.
22490
22491              size   The size of the file in bytes.
22492
22493              atime
22494              mtime
22495              ctime  The  last  access, modification and inode change times of
22496                     the file, respectively, as the number  of  seconds  since
22497                     midnight  GMT  on 1st January, 1970.  With the -s option,
22498                     these are printed as strings for the local time zone; the
22499                     format can be altered with the -F option, and with the -g
22500                     option the times are in GMT.
22501
22502              blksize
22503                     The number of bytes in one allocation block on the device
22504                     on which the file resides.
22505
22506              block  The number of disk blocks used by the file.
22507
22508              link   If  the  file  is  a link and the -L option is in effect,
22509                     this contains the name of the file linked  to,  otherwise
22510                     it  is  empty.   Note  that  if  this element is selected
22511                     (``zstat +link'') then the  -L  option  is  automatically
22512                     used.
22513
22514              A  particular element may be selected by including its name pre‐
22515              ceded by a `+' in the option list; only one element is  allowed.
22516              The  element may be shortened to any unique set of leading char‐
22517              acters.  Otherwise, all elements will be shown for all files.
22518
22519              Options:
22520
22521              -A array
22522                     Instead of displaying the results on standard output, as‐
22523                     sign  them to an array, one struct stat element per array
22524                     element for each file in order.  In this case neither the
22525                     name  of the element nor the name of the files appears in
22526                     array unless the -t or -n  options  were  given,  respec‐
22527                     tively.   If  -t  is given, the element name appears as a
22528                     prefix to the appropriate array element; if -n is  given,
22529                     the file name appears as a separate array element preced‐
22530                     ing all the others.  Other  formatting  options  are  re‐
22531                     spected.
22532
22533              -H hash
22534                     Similar  to  -A,  but  instead assign the values to hash.
22535                     The keys are the elements listed above.  If the -n option
22536                     is  provided then the name of the file is included in the
22537                     hash with key name.
22538
22539              -f fd  Use the file on  file  descriptor  fd  instead  of  named
22540                     files; no list of file names is allowed in this case.
22541
22542              -F fmt Supplies a strftime (see strftime(3)) string for the for‐
22543                     matting of the time elements.  The format string supports
22544                     all of the zsh extensions described in the section EXPAN‐
22545                     SION OF PROMPT SEQUENCES in zshmisc(1).  The -s option is
22546                     implied.
22547
22548              -g     Show  the time elements in the GMT time zone.  The -s op‐
22549                     tion is implied.
22550
22551              -l     List the names of the type elements (to  standard  output
22552                     or an array as appropriate) and return immediately; argu‐
22553                     ments, and options other than -A, are ignored.
22554
22555              -L     Perform an lstat (see lstat(2)) rather than a stat system
22556                     call.   In  this case, if the file is a link, information
22557                     about the link itself rather than the target file is  re‐
22558                     turned.  This option is required to make the link element
22559                     useful.  It's important to note that this  is  the  exact
22560                     opposite from ls(1), etc.
22561
22562              -n     Always  show  the names of files.  Usually these are only
22563                     shown when output is to standard output and there is more
22564                     than one file in the list.
22565
22566              -N     Never show the names of files.
22567
22568              -o     If a raw file mode is printed, show it in octal, which is
22569                     more useful for human consumption  than  the  default  of
22570                     decimal.   A  leading  zero will be printed in this case.
22571                     Note that this does not affect whether a raw or formatted
22572                     file  mode is shown, which is controlled by the -r and -s
22573                     options, nor whether a mode is shown at all.
22574
22575              -r     Print raw data (the default format) alongside string data
22576                     (the  -s  format); the string data appears in parentheses
22577                     after the raw data.
22578
22579              -s     Print mode, uid, gid  and  the  three  time  elements  as
22580                     strings  instead  of numbers.  In each case the format is
22581                     like that of ls -l.
22582
22583              -t     Always show the type names for  the  elements  of  struct
22584                     stat.   Usually  these  are  only shown when output is to
22585                     standard output and no individual element  has  been  se‐
22586                     lected.
22587
22588              -T     Never show the type names of the struct stat elements.
22589

THE ZSH/SYSTEM MODULE

22591       The  zsh/system module makes available various builtin commands and pa‐
22592       rameters.
22593
22594   Builtins
22595       syserror [ -e errvar ] [ -p prefix ] [ errno | errname ]
22596              This command prints out the error message associated with errno,
22597              a system error number, followed by a newline to standard error.
22598
22599              Instead of the error number, a name errname, for example ENOENT,
22600              may be used.  The set of names is the same as  the  contents  of
22601              the array errnos, see below.
22602
22603              If the string prefix is given, it is printed in front of the er‐
22604              ror message, with no intervening space.
22605
22606              If errvar is supplied, the entire message, without a newline, is
22607              assigned to the parameter names errvar and nothing is output.
22608
22609              A  return  status  of  0  indicates the message was successfully
22610              printed (although it may not be useful if the error  number  was
22611              out  of  the  system's range), a return status of 1 indicates an
22612              error in the parameters, and a return status of 2 indicates  the
22613              error name was not recognised (no message is printed for this).
22614
22615
22616       sysopen [ -arw ] [ -m permissions ] [ -o options ]
22617               -u fd file
22618              This  command  opens  a  file.  The -r, -w and -a flags indicate
22619              whether the file should be opened for reading, writing  and  ap‐
22620              pending,  respectively. The -m option allows the initial permis‐
22621              sions to use when creating a file to be specified in octal form.
22622              The  file  descriptor  is  specified with -u. Either an explicit
22623              file descriptor in the range 0 to 9 can be specified or a  vari‐
22624              able  name can be given to which the file descriptor number will
22625              be assigned.
22626
22627              The -o option allows various system specific options to be spec‐
22628              ified as a comma-separated list. The following is a list of pos‐
22629              sible options. Note that, depending on the system, some may  not
22630              be available.
22631              cloexec
22632                     mark  file  to be closed when other programs are executed
22633                     (else the file descriptor remains open in  subshells  and
22634                     forked external executables)
22635
22636              create
22637              creat  create file if it does not exist
22638
22639              excl   create file, error if it already exists
22640
22641              noatime
22642                     suppress updating of the file atime
22643
22644              nofollow
22645                     fail if file is a symbolic link
22646
22647              sync   request  that  writes wait until data has been physically
22648                     written
22649
22650              truncate
22651              trunc  truncate file to size 0
22652
22653              To close the file, use one of the following:
22654
22655                     exec {fd}<&-
22656                     exec {fd}>&-
22657
22658
22659       sysread [ -c countvar ] [ -i infd ] [ -o outfd ]
22660               [ -s bufsize ] [ -t timeout ] [ param ]
22661              Perform a single system read from file descriptor infd, or  zero
22662              if that is not given.  The result of the read is stored in param
22663              or REPLY if that is not given.  If countvar is given, the number
22664              of bytes read is assigned to the parameter named by countvar.
22665
22666              The  maximum  number of bytes read is bufsize or 8192 if that is
22667              not given, however the command returns as soon as any number  of
22668              bytes was successfully read.
22669
22670              If  timeout  is  given, it specifies a timeout in seconds, which
22671              may be zero to poll the file descriptor.  This is handled by the
22672              poll  system call if available, otherwise the select system call
22673              if available.
22674
22675              If outfd is given, an attempt is made to  write  all  the  bytes
22676              just  read to the file descriptor outfd.  If this fails, because
22677              of a system error other than EINTR or because of an internal zsh
22678              error  during  an  interrupt, the bytes read but not written are
22679              stored in the parameter named by param if supplied  (no  default
22680              is  used  in  this  case),  and the number of bytes read but not
22681              written is stored in the parameter named by countvar if that  is
22682              supplied.  If it was successful, countvar contains the full num‐
22683              ber of bytes transferred, as usual, and param is not set.
22684
22685              The error EINTR (interrupted system call) is handled  internally
22686              so  that  shell  interrupts  are transparent to the caller.  Any
22687              other error causes a return.
22688
22689              The possible return statuses are
22690              0      At least one byte of data was successfully read  and,  if
22691                     appropriate, written.
22692
22693              1      There  was  an  error  in  the parameters to the command.
22694                     This is the only error for which a message is printed  to
22695                     standard error.
22696
22697              2      There  was  an error on the read, or on polling the input
22698                     file descriptor for a timeout.  The parameter ERRNO gives
22699                     the error.
22700
22701              3      Data were successfully read, but there was an error writ‐
22702                     ing them to outfd.  The parameter ERRNO gives the error.
22703
22704              4      The attempt to read timed out.  Note this  does  not  set
22705                     ERRNO as this is not a system error.
22706
22707              5      No system error occurred, but zero bytes were read.  This
22708                     usually indicates end of file.  The  parameters  are  set
22709                     according  to  the  usual rules; no write to outfd is at‐
22710                     tempted.
22711
22712       sysseek [ -u fd ] [ -w start|end|current ] offset
22713              The current file position at which future reads and writes  will
22714              take  place is adjusted to the specified byte offset. The offset
22715              is evaluated as a math expression. The -u option allows the file
22716              descriptor  to  be specified. By default the offset is specified
22717              relative to the start or the file but, with the -w option, it is
22718              possible  to  specify  that the offset should be relative to the
22719              current position or the end of the file.
22720
22721       syswrite [ -c countvar ] [ -o outfd ] data
22722              The data (a single string of bytes) are written to the file  de‐
22723              scriptor  outfd, or 1 if that is not given, using the write sys‐
22724              tem call.  Multiple write operations may be used  if  the  first
22725              does not write all the data.
22726
22727              If  countvar  is  given, the number of byte written is stored in
22728              the parameter named by countvar; this may not be the full length
22729              of data if an error occurred.
22730
22731              The  error EINTR (interrupted system call) is handled internally
22732              by retrying; otherwise an error causes the  command  to  return.
22733              For  example, if the file descriptor is set to non-blocking out‐
22734              put, an error EAGAIN (on some systems, EWOULDBLOCK)  may  result
22735              in the command returning early.
22736
22737              The  return  status  may be 0 for success, 1 for an error in the
22738              parameters to the command, or 2 for an error on  the  write;  no
22739              error message is printed in the last case, but the parameter ER‐
22740              RNO will reflect the error that occurred.
22741
22742       zsystem flock [ -t timeout ] [ -f var ] [-er] file
22743       zsystem flock -u fd_expr
22744              The builtin zsystem's subcommand flock  performs  advisory  file
22745              locking  (via the fcntl(2) system call) over the entire contents
22746              of the given file.  This form of locking requires the  processes
22747              accessing the file to cooperate; its most obvious use is between
22748              two instances of the shell itself.
22749
22750              In the first form the named file, which must already  exist,  is
22751              locked  by  opening a file descriptor to the file and applying a
22752              lock to the file descriptor.  The lock terminates when the shell
22753              process  that created the lock exits; it is therefore often con‐
22754              venient to create file locks within subshells, since the lock is
22755              automatically  released  when the subshell exits.  Note that use
22756              of the print builtin with the -u option will, as a side  effect,
22757              release  the  lock, as will redirection to the file in the shell
22758              holding the lock.  To work around  this  use  a  subshell,  e.g.
22759              `(print  message)  >>  file'.   Status 0 is returned if the lock
22760              succeeds, else status 1.
22761
22762              In the second form the file descriptor given by  the  arithmetic
22763              expression  fd_expr  is  closed, releasing a lock.  The file de‐
22764              scriptor can be queried by using the `-f var'  form  during  the
22765              lock; on a successful lock, the shell variable var is set to the
22766              file descriptor used for locking.  The lock will be released  if
22767              the  file  descriptor  is closed by any other means, for example
22768              using `exec {var}>&-'; however, the form described here performs
22769              a safety check that the file descriptor is in use for file lock‐
22770              ing.
22771
22772              By default the shell waits indefinitely for the lock to succeed.
22773              The  option  -t timeout specifies a timeout for the lock in sec‐
22774              onds; currently this must be an integer.  The shell will attempt
22775              to  lock  the file once a second during this period.  If the at‐
22776              tempt times out, status 2 is returned.
22777
22778              If the option -e is given, the file descriptor for the  lock  is
22779              preserved  when the shell uses exec to start a new process; oth‐
22780              erwise it is closed at that point and the lock released.
22781
22782              If the option -r is given, the lock is only for reading,  other‐
22783              wise  it  is  for  reading  and writing.  The file descriptor is
22784              opened accordingly.
22785
22786       zsystem supports subcommand
22787              The builtin zsystem's subcommand supports tests whether a  given
22788              subcommand is supported.  It returns status 0 if so, else status
22789              1.  It operates silently unless there was a syntax  error  (i.e.
22790              the  wrong number of arguments), in which case status 255 is re‐
22791              turned.  Status 1 can indicate one of two things:  subcommand is
22792              known but not supported by the current operating system, or sub‐
22793              command is not known (possibly because this is an older  version
22794              of the shell before it was implemented).
22795
22796   Math Functions
22797       systell(fd)
22798              The  systell math function returns the current file position for
22799              the file descriptor passed as an argument.
22800
22801   Parameters
22802       errnos A readonly array of the names of errors defined on  the  system.
22803              These  are typically macros defined in C by including the system
22804              header file errno.h.  The index of each name (assuming  the  op‐
22805              tion  KSH_ARRAYS is unset) corresponds to the error number.  Er‐
22806              ror numbers num before the last known error which have  no  name
22807              are given the name Enum in the array.
22808
22809              Note that aliases for errors are not handled; only the canonical
22810              name is used.
22811
22812       sysparams
22813              A readonly associative array.  The keys are:
22814
22815              pid    Returns the process ID of the current  process,  even  in
22816                     subshells.   Compare  $$, which returns the process ID of
22817                     the main shell process.
22818
22819              ppid   Returns the process ID  of  the  parent  of  the  current
22820                     process, even in subshells.  Compare $PPID, which returns
22821                     the process ID of the parent of the main shell process.
22822
22823              procsubstpid
22824                     Returns the process ID of the last  process  started  for
22825                     process  substitution,  i.e. the <(...) and >(...) expan‐
22826                     sions.
22827

THE ZSH/NET/TCP MODULE

22829       The zsh/net/tcp module makes available one builtin command:
22830
22831       ztcp [ -acflLtv ] [ -d fd ] [ args ]
22832              ztcp is implemented as a builtin to allow full use of shell com‐
22833              mand line editing, file I/O, and job control mechanisms.
22834
22835              If  ztcp  is run with no options, it will output the contents of
22836              its session table.
22837
22838              If it is run with only the option -L, it will  output  the  con‐
22839              tents  of  the  session table in a format suitable for automatic
22840              parsing.  The option is ignored if given with a command to  open
22841              or  close a session.  The output consists of a set of lines, one
22842              per session, each containing the following elements separated by
22843              spaces:
22844
22845              File descriptor
22846                     The  file descriptor in use for the connection.  For nor‐
22847                     mal inbound (I) and outbound (O) connections this may  be
22848                     read and written by the usual shell mechanisms.  However,
22849                     it should only be close with `ztcp -c'.
22850
22851              Connection type
22852                     A letter indicating how the session was created:
22853
22854                     Z      A session created with the zftp command.
22855
22856                     L      A connection opened for listening with `ztcp -l'.
22857
22858                     I      An inbound connection accepted with `ztcp -a'.
22859
22860                     O      An outbound connection  created  with  `ztcp  host
22861                            ...'.
22862
22863              The local host
22864                     This  is usually set to an all-zero IP address as the ad‐
22865                     dress of the localhost is irrelevant.
22866
22867              The local port
22868                     This is likely to be zero unless the  connection  is  for
22869                     listening.
22870
22871              The remote host
22872                     This  is  the fully qualified domain name of the peer, if
22873                     available, else an IP address.  It is an all-zero IP  ad‐
22874                     dress for a session opened for listening.
22875
22876              The remote port
22877                     This is zero for a connection opened for listening.
22878
22879   Outbound Connections
22880       ztcp [ -v ] [ -d fd ] host [ port ]
22881              Open  a  new TCP connection to host.  If the port is omitted, it
22882              will default to port 23.  The connection will be  added  to  the
22883              session  table  and the shell parameter REPLY will be set to the
22884              file descriptor associated with that connection.
22885
22886              If -d is specified, its argument will be  taken  as  the  target
22887              file descriptor for the connection.
22888
22889              In order to elicit more verbose output, use -v.
22890
22891   Inbound Connections
22892       ztcp -l [ -v ] [ -d fd ] port
22893              ztcp  -l  will  open a socket listening on TCP port.  The socket
22894              will be added to the session table and the shell parameter REPLY
22895              will  be  set  to  the file descriptor associated with that lis‐
22896              tener.
22897
22898              If -d is specified, its argument will be  taken  as  the  target
22899              file descriptor for the connection.
22900
22901              In order to elicit more verbose output, use -v.
22902
22903       ztcp -a [ -tv ] [ -d targetfd ] listenfd
22904              ztcp  -a  will accept an incoming connection to the port associ‐
22905              ated with listenfd.  The connection will be added to the session
22906              table  and the shell parameter REPLY will be set to the file de‐
22907              scriptor associated with the inbound connection.
22908
22909              If -d is specified, its argument will be  taken  as  the  target
22910              file descriptor for the connection.
22911
22912              If  -t  is specified, ztcp will return if no incoming connection
22913              is pending.  Otherwise it will wait for one.
22914
22915              In order to elicit more verbose output, use -v.
22916
22917   Closing Connections
22918       ztcp -cf [ -v ] [ fd ]
22919       ztcp -c [ -v ] [ fd ]
22920              ztcp -c will close the socket associated with  fd.   The  socket
22921              will be removed from the session table.  If fd is not specified,
22922              ztcp will close everything in the session table.
22923
22924              Normally, sockets registered by zftp (see zshmodules(1) ) cannot
22925              be closed this way.  In order to force such a socket closed, use
22926              -f.
22927
22928              In order to elicit more verbose output, use -v.
22929
22930   Example
22931       Here is how to create a TCP connection between two  instances  of  zsh.
22932       We  need  to  pick  an unassigned port; here we use the randomly chosen
22933       5123.
22934
22935       On host1,
22936              zmodload zsh/net/tcp
22937              ztcp -l 5123
22938              listenfd=$REPLY
22939              ztcp -a $listenfd
22940              fd=$REPLY
22941       The second from last command blocks until there is an incoming  connec‐
22942       tion.
22943
22944       Now  create  a connection from host2 (which may, of course, be the same
22945       machine):
22946              zmodload zsh/net/tcp
22947              ztcp host1 5123
22948              fd=$REPLY
22949
22950       Now on each host, $fd contains a file descriptor  for  talking  to  the
22951       other.  For example, on host1:
22952              print This is a message >&$fd
22953       and on host2:
22954              read -r line <&$fd; print -r - $line
22955       prints `This is a message'.
22956
22957       To tidy up, on host1:
22958              ztcp -c $listenfd
22959              ztcp -c $fd
22960       and on host2
22961              ztcp -c $fd
22962

THE ZSH/TERMCAP MODULE

22964       The zsh/termcap module makes available one builtin command:
22965
22966       echotc cap [ arg ... ]
22967              Output  the  termcap  value corresponding to the capability cap,
22968              with optional arguments.
22969
22970       The zsh/termcap module makes available one parameter:
22971
22972       termcap
22973              An associative array that maps termcap capability codes to their
22974              values.
22975

THE ZSH/TERMINFO MODULE

22977       The zsh/terminfo module makes available one builtin command:
22978
22979       echoti cap [ arg ]
22980              Output  the  terminfo value corresponding to the capability cap,
22981              instantiated with arg if applicable.
22982
22983       The zsh/terminfo module makes available one parameter:
22984
22985       terminfo
22986              An associative array that  maps  terminfo  capability  names  to
22987              their values.
22988

THE ZSH/ZFTP MODULE

22990       The zsh/zftp module makes available one builtin command:
22991
22992       zftp subcommand [ args ]
22993              The  zsh/zftp  module  is a client for FTP (file transfer proto‐
22994              col).  It is implemented as a builtin to allow full use of shell
22995              command line editing, file I/O, and job control mechanisms.  Of‐
22996              ten, users will access it via shell functions providing  a  more
22997              powerful  interface; a set is provided with the zsh distribution
22998              and is described in zshzftpsys(1).  However, the zftp command is
22999              entirely usable in its own right.
23000
23001              All  commands  consist  of the command name zftp followed by the
23002              name of a subcommand.  These are listed below.  The return  sta‐
23003              tus  of  each  subcommand  is supposed to reflect the success or
23004              failure of the remote operation.  See a description of the vari‐
23005              able ZFTP_VERBOSE for more information on how responses from the
23006              server may be printed.
23007
23008   Subcommands
23009       open host[:port] [ user [ password [ account ] ] ]
23010              Open a new FTP session to host, which  may  be  the  name  of  a
23011              TCP/IP  connected host or an IP number in the standard dot nota‐
23012              tion.  If the argument is in the form host:port, open a  connec‐
23013              tion to TCP port port instead of the standard FTP port 21.  This
23014              may be the name of a TCP service or a number:  see the  descrip‐
23015              tion of ZFTP_PORT below for more information.
23016
23017              If  IPv6  addresses in colon format are used, the host should be
23018              surrounded by quoted square brackets to distinguish it from  the
23019              port, for example '[fe80::203:baff:fe02:8b56]'.  For consistency
23020              this is allowed with all forms of host.
23021
23022              Remaining arguments are passed to the  login  subcommand.   Note
23023              that if no arguments beyond host are supplied, open will not au‐
23024              tomatically call login.  If no arguments at  all  are  supplied,
23025              open will use the parameters set by the params subcommand.
23026
23027              After   a   successful  open,  the  shell  variables  ZFTP_HOST,
23028              ZFTP_PORT, ZFTP_IP and ZFTP_SYSTEM  are  available;  see  `Vari‐
23029              ables' below.
23030
23031       login [ name [ password [ account ] ] ]
23032       user [ name [ password [ account ] ] ]
23033              Login  the  user name with parameters password and account.  Any
23034              of the parameters can be omitted, and will be read from standard
23035              input if needed (name is always needed).  If standard input is a
23036              terminal, a prompt for each one will be printed on standard  er‐
23037              ror  and  password will not be echoed.  If any of the parameters
23038              are not used, a warning message is printed.
23039
23040              After  a  successful  login,  the  shell  variables   ZFTP_USER,
23041              ZFTP_ACCOUNT and ZFTP_PWD are available; see `Variables' below.
23042
23043              This  command may be re-issued when a user is already logged in,
23044              and the server will first be reinitialized for a new user.
23045
23046       params [ host [ user [ password [ account ] ] ] ]
23047       params -
23048              Store the given parameters for a later open command with no  ar‐
23049              guments.   Only  those  given on the command line will be remem‐
23050              bered.  If no arguments are given, the parameters currently  set
23051              are  printed,  although  the  password  will appear as a line of
23052              stars; the return status is one if no parameters were set,  zero
23053              otherwise.
23054
23055              Any  of the parameters may be specified as a `?', which may need
23056              to be quoted to protect it from shell expansion.  In this  case,
23057              the  appropriate  parameter  will be read from stdin as with the
23058              login subcommand, including special handling  of  password.   If
23059              the  `?' is followed by a string, that is used as the prompt for
23060              reading the parameter instead of the default message (any neces‐
23061              sary punctuation and whitespace should be included at the end of
23062              the prompt).  The first letter of the parameter  (only)  may  be
23063              quoted  with  a `\'; hence an argument "\\$word" guarantees that
23064              the string from the shell parameter $word will be treated liter‐
23065              ally, whether or not it begins with a `?'.
23066
23067              If  instead  a  single `-' is given, the existing parameters, if
23068              any, are deleted.  In that case, calling open with no  arguments
23069              will cause an error.
23070
23071              The  list of parameters is not deleted after a close, however it
23072              will be deleted if the zsh/zftp module is unloaded.
23073
23074              For example,
23075
23076                     zftp params ftp.elsewhere.xx juser '?Password for juser: '
23077
23078              will store the host ftp.elsewhere.xx and the user juser and then
23079              prompt  the  user  for the corresponding password with the given
23080              prompt.
23081
23082       test   Test the connection; if the server  has  reported  that  it  has
23083              closed the connection (maybe due to a timeout), return status 2;
23084              if no connection was open anyway, return status 1;  else  return
23085              status  0.   The  test subcommand is silent, apart from messages
23086              printed by the $ZFTP_VERBOSE mechanism, or error messages if the
23087              connection closes.  There is no network overhead for this test.
23088
23089              The  test is only supported on systems with either the select(2)
23090              or poll(2) system calls; otherwise the message `not supported on
23091              this system' is printed instead.
23092
23093              The test subcommand will automatically be called at the start of
23094              any other subcommand for the current session when  a  connection
23095              is open.
23096
23097       cd directory
23098              Change the remote directory to directory.  Also alters the shell
23099              variable ZFTP_PWD.
23100
23101       cdup   Change the remote directory to the one higher in  the  directory
23102              tree.  Note that cd .. will also work correctly on non-UNIX sys‐
23103              tems.
23104
23105       dir [ arg ... ]
23106              Give a (verbose) listing of the remote directory.  The args  are
23107              passed directly to the server. The command's behaviour is imple‐
23108              mentation dependent, but a UNIX server will typically  interpret
23109              args as arguments to the ls command and with no arguments return
23110              the result of `ls -l'. The directory is listed to standard  out‐
23111              put.
23112
23113       ls [ arg ... ]
23114              Give  a  (short)  listing of the remote directory.  With no arg,
23115              produces a raw list of the files in the directory, one per line.
23116              Otherwise,  up to vagaries of the server implementation, behaves
23117              similar to dir.
23118
23119       type [ type ]
23120              Change the type for the transfer to type, or print  the  current
23121              type if type is absent.  The allowed values are `A' (ASCII), `I'
23122              (Image, i.e. binary), or `B' (a synonym for `I').
23123
23124              The FTP default for a transfer is ASCII.  However, if zftp finds
23125              that  the remote host is a UNIX machine with 8-bit byes, it will
23126              automatically switch to using binary  for  file  transfers  upon
23127              open.  This can subsequently be overridden.
23128
23129              The  transfer type is only passed to the remote host when a data
23130              connection is established;  this  command  involves  no  network
23131              overhead.
23132
23133       ascii  The same as type A.
23134
23135       binary The same as type I.
23136
23137       mode [ S | B ]
23138              Set  the  mode  type to stream (S) or block (B).  Stream mode is
23139              the default; block mode is not widely supported.
23140
23141       remote file ...
23142       local [ file ... ]
23143              Print the size and last modification time of the remote or local
23144              files.   If there is more than one item on the list, the name of
23145              the file is printed first.  The first number is the  file  size,
23146              the second is the last modification time of the file in the for‐
23147              mat CCYYMMDDhhmmSS consisting of year, month, date,  hour,  min‐
23148              utes  and  seconds in GMT.  Note that this format, including the
23149              length, is guaranteed, so that time strings can be directly com‐
23150              pared  via  the [[ builtin's < and > operators, even if they are
23151              too long to be represented as integers.
23152
23153              Not all servers support the commands for retrieving this  infor‐
23154              mation.  In that case, the remote command will print nothing and
23155              return status 2, compared with status 1 for a file not found.
23156
23157              The local command (but not remote) may be  used  with  no  argu‐
23158              ments,  in  which case the information comes from examining file
23159              descriptor zero.  This is the same file as seen by a put command
23160              with no further redirection.
23161
23162       get file ...
23163              Retrieve all files from the server, concatenating them and send‐
23164              ing them to standard output.
23165
23166       put file ...
23167              For each file, read a file from standard input and send that  to
23168              the remote host with the given name.
23169
23170       append file ...
23171              As  put, but if the remote file already exists, data is appended
23172              to it instead of overwriting it.
23173
23174       getat file point
23175       putat file point
23176       appendat file point
23177              Versions of get, put and append which will start the transfer at
23178              the  given point in the remote file.  This is useful for append‐
23179              ing to an incomplete local file.  However, note that this  abil‐
23180              ity  is  not  universally supported by servers (and is not quite
23181              the behaviour specified by the standard).
23182
23183       delete file ...
23184              Delete the list of files on the server.
23185
23186       mkdir directory
23187              Create a new directory directory on the server.
23188
23189       rmdir directory
23190              Delete the directory directory  on the server.
23191
23192       rename old-name new-name
23193              Rename file old-name to new-name on the server.
23194
23195       site arg ...
23196              Send a host-specific command to the server.  You  will  probably
23197              only need this if instructed by the server to use it.
23198
23199       quote arg ...
23200              Send  the raw FTP command sequence to the server.  You should be
23201              familiar with the FTP command set as defined  in  RFC959  before
23202              doing  this.   Useful  commands may include STAT and HELP.  Note
23203              also the mechanism for returning messages as described  for  the
23204              variable  ZFTP_VERBOSE  below,  in  particular that all messages
23205              from the control connection are sent to standard error.
23206
23207       close
23208       quit   Close the current data connection.  This unsets the shell param‐
23209              eters  ZFTP_HOST,  ZFTP_PORT,  ZFTP_IP,  ZFTP_SYSTEM, ZFTP_USER,
23210              ZFTP_ACCOUNT, ZFTP_PWD, ZFTP_TYPE and ZFTP_MODE.
23211
23212       session [ sessname ]
23213              Allows multiple FTP sessions to be used at once.   The  name  of
23214              the  session  is  an arbitrary string of characters; the default
23215              session is called `default'.  If this command is called  without
23216              an  argument, it will list all the current sessions; with an ar‐
23217              gument, it will either switch to  the  existing  session  called
23218              sessname, or create a new session of that name.
23219
23220              Each  session remembers the status of the connection, the set of
23221              connection-specific shell parameters (the same set as are  unset
23222              when a connection closes, as given in the description of close),
23223              and any user parameters specified with  the  params  subcommand.
23224              Changing  to  a previous session restores those values; changing
23225              to a new session initialises them in the same way as if zftp had
23226              just  been  loaded.  The name of the current session is given by
23227              the parameter ZFTP_SESSION.
23228
23229       rmsession [ sessname ]
23230              Delete a session; if a name is not given, the current session is
23231              deleted.  If the current session is deleted, the earliest exist‐
23232              ing session becomes the new current session, otherwise the  cur‐
23233              rent  session  is  not changed.  If the session being deleted is
23234              the only one, a new session called `default' is created and  be‐
23235              comes  the current session; note that this is a new session even
23236              if the session being deleted is also  called  `default'.  It  is
23237              recommended  that  sessions not be deleted while background com‐
23238              mands which use zftp are still active.
23239
23240   Parameters
23241       The following shell parameters are used by  zftp.   Currently  none  of
23242       them are special.
23243
23244       ZFTP_TMOUT
23245              Integer.  The time in seconds to wait for a network operation to
23246              complete before returning an error.  If this is not set when the
23247              module  is  loaded,  it  will  be given the default value 60.  A
23248              value of zero turns off timeouts.  If a timeout  occurs  on  the
23249              control  connection  it  will  be closed.  Use a larger value if
23250              this occurs too frequently.
23251
23252       ZFTP_IP
23253              Readonly.  The IP address of the current connection in dot nota‐
23254              tion.
23255
23256       ZFTP_HOST
23257              Readonly.   The  hostname  of the current remote server.  If the
23258              host was opened as an IP number,  ZFTP_HOST  contains  that  in‐
23259              stead;  this saves the overhead for a name lookup, as IP numbers
23260              are most commonly used when a nameserver is unavailable.
23261
23262       ZFTP_PORT
23263              Readonly.  The number of the remote TCP port to which  the  con‐
23264              nection  is open (even if the port was originally specified as a
23265              named service).  Usually this is the standard FTP port, 21.
23266
23267              In the unlikely event that your system does not have the  appro‐
23268              priate conversion functions, this appears in network byte order.
23269              If your system is little-endian, the port then consists  of  two
23270              swapped  bytes  and  the standard port will be reported as 5376.
23271              In that case, numeric ports passed to zftp open will  also  need
23272              to be in this format.
23273
23274       ZFTP_SYSTEM
23275              Readonly.   The system type string returned by the server in re‐
23276              sponse to an FTP SYST request.  The most interesting case  is  a
23277              string beginning "UNIX Type: L8", which ensures maximum compati‐
23278              bility with a local UNIX host.
23279
23280       ZFTP_TYPE
23281              Readonly.  The type to be used for data transfers ,  either  `A'
23282              or `I'.   Use the type subcommand to change this.
23283
23284       ZFTP_USER
23285              Readonly.  The username currently logged in, if any.
23286
23287       ZFTP_ACCOUNT
23288              Readonly.   The  account name of the current user, if any.  Most
23289              servers do not require an account name.
23290
23291       ZFTP_PWD
23292              Readonly.  The current directory on the server.
23293
23294       ZFTP_CODE
23295              Readonly.  The three digit code of the last FTP reply  from  the
23296              server as a string.  This can still be read after the connection
23297              is closed, and is not changed when the current session changes.
23298
23299       ZFTP_REPLY
23300              Readonly.  The last line of the last reply sent by  the  server.
23301              This  can  still  be read after the connection is closed, and is
23302              not changed when the current session changes.
23303
23304       ZFTP_SESSION
23305              Readonly.  The name of the current FTP session; see the descrip‐
23306              tion of the session subcommand.
23307
23308       ZFTP_PREFS
23309              A  string  of  preferences for altering aspects of zftp's behav‐
23310              iour.  Each preference is a single character.  The following are
23311              defined:
23312
23313              P      Passive:  attempt to make the remote server initiate data
23314                     transfers.  This is slightly more efficient than sendport
23315                     mode.   If  the letter S occurs later in the string, zftp
23316                     will use sendport mode if passive mode is not available.
23317
23318              S      Sendport:  initiate transfers by the  FTP  PORT  command.
23319                     If  this  occurs before any P in the string, passive mode
23320                     will never be attempted.
23321
23322              D      Dumb:  use only the bare minimum of FTP  commands.   This
23323                     prevents  the variables ZFTP_SYSTEM and ZFTP_PWD from be‐
23324                     ing set, and will mean all connections default  to  ASCII
23325                     type.   It  may prevent ZFTP_SIZE from being set during a
23326                     transfer if the server does  not  send  it  anyway  (many
23327                     servers do).
23328
23329              If  ZFTP_PREFS is not set when zftp is loaded, it will be set to
23330              a default of `PS', i.e. use passive mode if available, otherwise
23331              fall back to sendport mode.
23332
23333       ZFTP_VERBOSE
23334              A  string  of digits between 0 and 5 inclusive, specifying which
23335              responses from the server should be printed.  All  responses  go
23336              to  standard  error.  If any of the numbers 1 to 5 appear in the
23337              string, raw responses from the server with reply codes beginning
23338              with  that  digit  will be printed to standard error.  The first
23339              digit of the three digit reply code is defined by RFC959 to cor‐
23340              respond to:
23341
23342              1.     A positive preliminary reply.
23343
23344              2.     A positive completion reply.
23345
23346              3.     A positive intermediate reply.
23347
23348              4.     A transient negative completion reply.
23349
23350              5.     A permanent negative completion reply.
23351
23352              It should be noted that, for unknown reasons, the reply `Service
23353              not available', which forces termination  of  a  connection,  is
23354              classified as 421, i.e. `transient negative', an interesting in‐
23355              terpretation of the word `transient'.
23356
23357              The code 0 is special:  it indicates that all but the last  line
23358              of  multiline  replies  read  from the server will be printed to
23359              standard error in a processed format.   By  convention,  servers
23360              use this mechanism for sending information for the user to read.
23361              The appropriate reply code, if it  matches  the  same  response,
23362              takes priority.
23363
23364              If  ZFTP_VERBOSE  is not set when zftp is loaded, it will be set
23365              to the default value 450, i.e., messages destined for  the  user
23366              and  all  errors  will  be  printed.  A null string is valid and
23367              specifies that no messages should be printed.
23368
23369   Functions
23370       zftp_chpwd
23371              If this function is set by the user, it is called every time the
23372              directory changes on the server, including when a user is logged
23373              in, or when a connection is closed.  In the last case, $ZFTP_PWD
23374              will be unset; otherwise it will reflect the new directory.
23375
23376       zftp_progress
23377              If  this function is set by the user, it will be called during a
23378              get, put or append operation each time sufficient data has  been
23379              received from the host.  During a get, the data is sent to stan‐
23380              dard output, so it is vital that this function should  write  to
23381              standard error or directly to the terminal, not to standard out‐
23382              put.
23383
23384              When it is called with a transfer in progress, the following ad‐
23385              ditional shell parameters are set:
23386
23387              ZFTP_FILE
23388                     The name of the remote file being transferred from or to.
23389
23390              ZFTP_TRANSFER
23391                     A G for a get operation and a P for a put operation.
23392
23393              ZFTP_SIZE
23394                     The  total  size  of the complete file being transferred:
23395                     the same as the first value provided by  the  remote  and
23396                     local  subcommands  for a particular file.  If the server
23397                     cannot supply this value for  a  remote  file  being  re‐
23398                     trieved, it will not be set.  If input is from a pipe the
23399                     value may be incorrect and correspond simply  to  a  full
23400                     pipe buffer.
23401
23402              ZFTP_COUNT
23403                     The  amount  of data so far transferred; a number between
23404                     zero and $ZFTP_SIZE, if that is set.  This number is  al‐
23405                     ways available.
23406
23407              The  function  is initially called with ZFTP_TRANSFER set appro‐
23408              priately and ZFTP_COUNT set to zero.  After the transfer is fin‐
23409              ished,   the   function  will  be  called  one  more  time  with
23410              ZFTP_TRANSFER set to GF or PF, in case it wishes to tidy up.  It
23411              is   otherwise  never  called  twice  with  the  same  value  of
23412              ZFTP_COUNT.
23413
23414              Sometimes the progress meter may cause disruption.  It is up  to
23415              the user to decide whether the function should be defined and to
23416              use unfunction when necessary.
23417
23418   Problems
23419       A connection may not be opened in the left hand side of a pipe as  this
23420       occurs  in  a  subshell  and the file information is not updated in the
23421       main shell.  In the case of type or mode changes or closing the connec‐
23422       tion  in  a subshell, the information is returned but variables are not
23423       updated until the next call to zftp.  Other status changes in subshells
23424       will not be reflected by changes to the variables (but should be other‐
23425       wise harmless).
23426
23427       Deleting sessions while a zftp command is active in the background  can
23428       have  unexpected  effects,  even  if  it does not use the session being
23429       deleted.  This is because all shell subprocesses share  information  on
23430       the state of all connections, and deleting a session changes the order‐
23431       ing of that information.
23432
23433       On some operating systems, the control connection is not valid after  a
23434       fork(),  so  that  operations  in subshells, on the left hand side of a
23435       pipeline, or in the background are not possible,  as  they  should  be.
23436       This is presumably a bug in the operating system.
23437

THE ZSH/ZLE MODULE

23439       The zsh/zle module contains the Zsh Line Editor.  See zshzle(1).
23440

THE ZSH/ZLEPARAMETER MODULE

23442       The  zsh/zleparameter module defines two special parameters that can be
23443       used to access internal information of the Zsh Line  Editor  (see  zsh‐
23444       zle(1)).
23445
23446       keymaps
23447              This array contains the names of the keymaps currently defined.
23448
23449       widgets
23450              This  associative  array contains one entry per widget. The name
23451              of the widget is the key and the value gives  information  about
23452              the widget. It is either
23453                the string `builtin' for builtin widgets,
23454                a string of the form `user:name' for user-defined widgets,
23455                  where  name  is  the name of the shell function implementing
23456              the widget,
23457                a string of the form `completion:type:name'
23458                  for completion widgets,
23459                or a null value if the widget is not yet  fully  defined.   In
23460              the penultimate case, type is the name of the builtin widget the
23461              completion widget imitates in its behavior and name is the  name
23462              of the shell function implementing the completion widget.
23463

THE ZSH/ZPROF MODULE

23465       When  loaded, the zsh/zprof causes shell functions to be profiled.  The
23466       profiling results can be obtained with the zprof builtin  command  made
23467       available  by this module.  There is no way to turn profiling off other
23468       than unloading the module.
23469
23470       zprof [ -c ]
23471              Without the -c option, zprof lists profiling results to standard
23472              output.   The  format  is  comparable  to  that of commands like
23473              gprof.
23474
23475              At the top there is a summary listing all  functions  that  were
23476              called  at least once.  This summary is sorted in decreasing or‐
23477              der of the amount of time spent in each.  The lines contain  the
23478              number of the function in order, which is used in other parts of
23479              the list in suffixes of the form `[num]',  then  the  number  of
23480              calls  made  to  the  function.  The next three columns list the
23481              time in milliseconds spent in the function and its  descendants,
23482              the  average  time in milliseconds spent in the function and its
23483              descendants per call and the percentage of  time  spent  in  all
23484              shell  functions used in this function and its descendants.  The
23485              following three columns give the same information, but  counting
23486              only  the  time  spent in the function itself.  The final column
23487              shows the name of the function.
23488
23489              After the summary, detailed  information  about  every  function
23490              that  was  invoked  is listed, sorted in decreasing order of the
23491              amount of time spent in each function and its descendants.  Each
23492              of these entries consists of descriptions for the functions that
23493              called the function described,  the  function  itself,  and  the
23494              functions  that  were  called  from it.  The description for the
23495              function itself has the same format as in the summary (and shows
23496              the same information).  The other lines don't show the number of
23497              the function at the beginning and have their function named  in‐
23498              dented  to  make  it  easier to distinguish the line showing the
23499              function described in the section from the surrounding lines.
23500
23501              The information shown in this case is almost the same as in  the
23502              summary,  but only refers to the call hierarchy being displayed.
23503              For example, for a calling function the column showing the total
23504              running  time lists the time spent in the described function and
23505              its descendants only for the times when it was called from  that
23506              particular  calling  function.  Likewise, for a called function,
23507              this columns lists the total time spent in the  called  function
23508              and  its  descendants only for the times when it was called from
23509              the function described.
23510
23511              Also in this case, the column showing the number of calls  to  a
23512              function also shows a slash and then the total number of invoca‐
23513              tions made to the called function.
23514
23515              As long as the zsh/zprof module is  loaded,  profiling  will  be
23516              done  and multiple invocations of the zprof builtin command will
23517              show the times and numbers of calls since the module was loaded.
23518              With the -c option, the zprof builtin command will reset its in‐
23519              ternal counters and will not show the listing.
23520

THE ZSH/ZPTY MODULE

23522       The zsh/zpty module offers one builtin:
23523
23524       zpty [ -e ] [ -b ] name [ arg ... ]
23525              The arguments following name are concatenated  with  spaces  be‐
23526              tween,  then  executed  as  a  command, as if passed to the eval
23527              builtin.  The command runs under a newly assigned  pseudo-termi‐
23528              nal; this is useful for running commands non-interactively which
23529              expect an interactive environment.  The name is not part of  the
23530              command,  but is used to refer to this command in later calls to
23531              zpty.
23532
23533              With the -e option, the pseudo-terminal is set up so that  input
23534              characters are echoed.
23535
23536              With the -b option, input to and output from the pseudo-terminal
23537              are made non-blocking.
23538
23539              The shell parameter REPLY is set to the file descriptor assigned
23540              to the master side of the pseudo-terminal.  This allows the ter‐
23541              minal to be monitored with ZLE  descriptor  handlers  (see  zsh‐
23542              zle(1))  or  manipulated  with  sysread  and  syswrite  (see THE
23543              ZSH/SYSTEM MODULE in zshmodules(1)).  Warning:  Use  of  sysread
23544              and  syswrite is not recommended; use zpty -r and zpty -w unless
23545              you know exactly what you are doing.
23546
23547       zpty -d [ name ... ]
23548              The second form, with the -d option, is used to delete  commands
23549              previously  started,  by supplying a list of their names.  If no
23550              name is given, all commands are  deleted.   Deleting  a  command
23551              causes the HUP signal to be sent to the corresponding process.
23552
23553       zpty -w [ -n ] name [ string ... ]
23554              The  -w option can be used to send the to command name the given
23555              strings as input (separated by spaces).  If the -n option is not
23556              given, a newline is added at the end.
23557
23558              If  no  string  is provided, the standard input is copied to the
23559              pseudo-terminal; this may stop before copying the full input  if
23560              the  pseudo-terminal is non-blocking.  The exact input is always
23561              copied: the -n option is not applied.
23562
23563              Note that the command under the pseudo-terminal sees this  input
23564              as  if  it were typed, so beware when sending special tty driver
23565              characters such as word-erase, line-kill, and end-of-file.
23566
23567       zpty -r [ -mt ] name [ param [ pattern ] ]
23568              The -r option can be used to read  the  output  of  the  command
23569              name.   With  only a name argument, the output read is copied to
23570              the standard output.  Unless the pseudo-terminal  is  non-block‐
23571              ing, copying continues until the command under the pseudo-termi‐
23572              nal exits; when non-blocking, only as much output as is  immedi‐
23573              ately  available  is  copied.   The return status is zero if any
23574              output is copied.
23575
23576              When also given a param argument, at most one line is  read  and
23577              stored  in the parameter named param.  Less than a full line may
23578              be read if the pseudo-terminal is non-blocking.  The return sta‐
23579              tus is zero if at least one character is stored in param.
23580
23581              If  a  pattern  is given as well, output is read until the whole
23582              string read matches the pattern, even in the non-blocking  case.
23583              The  return  status  is zero if the string read matches the pat‐
23584              tern, or if the command has exited but at  least  one  character
23585              could  still  be  read.  If the option -m is present, the return
23586              status is zero only if the pattern matches.  As of this writing,
23587              a maximum of one megabyte of output can be consumed this way; if
23588              a full megabyte is read without matching the pattern, the return
23589              status is non-zero.
23590
23591              In  all cases, the return status is non-zero if nothing could be
23592              read, and is 2 if this is because the command has finished.
23593
23594              If the -r option is combined with  the  -t  option,  zpty  tests
23595              whether output is available before trying to read.  If no output
23596              is available, zpty immediately returns the status 1.  When  used
23597              with  a  pattern,  the  behaviour on a failed poll is similar to
23598              when the command has exited:  the return value  is  zero  if  at
23599              least  one  character  could  still  be read even if the pattern
23600              failed to match.
23601
23602       zpty -t name
23603              The -t option without the -r option can be used to test  whether
23604              the  command name is still running.  It returns a zero status if
23605              the command is running and a non-zero value otherwise.
23606
23607       zpty [ -L ]
23608              The last form, without any arguments, is used to list  the  com‐
23609              mands  currently  defined.   If  the -L option is given, this is
23610              done in the form of calls to the zpty builtin.
23611

THE ZSH/ZSELECT MODULE

23613       The zsh/zselect module makes available one builtin command:
23614
23615       zselect [ -rwe ] [ -t timeout ] [ -a array ] [ -A assoc ] [ fd ... ]
23616              The zselect builtin is a front-end to the `select' system  call,
23617              which  blocks  until  a  file descriptor is ready for reading or
23618              writing, or has an error condition, with  an  optional  timeout.
23619              If  this  is not available on your system, the command prints an
23620              error message and returns status 2 (normal errors return  status
23621              1).   For  more  information, see your systems documentation for
23622              select(3).  Note there is no connection with the  shell  builtin
23623              of the same name.
23624
23625              Arguments and options may be intermingled in any order.  Non-op‐
23626              tion arguments are file descriptors, which must be decimal inte‐
23627              gers.   By  default, file descriptors are to be tested for read‐
23628              ing, i.e. zselect will return when data is available to be  read
23629              from  the file descriptor, or more precisely, when a read opera‐
23630              tion from the file descriptor will not block.  After  a  -r,  -w
23631              and -e, the given file descriptors are to be tested for reading,
23632              writing, or error conditions.  These options  and  an  arbitrary
23633              list of file descriptors may be given in any order.
23634
23635              (The presence of an `error condition' is not well defined in the
23636              documentation for many  implementations  of  the  select  system
23637              call.   According to recent versions of the POSIX specification,
23638              it is really an exception condition, of which the only  standard
23639              example  is out-of-band data received on a socket.  So zsh users
23640              are unlikely to find the -e option useful.)
23641
23642              The option `-t timeout' specifies a timeout in hundredths  of  a
23643              second.   This  may  be zero, in which case the file descriptors
23644              will simply be polled and zselect will return  immediately.   It
23645              is  possible  to  call  zselect  with  no file descriptors and a
23646              non-zero timeout for use  as  a  finer-grained  replacement  for
23647              `sleep';  note,  however,  the  return  status is always 1 for a
23648              timeout.
23649
23650              The option `-a array' indicates that array should be set to  in‐
23651              dicate the file descriptor(s) which are ready.  If the option is
23652              not given, the array reply will be used for this  purpose.   The
23653              array  will  contain  a string similar to the arguments for zse‐
23654              lect.  For example,
23655
23656                     zselect -t 0 -r 0 -w 1
23657
23658              might return immediately with status 0 and $reply containing `-r
23659              0 -w 1' to show that both file descriptors are ready for the re‐
23660              quested operations.
23661
23662              The option `-A assoc' indicates that the associative array assoc
23663              should  be  set  to  indicate  the  file descriptor(s) which are
23664              ready.  This option overrides the option -a, nor will  reply  be
23665              modified.   The  keys of assoc are the file descriptors, and the
23666              corresponding values are any of the characters `rwe' to indicate
23667              the condition.
23668
23669              The  command returns status 0 if some file descriptors are ready
23670              for reading.  If the operation timed out, or a timeout of 0  was
23671              given and no file descriptors were ready, or there was an error,
23672              it returns status 1 and the array will not be set (nor  modified
23673              in  any way).  If there was an error in the select operation the
23674              appropriate error message is printed.
23675

THE ZSH/ZUTIL MODULE

23677       The zsh/zutil module only adds some builtins:
23678
23679       zstyle [ -L [ metapattern [ style ] ] ]
23680       zstyle [ -e | - | -- ] pattern style string ...
23681       zstyle -d [ pattern [ style ... ] ]
23682       zstyle -g name [ pattern [ style ] ]
23683       zstyle -{a|b|s} context style name [ sep ]
23684       zstyle -{T|t} context style [ string ... ]
23685       zstyle -m context style pattern
23686              This builtin command  is  used  to  define  and  lookup  styles.
23687              Styles  are  pairs of names and values, where the values consist
23688              of any number of strings.  They are stored  together  with  pat‐
23689              terns  and  lookup  is done by giving a string, called the `con‐
23690              text', which is matched against the  patterns.   The  definition
23691              stored  for  the  most specific pattern that matches will be re‐
23692              turned.
23693
23694              A pattern is considered to be more specific than another  if  it
23695              contains  more components (substrings separated by colons) or if
23696              the patterns for the components are more specific, where  simple
23697              strings  are  considered  to  be more specific than patterns and
23698              complex patterns are considered to be  more  specific  than  the
23699              pattern `*'.  A `*' in the pattern will match zero or more char‐
23700              acters in the context; colons are not treated specially in  this
23701              regard.  If two patterns are equally specific, the tie is broken
23702              in favour of the pattern that was defined first.
23703
23704              Example
23705
23706              For example, to define your preferred form of precipitation  de‐
23707              pending  on which city you're in, you might set the following in
23708              your zshrc:
23709
23710                     zstyle ':weather:europe:*' preferred-precipitation rain
23711                     zstyle ':weather:europe:germany:* preferred-precipitation none
23712                     zstyle ':weather:europe:germany:*:munich' preferred-precipitation snow
23713
23714              Then, the fictional `weather' plugin might run under the hood  a
23715              command such as
23716
23717                     zstyle -s ":weather:${continent}:${country}:${county}:${city}" preferred-precipitation REPLY
23718
23719              in  order  to  retrieve your preference into the scalar variable
23720              $REPLY.
23721
23722              Usage
23723
23724              The forms that operate on patterns are the following.
23725
23726              zstyle [ -L [ metapattern [ style ] ] ]
23727                     Without arguments, lists style definitions.   Styles  are
23728                     shown  in  alphabetic order and patterns are shown in the
23729                     order zstyle will test them.
23730
23731                     If the -L option is given, listing is done in the form of
23732                     calls  to  zstyle.  The optional first argument, metapat‐
23733                     tern, is a pattern which  will  be  matched  against  the
23734                     string  supplied  as  pattern when the style was defined.
23735                     Note: this  means,  for  example,  `zstyle  -L  ":comple‐
23736                     tion:*"' will match any supplied pattern beginning `:com‐
23737                     pletion:',  not  just  ":completion:*":   use   ':comple‐
23738                     tion:\*'  to  match  that.   The optional second argument
23739                     limits the output to a specific style  (not  a  pattern).
23740                     -L is not compatible with any other options.
23741
23742              zstyle [ - | -- | -e ] pattern style string ...
23743                     Defines  the given style for the pattern with the strings
23744                     as the value.  If the -e option  is  given,  the  strings
23745                     will  be  concatenated  (separated by spaces) and the re‐
23746                     sulting string will be evaluated (in the same way  as  it
23747                     is  done  by  the eval builtin command) when the style is
23748                     looked up.  In this case the parameter  `reply'  must  be
23749                     assigned  to  set  the strings returned after the evalua‐
23750                     tion.  Before evaluating the value, reply is  unset,  and
23751                     if  it  is still unset after the evaluation, the style is
23752                     treated as if it were not set.
23753
23754              zstyle -d [ pattern [ style ... ] ]
23755                     Delete style definitions. Without arguments  all  defini‐
23756                     tions  are  deleted,  with  a pattern all definitions for
23757                     that pattern are deleted and if  any  styles  are  given,
23758                     then only those styles are deleted for the pattern.
23759
23760              zstyle -g name [ pattern [ style ] ]
23761                     Retrieve a style definition. The name is used as the name
23762                     of an array in which the results are stored. Without  any
23763                     further  arguments,  all  patterns  defined are returned.
23764                     With a pattern the styles defined for  that  pattern  are
23765                     returned  and  with both a pattern and a style, the value
23766                     strings of that combination is returned.
23767
23768              The other forms can be used to look up  or  test  styles  for  a
23769              given context.
23770
23771              zstyle -s context style name [ sep ]
23772                     The  parameter  name is set to the value of the style in‐
23773                     terpreted as a string.  If  the  value  contains  several
23774                     strings  they  are  concatenated with spaces (or with the
23775                     sep string if that is given) between them.
23776
23777                     Return 0 if the style is set, 1 otherwise.
23778
23779              zstyle -b context style name
23780                     The value is stored in name as a  boolean,  i.e.  as  the
23781                     string  `yes'  if  the value has only one string and that
23782                     string is equal to one of `yes', `true', `on', or `1'. If
23783                     the  value  is  any  other  string  or  has more than one
23784                     string, the parameter is set to `no'.
23785
23786                     Return 0 if name is set to `yes', 1 otherwise.
23787
23788              zstyle -a context style name
23789                     The value is stored in name as an array. If name  is  de‐
23790                     clared  as  an associative array,  the first, third, etc.
23791                     strings are used as the keys and the  other  strings  are
23792                     used as the values.
23793
23794                     Return 0 if the style is set, 1 otherwise.
23795
23796              zstyle -t context style [ string ... ]
23797              zstyle -T context style [ string ... ]
23798                     Test  the  value  of a style, i.e. the -t option only re‐
23799                     turns a status (sets $?).  Without any string the  return
23800                     status  is  zero if the style is defined for at least one
23801                     matching pattern, has only one string in its  value,  and
23802                     that  is  equal  to one of `true', `yes', `on' or `1'. If
23803                     any strings are given the status is zero if and  only  if
23804                     at  least  one of the strings is equal to at least one of
23805                     the strings in the value. If the  style  is  defined  but
23806                     doesn't  match,  the  return status is 1. If the style is
23807                     not defined, the status is 2.
23808
23809                     The -T option tests the values of the style like -t,  but
23810                     it  returns  status  zero (rather than 2) if the style is
23811                     not defined for any matching pattern.
23812
23813              zstyle -m context style pattern
23814                     Match a value. Returns status zero if the pattern matches
23815                     at least one of the strings in the value.
23816
23817       zformat -f param format spec ...
23818       zformat -a array sep spec ...
23819              This  builtin  provides  two  different forms of formatting. The
23820              first form is selected with the -f option. In this case the for‐
23821              mat string will be modified by replacing sequences starting with
23822              a percent sign in it with strings from  the  specs.   Each  spec
23823              should  be  of the form `char:string' which will cause every ap‐
23824              pearance of the sequence `%char' in format to be replaced by the
23825              string.   The `%' sequence may also contain optional minimum and
23826              maximum field width  specifications  between  the  `%'  and  the
23827              `char'  in the form `%min.maxc', i.e. the minimum field width is
23828              given first and if the maximum field width is used, it has to be
23829              preceded  by  a dot.  Specifying a minimum field width makes the
23830              result be padded with spaces to  the  right  if  the  string  is
23831              shorter  than  the  requested width.  Padding to the left can be
23832              achieved by giving a negative minimum field width.  If a maximum
23833              field  width  is  specified,  the string will be truncated after
23834              that many characters.  After all `%'  sequences  for  the  given
23835              specs have been processed, the resulting string is stored in the
23836              parameter param.
23837
23838              The %-escapes also understand ternary expressions  in  the  form
23839              used  by  prompts.  The % is followed by a `(' and then an ordi‐
23840              nary format specifier character as described above.   There  may
23841              be a set of digits either before or after the `('; these specify
23842              a test number, which defaults to  zero.   Negative  numbers  are
23843              also allowed.  An arbitrary delimiter character follows the for‐
23844              mat specifier, which is followed by a piece of `true' text,  the
23845              delimiter  character again, a piece of `false' text, and a clos‐
23846              ing parenthesis.  The complete expression (without  the  digits)
23847              thus  looks like `%(X.text1.text2)', except that the `.' charac‐
23848              ter is arbitrary.  The value given for the format  specifier  in
23849              the  char:string  expressions is evaluated as a mathematical ex‐
23850              pression, and compared with the test number.  If  they  are  the
23851              same,  text1 is output, else text2 is output.  A parenthesis may
23852              be escaped in text2 as %).  Either of text1 or text2 may contain
23853              nested %-escapes.
23854
23855              For example:
23856
23857                     zformat -f REPLY "The answer is '%3(c.yes.no)'." c:3
23858
23859              outputs  "The answer is 'yes'." to REPLY since the value for the
23860              format specifier c is 3, agreeing with the digit argument to the
23861              ternary expression.
23862
23863              The  second  form, using the -a option, can be used for aligning
23864              strings.  Here, the specs are of  the  form  `left:right'  where
23865              `left'  and  `right'  are  arbitrary strings.  These strings are
23866              modified by replacing the colons by the sep string  and  padding
23867              the  left  strings  with  spaces  to  the  right so that the sep
23868              strings in the result (and hence the right strings  after  them)
23869              are  all  aligned  if  the strings are printed below each other.
23870              All strings without a colon are left unchanged and  all  strings
23871              with  an empty right string have the trailing colon removed.  In
23872              both cases the lengths of the strings are not used to  determine
23873              how  the  other  strings are to be aligned.  A colon in the left
23874              string can be escaped with a backslash.  The  resulting  strings
23875              are stored in the array.
23876
23877       zregexparse
23878              This implements some internals of the _regex_arguments function.
23879
23880       zparseopts [ -D -E -F -K -M ] [ -a array ] [ -A assoc ] [ - ] spec ...
23881              This builtin simplifies the parsing of options in positional pa‐
23882              rameters, i.e. the set of arguments given by $*.  Each spec  de‐
23883              scribes one option and must be of the form `opt[=array]'.  If an
23884              option described by opt is found in the positional parameters it
23885              is  copied  into  the array specified with the -a option; if the
23886              optional `=array' is given, it is instead copied into  that  ar‐
23887              ray,  which should be declared as a normal array and never as an
23888              associative array.
23889
23890              Note that it is an error to give any spec  without  an  `=array'
23891              unless one of the -a or -A options is used.
23892
23893              Unless the -E option is given, parsing stops at the first string
23894              that isn't described by one of the specs.  Even with -E, parsing
23895              always stops at a positional parameter equal to `-' or `--'. See
23896              also -F.
23897
23898              The opt description must be one of the following.   Any  of  the
23899              special  characters can appear in the option name provided it is
23900              preceded by a backslash.
23901
23902              name
23903              name+  The name is the name of the option  without  the  leading
23904                     `-'.   To  specify  a  GNU-style  long option, one of the
23905                     usual two leading `-' must be included in name; for exam‐
23906                     ple,  a  `--file'  option  is  represented  by  a name of
23907                     `-file'.
23908
23909                     If a `+' appears after name, the option  is  appended  to
23910                     array each time it is found in the positional parameters;
23911                     without the `+' only the last occurrence of the option is
23912                     preserved.
23913
23914                     If  one of these forms is used, the option takes no argu‐
23915                     ment, so parsing stops if the next  positional  parameter
23916                     does  not  also  begin  with `-' (unless the -E option is
23917                     used).
23918
23919              name:
23920              name:-
23921              name:: If one or two colons are given, the option takes an argu‐
23922                     ment;  with one colon, the argument is mandatory and with
23923                     two colons it is optional.  The argument is  appended  to
23924                     the array after the option itself.
23925
23926                     An  optional  argument is put into the same array element
23927                     as the option name (note that this makes empty strings as
23928                     arguments  indistinguishable).   A  mandatory argument is
23929                     added as a separate element unless the `:-' form is used,
23930                     in which case the argument is put into the same element.
23931
23932                     A  `+' as described above may appear between the name and
23933                     the first colon.
23934
23935              In all cases, option-arguments must  appear  either  immediately
23936              following  the option in the same positional parameter or in the
23937              next one. Even an optional argument may appear in the  next  pa‐
23938              rameter,  unless it begins with a `-'.  There is no special han‐
23939              dling of `=' as with GNU-style argument parsers; given the  spec
23940              `-foo:',  the  positional  parameter  `--foo=bar'  is  parsed as
23941              `--foo' with an argument of `=bar'.
23942
23943              When the names of two options that take  no  arguments  overlap,
23944              the  longest one wins, so that parsing for the specs `-foo -foo‐
23945              bar' (for example) is unambiguous. However, due to the aforemen‐
23946              tioned  handling of option-arguments, ambiguities may arise when
23947              at least one overlapping spec takes an argument,  as  in  `-foo:
23948              -foobar'. In that case, the last matching spec wins.
23949
23950              The  options of zparseopts itself cannot be stacked because, for
23951              example, the stack `-DEK' is indistinguishable from a  spec  for
23952              the  GNU-style  long  option `--DEK'.  The options of zparseopts
23953              itself are:
23954
23955              -a array
23956                     As described above, this names the default array in which
23957                     to store the recognised options.
23958
23959              -A assoc
23960                     If  this  is given, the options and their values are also
23961                     put into an associative array with the  option  names  as
23962                     keys and the arguments (if any) as the values.
23963
23964              -D     If  this  option  is given, all options found are removed
23965                     from the positional parameters of the  calling  shell  or
23966                     shell function, up to but not including any not described
23967                     by the specs.  If the first  such  parameter  is  `-'  or
23968                     `--',  it  is  removed as well.  This is similar to using
23969                     the shift builtin.
23970
23971              -E     This changes the parsing rules to not stop at  the  first
23972                     string  that isn't described by one of the specs.  It can
23973                     be used to test for or (if used together with -D) extract
23974                     options  and  their arguments, ignoring all other options
23975                     and arguments that may be in the  positional  parameters.
23976                     As  indicated above, parsing still stops at the first `-'
23977                     or `--' not described by a spec, but it  is  not  removed
23978                     when used with -D.
23979
23980              -F     If  this option is given, zparseopts immediately stops at
23981                     the first option-like parameter not described by  one  of
23982                     the specs, prints an error message, and returns status 1.
23983                     Removal (-D) and extraction (-E) are not  performed,  and
23984                     option arrays are not updated.  This provides basic vali‐
23985                     dation for the given options.
23986
23987                     Note that the appearance in the positional parameters  of
23988                     an  option  without  its  required argument always aborts
23989                     parsing and returns an error as described  above  regard‐
23990                     less of whether this option is used.
23991
23992              -K     With this option, the arrays specified with the -a option
23993                     and with the `=array' forms are kept unchanged when  none
23994                     of  the specs for them is used.  Otherwise the entire ar‐
23995                     ray is replaced when any of the specs is used.   Individ‐
23996                     ual  elements of associative arrays specified with the -A
23997                     option are preserved by -K.  This  allows  assignment  of
23998                     default values to arrays before calling zparseopts.
23999
24000              -M     This  changes  the  assignment  rules  to implement a map
24001                     among equivalent option names.   If  any  spec  uses  the
24002                     `=array'  form,  the  string  array is interpreted as the
24003                     name of another spec, which is used to  choose  where  to
24004                     store  the values.  If no other spec is found, the values
24005                     are stored as usual.  This changes only the way the  val‐
24006                     ues  are stored, not the way $* is parsed, so results may
24007                     be unpredictable if the `name+' specifier is used  incon‐
24008                     sistently.
24009
24010              For example,
24011
24012                     set -- -a -bx -c y -cz baz -cend
24013                     zparseopts a=foo b:=bar c+:=bar
24014
24015              will have the effect of
24016
24017                     foo=(-a)
24018                     bar=(-b x -c y -c z)
24019
24020              The arguments from `baz' on will not be used.
24021
24022              As an example for the -E option, consider:
24023
24024                     set -- -a x -b y -c z arg1 arg2
24025                     zparseopts -E -D b:=bar
24026
24027              will have the effect of
24028
24029                     bar=(-b y)
24030                     set -- -a x -c z arg1 arg2
24031
24032              I.e.,  the  option -b and its arguments are taken from the posi‐
24033              tional parameters and put into the array bar.
24034
24035              The -M option can be used like this:
24036
24037                     set -- -a -bx -c y -cz baz -cend
24038                     zparseopts -A bar -M a=foo b+: c:=b
24039
24040              to have the effect of
24041
24042                     foo=(-a)
24043                     bar=(-a '' -b xyz)
24044
24045
24046
24047ZSHCALSYS(1)                General Commands Manual               ZSHCALSYS(1)
24048
24049
24050

NAME

24052       zshcalsys - zsh calendar system
24053

DESCRIPTION

24055       The shell is supplied with a series of functions to replace and enhance
24056       the  traditional Unix calendar programme, which warns the user of immi‐
24057       nent or future events, details of which are stored in a text file (typ‐
24058       ically  calendar  in  the user's home directory).  The version provided
24059       here includes a mechanism for alerting the user when an event is due.
24060
24061       In addition functions age, before and after are provided  that  can  be
24062       used  in  a  glob  qualifier;  they allow files to be selected based on
24063       their modification times.
24064
24065       The format of the calendar file and the dates used there in and in  the
24066       age function are described first, then the functions that can be called
24067       to examine and modify the calendar file.
24068
24069       The functions here depend on the availability of the zsh/datetime  mod‐
24070       ule  which  is  usually installed with the shell.  The library function
24071       strptime() must be available; it is present on  most  recent  operating
24072       systems.
24073

FILE AND DATE FORMATS

24075   Calendar File Format
24076       The  calendar file is by default ~/calendar.  This can be configured by
24077       the calendar-file style, see the section STYLES below.  The basic  for‐
24078       mat  consists  of a series of separate lines, with no indentation, each
24079       including a date and time specification followed by  a  description  of
24080       the event.
24081
24082       Various  enhancements to this format are supported, based on the syntax
24083       of Emacs calendar mode.  An indented line indicates a continuation line
24084       that  continues  the  description  of the event from the preceding line
24085       (note the date may not be continued in this way).  An initial ampersand
24086       (&) is ignored for compatibility.
24087
24088       An  indented  line  on which the first non-whitespace character is # is
24089       not displayed with the calendar entry, but is still scanned for  infor‐
24090       mation.   This  can  be used to hide information useful to the calendar
24091       system but not to the user, such as the unique identifier used by  cal‐
24092       endar_add.
24093
24094       The Emacs extension that a date with no description may refer to a num‐
24095       ber of succeeding events at different times is not supported.
24096
24097       Unless the done-file style has been altered, any events which have been
24098       processed  are  appended to the file with the same name as the calendar
24099       file with the suffix .done, hence ~/calendar.done by default.
24100
24101       An example is shown below.
24102
24103   Date Format
24104       The format of the date and time is designed to allow flexibility  with‐
24105       out admitting ambiguity.  (The words `date' and `time' are both used in
24106       the documentation below; except where specifically noted this implies a
24107       string  that  may  include both a date and a time specification.)  Note
24108       that there is no localization support; month and day names must  be  in
24109       English  and separator characters are fixed.  Matching is case insensi‐
24110       tive, and only the first three letters of the  names  are  significant,
24111       although  as  a  special  case  a form beginning "month" does not match
24112       "Monday".  Furthermore, time zones are not handled; all times  are  as‐
24113       sumed to be local.
24114
24115       It  is  recommended  that, rather than exploring the intricacies of the
24116       system, users find a date format that is natural to them and  stick  to
24117       it.   This  will avoid unexpected effects.  Various key facts should be
24118       noted.
24119
24120       •      In particular, note the  confusion  between  month/day/year  and
24121              day/month/year  when  the month is numeric; these formats should
24122              be avoided if at all possible.  Many alternatives are available.
24123
24124       •      The year must be given in full  to  avoid  confusion,  and  only
24125              years from 1900 to 2099 inclusive are matched.
24126
24127       The  following  give some obvious examples; users finding here a format
24128       they like and not subject to vagaries of style may skip  the  full  de‐
24129       scription.   As dates and times are matched separately (even though the
24130       time may be embedded in the date), any date format may  be  mixed  with
24131       any format for the time of day provide the separators are clear (white‐
24132       space, colons, commas).
24133
24134              2007/04/03 13:13
24135              2007/04/03:13:13
24136              2007/04/03 1:13 pm
24137              3rd April 2007, 13:13
24138              April 3rd 2007 1:13 p.m.
24139              Apr 3, 2007 13:13
24140              Tue Apr 03 13:13:00 2007
24141              13:13 2007/apr/3
24142
24143       More detailed rules follow.
24144
24145       Times are parsed and extracted before dates.  They must use  colons  to
24146       separate  hours  and minutes, though a dot is allowed before seconds if
24147       they are present.  This limits time formats to the following:
24148
24149HH:MM[:SS[.FFFFF]] [am|pm|a.m.|p.m.]
24150
24151HH:MM.SS[.FFFFF] [am|pm|a.m.|p.m.]
24152
24153       Here, square brackets indicate optional elements, possibly with  alter‐
24154       natives.   Fractions of a second are recognised but ignored.  For abso‐
24155       lute times (the normal format require by the calendar file and the age,
24156       before  and  after  functions) a date is mandatory but a time of day is
24157       not; the time returned is at the start of the date.  One  variation  is
24158       allowed:  if  a.m. or p.m. or one of their variants is present, an hour
24159       without a minute is allowed, e.g. 3 p.m..
24160
24161       Time zones are not handled, though if one is matched following  a  time
24162       specification  it  will  be  removed  to allow a surrounding date to be
24163       parsed.  This only happens if the format of the timezone is not too un‐
24164       usual.  The following are examples of forms that are understood:
24165
24166              +0100
24167              GMT
24168              GMT-7
24169              CET+1CDT
24170
24171       Any  part  of  the timezone that is not numeric must have exactly three
24172       capital letters in the name.
24173
24174       Dates suffer from the ambiguity between DD/MM/YYYY and MM/DD/YYYY.   It
24175       is  recommended this form is avoided with purely numeric dates, but use
24176       of ordinals, eg. 3rd/04/2007, will resolve the ambiguity as the ordinal
24177       is  always  parsed  as the day of the month.  Years must be four digits
24178       (and the first two must be 19  or  20);  03/04/08  is  not  recognised.
24179       Other  numbers may have leading zeroes, but they are not required.  The
24180       following are handled:
24181
24182YYYY/MM/DD
24183
24184YYYY-MM-DD
24185
24186YYYY/MNM/DD
24187
24188YYYY-MNM-DD
24189
24190DD[th|st|rd] MNM[,] [ YYYY ]
24191
24192MNM DD[th|st|rd][,] [ YYYY ]
24193
24194DD[th|st|rd]/MM[,] YYYY
24195
24196DD[th|st|rd]/MM/YYYY
24197
24198MM/DD[th|st|rd][,] YYYY
24199
24200MM/DD[th|st|rd]/YYYY
24201
24202       Here, MNM is at least the first three letters of a month name,  matched
24203       case-insensitively.  The remainder of the month name may appear but its
24204       contents are  irrelevant,  so  janissary,  febrile,  martial,  apricot,
24205       maybe, junta, etc. are happily handled.
24206
24207       Where  the  year  is  shown  as  optional, the current year is assumed.
24208       There are only two such cases, the form Jun 20  or  14  September  (the
24209       only  two commonly occurring forms, apart from a "the" in some forms of
24210       English, which isn't currently supported).  Such dates will  of  course
24211       become ambiguous in the future, so should ideally be avoided.
24212
24213       Times  may follow dates with a colon, e.g. 1965/07/12:09:45; this is in
24214       order to provide a format with no whitespace.  A comma  and  whitespace
24215       are allowed, e.g. 1965/07/12, 09:45.  Currently the order of these sep‐
24216       arators is not checked, so illogical  formats  such  as  1965/07/12,  :
24217       ,09:45  will  also  be matched.  For simplicity such variations are not
24218       shown in the list above.  Otherwise, a time is only recognised as being
24219       associated  with  a  date if there is only whitespace in between, or if
24220       the time was embedded in the date.
24221
24222       Days of the week are not normally scanned, but will be ignored if  they
24223       occur  at  the  start  of  the date pattern only.  However, in contexts
24224       where it is useful to specify dates relative to today, days of the week
24225       with  no  other date specification may be given.  The day is assumed to
24226       be either today or within the past week.  Likewise, the  words  yester‐
24227       day, today and tomorrow are handled.  All matches are case-insensitive.
24228       Hence if today is Monday, then Sunday is equivalent to yesterday,  Mon‐
24229       day  is  equivalent  to  today,  but Tuesday gives a date six days ago.
24230       This is not generally useful within the calendar file.  Dates  in  this
24231       format may be combined with a time specification; for example Tomorrow,
24232       8 p.m..
24233
24234       For example, the standard date format:
24235
24236              Fri Aug 18 17:00:48 BST 2006
24237
24238       is handled by matching HH:MM:SS  and  removing  it  together  with  the
24239       matched (but unused) time zone.  This leaves the following:
24240
24241              Fri Aug 18 2006
24242
24243       Fri is ignored and the rest is matched according to the standard rules.
24244
24245   Relative Time Format
24246       In  certain places relative times are handled.  Here, a date is not al‐
24247       lowed; instead a combination of various supported periods are  allowed,
24248       together with an optional time.  The periods must be in order from most
24249       to least significant.
24250
24251       In some cases, a more accurate calculation is possible when there is an
24252       anchor  date:   offsets of months or years pick the correct day, rather
24253       than being rounded, and it is possible to pick a particular  day  in  a
24254       month as `(1st Friday)', etc., as described in more detail below.
24255
24256       Anchors  are available in the following cases.  If one or two times are
24257       passed to the function calendar, the start time acts an anchor for  the
24258       end  time  when the end time is relative (even if the start time is im‐
24259       plicit).  When examining calendar files, the scheduled event being  ex‐
24260       amined anchors the warning time when it is given explicitly by means of
24261       the WARN keyword; likewise, the scheduled event  anchors  a  repetition
24262       period  when  given  by the RPT keyword, so that specifications such as
24263       RPT 2 months, 3rd Thursday are handled properly.  Finally, the -R argu‐
24264       ment to calendar_scandate directly provides an anchor for relative cal‐
24265       culations.
24266
24267       The periods handled, with possible abbreviations are:
24268
24269       Years  years, yrs, ys, year, yr, y, yearly.  A year is 365.25 days  un‐
24270              less there is an anchor.
24271
24272       Months months, mons, mnths, mths, month, mon, mnth, mth, monthly.  Note
24273              that m, ms, mn, mns are ambiguous and are not handled.  A  month
24274              is a period of 30 days rather than a calendar month unless there
24275              is an anchor.
24276
24277       Weeks  weeks, wks, ws, week, wk, w, weekly
24278
24279       Days   days, dys, ds, day, dy, d, daily
24280
24281       Hours  hours, hrs, hs, hour, hr, h, hourly
24282
24283       Minutes
24284              minutes, mins, minute, min, but not m, ms, mn or mns
24285
24286       Seconds
24287              seconds, secs, ss, second, sec, s
24288
24289       Spaces between the numbers  are  optional,  but  are  required  between
24290       items, although a comma may be used (with or without spaces).
24291
24292       The  forms  yearly  to hourly allow the number to be omitted; it is as‐
24293       sumed to be 1.  For example, 1 d and daily are equivalent.   Note  that
24294       using  those forms with plurals is confusing; 2 yearly is the same as 2
24295       years, not twice yearly, so it is recommended they only be used without
24296       numbers.
24297
24298       When an anchor time is present, there is an extension to handle regular
24299       events in the form of the nth someday of the month.  Such a  specifica‐
24300       tion must occur immediately after any year and month specification, but
24301       before any time of day, and must be in the form  n(th|st|rd)  day,  for
24302       example  1st  Tuesday  or  3rd  Monday.   As  in other places, days are
24303       matched case insensitively, must be in  English,  and  only  the  first
24304       three letters are significant except that a form beginning `month' does
24305       not match `Monday'.  No attempt is made to sanitize the resulting date;
24306       attempts to squeeze too many occurrences into a month will push the day
24307       into the next month (but in the obvious fashion, retaining the  correct
24308       day of the week).
24309
24310       Here are some examples:
24311
24312              30 years 3 months 4 days 3:42:41
24313              14 days 5 hours
24314              Monthly, 3rd Thursday
24315              4d,10hr
24316
24317   Example
24318       Here is an example calendar file.  It uses a consistent date format, as
24319       recommended above.
24320
24321              Feb 1, 2006 14:30 Pointless bureaucratic meeting
24322              Mar 27, 2006 11:00 Mutual recrimination and finger pointing
24323                Bring water pistol and waterproofs
24324              Mar 31, 2006 14:00 Very serious managerial pontification
24325                # UID 12C7878A9A50
24326              Apr 10, 2006 13:30 Even more pointless blame assignment exercise WARN 30 mins
24327              May 18, 2006 16:00 Regular moaning session RPT monthly, 3rd Thursday
24328
24329       The second entry has a continuation line.  The third entry has  a  con‐
24330       tinuation  line that will not be shown when the entry is displayed, but
24331       the unique identifier will be used by the  calendar_add  function  when
24332       updating the event.  The fourth entry will produce a warning 30 minutes
24333       before the event (to allow you to equip yourself  appropriately).   The
24334       fifth  entry  repeats  after a month on the 3rd Thursday, i.e. June 15,
24335       2006, at the same time.
24336

USER FUNCTIONS

24338       This section describes functions that are designed  to  be  called  di‐
24339       rectly  by  the user.  The first part describes those functions associ‐
24340       ated with the user's calendar; the second part  describes  the  use  in
24341       glob qualifiers.
24342
24343   Calendar system functions
24344       calendar [ -abdDsv ] [ -C calfile ] [ -n num ] [ -S showprog ]
24345                [ [ start ] end ]
24346       calendar -r [ -abdDrsv ] [ -C calfile ] [ -n num ] [ -S showprog ]
24347                [ start ]
24348              Show events in the calendar.
24349
24350              With no arguments, show events from the start of today until the
24351              end of the next working day after today.  In other words, if to‐
24352              day  is  Friday,  Saturday, or Sunday, show up to the end of the
24353              following Monday, otherwise show today and tomorrow.
24354
24355              If end is given, show events from the start of today up  to  the
24356              time  and  date  given,  which is in the format described in the
24357              previous section.  Note that if this is a date the time  is  as‐
24358              sumed  to  be  midnight at the start of the date, so that effec‐
24359              tively this shows all events before the given date.
24360
24361              end may start with a +, in which case the remainder of the spec‐
24362              ification is a relative time format as described in the previous
24363              section indicating the range of time from the start time that is
24364              to be included.
24365
24366              If  start is also given, show events starting from that time and
24367              date.  The word now can be used to indicate the current time.
24368
24369              To implement an alert when events are due, include  calendar  -s
24370              in your ~/.zshrc file.
24371
24372              Options:
24373
24374              -a     Show  all  items in the calendar, regardless of the start
24375                     and end.
24376
24377              -b     Brief:  don't display continuation lines  (i.e.  indented
24378                     lines  following  the  line with the date/time), just the
24379                     first line.
24380
24381              -B lines
24382                     Brief: display at most the first lines lines of the  cal‐
24383                     endar entry.  `-B 1' is equivalent to `-b'.
24384
24385              -C calfile
24386                     Explicitly  specify  a calendar file instead of the value
24387                     of the calendar-file style or the default ~/calendar.
24388
24389              -d     Move any events that have passed from the  calendar  file
24390                     to  the  "done"  file, as given by the done-file style or
24391                     the default which is the calendar  file  with  .done  ap‐
24392                     pended.  This option is implied by the -s option.
24393
24394              -D     Turns  off  the  option -d, even if the -s option is also
24395                     present.
24396
24397              -n num, -num
24398                     Show at least num events,  if  present  in  the  calendar
24399                     file, regardless of the start and end.
24400
24401              -r     Show  all the remaining options in the calendar, ignoring
24402                     the given end time.  The start time is respected; any ar‐
24403                     gument given is treated as a start time.
24404
24405              -s     Use  the  shell's sched command to schedule a timed event
24406                     that will warn the user when an event is due.  Note  that
24407                     the  sched command only runs if the shell is at an inter‐
24408                     active prompt; a foreground  task  blocks  the  scheduled
24409                     task from running until it is finished.
24410
24411                     The  timed event usually runs the programme calendar_show
24412                     to show the event, as described in  the  section  UTILITY
24413                     FUNCTIONS below.
24414
24415                     By  default, a warning of the event is shown five minutes
24416                     before it is due.  The warning period can  be  configured
24417                     by  the style warn-time or for a single calendar entry by
24418                     including WARN reltime in the first line  of  the  entry,
24419                     where reltime is one of the usual relative time formats.
24420
24421                     A  repeated  event may be indicated by including RPT rel‐
24422                     date in the first line of the entry.  After the scheduled
24423                     event  has  been displayed it will be re-entered into the
24424                     calendar file at a time reldate after the existing event.
24425                     Note  that this is currently the only use made of the re‐
24426                     peat count, so that it  is  not  possible  to  query  the
24427                     schedule for a recurrence of an event in the calendar un‐
24428                     til the previous event has passed.
24429
24430                     If RPT is used, it is also possible to specify that  cer‐
24431                     tain  recurrences  of  an  event  are rescheduled or can‐
24432                     celled.  This is done with the OCCURRENCE  keyword,  fol‐
24433                     lowed  by  whitespace and the date and time of the occur‐
24434                     rence in the regular sequence, followed by whitespace and
24435                     either  the date and time of the rescheduled event or the
24436                     exact string CANCELLED.  In this case the date  and  time
24437                     must be in exactly the "date with local time" format used
24438                     by   the   text/calendar   MIME    type    (RFC    2445),
24439                     <YYYY><MM><DD>T<hh><mm><ss>  (note  the  presence  of the
24440                     literal character T).  The first word (the regular recur‐
24441                     rence)  may be something other than a proper date/time to
24442                     indicate that the event is additional to the  normal  se‐
24443                     quence;  a convention that retains the formatting appear‐
24444                     ance is XXXXXXXXTXXXXXX.
24445
24446                     Furthermore, it is useful to record the next regular  re‐
24447                     currence  (as  then  the  displayed  date  may  be  for a
24448                     rescheduled event so cannot be used for  calculating  the
24449                     regular sequence).  This is specified by RECURRENCE and a
24450                     time or date in the same format.  calendar_add adds  such
24451                     an  indication  when it encounters a recurring event that
24452                     does not include one, based on the headline date/time.
24453
24454                     If calendar_add is used to  update  occurrences  the  UID
24455                     keyword described there should be present in both the ex‐
24456                     isting entry and the added occurrence in order  to  iden‐
24457                     tify recurring event sequences.
24458
24459                     For example,
24460
24461                            Thu May 6, 2010 11:00 Informal chat RPT 1 week
24462                              # RECURRENCE 20100506T110000
24463                              # OCCURRENCE 20100513T110000 20100513T120000
24464                              # OCCURRENCE 20100520T110000 CANCELLED
24465
24466                     The  event  that  occurs  at  11:00  on  13th May 2010 is
24467                     rescheduled an hour later.  The event that occurs a  week
24468                     later  is cancelled.  The occurrences are given on a con‐
24469                     tinuation line starting with a # character  so  will  not
24470                     usually be displayed as part of the event.  As elsewhere,
24471                     no account of time zones is taken with the  times.  After
24472                     the next event occurs the headline date/time will be `Thu
24473                     May 13, 2010 12:00' while the RECURRENCE  date/time  will
24474                     be  `20100513T110000'  (note  that  cancelled  and  moved
24475                     events are not taken account of in the RECURRENCE,  which
24476                     records what the next regular recurrence is, but they are
24477                     accounted for in the headline date/time).
24478
24479                     It is safe to run calendar -s to reschedule  an  existing
24480                     event  (if  the  calendar file has changed, for example),
24481                     and also to have it running in multiples instances of the
24482                     shell since the calendar file is locked when in use.
24483
24484                     By  default, expired events are moved to the "done" file;
24485                     see the -d option.  Use -D to prevent this.
24486
24487              -S showprog
24488                     Explicitly specify a programme to  be  used  for  showing
24489                     events instead of the value of the show-prog style or the
24490                     default calendar_show.
24491
24492              -v     Verbose:  show more information about stages of  process‐
24493                     ing.  This is useful for confirming that the function has
24494                     successfully parsed the dates in the calendar file.
24495
24496       calendar_add [ -BL ] event ...
24497              Adds a single event to the calendar in the appropriate location.
24498              The  event  can contain multiple lines, as described in the sec‐
24499              tion Calendar File Format above.  Using  this  function  ensures
24500              that  the  calendar  file  is sorted in date and time order.  It
24501              also makes special arrangements for locking the file while it is
24502              altered.   The  old  calendar  is left in a file with the suffix
24503              .old.
24504
24505              The option -B indicates that backing up the calendar  file  will
24506              be  handled  by the caller and should not be performed by calen‐
24507              dar_add.  The option -L indicates  that  calendar_add  does  not
24508              need  to  lock the calendar file as it is already locked.  These
24509              options will not usually be needed by users.
24510
24511              If the style reformat-date is true, the date and time of the new
24512              entry  will be rewritten into the standard date format:  see the
24513              descriptions of this style and the style date-format.
24514
24515              The function can use a unique identifier stored with each  event
24516              to ensure that updates to existing events are treated correctly.
24517              The entry should contain the word UID, followed  by  whitespace,
24518              followed  by a word consisting entirely of hexadecimal digits of
24519              arbitrary length (all digits are significant, including  leading
24520              zeroes).   As  the UID is not directly useful to the user, it is
24521              convenient to hide it on an indented continuation line  starting
24522              with a #, for example:
24523
24524                     Aug 31, 2007 09:30  Celebrate the end of the holidays
24525                       # UID 045B78A0
24526
24527              The second line will not be shown by the calendar function.
24528
24529              It  is possible to specify the RPT keyword followed by CANCELLED
24530              instead of a relative time.  This causes any  matched  event  or
24531              series  of  events  to be cancelled (the original event does not
24532              have to be marked as recurring in order to be cancelled by  this
24533              method).   A UID is required in order to match an existing event
24534              in the calendar.
24535
24536              calendar_add will attempt to manage recurrences and  occurrences
24537              of  repeating events as described for event scheduling by calen‐
24538              dar -s above.  To reschedule or cancel  a  single  event  calen‐
24539              dar_add should be called with an entry that includes the correct
24540              UID but does not include the RPT keyword as  this  is  taken  to
24541              mean the entry applies to a series of repeating events and hence
24542              replaces all existing information.   Each  rescheduled  or  can‐
24543              celled  occurrence  must have an OCCURRENCE keyword in the entry
24544              passed to calendar_add which will be merged  into  the  calendar
24545              file.  Any existing reference to the occurrence is replaced.  An
24546              occurrence that does not refer to  a  valid  existing  event  is
24547              added as a one-off occurrence to the same calendar entry.
24548
24549       calendar_edit
24550              This  calls  the  user's  editor  to edit the calendar file.  If
24551              there are arguments, they are taken as the editor  to  use  (the
24552              file name is appended to the commands); otherwise, the editor is
24553              given by the variable VISUAL, if set, else the variable EDITOR.
24554
24555              If the calendar scheduler was running, then  after  editing  the
24556              file calendar -s is called to update it.
24557
24558              This  function  locks  out  the calendar system during the edit.
24559              Hence it should be used to edit the calendar file  if  there  is
24560              any  possibility  of a calendar event occurring meanwhile.  Note
24561              this can lead to another shell with calendar  functions  enabled
24562              hanging  waiting for a lock, so it is necessary to quit the edi‐
24563              tor as soon as possible.
24564
24565       calendar_parse calendar-entry
24566              This is the internal function that analyses the parts of a  cal‐
24567              endar entry, which is passed as the only argument.  The function
24568              returns status 1 if the argument could not be parsed as a calen‐
24569              dar  entry  and  status  2 if the wrong number of arguments were
24570              passed; it also sets the parameter reply to an empty associative
24571              array.   Otherwise, it returns status 0 and sets elements of the
24572              associative array reply as follows:
24573
24574              time   The time as a string of  digits  in  the  same  units  as
24575                     $EPOCHSECONDS
24576              schedtime
24577                     The  regularly  scheduled time.  This may differ from the
24578                     actual event time time if this is a recurring  event  and
24579                     the  next  occurrence  has  been  rescheduled.  Then time
24580                     gives the actual time and schedtime the time of the regu‐
24581                     lar recurrence before modification.
24582              text1  The text from the line not including the date and time of
24583                     the event, but including any WARN  or  RPT  keywords  and
24584                     values.
24585              warntime
24586                     Any warning time given by the WARN keyword as a string of
24587                     digits containing the time at which to warn in  the  same
24588                     units  as $EPOCHSECONDS.  (Note this is an absolute time,
24589                     not the relative time passed down.)  Not set no WARN key‐
24590                     word and value were matched.
24591              warnstr
24592                     The  raw  string matched after the WARN keyword, else un‐
24593                     set.
24594              rpttime
24595                     Any recurrence time given by the RPT keyword as a  string
24596                     of  digits  containing  the time of the recurrence in the
24597                     same units as $EPOCHSECONDS.  (Note this is  an  absolute
24598                     time.)  Not set if no RPT keyword and value were matched.
24599              schedrpttime
24600                     The  next  regularly  scheduled occurrence of a recurring
24601                     event before modification.  This may differ from rpttime,
24602                     which  is the actual time of the event that may have been
24603                     rescheduled from the regular time.
24604              rptstr The raw string matched after the RPT keyword, else unset.
24605              text2  The text from the line after removal of the date and  any
24606                     keywords and values.
24607
24608       calendar_showdate [ -r ] [ -f fmt ] date-spec ...
24609              The  given  date-spec  is interpreted and the corresponding date
24610              and time printed.  If the initial date-spec begins with a + or -
24611              it  is treated as relative to the current time; date-specs after
24612              the first are treated as relative to the date calculated so  far
24613              and  a  leading  + is optional in that case.  This allows one to
24614              use the system  as  a  date  calculator.   For  example,  calen‐
24615              dar_showdate  '+1 month, 1st Friday' shows the date of the first
24616              Friday of next month.
24617
24618              With the option -r nothing is printed but the value of the  date
24619              and  time  in seconds since the epoch is stored in the parameter
24620              REPLY.
24621
24622              With the option -f fmt the given date/time conversion format  is
24623              passed to strftime; see notes on the date-format style below.
24624
24625              In order to avoid ambiguity with negative relative date specifi‐
24626              cations, options must occur in separate words; in  other  words,
24627              -r and -f should not be combined in the same word.
24628
24629       calendar_sort
24630              Sorts  the  calendar  file  into date and time order.    The old
24631              calendar is left in a file with the suffix .old.
24632
24633   Glob qualifiers
24634       age    The function age can be autoloaded and use separately  from  the
24635              calendar system, although it uses the function calendar_scandate
24636              for date formatting.  It requires the zsh/stat builtin, but uses
24637              only the builtin zstat.
24638
24639              age  selects files having a given modification time for use as a
24640              glob qualifier.  The format of the date is the same as that  un‐
24641              derstood  by  the calendar system, described in the section FILE
24642              AND DATE FORMATS above.
24643
24644              The function can take one or two arguments, which  can  be  sup‐
24645              plied  either directly as command or arguments, or separately as
24646              shell parameters.
24647
24648                     print *(e:age 2006/10/04 2006/10/09:)
24649
24650              The example above matches all files modified between  the  start
24651              of those dates.  The second argument may alternatively be a rel‐
24652              ative time introduced by a +:
24653
24654                     print *(e:age 2006/10/04 +5d:)
24655
24656              The example above is equivalent to the previous example.
24657
24658              In addition to the special use of days of the  week,  today  and
24659              yesterday,  times  with no date may be specified; these apply to
24660              today.  Obviously such uses become problematic around midnight.
24661
24662                     print *(e-age 12:00 13:30-)
24663
24664              The example above shows files modified between 12:00  and  13:00
24665              today.
24666
24667                     print *(e:age 2006/10/04:)
24668
24669              The  example  above matches all files modified on that date.  If
24670              the second argument is omitted it is  taken  to  be  exactly  24
24671              hours  after the first argument (even if the first argument con‐
24672              tains a time).
24673
24674                     print *(e-age 2006/10/04:10:15 2006/10/04:10:45-)
24675
24676              The example above supplies times.  Note that  whitespace  within
24677              the time and date specification must be quoted to ensure age re‐
24678              ceives the correct arguments, hence the use  of  the  additional
24679              colon to separate the date and time.
24680
24681                     AGEREF=2006/10/04:10:15
24682                     AGEREF2=2006/10/04:10:45
24683                     print *(+age)
24684
24685              This  shows  the same example before using another form of argu‐
24686              ment passing.  The dates and times in the parameters AGEREF  and
24687              AGEREF2  stay  in  effect until unset, but will be overridden if
24688              any argument is passed as an explicit argument to age.  Any  ex‐
24689              plicit argument causes both parameters to be ignored.
24690
24691              Instead  of  an explicit date and time, it's possible to use the
24692              modification time of a file as the date and time for either  ar‐
24693              gument by introducing the file name with a colon:
24694
24695                     print *(e-age :file1-)
24696
24697              matches  all  files  created  on the same day (24 hours starting
24698              from midnight) as file1.
24699
24700                     print *(e-age :file1 :file2-)
24701
24702              matches all files modified no earlier than file1  and  no  later
24703              than file2; precision here is to the nearest second.
24704
24705       after
24706       before The  functions after and before are simpler versions of age that
24707              take just one argument.  The argument is parsed similarly to  an
24708              argument  of age; if it is not given the variable AGEREF is con‐
24709              sulted.  As the names of the functions suggest, a  file  matches
24710              if  its  modification  time is after or before the time and date
24711              specified.  If a time only is given the date is today.
24712
24713              The two following examples are therefore equivalent:
24714                     print *(e-after 12:00-)
24715                     print *(e-after today:12:00-)
24716

STYLES

24718       The zsh style mechanism using the zstyle command is describe in zshmod‐
24719       ules(1).  This is the same mechanism used in the completion system.
24720
24721       The  styles  below are all examined in the context :datetime:function:,
24722       for example :datetime:calendar:.
24723
24724       calendar-file
24725              The location of the main calendar.  The default is ~/calendar.
24726
24727       date-format
24728              A strftime format string (see strftime(3)) with the  zsh  exten‐
24729              sions providing various numbers with no leading zero or space if
24730              the number is a single digit as  described  for  the  %D{string}
24731              prompt  format  in  the section EXPANSION OF PROMPT SEQUENCES in
24732              zshmisc(1).
24733
24734              This is used for outputting dates in calendar, both  to  support
24735              the  -v option and when adding recurring events back to the cal‐
24736              endar file, and in calendar_showdate as the final output format.
24737
24738              If the style is not set, the default used is similar  the  stan‐
24739              dard  system format as output by the date command (also known as
24740              `ctime format'): `%a %b %d %H:%M:%S %Z %Y'.
24741
24742       done-file
24743              The location of the file to which events which have  passed  are
24744              appended.   The  default  is the calendar file location with the
24745              suffix .done.  The style may be set to an empty string in  which
24746              case a "done" file will not be maintained.
24747
24748       reformat-date
24749              Boolean, used by calendar_add.  If it is true, the date and time
24750              of new entries added to the calendar will be reformatted to  the
24751              format  given by the style date-format or its default.  Only the
24752              date and time of the event itself is reformatted; any subsidiary
24753              dates and times such as those associated with repeat and warning
24754              times are left alone.
24755
24756       show-prog
24757              The programme run by calendar for showing events.   It  will  be
24758              passed  the  start time and stop time of the events requested in
24759              seconds since the epoch followed by the event text.   Note  that
24760              calendar -s uses a start time and stop time equal to one another
24761              to indicate alerts for specific events.
24762
24763              The default is the function calendar_show.
24764
24765       warn-time
24766              The time before an event at which a warning will  be  displayed,
24767              if  the  first line of the event does not include the text EVENT
24768              reltime.  The default is 5 minutes.
24769

UTILITY FUNCTIONS

24771       calendar_lockfiles
24772              Attempt to lock the files given in  the  argument.   To  prevent
24773              problems  with  network  file  locking this is done in an ad hoc
24774              fashion by attempting to create a symbolic link to the file with
24775              the  name  file.lockfile.   No  other system level functions are
24776              used for locking, i.e. the file can be accessed and modified  by
24777              any  utility  that  does not use this mechanism.  In particular,
24778              the user is not prevented from editing the calendar file at  the
24779              same time unless calendar_edit is used.
24780
24781              Three  attempts  are made to lock the file before giving up.  If
24782              the module zsh/zselect is available, the times of  the  attempts
24783              are  jittered so that multiple instances of the calling function
24784              are unlikely to retry at the same time.
24785
24786              The files locked are appended  to  the  array  lockfiles,  which
24787              should be local to the caller.
24788
24789              If  all files were successfully locked, status zero is returned,
24790              else status one.
24791
24792              This function may be used as a general  file  locking  function,
24793              although  this  will only work if only this mechanism is used to
24794              lock files.
24795
24796       calendar_read
24797              This is a backend used by various other functions to  parse  the
24798              calendar  file, which is passed as the only argument.  The array
24799              calendar_entries is set to the list of events in  the  file;  no
24800              pruning  is  done  except  that  ampersands are removed from the
24801              start of the line.  Each entry may contain multiple lines.
24802
24803       calendar_scandate
24804              This is a generic function to parse dates and times that may  be
24805              used  separately  from  the  calendar system.  The argument is a
24806              date or time specification as described in the section FILE  AND
24807              DATE FORMATS above.  The parameter REPLY is set to the number of
24808              seconds since the epoch corresponding to that date or time.   By
24809              default,  the  date and time may occur anywhere within the given
24810              argument.
24811
24812              Returns status zero if  the  date  and  time  were  successfully
24813              parsed, else one.
24814
24815              Options:
24816              -a     The  date and time are anchored to the start of the argu‐
24817                     ment; they will not be  matched  if  there  is  preceding
24818                     text.
24819
24820              -A     The  date and time are anchored to both the start and end
24821                     of the argument; they will not be matched if the  is  any
24822                     other text in the argument.
24823
24824              -d     Enable additional debugging output.
24825
24826              -m     Minus.   When  -R  anchor_time is also given the relative
24827                     time is calculated backwards from anchor_time.
24828
24829              -r     The argument passed is to be parsed as a relative time.
24830
24831              -R anchor_time
24832                     The argument passed is to be parsed as a  relative  time.
24833                     The  time  is  relative to anchor_time, a time in seconds
24834                     since the epoch, and the returned value is  the  absolute
24835                     time  corresponding to advancing anchor_time by the rela‐
24836                     tive time given.  This allows lengths  of  months  to  be
24837                     correctly  taken into account.  If the final day does not
24838                     exist in the given month, the last day of the final month
24839                     is given.  For example, if the anchor time is during 31st
24840                     January 2007 and the relative time is 1 month, the  final
24841                     time is the same time of day during 28th February 2007.
24842
24843              -s     In addition to setting REPLY, set REPLY2 to the remainder
24844                     of the  argument  after  the  date  and  time  have  been
24845                     stripped.  This is empty if the option -A was given.
24846
24847              -t     Allow a time with no date specification.  The date is as‐
24848                     sumed to be today.  The behaviour is unspecified  if  the
24849                     iron tongue of midnight is tolling twelve.
24850
24851       calendar_show
24852              The  function  used  by default to display events.  It accepts a
24853              start time and end time for events, both in epoch  seconds,  and
24854              an event description.
24855
24856              The  event is always printed to standard output.  If the command
24857              line editor is active (which will usually be the case) the  com‐
24858              mand line will be redisplayed after the output.
24859
24860              If  the parameter DISPLAY is set and the start and end times are
24861              the same (indicating a scheduled event), the function  uses  the
24862              command xmessage to display a window with the event details.
24863

BUGS

24865       As  the system is based entirely on shell functions (with a little sup‐
24866       port from the zsh/datetime module) the mechanisms used are not  as  ro‐
24867       bust  as  those provided by a dedicated calendar utility.  Consequently
24868       the user should not rely on the shell for vital alerts.
24869
24870       There is no calendar_delete function.
24871
24872       There is no localization support for dates and times, nor  any  support
24873       for the use of time zones.
24874
24875       Relative periods of months and years do not take into account the vari‐
24876       able number of days.
24877
24878       The calendar_show function is currently hardwired to use  xmessage  for
24879       displaying  alerts on X Window System displays.  This should be config‐
24880       urable and ideally integrate better with the desktop.
24881
24882       calendar_lockfiles hangs the shell while waiting for a lock on a  file.
24883       If called from a scheduled task, it should instead reschedule the event
24884       that caused it.
24885
24886
24887
24888ZSHTCPSYS(1)                General Commands Manual               ZSHTCPSYS(1)
24889
24890
24891

NAME

24893       zshtcpsys - zsh tcp system
24894

DESCRIPTION

24896       A module zsh/net/tcp is provided to provide  network  I/O  over  TCP/IP
24897       from within the shell; see its description in zshmodules(1).  This man‐
24898       ual page describes a function suite based on the module.  If the module
24899       is  installed, the functions are usually installed at the same time, in
24900       which case they will be available for autoloading in the default  func‐
24901       tion  search path.  In addition to the zsh/net/tcp module, the zsh/zse‐
24902       lect module is used to implement  timeouts  on  read  operations.   For
24903       troubleshooting  tips,  consult  the  corresponding advice for the zftp
24904       functions described in zshzftpsys(1).
24905
24906       There are functions corresponding to the  basic  I/O  operations  open,
24907       close,  read  and  send,  named  tcp_open  etc.,  as well as a function
24908       tcp_expect for pattern match analysis of data read as input.  The  sys‐
24909       tem  makes it easy to receive data from and send data to multiple named
24910       sessions at once.  In addition, it can be linked with the shell's  line
24911       editor in such a way that input data is automatically shown at the ter‐
24912       minal.  Other facilities available  including  logging,  filtering  and
24913       configurable output prompts.
24914
24915       To  use  the  system where it is available, it should be enough to `au‐
24916       toload -U tcp_open' and run tcp_open as documented  below  to  start  a
24917       session.  The tcp_open function will autoload the remaining functions.
24918

TCP USER FUNCTIONS

24920   Basic I/O
24921       tcp_open [ -qz ] host port [ sess ]
24922       tcp_open [ -qz ] [ -s sess | -l sess[,...] ] ...
24923       tcp_open [ -qz ] [ -a fd | -f fd ] [ sess ]
24924              Open  a new session.  In the first and simplest form, open a TCP
24925              connection to host host at port port; numeric and symbolic forms
24926              are understood for both.
24927
24928              If sess is given, this becomes the name of the session which can
24929              be used to refer to multiple different TCP connections.  If sess
24930              is  not  given,  the  function  will invent a numeric name value
24931              (note this is not the same as the file descriptor to  which  the
24932              session  is attached).  It is recommended that session names not
24933              include `funny'  characters,  where  funny  characters  are  not
24934              well-defined  but  certainly do not include alphanumerics or un‐
24935              derscores, and certainly do include whitespace.
24936
24937              In the second case, one or more sessions to be opened are  given
24938              by  name.   A  single  session  name  is  given  after  -s and a
24939              comma-separated list after -l; both options may be  repeated  as
24940              many  times  as necessary.  A failure to open any session causes
24941              tcp_open to abort.  The host and port are  read  from  the  file
24942              .ztcp_sessions in the same directory as the user's zsh initiali‐
24943              sation files, i.e. usually the home directory, but  $ZDOTDIR  if
24944              that  is  set.  The file consists of lines each giving a session
24945              name and the corresponding host and port, in  that  order  (note
24946              the  session  name  comes  first, not last), separated by white‐
24947              space.
24948
24949              The third form allows passive and fake TCP connections.  If  the
24950              option  -a  is  used, its argument is a file descriptor open for
24951              listening for connections.  No function front-end is provided to
24952              open  such  a file descriptor, but a call to `ztcp -l port' will
24953              create one with the file descriptor stored in the parameter $RE‐
24954              PLY.   The  listening  port  can be closed with `ztcp -c fd'.  A
24955              call to `tcp_open -a fd' will block until a remote  TCP  connec‐
24956              tion  is  made  to  port on the local machine.  At this point, a
24957              session is created in the usual way  and  is  largely  indistin‐
24958              guishable  from  an  active  connection  created with one of the
24959              first two forms.
24960
24961              If the option -f is used, its  argument  is  a  file  descriptor
24962              which  is  used  directly as if it were a TCP session.  How well
24963              the remainder of the TCP function system copes with this depends
24964              on what actually underlies this file descriptor.  A regular file
24965              is likely to be unusable; a FIFO (pipe) of some sort  will  work
24966              better,  but  note  that it is not a good idea for two different
24967              sessions to attempt to read from the same FIFO at once.
24968
24969              If the option -q is given with any of the three forms,  tcp_open
24970              will  not  print informational messages, although it will in any
24971              case exit with an appropriate status.
24972
24973              If the line editor (zle) is in use, which is typically the  case
24974              if  the shell is interactive, tcp_open installs a handler inside
24975              zle which will check for new data at the same time as it  checks
24976              for keyboard input.  This is convenient as the shell consumes no
24977              CPU time while waiting; the test is performed by  the  operating
24978              system.   Giving  the  option -z to any of the forms of tcp_open
24979              prevents the handler from being installed, so data must be  read
24980              explicitly.   Note, however, this is not necessary for executing
24981              complete sets of send and read commands from a function, as  zle
24982              is not active at this point.  Generally speaking, the handler is
24983              only active when the shell is waiting for  input  at  a  command
24984              prompt or in the vared builtin.  The option has no effect if zle
24985              is not active; `[[ -o zle]]' will test for this.
24986
24987              The first session to be opened becomes the current  session  and
24988              subsequent calls to tcp_open do not change it.  The current ses‐
24989              sion is stored in the parameter $TCP_SESS; see  below  for  more
24990              detail about the parameters used by the system.
24991
24992              The  function  tcp_on_open, if defined, is called when a session
24993              is opened.  See the description below.
24994
24995       tcp_close [ -qn ] [ -a | -l sess[,...] | sess ... ]
24996              Close the named sessions, or the  current  session  if  none  is
24997              given,  or all open sessions if -a is given.  The options -l and
24998              -s are both handled for consistency with tcp_open, although  the
24999              latter is redundant.
25000
25001              If the session being closed is the current one, $TCP_SESS is un‐
25002              set, leaving no current session, even if there  are  other  ses‐
25003              sions still open.
25004
25005              If  the session was opened with tcp_open -f, the file descriptor
25006              is closed so long as it is in the range 0 to  9  accessible  di‐
25007              rectly from the command line.  If the option -n is given, no at‐
25008              tempt will be made to close file descriptors in this case.   The
25009              -n  option  is  not  used for genuine ztcp session; the file de‐
25010              scriptors are always closed with the session.
25011
25012              If the option -q is given, no  informational  messages  will  be
25013              printed.
25014
25015
25016       tcp_read [ -bdq ] [ -t TO ] [ -T TO ]
25017                [ -a | -u fd[,...] | -l sess[,...] | -s sess ... ]
25018              Perform a read operation on the current session, or on a list of
25019              sessions if any are given with -u, -l or -s, or  all  open  ses‐
25020              sions  if  the  option -a is given.  Any of the -u, -l or -s op‐
25021              tions may be repeated or mixed together.  The -u  option  speci‐
25022              fies a file descriptor directly (only those managed by this sys‐
25023              tem are useful), the other two specify sessions as described for
25024              tcp_open above.
25025
25026              The  function  checks for new data available on all the sessions
25027              listed.  Unless the -b option is given, it will not block  wait‐
25028              ing  for  new data.  Any one line of data from any of the avail‐
25029              able sessions will be read, stored in the  parameter  $TCP_LINE,
25030              and  displayed  to standard output unless $TCP_SILENT contains a
25031              non-empty string.  When printed to standard  output  the  string
25032              $TCP_PROMPT  will be shown at the start of the line; the default
25033              form for this includes the name of the session being read.   See
25034              below  for  more information on these parameters.  In this mode,
25035              tcp_read can be called repeatedly  until  it  returns  status  2
25036              which  indicates  all  pending input from all specified sessions
25037              has been handled.
25038
25039              With the option -b, equivalent to an infinite timeout, the func‐
25040              tion  will  block  until a line is available to read from one of
25041              the specified sessions.  However, only  a  single  line  is  re‐
25042              turned.
25043
25044              The  option  -d  indicates  that  all  pending  input  should be
25045              drained.  In this case tcp_read may process  multiple  lines  in
25046              the  manner  given  above; only the last is stored in $TCP_LINE,
25047              but the complete set is stored in the array $tcp_lines.  This is
25048              cleared at the start of each call to tcp_read.
25049
25050              The options -t and -T specify a timeout in seconds, which may be
25051              a floating point number for increased  accuracy.   With  -t  the
25052              timeout  is applied before each line read.  With -T, the timeout
25053              applies to the overall operation,  possibly  including  multiple
25054              read  operations  if  the option -d is present; without this op‐
25055              tion, there is no distinction between -t and -T.
25056
25057              The function does not print informational messages, but  if  the
25058              option  -q is given, no error message is printed for a non-exis‐
25059              tent session.
25060
25061              A return status of 2 indicates a timeout or  no  data  to  read.
25062              Any other non-zero return status indicates some error condition.
25063
25064              See tcp_log for how to control where data is sent by tcp_read.
25065
25066       tcp_send [ -cnq ] [ -s sess | -l sess[,...] ] data ...
25067       tcp_send [ -cnq ] -a data ...
25068              Send  the supplied data strings to all the specified sessions in
25069              turn.  The underlying operation differs little from a `print -r'
25070              to  the  session's file descriptor, although it attempts to pre‐
25071              vent the shell from dying owing to a SIGPIPE caused  by  an  at‐
25072              tempt to write to a defunct session.
25073
25074              The  option  -c  causes  tcp_send  to behave like cat.  It reads
25075              lines from standard input until end of input and sends  them  in
25076              turn  to  the specified session(s) exactly as if they were given
25077              as data arguments to individual tcp_send commands.
25078
25079              The option -n prevents tcp_send from putting a  newline  at  the
25080              end of the data strings.
25081
25082              The remaining options all behave as for tcp_read.
25083
25084              The data arguments are not further processed once they have been
25085              passed to tcp_send; they are simply passed down to print -r.
25086
25087              If the parameter $TCP_OUTPUT is a non-empty string  and  logging
25088              is  enabled then the data sent to each session will be echoed to
25089              the log file(s) with $TCP_OUTPUT  in  front  where  appropriate,
25090              much in the manner of $TCP_PROMPT.
25091
25092   Session Management
25093       tcp_alias [ -q ] alias=sess ...
25094       tcp_alias [ -q ] [ alias ... ]
25095       tcp_alias -d [ -q ] alias ...
25096              This function is not particularly well tested.
25097
25098              The  first  form  creates an alias for a session name; alias can
25099              then be used to refer to the existing  session  sess.   As  many
25100              aliases may be listed as required.
25101
25102              The  second  form lists any aliases specified, or all aliases if
25103              none.
25104
25105              The third form deletes all the aliases listed.   The  underlying
25106              sessions are not affected.
25107
25108              The  option -q suppresses an inconsistently chosen subset of er‐
25109              ror messages.
25110
25111       tcp_log [ -asc ] [ -n | -N ] [ logfile ]
25112              With an argument logfile, all future input from tcp_read will be
25113              logged  to  the  named  file.  Unless -a (append) is given, this
25114              file will first be truncated or created empty.   With  no  argu‐
25115              ments, show the current status of logging.
25116
25117              With  the option -s, per-session logging is enabled.  Input from
25118              tcp_read is output to the file logfile.sess.  As the session  is
25119              automatically  discriminated  by  the filename, the contents are
25120              raw  (no  $TCP_PROMPT).   The  option   -a  applies  as   above.
25121              Per-session  logging and logging of all data in one file are not
25122              mutually exclusive.
25123
25124              The option -c closes all logging, both complete and  per-session
25125              logs.
25126
25127              The options -n and -N respectively turn off or restore output of
25128              data read by tcp_read to standard output;  hence  `tcp_log  -cn'
25129              turns off all output by tcp_read.
25130
25131              The function is purely a convenient front end to setting the pa‐
25132              rameters $TCP_LOG, $TCP_LOG_SESS,  $TCP_SILENT,  which  are  de‐
25133              scribed below.
25134
25135       tcp_rename old new
25136              Rename  session  old  to  session new.  The old name becomes in‐
25137              valid.
25138
25139       tcp_sess [ sess [ command [ arg ... ] ] ]
25140              With no arguments, list all the  open  sessions  and  associated
25141              file  descriptors.   The  current session is marked with a star.
25142              For  use  in  functions,  direct  access   to   the   parameters
25143              $tcp_by_name,  $tcp_by_fd  and $TCP_SESS is probably more conve‐
25144              nient; see below.
25145
25146              With a sess argument, set the current session to sess.  This  is
25147              equivalent to changing $TCP_SESS directly.
25148
25149              With  additional  arguments, temporarily set the current session
25150              while executing `command arg ...'.  command is  re-evaluated  so
25151              as  to  expand  aliases  etc., but the remaining args are passed
25152              through as that appear to tcp_sess.  The original session is re‐
25153              stored when tcp_sess exits.
25154
25155   Advanced I/O
25156       tcp_command send-option ... send-argument ...
25157              This  is  a convenient front-end to tcp_send.  All arguments are
25158              passed to tcp_send, then the function pauses waiting  for  data.
25159              While data is arriving at least every $TCP_TIMEOUT (default 0.3)
25160              seconds, data is handled and printed out according to  the  cur‐
25161              rent settings.  Status 0 is always returned.
25162
25163              This  is  generally  only useful for interactive use, to prevent
25164              the display becoming fragmented by output returned from the con‐
25165              nection.   Within a programme or function it is generally better
25166              to handle reading data by a more explicit method.
25167
25168
25169       tcp_expect [ -q ] [ -p var | -P var ] [ -t TO | -T TO ]
25170                  [ -a | -s sess | -l sess[,...] ] pattern ...
25171              Wait for input matching any of the given patterns  from  any  of
25172              the  specified  sessions.   Input is ignored until an input line
25173              matches one of the given patterns; at this point status zero  is
25174              returned, the matching line is stored in $TCP_LINE, and the full
25175              set of lines read during the call to tcp_expect is stored in the
25176              array $tcp_expect_lines.
25177
25178              Sessions  are specified in the same way as tcp_read: the default
25179              is to use the current session, otherwise the sessions  specified
25180              by -a, -s, or -l are used.
25181
25182              Each  pattern  is a standard zsh extended-globbing pattern; note
25183              that it needs to be quoted to avoid it  being  expanded  immedi‐
25184              ately  by  filename generation.  It must match the full line, so
25185              to match a substring there must be a `*' at the start  and  end.
25186              The  line  matched  against  includes  the  $TCP_PROMPT added by
25187              tcp_read.  It is possible to include the globbing flags `#b'  or
25188              `#m' in the patterns to make backreferences available in the pa‐
25189              rameters $MATCH, $match, etc., as described in the base zsh doc‐
25190              umentation on pattern matching.
25191
25192              Unlike tcp_read, the default behaviour of tcp_expect is to block
25193              indefinitely until the required input is  found.   This  can  be
25194              modified  by  specifying a timeout with -t or -T; these function
25195              as in tcp_read, specifying a per-read or  overall  timeout,  re‐
25196              spectively,  in seconds, as an integer or floating-point number.
25197              As tcp_read, the function returns status 2 if a timeout occurs.
25198
25199              The function returns as soon as any one of  the  patterns  given
25200              match.   If  the  caller  needs  to  know  which of the patterns
25201              matched, the option -p var can be used; on return, $var  is  set
25202              to  the  number of the pattern using ordinary zsh indexing, i.e.
25203              the first is 1, and so on.  Note the absence of a `$'  in  front
25204              of var.  To avoid clashes, the parameter cannot begin with `_ex‐
25205              pect'.  The index -1 is used if there is  a  timeout  and  0  if
25206              there is no match.
25207
25208              The  option -P var works similarly to -p, but instead of numeri‐
25209              cal indexes the regular arguments must begin with a prefix  fol‐
25210              lowed by a colon: that prefix is then used as a tag to which var
25211              is set when the argument matches.  The tag timeout  is  used  if
25212              there  is  a  timeout and the empty string if there is no match.
25213              Note it is acceptable for different arguments to start with  the
25214              same prefix if the matches do not need to be distinguished.
25215
25216              The option -q is passed directly down to tcp_read.
25217
25218              As  all  input  is  done via tcp_read, all the usual rules about
25219              output of lines read apply.  One exception is that the parameter
25220              $tcp_lines  will  only  reflect  the  line  actually  matched by
25221              tcp_expect; use $tcp_expect_lines for the full set of lines read
25222              during the function call.
25223
25224       tcp_proxy
25225              This  is a simple-minded function to accept a TCP connection and
25226              execute a command with I/O redirected to  the  connection.   Ex‐
25227              treme caution should be taken as there is no security whatsoever
25228              and this can leave your computer open to the world.  Ideally, it
25229              should only be used behind a firewall.
25230
25231              The first argument is a TCP port on which the function will lis‐
25232              ten.
25233
25234              The remaining arguments give a command and its arguments to exe‐
25235              cute  with  standard  input,  standard output and standard error
25236              redirected to the file descriptor on which the TCP  session  has
25237              been  accepted.   If  no command is given, a new zsh is started.
25238              This gives everyone on your network direct access  to  your  ac‐
25239              count, which in many cases will be a bad thing.
25240
25241              The  command is run in the background, so tcp_proxy can then ac‐
25242              cept new connections.  It continues to  accept  new  connections
25243              until interrupted.
25244
25245       tcp_spam [ -ertv ] [ -a | -s sess | -l sess[,...] ] cmd [ arg ... ]
25246              Execute  `cmd  [ arg ... ]' for each session in turn.  Note this
25247              executes the command and arguments; it does not send the command
25248              line as data unless the -t (transmit) option is given.
25249
25250              The sessions may be selected explicitly with the standard -a, -s
25251              or -l options, or may be chosen  implicitly.   If  none  of  the
25252              three  options  is  given  the  rules  are:  first, if the array
25253              $tcp_spam_list is set, this is taken as the  list  of  sessions,
25254              otherwise all sessions are taken.  Second, any sessions given in
25255              the array $tcp_no_spam_list are removed from the  list  of  ses‐
25256              sions.
25257
25258              Normally,  any  sessions added by the `-a' flag or when all ses‐
25259              sions are chosen implicitly are  spammed  in  alphabetic  order;
25260              sessions  given  by  the  $tcp_spam_list array or on the command
25261              line are spammed in the order given.  The -r flag  reverses  the
25262              order however it was arrived it.
25263
25264              The  -v  flag specifies that a $TCP_PROMPT will be output before
25265              each session.  This is output after any modification to TCP_SESS
25266              by  the user-defined tcp_on_spam function described below.  (Ob‐
25267              viously that function is able to generate its own output.)
25268
25269              If the option -e is present, the line given as `cmd [ arg ... ]'
25270              is  executed  using  eval,  otherwise it is executed without any
25271              further processing.
25272
25273       tcp_talk
25274              This is a fairly simple-minded attempt to  force  input  to  the
25275              line editor to go straight to the default TCP_SESS.
25276
25277              An  escape string, $TCP_TALK_ESCAPE, default `:', is used to al‐
25278              low access to normal shell operation.  If it is on  its  own  at
25279              the  start of the line, or followed only by whitespace, the line
25280              editor returns to normal operation.  Otherwise, the  string  and
25281              any  following  whitespace  are skipped and the remainder of the
25282              line executed as shell input without any change of the line edi‐
25283              tor's operating mode.
25284
25285              The current implementation is somewhat deficient in terms of use
25286              of the command history.  For this reason, many users will prefer
25287              to use some form of alternative approach for sending data easily
25288              to the current session.  One simple approach is  to  alias  some
25289              special character (such as `%') to `tcp_command --'.
25290
25291       tcp_wait
25292              The  sole  argument is an integer or floating point number which
25293              gives the seconds to delay.  The shell will do nothing for  that
25294              period  except  wait  for  input  on all TCP sessions by calling
25295              tcp_read -a.  This is similar to the  interactive  behaviour  at
25296              the command prompt when zle handlers are installed.
25297
25298   `One-shot' file transfer
25299       tcp_point port
25300       tcp_shoot host port
25301              This  pair  of functions provide a simple way to transfer a file
25302              between two hosts within the shell.  Note,  however,  that  bulk
25303              data  transfer is currently done using cat.  tcp_point reads any
25304              data arriving at port and sends it to standard output; tcp_shoot
25305              connects  to port on host and sends its standard input.  Any un‐
25306              used port may be used; the standard mechanism for picking a port
25307              is  to  think of a random four-digit number above 1024 until one
25308              works.
25309
25310              To transfer a file from  host  woodcock  to  host  springes,  on
25311              springes:
25312
25313                     tcp_point 8091 >output_file
25314
25315              and on woodcock:
25316
25317                     tcp_shoot springes 8091 <input_file
25318
25319              As  these  two functions do not require tcp_open to set up a TCP
25320              connection first, they may need to be autoloaded separately.
25321

TCP USER-DEFINED FUNCTIONS

25323       Certain functions, if defined by the user, will be called by the  func‐
25324       tion  system  in certain contexts.  This facility depends on the module
25325       zsh/parameter, which is usually available in interactive shells as  the
25326       completion  system  depends  on  it.  None of the functions need be de‐
25327       fined; they simply provide convenient hooks when necessary.
25328
25329       Typically, these are called after the requested action has been  taken,
25330       so that the various parameters will reflect the new state.
25331
25332       tcp_on_alias alias fd
25333              When  an alias is defined, this function will be called with two
25334              arguments: the name of the alias, and the file descriptor of the
25335              corresponding session.
25336
25337       tcp_on_awol sess fd
25338              If  the  function tcp_fd_handler is handling input from the line
25339              editor and detects that the file descriptor is no  longer  reus‐
25340              able, by default it removes it from the list of file descriptors
25341              handled by this method and prints a message.   If  the  function
25342              tcp_on_awol  is  defined  it  is  called immediately before this
25343              point.  It may return status 100, which indicates that the  nor‐
25344              mal  handling should still be performed; any other return status
25345              indicates that  no  further  action  should  be  taken  and  the
25346              tcp_fd_handler  should return immediately with the given status.
25347              Typically the action of tcp_on_awol will be to  close  the  ses‐
25348              sion.
25349
25350              The variable TCP_INVALIDATE_ZLE will be a non-empty string if it
25351              is necessary to invalidate the line editor  display  using  `zle
25352              -I' before printing output from the function.
25353
25354              (`AWOL'  is  military  jargon for `absent without leave' or some
25355              variation.  It has no pre-existing technical  meaning  known  to
25356              the author.)
25357
25358       tcp_on_close sess fd
25359              This  is  called with the name of a session being closed and the
25360              file descriptor which corresponded to that session.   Both  will
25361              be invalid by the time the function is called.
25362
25363       tcp_on_open sess fd
25364              This  is  called  after  a new session has been defined with the
25365              session name and file descriptor as arguments.  If it returns  a
25366              non-zero  status, opening the session is assumed to fail and the
25367              session is closed again; however, tcp_open will continue to  at‐
25368              tempt to open any remaining sessions given on the command line.
25369
25370       tcp_on_rename oldsess fd newsess
25371              This  is  called after a session has been renamed with the three
25372              arguments old session name, file descriptor, new session name.
25373
25374       tcp_on_spam sess command ...
25375              This is called once for each session spammed, just before a com‐
25376              mand  is  executed for a session by tcp_spam.  The arguments are
25377              the session name followed by the command list  to  be  executed.
25378              If  tcp_spam  was  called  with the option -t, the first command
25379              will be tcp_send.
25380
25381              This function is called after $TCP_SESS is set  to  reflect  the
25382              session  to be spammed, but before any use of it is made.  Hence
25383              it is possible to alter the value of $TCP_SESS within this func‐
25384              tion.   For example, the session arguments to tcp_spam could in‐
25385              clude extra information to be  stripped  off  and  processed  in
25386              tcp_on_spam.
25387
25388              If the function sets the parameter $REPLY to `done', the command
25389              line is not executed; in addition, no prompt is printed for  the
25390              -v option to tcp_spam.
25391
25392       tcp_on_unalias alias fd
25393              This  is  called with the name of an alias and the corresponding
25394              session's file descriptor after an alias has been deleted.
25395

TCP UTILITY FUNCTIONS

25397       The following functions are used by the TCP function  system  but  will
25398       rarely if ever need to be called directly.
25399
25400       tcp_fd_handler
25401              This  is  the  function installed by tcp_open for handling input
25402              from within the line editor, if that is required.  It is in  the
25403              format documented for the builtin `zle -F' in zshzle(1) .
25404
25405              While active, the function sets the parameter TCP_HANDLER_ACTIVE
25406              to 1.  This allows shell code called internally (for example, by
25407              setting  tcp_on_read)  to tell if is being called when the shell
25408              is otherwise idle at the editor prompt.
25409
25410       tcp_output [ -q ] -P prompt -F fd -S sess
25411              This function is used for both logging and  handling  output  to
25412              standard  output,  from  within  tcp_read and (if $TCP_OUTPUT is
25413              set) tcp_send.
25414
25415              The prompt to use is specified by -P; the default is  the  empty
25416              string.  It can contain:
25417              %c     Expands  to 1 if the session is the current session, oth‐
25418                     erwise  0.   Used  with  ternary  expressions   such   as
25419                     `%(c.-.+)'  to output `+' for the current session and `-'
25420                     otherwise.
25421
25422              %f     Replaced by the session's file descriptor.
25423
25424              %s     Replaced by the session name.
25425
25426              %%     Replaced by a single `%'.
25427
25428              The option -q suppresses output to standard output, but  not  to
25429              any log files which are configured.
25430
25431              The  -S  and -F options are used to pass in the session name and
25432              file descriptor for possible replacement in the prompt.
25433

TCP USER PARAMETERS

25435       Parameters follow the usual  convention  that  uppercase  is  used  for
25436       scalars  and  integers, while lowercase is used for normal and associa‐
25437       tive array.  It is always safe for user code to read these  parameters.
25438       Some  parameters  may  also be set; these are noted explicitly.  Others
25439       are included in this group as they are set by the function  system  for
25440       the  user's  benefit,  i.e. setting them is typically not useful but is
25441       benign.
25442
25443       It is often also useful to make settable parameters local  to  a  func‐
25444       tion.   For example, `local TCP_SILENT=1' specifies that data read dur‐
25445       ing the function call will not be printed to standard  output,  regard‐
25446       less   of   the   setting   outside  the  function.   Likewise,  `local
25447       TCP_SESS=sess' sets a session for the duration of a function, and  `lo‐
25448       cal  TCP_PROMPT=' specifies that no prompt is used for input during the
25449       function.
25450
25451       tcp_expect_lines
25452              Array.  The set of lines read during the last  call  to  tcp_ex‐
25453              pect, including the last ($TCP_LINE).
25454
25455       tcp_filter
25456              Array. May be set directly.  A set of extended globbing patterns
25457              which, if matched in tcp_output, will cause the line not  to  be
25458              printed  to  standard output.  The patterns should be defined as
25459              described for the arguments to tcp_expect.  Output  of  line  to
25460              log files is not affected.
25461
25462       TCP_HANDLER_ACTIVE
25463              Scalar.  Set to 1 within tcp_fd_handler to indicate to functions
25464              called recursively that they have been called during  an  editor
25465              session.  Otherwise unset.
25466
25467       TCP_LINE
25468              The last line read by tcp_read, and hence also tcp_expect.
25469
25470       TCP_LINE_FD
25471              The   file   descriptor   from   which   $TCP_LINE   was   read.
25472              ${tcp_by_fd[$TCP_LINE_FD]} will give the  corresponding  session
25473              name.
25474
25475       tcp_lines
25476              Array.  The  set of lines read during the last call to tcp_read,
25477              including the last ($TCP_LINE).
25478
25479       TCP_LOG
25480              May be set directly, although it is also controlled by  tcp_log.
25481              The  name  of  a  file to which output from all sessions will be
25482              sent.  The output is proceeded by the usual $TCP_PROMPT.  If  it
25483              is  not an absolute path name, it will follow the user's current
25484              directory.
25485
25486       TCP_LOG_SESS
25487              May be set directly, although it is also controlled by  tcp_log.
25488              The  prefix for a set of files to which output from each session
25489              separately   will   be    sent;    the    full    filename    is
25490              ${TCP_LOG_SESS}.sess.   Output to each file is raw; no prompt is
25491              added.  If it is not an absolute path name, it will  follow  the
25492              user's current directory.
25493
25494       tcp_no_spam_list
25495              Array.  May be set directly.  See tcp_spam for how this is used.
25496
25497       TCP_OUTPUT
25498              May  be set directly.  If a non-empty string, any data sent to a
25499              session by tcp_send will be logged.  This  parameter  gives  the
25500              prompt  to  be used in a file specified by $TCP_LOG but not in a
25501              file generated from $TCP_LOG_SESS.  The prompt  string  has  the
25502              same format as TCP_PROMPT and the same rules for its use apply.
25503
25504       TCP_PROMPT
25505              May  be  set  directly.   Used  as  the  prefix for data read by
25506              tcp_read which is printed to standard output or to the log  file
25507              given  by $TCP_LOG, if any.  Any `%s', `%f' or `%%' occurring in
25508              the string will be replaced by the name of the session, the ses‐
25509              sion's  underlying  file  descriptor,  or  a single `%', respec‐
25510              tively.  The expression `%c' expands to 1 if the  session  being
25511              read  is  the  current  session,  else 0; this is most useful in
25512              ternary expressions such as `%(c.-.+)' which outputs `+' if  the
25513              session is the current one, else `-'.
25514
25515              If  the prompt starts with %P, this is stripped and the complete
25516              result of the previous stage is passed through  standard  prompt
25517              %-style formatting before being output.
25518
25519       TCP_READ_DEBUG
25520              May be set directly.  If this has non-zero length, tcp_read will
25521              give some limited diagnostics about data being read.
25522
25523       TCP_SECONDS_START
25524              This value is created and initialised to zero by tcp_open.
25525
25526              The functions tcp_read and tcp_expect use  the  shell's  SECONDS
25527              parameter  for  their own timing purposes.  If that parameter is
25528              not of floating point type on entry to one of the functions,  it
25529              will  create  a  local parameter SECONDS which is floating point
25530              and set the parameter TCP_SECONDS_START to the previous value of
25531              $SECONDS.   If  the  parameter  is already floating point, it is
25532              used without a local copy being created and TCP_SECONDS_START is
25533              not set.  As the global value is zero, the shell elapsed time is
25534              guaranteed to be the sum of $SECONDS and $TCP_SECONDS_START.
25535
25536              This can be avoided by setting SECONDS globally  to  a  floating
25537              point  value  using `typeset -F SECONDS'; then the TCP functions
25538              will never make a local copy and never set TCP_SECONDS_START  to
25539              a non-zero value.
25540
25541       TCP_SESS
25542              May  be set directly.  The current session; must refer to one of
25543              the sessions established by tcp_open.
25544
25545       TCP_SILENT
25546              May be set directly, although it is also controlled by  tcp_log.
25547              If of non-zero length, data read by tcp_read will not be written
25548              to standard output, though may still be written to a log file.
25549
25550       tcp_spam_list
25551              Array.  May be set directly.  See the description of  the  func‐
25552              tion tcp_spam for how this is used.
25553
25554       TCP_TALK_ESCAPE
25555              May  be  set  directly.   See  the  description  of the function
25556              tcp_talk for how this is used.
25557
25558       TCP_TIMEOUT
25559              May be set directly.  Currently this is only used by  the  func‐
25560              tion tcp_command, see above.
25561

TCP USER-DEFINED PARAMETERS

25563       The following parameters are not set by the function system, but have a
25564       special effect if set by the user.
25565
25566       tcp_on_read
25567              This should be an associative array; if it is not, the behaviour
25568              is undefined.  Each key is the name of a shell function or other
25569              command, and the corresponding value is a shell  pattern  (using
25570              EXTENDED_GLOB).   Every line read from a TCP session directly or
25571              indirectly using tcp_read (which includes lines read by  tcp_ex‐
25572              pect) is compared against the pattern.  If the line matches, the
25573              command given in the key is called with two arguments: the  name
25574              of  the  session  from which the line was read, and the line it‐
25575              self.
25576
25577              If any function called to handle a line returns a non-zero  sta‐
25578              tus,  the  line  is not output.  Thus a tcp_on_read handler con‐
25579              taining only the instruction `return 1' can be used to  suppress
25580              output  of  particular  lines  (see, however, tcp_filter above).
25581              However, the line is still stored  in  TCP_LINE  and  tcp_lines;
25582              this occurs after all tcp_on_read processing.
25583

TCP UTILITY PARAMETERS

25585       These  parameters  are  controlled  by the function system; they may be
25586       read directly, but should not usually be set by user code.
25587
25588       tcp_aliases
25589              Associative array.  The keys are the names  of  sessions  estab‐
25590              lished  with  tcp_open;  each value is a space-separated list of
25591              aliases which refer to that session.
25592
25593       tcp_by_fd
25594              Associative array.  The keys are session file descriptors;  each
25595              value is the name of that session.
25596
25597       tcp_by_name
25598              Associative  array.   The  keys  are the names of sessions; each
25599              value is the file descriptor associated with that session.
25600

TCP EXAMPLES

25602       Here is a trivial example using a remote calculator.
25603
25604       To create a calculator server on port 7337 (see the dc manual page  for
25605       quite how infuriating the underlying command is):
25606
25607              tcp_proxy 7337 dc
25608
25609       To connect to this from the same host with a session also named `dc':
25610
25611              tcp_open localhost 7337 dc
25612
25613       To send a command to the remote session and wait a short while for out‐
25614       put (assuming dc is the current session):
25615
25616              tcp_command 2 4 + p
25617
25618       To close the session:
25619
25620              tcp_close
25621
25622       The tcp_proxy needs to be killed to be stopped.   Note  this  will  not
25623       usually kill any connections which have already been accepted, and also
25624       that the port is not immediately available for reuse.
25625
25626       The following chunk of code puts a  list  of  sessions  into  an  xterm
25627       header, with the current session followed by a star.
25628
25629              print -n "\033]2;TCP:" ${(k)tcp_by_name:/$TCP_SESS/$TCP_SESS\*} "\a"
25630

TCP BUGS

25632       The  function  tcp_read  uses the shell's normal read builtin.  As this
25633       reads a complete line at once, data arriving without a terminating new‐
25634       line can cause the function to block indefinitely.
25635
25636       Though  the  function suite works well for interactive use and for data
25637       arriving in small amounts, the performance when large amounts  of  data
25638       are being exchanged is likely to be extremely poor.
25639
25640
25641
25642ZSHZFTPSYS(1)               General Commands Manual              ZSHZFTPSYS(1)
25643
25644
25645

NAME

25647       zshzftpsys - zftp function front-end
25648

DESCRIPTION

25650       This describes the set of shell functions supplied with the source dis‐
25651       tribution as an interface to the zftp builtin command, allowing you  to
25652       perform  FTP operations from the shell command line or within functions
25653       or scripts.  The interface is similar to a traditional FTP client (e.g.
25654       the  ftp command itself, see ftp(1)), but as it is entirely done within
25655       the shell all the familiar completion, editing and  globbing  features,
25656       and  so on, are present, and macros are particularly simple to write as
25657       they are just ordinary shell functions.
25658
25659       The prerequisite is that the zftp  command,  as  described  in  zshmod‐
25660       ules(1)  ,  must  be  available in the version of zsh installed at your
25661       site.  If the shell is configured to load new commands at run time,  it
25662       probably  is:  typing  `zmodload zsh/zftp' will make sure (if that runs
25663       silently, it has worked).  If this is not the case, it is possible zftp
25664       was  linked  into the shell anyway: to test this, type `which zftp' and
25665       if zftp is available you will get the  message  `zftp:  shell  built-in
25666       command'.
25667
25668       Commands  given  directly with zftp builtin may be interspersed between
25669       the functions in this suite; in a few cases, using  zftp  directly  may
25670       cause  some of the status information stored in shell parameters to be‐
25671       come invalid.  Note in particular  the  description  of  the  variables
25672       $ZFTP_TMOUT, $ZFTP_PREFS and $ZFTP_VERBOSE for zftp.
25673

INSTALLATION

25675       You  should  make sure all the functions from the Functions/Zftp direc‐
25676       tory of the source distribution are available; they all begin with  the
25677       two letters `zf'.  They may already have been installed on your system;
25678       otherwise, you will need to find them and  copy  them.   The  directory
25679       should  appear  as one of the elements of the $fpath array (this should
25680       already be the case if they were installed), and at least the  function
25681       zfinit  should  be  autoloaded; it will autoload the rest.  Finally, to
25682       initialize the use of the system you need to call the zfinit  function.
25683       The  following  code  in  your .zshrc will arrange for this; assume the
25684       functions are stored in the directory ~/myfns:
25685
25686              fpath=(~/myfns $fpath)
25687              autoload -U zfinit
25688              zfinit
25689
25690       Note that zfinit assumes you are using the zmodload method to load  the
25691       zftp  command.  If it is already built into the shell, change zfinit to
25692       zfinit -n.  It is helpful (though not essential) if the call to  zfinit
25693       appears  after  any  code to initialize the new completion system, else
25694       unnecessary compctl commands will be given.
25695

FUNCTIONS

25697       The sequence of operations in performing a file transfer is essentially
25698       the  same  as that in a standard FTP client.  Note that, due to a quirk
25699       of the shell's getopts builtin, for those functions that handle options
25700       you must use `--' rather than `-' to ensure the remaining arguments are
25701       treated literally (a single `-' is treated as an argument).
25702
25703   Opening a connection
25704       zfparams [ host [ user [ password ... ] ] ]
25705              Set or show the parameters for a future  zfopen  with  no  argu‐
25706              ments.   If  no  arguments are given, the current parameters are
25707              displayed (the password will be shown as a line  of  asterisks).
25708              If a host is given, and either the user or password is not, they
25709              will be prompted for; also, any parameter given as `?'  will  be
25710              prompted  for, and if the `?' is followed by a string, that will
25711              be used as the prompt.  As zfopen calls zfparams  to  store  the
25712              parameters, this usually need not be called directly.
25713
25714              A  single  argument `-' will delete the stored parameters.  This
25715              will also cause the memory of the last directory (and so on)  on
25716              the other host to be deleted.
25717
25718       zfopen [ -1 ] [ host [ user [ password [ account ] ] ] ]
25719              If  host  is present, open a connection to that host under user‐
25720              name user with password password (and,  on  the  rare  occasions
25721              when  it is necessary, account account).  If a necessary parame‐
25722              ter is missing or given as `?' it will be prompted for.  If host
25723              is not present, use a previously stored set of parameters.
25724
25725              If  the  command  was successful, and the terminal is compatible
25726              with xterm or is sun-cmd, a summary will  appear  in  the  title
25727              bar,  giving the local host:directory and the remote host:direc‐
25728              tory; this is handled by the function zftp_chpwd, described  be‐
25729              low.
25730
25731              Normally,  the  host,  user and password are internally recorded
25732              for later re-opening, either by a zfopen with no  arguments,  or
25733              automatically (see below).  With the option `-1', no information
25734              is stored.  Also, if an open command with arguments failed,  the
25735              parameters  will  not  be  retained (and any previous parameters
25736              will also be deleted).  A zfopen on its own,  or  a  zfopen  -1,
25737              never alters the stored parameters.
25738
25739              Both zfopen and zfanon (but not zfparams) understand URLs of the
25740              form ftp://host/path... as meaning to connect to the host,  then
25741              change  directory  to  path  (which  must  be a directory, not a
25742              file).  The `ftp://' can be omitted; the trailing `/' is  enough
25743              to  trigger  recognition  of the path.  Note prefixes other than
25744              `ftp:' are not recognized, and that  all  characters  after  the
25745              first slash beyond host are significant in path.
25746
25747       zfanon [ -1 ] host
25748              Open  a connection host for anonymous FTP.  The username used is
25749              `anonymous'.  The password (which will  be  reported  the  first
25750              time)  is  generated  as  user@host;  this is then stored in the
25751              shell parameter $EMAIL_ADDR which can alternatively be set manu‐
25752              ally to a suitable string.
25753
25754   Directory management
25755       zfcd [ dir ]
25756       zfcd -
25757       zfcd old new
25758              Change  the current directory on the remote server:  this is im‐
25759              plemented to have many of the features of the shell builtin cd.
25760
25761              In the first form with dir present, change to the directory dir.
25762              The  command `zfcd ..' is treated specially, so is guaranteed to
25763              work on non-UNIX servers (note this  is  handled  internally  by
25764              zftp).  If dir is omitted, has the effect of `zfcd ~'.
25765
25766              The second form changes to the directory previously current.
25767
25768              The  third  form attempts to change the current directory by re‐
25769              placing the first occurrence of the string old with  the  string
25770              new in the current directory.
25771
25772              Note that in this command, and indeed anywhere a remote filename
25773              is expected, the string which on the local host  corresponds  to
25774              `~' is converted back to a `~' before being passed to the remote
25775              machine.  This is convenient because of  the  way  expansion  is
25776              performed  on  the  command  line before zfcd receives a string.
25777              For example, suppose the command is  `zfcd  ~/foo'.   The  shell
25778              will    expand   this   to   a   full   path   such   as   `zfcd
25779              /home/user2/pws/foo'.  At this stage, zfcd recognises  the  ini‐
25780              tial path as corresponding to `~' and will send the directory to
25781              the remote host as ~/foo, so that the `~' will  be  expanded  by
25782              the  server  to  the correct remote host directory.  Other named
25783              directories of the form `~name' are not treated in this fashion.
25784
25785       zfhere Change directory on the remote server to the  one  corresponding
25786              to  the current local directory, with special handling of `~' as
25787              in zfcd.   For  example,  if  the  current  local  directory  is
25788              ~/foo/bar, then zfhere performs the effect of `zfcd ~/foo/bar'.
25789
25790       zfdir [ -rfd ] [ - ] [ dir-options ] [ dir ]
25791              Produce a long directory listing.  The arguments dir-options and
25792              dir are passed directly to the server and their effect is imple‐
25793              mentation  dependent,  but specifying a particular remote direc‐
25794              tory dir is usually possible.  The output is  passed  through  a
25795              pager  given  by  the  environment variable $PAGER, or `more' if
25796              that is not set.
25797
25798              The directory is usually cached for re-use.  In fact, two caches
25799              are  maintained.  One is for use when there is no dir-options or
25800              dir, i.e. a full listing of the current remote directory; it  is
25801              flushed when the current remote directory changes.  The other is
25802              kept for repeated use of zfdir with the same arguments; for  ex‐
25803              ample,  repeated  use  of `zfdir /pub/gnu' will only require the
25804              directory to be retrieved on  the  first  call.   Alternatively,
25805              this cache can be re-viewed with the -r option.  As relative di‐
25806              rectories will confuse zfdir, the -f option can be used to force
25807              the cache to be flushed before the directory is listed.  The op‐
25808              tion -d will delete both  caches  without  showing  a  directory
25809              listing; it will also delete the cache of file names in the cur‐
25810              rent remote directory, if any.
25811
25812       zfls [ ls-options ] [ dir ]
25813              List files on the remote server.  With no arguments,  this  will
25814              produce  a  simple list of file names for the current remote di‐
25815              rectory.  Any arguments are passed directly to the  server.   No
25816              pager and no caching is used.
25817
25818   Status commands
25819       zftype [ type ]
25820              With no arguments, show the type of data to be transferred, usu‐
25821              ally ASCII or binary.  With an argument, change  the  type:  the
25822              types  `A' or `ASCII' for ASCII data and `B' or `BINARY', `I' or
25823              `IMAGE' for binary data are understood case-insensitively.
25824
25825       zfstat [ -v ]
25826              Show the status of the current or last connection,  as  well  as
25827              the  status of some of zftp's status variables.  With the -v op‐
25828              tion, a more verbose listing is produced by querying the  server
25829              for its version of events, too.
25830
25831   Retrieving files
25832       The  commands  for  retrieving  files all take at least two options. -G
25833       suppresses remote filename expansion which would otherwise be performed
25834       (see  below  for  a more detailed description of that).  -t attempts to
25835       set the modification time of the local file to that of the remote file:
25836       see the description of the function zfrtime below for more information.
25837
25838       zfget [ -Gtc ] file1 ...
25839              Retrieve  all  the listed files file1 ... one at a time from the
25840              remote server.  If a file contains  a  `/',  the  full  name  is
25841              passed  to the remote server, but the file is stored locally un‐
25842              der the name given by the part after the final `/'.  The  option
25843              -c (cat) forces all files to be sent as a single stream to stan‐
25844              dard output; in this case the -t option has no effect.
25845
25846       zfuget [ -Gvst ] file1 ...
25847              As zfget, but only retrieve files where the version on  the  re‐
25848              mote  server  is newer (has a later modification time), or where
25849              the local file does not exist.  If the remote file is older  but
25850              the files have different sizes, or if the sizes are the same but
25851              the remote file is newer, the  user  will  usually  be  queried.
25852              With  the  option  -s, the command runs silently and will always
25853              retrieve the file in either of those two cases.  With the option
25854              -v, the command prints more information about the files while it
25855              is working out whether or not to transfer them.
25856
25857       zfcget [ -Gt ] file1 ...
25858              As zfget, but if any of the local files exists, and  is  shorter
25859              than  the corresponding remote file, the command assumes that it
25860              is the result of a partially completed transfer and attempts  to
25861              transfer the rest of the file.  This is useful on a poor connec‐
25862              tion which keeps failing.
25863
25864              Note that this requires a commonly  implemented,  but  non-stan‐
25865              dard,  version of the FTP protocol, so is not guaranteed to work
25866              on all servers.
25867
25868       zfgcp [ -Gt ] remote-file local-file
25869       zfgcp [ -Gt ] rfile1 ... ldir
25870              This retrieves files from the remote server with  arguments  be‐
25871              having similarly to the cp command.
25872
25873              In the first form, copy remote-file from the server to the local
25874              file local-file.
25875
25876              In the second form, copy all the remote files  rfile1  ...  into
25877              the local directory ldir retaining the same basenames.  This as‐
25878              sumes UNIX directory semantics.
25879
25880   Sending files
25881       zfput [ -r ] file1 ...
25882              Send all the file1 ... given separately to  the  remote  server.
25883              If  a filename contains a `/', the full filename is used locally
25884              to find the file, but only the basename is used for  the  remote
25885              file name.
25886
25887              With the option -r, if any of the files are directories they are
25888              sent recursively with all their subdirectories, including  files
25889              beginning  with  `.'.  This requires that the remote machine un‐
25890              derstand UNIX file semantics, since `/' is used as  a  directory
25891              separator.
25892
25893       zfuput [ -vs ] file1 ...
25894              As  zfput, but only send files which are newer than their remote
25895              equivalents, or if the remote file does not exist.  The logic is
25896              the  same  as  for zfuget, but reversed between local and remote
25897              files.
25898
25899       zfcput file1 ...
25900              As zfput, but if any remote file already exists and  is  shorter
25901              than  the local equivalent, assume it is the result of an incom‐
25902              plete transfer and send the rest of the file to  append  to  the
25903              existing  part.   As the FTP append command is part of the stan‐
25904              dard set, this is in principle more likely to work than zfcget.
25905
25906       zfpcp local-file remote-file
25907       zfpcp lfile1 ... rdir
25908              This sends files to the remote server  with  arguments  behaving
25909              similarly to the cp command.
25910
25911              With  two  arguments,  copy  local-file  to  the  server  as re‐
25912              mote-file.
25913
25914              With more than two arguments, copy all the  local  files  lfile1
25915              ...  into  the existing remote directory rdir retaining the same
25916              basenames.  This assumes UNIX directory semantics.
25917
25918              A problem arises if you attempt to use zfpcp lfile1  rdir,  i.e.
25919              the  second  form of copying but with two arguments, as the com‐
25920              mand has no simple way of knowing if rdir corresponds to  a  di‐
25921              rectory  or  a filename.  It attempts to resolve this in various
25922              ways.  First, if the rdir argument is `.' or `..' or ends  in  a
25923              slash, it is assumed to be a directory.  Secondly, if the opera‐
25924              tion of copying to a remote file in the first form  failed,  and
25925              the remote server sends back the expected failure code 553 and a
25926              reply including the string `Is a  directory',  then  zfpcp  will
25927              retry using the second form.
25928
25929   Closing the connection
25930       zfclose
25931              Close the connection.
25932
25933   Session management
25934       zfsession [ -lvod ] [ sessname ]
25935              Allows you to manage multiple FTP sessions at once.  By default,
25936              connections take place in a session called `default'; by  giving
25937              the  command `zfsession sessname' you can change to a new or ex‐
25938              isting session with a name of your choice.  The new session  re‐
25939              members  its own connection, as well as associated shell parame‐
25940              ters, and also the host/user parameters set by zfparams.   Hence
25941              you  can  have different sessions set up to connect to different
25942              hosts, each remembering the appropriate host, user and password.
25943
25944              With no arguments, zfsession prints the name of the current ses‐
25945              sion;  with  the option -l it lists all sessions which currently
25946              exist, and with the option -v it gives a  verbose  list  showing
25947              the  host and directory for each session, where the current ses‐
25948              sion is marked with an asterisk.  With -o, it will switch to the
25949              most recent previous session.
25950
25951              With -d, the given session (or else the current one) is removed;
25952              everything to do with it is completely forgotten.  If it was the
25953              only session, a new session called `default' is created and made
25954              current.  It is safest not to delete sessions  while  background
25955              commands using zftp are active.
25956
25957       zftransfer sess1:file1 sess2:file2
25958              Transfer files between two sessions; no local copy is made.  The
25959              file is read from the session sess1 as file1 and written to ses‐
25960              sion sess2 as file file2; file1 and file2 may be relative to the
25961              current directories of the session.  Either sess1 or  sess2  may
25962              be  omitted  (though  the colon should be retained if there is a
25963              possibility of a colon appearing in the file name) and  defaults
25964              to  the  current session; file2 may be omitted or may end with a
25965              slash, in which case the basename of file1 will be  added.   The
25966              sessions sess1 and sess2 must be distinct.
25967
25968              The  operation  is performed using pipes, so it is required that
25969              the connections still be valid in a subshell, which is  not  the
25970              case under versions of some operating systems, presumably due to
25971              a system bug.
25972
25973   Bookmarks
25974       The two functions zfmark and zfgoto allow you to `bookmark' the present
25975       location  (host,  user and directory) of the current FTP connection for
25976       later use.  The file to be used for storing and retrieving bookmarks is
25977       given  by  the  parameter  $ZFTP_BMFILE; if not set when one of the two
25978       functions is called, it will be set to the file .zfbkmarks in  the  di‐
25979       rectory where your zsh startup files live (usually ~).
25980
25981       zfmark [ bookmark ]
25982              If  given an argument, mark the current host, user and directory
25983              under the name bookmark for later use by zfgoto.  If there is no
25984              connection  open, use the values for the last connection immedi‐
25985              ately before it was closed; it is an error if  there  was  none.
25986              Any  existing  bookmark under the same name will be silently re‐
25987              placed.
25988
25989              If not given an argument, list the existing  bookmarks  and  the
25990              points to which they refer in the form user@host:directory; this
25991              is the format in which they are stored,  and  the  file  may  be
25992              edited directly.
25993
25994       zfgoto [ -n ] bookmark
25995              Return  to  the location given by bookmark, as previously set by
25996              zfmark.  If the location has user `ftp' or `anonymous', open the
25997              connection with zfanon, so that no password is required.  If the
25998              user and host parameters match those stored for the current ses‐
25999              sion,  if  any, those will be used, and again no password is re‐
26000              quired.  Otherwise a password will be prompted for.
26001
26002              With the option -n, the bookmark  is  taken  to  be  a  nickname
26003              stored  by  the ncftp program in its bookmark file, which is as‐
26004              sumed to be ~/.ncftp/bookmarks.  The function works  identically
26005              in  other  ways.   Note that there is no mechanism for adding or
26006              modifying ncftp bookmarks from the zftp functions.
26007
26008   Other functions
26009       Mostly, these  functions  will  not  be  called  directly  (apart  from
26010       zfinit),  but are described here for completeness.  You may wish to al‐
26011       ter zftp_chpwd and zftp_progress, in particular.
26012
26013       zfinit [ -n ]
26014              As described above, this is used to initialize the zftp function
26015              system.  The -n option should be used if the zftp command is al‐
26016              ready built into the shell.
26017
26018       zfautocheck [ -dn ]
26019              This function is called to implement automatic reopening  behav‐
26020              iour,  as  described in more detail below.  The options must ap‐
26021              pear in the first argument; -n prevents the command from  chang‐
26022              ing  to the old directory, while -d prevents it from setting the
26023              variable do_close, which it otherwise does as a flag  for  auto‐
26024              matically closing the connection after a transfer.  The host and
26025              directory for the  last  session  are  stored  in  the  variable
26026              $zflastsession,  but  the internal host/user/password parameters
26027              must also be correctly set.
26028
26029       zfcd_match prefix suffix
26030              This performs matching for completion of remote directory names.
26031              If  the  remote  server is UNIX, it will attempt to persuade the
26032              server to list the remote directory with subdirectories  marked,
26033              which  usually  works  but is not guaranteed.  On other hosts it
26034              simply calls zfget_match and hence completes all files, not just
26035              directories.   On  some  systems,  directories may not even look
26036              like filenames.
26037
26038       zfget_match prefix suffix
26039              This performs matching for completion of remote  filenames.   It
26040              caches  files  for the current directory (only) in the shell pa‐
26041              rameter $zftp_fcache.  It is in the form to be called by the  -K
26042              option  of  compctl,  but  also  works  when  called from a wid‐
26043              get-style completion function with prefix and suffix set  appro‐
26044              priately.
26045
26046       zfrglob varname
26047              Perform  remote  globbing,  as  describes  in more detail below.
26048              varname is the name of a variable containing the pattern  to  be
26049              expanded;  if  there were any matches, the same variable will be
26050              set to the expanded set of filenames on return.
26051
26052       zfrtime lfile rfile [ time ]
26053              Set the local file lfile to have the same modification  time  as
26054              the  remote  file rfile, or the explicit time time in FTP format
26055              CCYYMMDDhhmmSS for the GMT  timezone.   This  uses  the  shell's
26056              zsh/datetime  module to perform the conversion from GMT to local
26057              time.
26058
26059       zftp_chpwd
26060              This function is called every time a connection  is  opened,  or
26061              closed,  or  the  remote directory changes.  This version alters
26062              the title bar of an xterm-compatible or sun-cmd terminal  emula‐
26063              tor to reflect the local and remote hostnames and current direc‐
26064              tories.  It works best when combined with  the  function  chpwd.
26065              In particular, a function of the form
26066
26067                     chpwd() {
26068                       if [[ -n $ZFTP_USER ]]; then
26069                         zftp_chpwd
26070                       else
26071                         # usual chpwd e.g put host:directory in title bar
26072                       fi
26073                     }
26074
26075              fits in well.
26076
26077       zftp_progress
26078              This  function  shows  the  status of the transfer.  It will not
26079              write anything unless the output is going to  a  terminal;  how‐
26080              ever,  if  you transfer files in the background, you should turn
26081              off progress reports by hand using  `zstyle  ':zftp:*'  progress
26082              none'.   Note  also  that if you alter it, any output must be to
26083              standard error, as standard output may be a file being received.
26084              The  form  of  the progress meter, or whether it is used at all,
26085              can be configured without altering the function, as described in
26086              the next section.
26087
26088       zffcache
26089              This is used to implement caching of files in the current direc‐
26090              tory for each session separately.  It is used by zfget_match and
26091              zfrglob.
26092

MISCELLANEOUS FEATURES

26094   Configuration
26095       Various  styles are available using the standard shell style mechanism,
26096       described in zshmodules(1).  Briefly,  the  command  `zstyle  ':zftp:*'
26097       style value ...'.  defines the style to have value value; more than one
26098       value may be given, although that is not useful in the cases  described
26099       here.  These values will then be used throughout the zftp function sys‐
26100       tem.  For more precise control, the first argument, which gives a  con‐
26101       text  in which the style applies, can be modified to include a particu‐
26102       lar function, as for example `:zftp:zfget': the style  will  then  have
26103       the  given value only in the zfget function.  Values for the same style
26104       in different contexts may be set; the most specific  function  will  be
26105       used,  where  strings  are  held to be more specific than patterns, and
26106       longer patterns and shorter patterns.  Note that  only  the  top  level
26107       function  name,  as called by the user, is used; calling of lower level
26108       functions is transparent to the user.  Hence modifications to the title
26109       bar  in zftp_chpwd use the contexts :zftp:zfopen, :zftp:zfcd, etc., de‐
26110       pending where it was called from.  The following styles are understood:
26111
26112       progress
26113              Controls the way that zftp_progress reports on the progress of a
26114              transfer.   If  empty,  unset,  or `none', no progress report is
26115              made; if `bar' a growing bar of inverse video is shown; if `per‐
26116              cent'  (or  any other string, though this may change in future),
26117              the percentage of the file transferred is shown.  The bar  meter
26118              requires  that  the  width  of the terminal be available via the
26119              $COLUMNS parameter (normally this is set automatically).  If the
26120              size  of  the  file  being transferred is not available, bar and
26121              percent meters will simply show the number of bytes  transferred
26122              so far.
26123
26124              When zfinit is run, if this style is not defined for the context
26125              :zftp:*, it will be set to `bar'.
26126
26127       update Specifies the minimum  time  interval  between  updates  of  the
26128              progress  meter  in  seconds.  No update is made unless new data
26129              has been received, so the actual time interval is  limited  only
26130              by $ZFTP_TIMEOUT.
26131
26132              As  described for progress, zfinit will force this to default to
26133              1.
26134
26135       remote-glob
26136              If set to `1', `yes' or `true', filename  generation  (globbing)
26137              is performed on the remote machine instead of by zsh itself; see
26138              below.
26139
26140       titlebar
26141              If set to `1', `yes' or `true', zftp_chpwd will put  the  remote
26142              host  and  remote directory into the titlebar of terminal emula‐
26143              tors such as xterm or sun-cmd that allow this.
26144
26145              As described for progress, zfinit will force this to default  to
26146              1.
26147
26148       chpwd  If set to `1' `yes' or `true', zftp_chpwd will call the function
26149              chpwd when a connection is closed.  This is useful if the remote
26150              host  details were put into the terminal title bar by zftp_chpwd
26151              and your usual chpwd also modifies the title bar.
26152
26153              When zfinit is run, it will determine whether chpwd  exists  and
26154              if  so  it will set the default value for the style to 1 if none
26155              exists already.
26156
26157       Note that there is also an associative array  zfconfig  which  contains
26158       values  used  by  the  function system.  This should not be modified or
26159       overwritten.
26160
26161   Remote globbing
26162       The commands for retrieving files usually perform  filename  generation
26163       (globbing)  on  their  arguments; this can be turned off by passing the
26164       option -G to each of the commands.  Normally this operates by  retriev‐
26165       ing a complete list of files for the directory in question, then match‐
26166       ing these locally against the pattern supplied.  This has the advantage
26167       that  the full range of zsh patterns (respecting the setting of the op‐
26168       tion EXTENDED_GLOB) can be used.  However, it means that the  directory
26169       part  of a filename will not be expanded and must be given exactly.  If
26170       the remote server does not support the UNIX directory semantics, direc‐
26171       tory  handling  is problematic and it is recommended that globbing only
26172       be used within the current directory.  The list of files in the current
26173       directory,  if  retrieved,  will be cached, so that subsequent globs in
26174       the same directory without an intervening zfcd are much faster.
26175
26176       If the remote-glob style (see above) is set, globbing is  instead  per‐
26177       formed  on  the remote host: the server is asked for a list of matching
26178       files.  This is highly dependent on  how  the  server  is  implemented,
26179       though  typically UNIX servers will provide support for basic glob pat‐
26180       terns.  This may in some cases be faster, as it avoids  retrieving  the
26181       entire list of directory contents.
26182
26183   Automatic and temporary reopening
26184       As described for the zfopen command, a subsequent zfopen with no param‐
26185       eters will reopen the connection to the last host (this  includes  con‐
26186       nections  made  with  the zfanon command).  Opened in this fashion, the
26187       connection starts in the default remote directory and will remain  open
26188       until explicitly closed.
26189
26190       Automatic  re-opening  is  also available.  If a connection is not cur‐
26191       rently open and a command requiring a connection  is  given,  the  last
26192       connection  is  implicitly  reopened.  In this case the directory which
26193       was current when the connection was closed again  becomes  the  current
26194       directory (unless, of course, the command given changes it).  Automatic
26195       reopening will also take place if the connection was close by  the  re‐
26196       mote  server for whatever reason (e.g. a timeout).  It is not available
26197       if the -1 option to zfopen or zfanon was used.
26198
26199       Furthermore, if the command issued is a file transfer,  the  connection
26200       will  be  closed  after  the  transfer  is  finished, hence providing a
26201       one-shot mode for transfers.  This does not apply to directory changing
26202       or  listing  commands;  for example a zfdir may reopen a connection but
26203       will leave it open.  Also, automatic closure will only ever  happen  in
26204       the same command as automatic opening, i.e a zfdir directly followed by
26205       a zfget will never close the connection automatically.
26206
26207       Information about the previous connection is given by the zfstat  func‐
26208       tion.  So, for example, if that reports:
26209
26210              Session:        default
26211              Not connected.
26212              Last session:   ftp.bar.com:/pub/textfiles
26213
26214       then  the command zfget file.txt will attempt to reopen a connection to
26215       ftp.bar.com, retrieve the file /pub/textfiles/file.txt, and immediately
26216       close  the connection again.  On the other hand, zfcd ..  will open the
26217       connection in the directory /pub and leave it open.
26218
26219       Note that all the above is local to each session; if you  return  to  a
26220       previous session, the connection for that session is the one which will
26221       be reopened.
26222
26223   Completion
26224       Completion of local and remote files, directories, sessions  and  book‐
26225       marks  is  supported.   The  older, compctl-style completion is defined
26226       when zfinit is called; support for the new widget-based completion sys‐
26227       tem  is  provided  in  the function Completion/Zsh/Command/_zftp, which
26228       should be installed with the other functions of the  completion  system
26229       and hence should automatically be available.
26230
26231
26232
26233ZSHCONTRIB(1)               General Commands Manual              ZSHCONTRIB(1)
26234
26235
26236

NAME

26238       zshcontrib - user contributions to zsh
26239

DESCRIPTION

26241       The  Zsh  source distribution includes a number of items contributed by
26242       the user community.  These are not inherently a part of the shell,  and
26243       some may not be available in every zsh installation.  The most signifi‐
26244       cant of these are documented here.  For documentation on other contrib‐
26245       uted  items  such as shell functions, look for comments in the function
26246       source files.
26247

UTILITIES

26249   Accessing On-Line Help
26250       The key sequence ESC h is normally bound by ZLE to execute the run-help
26251       widget  (see  zshzle(1)).   This  invokes the run-help command with the
26252       command word from the current input line as its argument.  By  default,
26253       run-help  is an alias for the man command, so this often fails when the
26254       command word is a shell builtin or a  user-defined  function.   By  re‐
26255       defining  the run-help alias, one can improve the on-line help provided
26256       by the shell.
26257
26258       The helpfiles utility, found in the Util directory of the distribution,
26259       is a Perl program that can be used to process the zsh manual to produce
26260       a separate help file for each shell builtin and for  many  other  shell
26261       features  as  well.  The autoloadable run-help function, found in Func‐
26262       tions/Misc, searches for these helpfiles  and  performs  several  other
26263       tests to produce the most complete help possible for the command.
26264
26265       Help files are installed by default to a subdirectory of /usr/share/zsh
26266       or /usr/local/share/zsh.
26267
26268       To create your own help files with helpfiles, choose or create a direc‐
26269       tory where the individual command help files will reside.  For example,
26270       you might choose ~/zsh_help.  If you unpacked the zsh  distribution  in
26271       your home directory, you would use the commands:
26272
26273              mkdir ~/zsh_help
26274              perl ~/zsh-5.8.1/Util/helpfiles ~/zsh_help
26275
26276       The  HELPDIR parameter tells run-help where to look for the help files.
26277       When unset, it uses the default installation path.  To use your own set
26278       of  help files, set this to the appropriate path in one of your startup
26279       files:
26280
26281              HELPDIR=~/zsh_help
26282
26283       To use the run-help function, you need to add lines something like  the
26284       following to your .zshrc or equivalent startup file:
26285
26286              unalias run-help
26287              autoload run-help
26288
26289       Note  that  in order for `autoload run-help' to work, the run-help file
26290       must be in one of the directories named in your fpath array  (see  zsh‐
26291       param(1)).   This should already be the case if you have a standard zsh
26292       installation; if it is not, copy Functions/Misc/run-help to  an  appro‐
26293       priate directory.
26294
26295   Recompiling Functions
26296       If  you frequently edit your zsh functions, or periodically update your
26297       zsh installation to track the latest developments, you  may  find  that
26298       function  digests compiled with the zcompile builtin are frequently out
26299       of date with respect to the function source files.  This is not usually
26300       a  problem, because zsh always looks for the newest file when loading a
26301       function, but it may cause slower shell startup and  function  loading.
26302       Also,  if  a digest file is explicitly used as an element of fpath, zsh
26303       won't check whether any of its source files has changed.
26304
26305       The zrecompile autoloadable function, found in Functions/Misc,  can  be
26306       used to keep function digests up to date.
26307
26308       zrecompile [ -qt ] [ name ... ]
26309       zrecompile [ -qt ] -p arg ... [ -- arg ... ]
26310              This tries to find *.zwc files and automatically re-compile them
26311              if at least one of the original files is newer than the compiled
26312              file.  This works only if the names stored in the compiled files
26313              are full paths or are relative to the  directory  that  contains
26314              the .zwc file.
26315
26316              In the first form, each name is the name of a compiled file or a
26317              directory containing *.zwc files that should be checked.  If  no
26318              arguments  are  given,  the directories and *.zwc files in fpath
26319              are used.
26320
26321              When -t is given, no compilation is performed, but a return sta‐
26322              tus  of  zero  (true)  is set if there are files that need to be
26323              re-compiled and non-zero (false) otherwise.  The -q option  qui‐
26324              ets the chatty output that describes what zrecompile is doing.
26325
26326              Without  the  -t  option, the return status is zero if all files
26327              that needed re-compilation could be  compiled  and  non-zero  if
26328              compilation for at least one of the files failed.
26329
26330              If  the  -p  option is given, the args are interpreted as one or
26331              more sets of arguments for zcompile, separated by `--'.  For ex‐
26332              ample:
26333
26334                     zrecompile -p \
26335                                -R ~/.zshrc -- \
26336                                -M ~/.zcompdump -- \
26337                                ~/zsh/comp.zwc ~/zsh/Completion/*/_*
26338
26339              This  compiles  ~/.zshrc into ~/.zshrc.zwc if that doesn't exist
26340              or if it is older than  ~/.zshrc.  The  compiled  file  will  be
26341              marked  for  reading  instead  of  mapping. The same is done for
26342              ~/.zcompdump and ~/.zcompdump.zwc, but  this  compiled  file  is
26343              marked   for   mapping.   The  last  line  re-creates  the  file
26344              ~/zsh/comp.zwc if any of the files matching the given pattern is
26345              newer than it.
26346
26347              Without  the  -p option, zrecompile does not create function di‐
26348              gests that do not already exist, nor does it add  new  functions
26349              to the digest.
26350
26351       The  following  shell loop is an example of a method for creating func‐
26352       tion digests for all functions in your fpath, assuming  that  you  have
26353       write permission to the directories:
26354
26355              for ((i=1; i <= $#fpath; ++i)); do
26356                dir=$fpath[i]
26357                zwc=${dir:t}.zwc
26358                if [[ $dir == (.|..) || $dir == (.|..)/* ]]; then
26359                  continue
26360                fi
26361                files=($dir/*(N-.))
26362                if [[ -w $dir:h && -n $files ]]; then
26363                  files=(${${(M)files%/*/*}#/})
26364                  if ( cd $dir:h &&
26365                       zrecompile -p -U -z $zwc $files ); then
26366                    fpath[i]=$fpath[i].zwc
26367                  fi
26368                fi
26369              done
26370
26371       The  -U and -z options are appropriate for functions in the default zsh
26372       installation fpath; you may need to use different options for your per‐
26373       sonal function directories.
26374
26375       Once  the digests have been created and your fpath modified to refer to
26376       them, you can keep them up to date by running zrecompile with no  argu‐
26377       ments.
26378
26379   Keyboard Definition
26380       The  large  number of possible combinations of keyboards, workstations,
26381       terminals, emulators, and window systems makes it impossible for zsh to
26382       have  built-in  key  bindings  for  every situation.  The zkbd utility,
26383       found in Functions/Misc, can help you quickly create key  bindings  for
26384       your configuration.
26385
26386       Run zkbd either as an autoloaded function, or as a shell script:
26387
26388              zsh -f ~/zsh-5.8.1/Functions/Misc/zkbd
26389
26390       When  you  run  zkbd, it first asks you to enter your terminal type; if
26391       the default it offers is correct, just press return.  It then asks  you
26392       to  press  a  number  of different keys to determine characteristics of
26393       your keyboard and terminal; zkbd warns you if it finds anything out  of
26394       the ordinary, such as a Delete key that sends neither ^H nor ^?.
26395
26396       The  keystrokes  read by zkbd are recorded as a definition for an asso‐
26397       ciative array named key, written to a file in  the  subdirectory  .zkbd
26398       within  either your HOME or ZDOTDIR directory.  The name of the file is
26399       composed from the TERM, VENDOR and OSTYPE  parameters,  joined  by  hy‐
26400       phens.
26401
26402       You  may  read  this file into your .zshrc or another startup file with
26403       the `source' or `.' commands, then reference the key parameter in bind‐
26404       key commands, like this:
26405
26406              source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE
26407              [[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
26408              [[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char
26409              # etc.
26410
26411       Note  that  in order for `autoload zkbd' to work, the zkdb file must be
26412       in one of the directories named in your fpath array (see  zshparam(1)).
26413       This  should  already  be the case if you have a standard zsh installa‐
26414       tion; if it is not, copy Functions/Misc/zkbd to an  appropriate  direc‐
26415       tory.
26416
26417   Dumping Shell State
26418       Occasionally  you  may encounter what appears to be a bug in the shell,
26419       particularly if you are using a beta version of zsh  or  a  development
26420       release.  Usually it is sufficient to send a description of the problem
26421       to one of the zsh mailing lists (see zsh(1)), but sometimes one of  the
26422       zsh developers will need to recreate your environment in order to track
26423       the problem down.
26424
26425       The script named reporter, found in the Util directory of the distribu‐
26426       tion,  is  provided for this purpose.  (It is also possible to autoload
26427       reporter, but reporter is not installed in  fpath  by  default.)   This
26428       script  outputs  a detailed dump of the shell state, in the form of an‐
26429       other script that can be read with `zsh -f' to recreate that state.
26430
26431       To use reporter, read the script into your shell with the  `.'  command
26432       and redirect the output into a file:
26433
26434              . ~/zsh-5.8.1/Util/reporter > zsh.report
26435
26436       You should check the zsh.report file for any sensitive information such
26437       as passwords and delete them by hand before sending the script  to  the
26438       developers.   Also,  as the output can be voluminous, it's best to wait
26439       for the developers to ask for this information before sending it.
26440
26441       You can also use reporter to dump only a subset  of  the  shell  state.
26442       This is sometimes useful for creating startup files for the first time.
26443       Most of the output from reporter is far more detailed than  usually  is
26444       necessary  for  a  startup  file, but the aliases, options, and zstyles
26445       states may be useful because they include only  changes  from  the  de‐
26446       faults.   The  bindings  state may be useful if you have created any of
26447       your own keymaps, because reporter arranges to dump the keymap creation
26448       commands as well as the bindings for every keymap.
26449
26450       As is usual with automated tools, if you create a startup file with re‐
26451       porter, you should edit the results  to  remove  unnecessary  commands.
26452       Note  that  if  you're  using the new completion system, you should not
26453       dump the functions state to your startup files with reporter;  use  the
26454       compdump function instead (see zshcompsys(1)).
26455
26456       reporter [ state ... ]
26457              Print  to  standard  output  the indicated subset of the current
26458              shell state.  The state arguments may be one or more of:
26459
26460              all    Output everything listed below.
26461              aliases
26462                     Output alias definitions.
26463              bindings
26464                     Output ZLE key maps and bindings.
26465              completion
26466                     Output old-style compctl  commands.   New  completion  is
26467                     covered by functions and zstyles.
26468              functions
26469                     Output autoloads and function definitions.
26470              limits Output limit commands.
26471              options
26472                     Output setopt commands.
26473              styles Same as zstyles.
26474              variables
26475                     Output  shell parameter assignments, plus export commands
26476                     for any environment variables.
26477              zstyles
26478                     Output zstyle commands.
26479
26480              If the state is omitted, all is assumed.
26481
26482       With the exception of `all', every state can be abbreviated by any pre‐
26483       fix, even a single letter; thus a is the same as aliases, z is the same
26484       as zstyles, etc.
26485
26486   Manipulating Hook Functions
26487       add-zsh-hook [ -L | -dD ] [ -Uzk ] hook function
26488              Several functions are special to the shell, as described in  the
26489              section  SPECIAL FUNCTIONS, see zshmisc(1), in that they are au‐
26490              tomatically called at specific points  during  shell  execution.
26491              Each has an associated array consisting of names of functions to
26492              be called at the same point; these  are  so-called  `hook  func‐
26493              tions'.   The  shell function add-zsh-hook provides a simple way
26494              of adding or removing functions from the array.
26495
26496              hook is one of chpwd, periodic, precmd, preexec,  zshaddhistory,
26497              zshexit,  or  zsh_directory_name, the special functions in ques‐
26498              tion.  Note that zsh_directory_name is called in a different way
26499              from  the  other  functions,  but  may still be manipulated as a
26500              hook.
26501
26502              function is name of an ordinary shell function.  If  no  options
26503              are given this will be added to the array of functions to be ex‐
26504              ecuted in the given context.  Functions are invoked in the order
26505              they were added.
26506
26507              If  the  option -L is given, the current values for the hook ar‐
26508              rays are listed with typeset.
26509
26510              If the option -d is given, the function is removed from the  ar‐
26511              ray of functions to be executed.
26512
26513              If  the option -D is given, the function is treated as a pattern
26514              and any matching names of functions are removed from  the  array
26515              of functions to be executed.
26516
26517              The  options  -U,  -z and -k are passed as arguments to autoload
26518              for function.  For functions contributed with zsh,  the  options
26519              -Uz are appropriate.
26520
26521       add-zle-hook-widget [ -L | -dD ] [ -Uzk ] hook widgetname
26522              Several  widget  names  are  special  to the line editor, as de‐
26523              scribed in the section Special Widgets, see zshzle(1),  in  that
26524              they are automatically called at specific points during editing.
26525              Unlike function hooks, these do not use a  predefined  array  of
26526              other  names  to  call  at  the  same  point; the shell function
26527              add-zle-hook-widget maintains a similar array and  arranges  for
26528              the special widget to invoke those additional widgets.
26529
26530              hook  is  one  of isearch-exit, isearch-update, line-pre-redraw,
26531              line-init, line-finish, history-line-set, or keymap-select, cor‐
26532              responding to each of the special widgets zle-isearch-exit, etc.
26533              The special widget names are also accepted as the hook argument.
26534
26535              widgetname is the name of a ZLE widget.  If no options are given
26536              this is added to the array of widgets to be invoked in the given
26537              hook context.  Widgets are invoked in the order they were added,
26538              with
26539                     zle widgetname -Nw -- "$@"
26540
26541              Note  that this means that the `WIDGET' special parameter tracks
26542              the widgetname when the widget function is called,  rather  than
26543              tracking the name of the corresponding special hook widget.
26544
26545              If  the  option  -d is given, the widgetname is removed from the
26546              array of widgets to be executed.
26547
26548              If the option -D is given, the widgetname is treated as  a  pat‐
26549              tern  and any matching names of widgets are removed from the ar‐
26550              ray.
26551
26552              If widgetname does not name an existing widget when added to the
26553              array, it is assumed that a shell function also named widgetname
26554              is meant to provide the implementation of the widget.  This name
26555              is  therefore marked for autoloading, and the options -U, -z and
26556              -k are passed as arguments to  autoload  as  with  add-zsh-hook.
26557              The widget is also created with `zle -N widgetname' to cause the
26558              corresponding function to be loaded the first time the  hook  is
26559              called.
26560
26561              The arrays of widgetname are currently maintained in zstyle con‐
26562              texts, one for each hook context, with a style of `widgets'.  If
26563              the  -L  option  is  given,  this  set  of styles is listed with
26564              `zstyle -L'.  This implementation may change,  and  the  special
26565              widgets   that   refer   to  the  styles  are  created  only  if
26566              add-zle-hook-widget is called to add at least one widget, so  if
26567              this  function  is  used for any hooks, then all hooks should be
26568              managed only via this function.
26569

REMEMBERING RECENT DIRECTORIES

26571       The function cdr allows you to change the working directory to a previ‐
26572       ous working directory from a list maintained automatically.  It is sim‐
26573       ilar in concept to the directory stack controlled by  the  pushd,  popd
26574       and  dirs  builtins, but is more configurable, and as it stores all en‐
26575       tries in files it is maintained across sessions and  (by  default)  be‐
26576       tween  terminal emulators in the current session.  Duplicates are auto‐
26577       matically removed, so that the list reflects the single most recent use
26578       of each directory.
26579
26580       Note that the pushd directory stack is not actually modified or used by
26581       cdr unless you configure it to do so as described in the  configuration
26582       section below.
26583
26584   Installation
26585       The  system works by means of a hook function that is called every time
26586       the directory changes.  To install the system,  autoload  the  required
26587       functions and use the add-zsh-hook function described above:
26588
26589              autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
26590              add-zsh-hook chpwd chpwd_recent_dirs
26591
26592       Now  every time you change directly interactively, no matter which com‐
26593       mand you use, the directory to which you change will be  remembered  in
26594       most-recent-first order.
26595
26596   Use
26597       All direct user interaction is via the cdr function.
26598
26599       The  argument  to  cdr  is a number N corresponding to the Nth most re‐
26600       cently changed-to directory.  1 is the immediately preceding directory;
26601       the  current  directory  is remembered but is not offered as a destina‐
26602       tion.  Note that if you have multiple windows open 1 may refer to a di‐
26603       rectory  changed  to  in  another  window; you can avoid this by having
26604       per-terminal files for storing  directory  as  described  for  the  re‐
26605       cent-dirs-file style below.
26606
26607       If  you  set the recent-dirs-default style described below cdr will be‐
26608       have the same as cd if given a non-numeric argument, or more  than  one
26609       argument.   The  recent directory list is updated just the same however
26610       you change directory.
26611
26612       If the argument is omitted, 1 is assumed.  This is similar  to  pushd's
26613       behaviour of swapping the two most recent directories on the stack.
26614
26615       Completion  for  the  argument to cdr is available if compinit has been
26616       run; menu selection is recommended, using:
26617
26618              zstyle ':completion:*:*:cdr:*:*' menu selection
26619
26620       to allow you to cycle through recent directories;  the  order  is  pre‐
26621       served,  so  the  first  choice is the most recent directory before the
26622       current one.  The verbose style is also recommended to ensure  the  di‐
26623       rectory  is shown; this style is on by default so no action is required
26624       unless you have changed it.
26625
26626   Options
26627       The behaviour of cdr may be modified by the following options.
26628
26629       -l     lists the numbers and the corresponding directories in  abbrevi‐
26630              ated  form  (i.e.  with ~ substitution reapplied), one per line.
26631              The directories here are not quoted (this would only be an issue
26632              if  a  directory name contained a newline).  This is used by the
26633              completion system.
26634
26635       -r     sets the variable reply  to  the  current  set  of  directories.
26636              Nothing is printed and the directory is not changed.
26637
26638       -e     allows  you  to edit the list of directories, one per line.  The
26639              list can be edited to any extent you like; no sanity checking is
26640              performed.   Completion  is  available.  No quoting is necessary
26641              (except for newlines, where I have in any case no sympathy); di‐
26642              rectories  are  in  unabbreviated  from  and contain an absolute
26643              path, i.e. they start with /.  Usually the first entry should be
26644              left as the current directory.
26645
26646       -p 'pattern'
26647              Prunes  any items in the directory list that match the given ex‐
26648              tended glob pattern; the pattern needs to be quoted from immedi‐
26649              ate  expansion  on  the  command  line.   The pattern is matched
26650              against each completely expanded file name in the list; the full
26651              string  must  match, so wildcards at the end (e.g. '*removeme*')
26652              are needed to remove entries with a given substring.
26653
26654              If output is to a terminal, then the function will print the new
26655              list  after  pruning  and  prompt  for confirmation by the user.
26656              This output and confirmation step can be skipped by using -P in‐
26657              stead of -p.
26658
26659   Configuration
26660       Configuration is by means of the styles mechanism that should be famil‐
26661       iar from completion; if not, see the description of the zstyle  command
26662       in  see  zshmodules(1).  The context for setting styles should be ':ch‐
26663       pwd:*' in case the meaning of the context is extended  in  future,  for
26664       example:
26665
26666              zstyle ':chpwd:*' recent-dirs-max 0
26667
26668       sets  the  value  of  the  recent-dirs-max style to 0.  In practice the
26669       style name is specific enough that a context of '*' should be fine.
26670
26671       An exception is recent-dirs-insert, which is used  exclusively  by  the
26672       completion  system  and  so  has  the  usual  completion system context
26673       (':completion:*' if nothing more specific is needed), though again  '*'
26674       should be fine in practice.
26675
26676       recent-dirs-default
26677              If  true, and the command is expecting a recent directory index,
26678              and either there is more than one argument or  the  argument  is
26679              not an integer, then fall through to "cd".  This allows the lazy
26680              to use only one  command  for  directory  changing.   Completion
26681              recognises  this, too; see recent-dirs-insert for how to control
26682              completion when this option is in use.
26683
26684       recent-dirs-file
26685              The file where the list of directories is saved.  The default is
26686              ${ZDOTDIR:-$HOME}/.chpwd-recent-dirs,  i.e. this is in your home
26687              directory unless you have set  the  variable  ZDOTDIR  to  point
26688              somewhere  else.   Directory  names  are  saved in $'...' quoted
26689              form, so each line in the file can be supplied directly  to  the
26690              shell as an argument.
26691
26692              The  value  of  this  style  may be an array.  In this case, the
26693              first file in the list will always be used for  saving  directo‐
26694              ries while any other files are left untouched.  When reading the
26695              recent directory list, if there are fewer than the maximum  num‐
26696              ber of entries in the first file, the contents of later files in
26697              the array will be appended with duplicates removed from the list
26698              shown.   The  contents of the two files are not sorted together,
26699              i.e. all the entries in the first file  are  shown  first.   The
26700              special  value  + can appear in the list to indicate the default
26701              file should be read at that point.  This allows effects like the
26702              following:
26703
26704                     zstyle ':chpwd:*' recent-dirs-file \
26705                     ~/.chpwd-recent-dirs-${TTY##*/} +
26706
26707              Recent  directories  are  read from a file numbered according to
26708              the terminal.  If there are insufficient  entries  the  list  is
26709              supplemented from the default file.
26710
26711              It  is  possible  to use zstyle -e to make the directory config‐
26712              urable at run time:
26713
26714                     zstyle -e ':chpwd:*' recent-dirs-file pick-recent-dirs-file
26715                     pick-recent-dirs-file() {
26716                       if [[ $PWD = ~/text/writing(|/*) ]]; then
26717                         reply=(~/.chpwd-recent-dirs-writing)
26718                       else
26719                         reply=(+)
26720                       fi
26721                     }
26722
26723              In this example, if the current directory is ~/text/writing or a
26724              directory  under  it,  then use a special file for saving recent
26725              directories, else use the default.
26726
26727       recent-dirs-insert
26728              Used by completion.  If recent-dirs-default is true,  then  set‐
26729              ting  this  to true causes the actual directory, rather than its
26730              index, to be inserted on the command line; this has the same ef‐
26731              fect  as  using  the  corresponding index, but makes the history
26732              clearer and the line easier to edit.  With this setting, if part
26733              of  an  argument  was already typed, normal directory completion
26734              rather than recent directory completion is done; this is because
26735              recent  directory  completion  is expected to be done by cycling
26736              through entries menu fashion.
26737
26738              If the value of the style is always, then only  recent  directo‐
26739              ries  will  be  completed; in that case, use the cd command when
26740              you want to complete other directories.
26741
26742              If the value is  fallback,  recent  directories  will  be  tried
26743              first,  then  normal directory completion is performed if recent
26744              directory completion failed to find a match.
26745
26746              Finally, if the value is both then both sets of completions  are
26747              presented;  the  usual  tag mechanism can be used to distinguish
26748              results, with recent directories tagged  as  recent-dirs.   Note
26749              that the recent directories inserted are abbreviated with direc‐
26750              tory names where appropriate.
26751
26752       recent-dirs-max
26753              The maximum number of directories to save to the file.  If  this
26754              is  zero  or  negative  there is no maximum.  The default is 20.
26755              Note this includes the current directory, which  isn't  offered,
26756              so  the highest number of directories you will be offered is one
26757              less than the maximum.
26758
26759       recent-dirs-prune
26760              This style is an array determining what directories  should  (or
26761              should  not) be added to the recent list.  Elements of the array
26762              can include:
26763
26764              parent Prune parents (more accurately, ancestors) from  the  re‐
26765                     cent  list.   If  present,  changing directly down by any
26766                     number of directories causes the current directory to  be
26767                     overwritten.    For   example,   changing  from  ~pws  to
26768                     ~pws/some/other/dir causes ~pws not to be left on the re‐
26769                     cent  directory  stack.   This  only  applies  to  direct
26770                     changes to descendant directories; earlier directories on
26771                     the  list  are  not  pruned.   For example, changing from
26772                     ~pws/yet/another to ~pws/some/other/dir  does  not  cause
26773                     ~pws to be pruned.
26774
26775              pattern:pattern
26776                     Gives  a  zsh  pattern for directories that should not be
26777                     added to the recent list (if not  already  there).   This
26778                     element  can  be repeated to add different patterns.  For
26779                     example, 'pattern:/tmp(|/*)' stops /tmp  or  its  descen‐
26780                     dants  from being added.  The EXTENDED_GLOB option is al‐
26781                     ways turned on for these patterns.
26782
26783       recent-dirs-pushd
26784              If set to true, cdr will use pushd instead of cd to  change  the
26785              directory, so the directory is saved on the directory stack.  As
26786              the directory stack is completely  separate  from  the  list  of
26787              files saved by the mechanism used in this file there is no obvi‐
26788              ous reason to do this.
26789
26790   Use with dynamic directory naming
26791       It is possible to refer to recent directories using the dynamic  direc‐
26792       tory  name syntax by using the supplied function zsh_directory_name_cdr
26793       a hook:
26794
26795              autoload -Uz add-zsh-hook
26796              add-zsh-hook -Uz zsh_directory_name zsh_directory_name_cdr
26797
26798       When this is done, ~[1] will refer to the most recent  directory  other
26799       than $PWD, and so on.  Completion after ~[...  also works.
26800
26801   Details of directory handling
26802       This  section  is for the curious or confused; most users will not need
26803       to know this information.
26804
26805       Recent directories are saved to a file immediately and hence  are  pre‐
26806       served across sessions.  Note currently no file locking is applied: the
26807       list is updated immediately on interactive commands  and  nowhere  else
26808       (unlike history), and it is assumed you are only going to change direc‐
26809       tory in one window at once.  This is not safe on shared  accounts,  but
26810       in  any case the system has limited utility when someone else is chang‐
26811       ing to a different set of directories behind your back.
26812
26813       To make this a little safer, only directory changes instituted from the
26814       command  line,  either  directly  or  indirectly through shell function
26815       calls (but not through subshells, evals,  traps,  completion  functions
26816       and  the like) are saved.  Shell functions should use cd -q or pushd -q
26817       to avoid side effects if the change to the directory is to be invisible
26818       at  the  command  line.   See  the  contents  of the function chpwd_re‐
26819       cent_dirs for more details.
26820

ABBREVIATED DYNAMIC REFERENCES TO DIRECTORIES

26822       The dynamic directory naming system is described in the subsection  Dy‐
26823       namic  named  directories of the section Filename Expansion in expn(1).
26824       In this, a reference to ~[...] is expanded by a function found  by  the
26825       hooks mechanism.
26826
26827       The  contributed  function zsh_directory_name_generic provides a system
26828       allowing the user to refer to directories with only a limited amount of
26829       new  code.  It supports all three of the standard interfaces for direc‐
26830       tory naming: converting from a name to a directory, converting  in  the
26831       reverse direction to find a short name, and completion of names.
26832
26833       The  main feature of this function is a path-like syntax, combining ab‐
26834       breviations at multiple  levels  separated  by  ":".   As  an  example,
26835       ~[g:p:s] might specify:
26836       g      The top level directory for your git area.  This first component
26837              has to match, or the function will return indicating another di‐
26838              rectory name hook function should be tried.
26839
26840       p      The name of a project within your git area.
26841
26842       s      The  source  area  within that project.  This allows you to col‐
26843              lapse references to long hierarchies to  a  very  compact  form,
26844              particularly if the hierarchies are similar across different ar‐
26845              eas of the disk.
26846
26847       Name components may be completed: if a description is shown at the  top
26848       of the list of completions, it includes the path to which previous com‐
26849       ponents expand, while the  description  for  an  individual  completion
26850       shows  the  path  segment it would add.  No additional configuration is
26851       needed for this as the completion system is aware of the dynamic direc‐
26852       tory name mechanism.
26853
26854   Usage
26855       To  use the function, first define a wrapper function for your specific
26856       case.  We'll assume it's to be autoloaded.  This can have any name  but
26857       we'll  refer to it as zdn_mywrapper.  This wrapper function will define
26858       various variables and then call this function with the  same  arguments
26859       that the wrapper function gets.  This configuration is described below.
26860
26861       Then arrange for the wrapper to be run as a zsh_directory_name hook:
26862
26863              autoload -Uz add-zsh-hook zsh_diretory_name_generic zdn_mywrapper
26864              add-zsh-hook -U zsh_directory_name zdn_mywrapper
26865
26866   Configuration
26867       The  wrapper  function should define a local associative array zdn_top.
26868       Alternatively, this can be set with a style called mapping.   The  con‐
26869       text for the style is :zdn:wrapper-name where wrapper-name is the func‐
26870       tion calling zsh_directory_name_generic; for example:
26871
26872              zstyle :zdn:zdn_mywrapper: mapping zdn_mywrapper_top
26873
26874       The keys in this associative array correspond to the first component of
26875       the  name.   The values are matching directories.  They may have an op‐
26876       tional suffix with a slash followed by a colon and the name of a  vari‐
26877       able  in the same format to give the next component.  (The slash before
26878       the colon is to disambiguate the case where a colon is  needed  in  the
26879       path  for  a drive.  There is otherwise no syntax for escaping this, so
26880       path components whose names start with a colon are not  supported.)   A
26881       special component :default: specifies a variable in the form /:var (the
26882       path section is ignored and so is usually empty) that will be used  for
26883       the next component if no variable is given for the path.  Variables re‐
26884       ferred to within zdn_top have the same format as  zdn_top  itself,  but
26885       contain relative paths.
26886
26887       For example,
26888
26889              local -A zdn_top=(
26890                g   ~/git
26891                ga  ~/alternate/git
26892                gs  /scratch/$USER/git/:second2
26893                :default: /:second1
26894              )
26895
26896       This specifies the behaviour of a directory referred to as ~[g:...]  or
26897       ~[ga:...] or ~[gs:...].  Later path components are  optional;  in  that
26898       case   ~[g]   expands   to   ~/git,   and   so   on.    gs  expands  to
26899       /scratch/$USER/git and uses the associative array second2 to match  the
26900       second  component;  g and ga use the associative array second1 to match
26901       the second component.
26902
26903       When expanding a name to a directory, if the first component is  not  g
26904       or  ga or gs, it is not an error; the function simply returns 1 so that
26905       a later hook function can be tried.  However, matching the first compo‐
26906       nent  commits  the function, so if a later component does not match, an
26907       error is printed (though this still does not stop later hooks from  be‐
26908       ing executed).
26909
26910       For  components  after the first, a relative path is expected, but note
26911       that multiple levels may still appear.  Here is an example of second1:
26912
26913              local -A second1=(
26914                p   myproject
26915                s   somproject
26916                os  otherproject/subproject/:third
26917              )
26918
26919       The path as found from zdn_top is extended with the matching directory,
26920       so ~[g:p] becomes ~/git/myproject.  The slash between is added automat‐
26921       ically (it's not possible to have a later component modify the name  of
26922       a directory already matched).  Only os specifies a variable for a third
26923       component, and there's no :default:, so it's an error  to  use  a  name
26924       like  ~[g:p:x] or ~[ga:s:y] because there's nowhere to look up the x or
26925       y.
26926
26927       The associative arrays need to be visible  within  this  function;  the
26928       generic function therefore uses internal variable names beginning _zdn_
26929       in order to avoid clashes.  Note that the variable reply  needs  to  be
26930       passed  back  to the shell, so should not be local in the calling func‐
26931       tion.
26932
26933       The function does not test whether directories assembled  by  component
26934       actually  exist; this allows the system to work across automounted file
26935       systems.  The error from the command trying to use a  non-existent  di‐
26936       rectory should be sufficient to indicate the problem.
26937
26938   Complete example
26939       Here is a full fictitious but usable autoloadable definition of the ex‐
26940       ample function defined by the code  above.   So  ~[gs:p:s]  expands  to
26941       /scratch/$USER/git/myscratchproject/top/srcdir  (with  $USER  also  ex‐
26942       panded).
26943
26944              local -A zdn_top=(
26945                g   ~/git
26946                ga  ~/alternate/git
26947                gs  /scratch/$USER/git/:second2
26948                :default: /:second1
26949              )
26950
26951              local -A second1=(
26952                p   myproject
26953                s   somproject
26954                os  otherproject/subproject/:third
26955              )
26956
26957              local -A second2=(
26958                p   myscratchproject
26959                s   somescratchproject
26960              )
26961
26962              local -A third=(
26963                s   top/srcdir
26964                d   top/documentation
26965              )
26966
26967              # autoload not needed if you did this at initialisation...
26968              autoload -Uz zsh_directory_name_generic
26969              zsh_directory_name_generic "$@
26970
26971       It is also possible to use global associative arrays,  suitably  named,
26972       and  set the style for the context of your wrapper function to refer to
26973       this.  Then your set up code would contain the following:
26974
26975              typeset -A zdn_mywrapper_top=(...)
26976              # ... and so on for other associative arrays ...
26977              zstyle ':zdn:zdn_mywrapper:' mapping zdn_mywrapper_top
26978              autoload -Uz add-zsh-hook zsh_directory_name_generic zdn_mywrapper
26979              add-zsh-hook -U zsh_directory_name zdn_mywrapper
26980
26981       and the function zdn_mywrapper would contain only the following:
26982
26983              zsh_directory_name_generic "$@"
26984

GATHERING INFORMATION FROM VERSION CONTROL SYSTEMS

26986       In a lot of cases, it is nice  to  automatically  retrieve  information
26987       from version control systems (VCSs), such as subversion, CVS or git, to
26988       be able to provide it to the user; possibly in the  user's  prompt.  So
26989       that  you can instantly tell which branch you are currently on, for ex‐
26990       ample.
26991
26992       In order to do that, you may use the vcs_info function.
26993
26994       The following VCSs are supported, showing the abbreviated name by which
26995       they are referred to within the system:
26996       Bazaar (bzr)
26997              https://bazaar.canonical.com/
26998       Codeville (cdv)
26999              http://freecode.com/projects/codeville/
27000       Concurrent Versioning System (cvs)
27001              https://www.nongnu.org/cvs/
27002       Darcs (darcs)
27003              http://darcs.net/
27004       Fossil (fossil)
27005              https://fossil-scm.org/
27006       Git (git)
27007              https://git-scm.com/
27008       GNU arch (tla)
27009              https://www.gnu.org/software/gnu-arch/
27010       Mercurial (hg)
27011              https://www.mercurial-scm.org/
27012       Monotone (mtn)
27013              https://monotone.ca/
27014       Perforce (p4)
27015              https://www.perforce.com/
27016       Subversion (svn)
27017              https://subversion.apache.org/
27018       SVK (svk)
27019              https://svk.bestpractical.com/
27020
27021       There   is   also   support  for  the  patch  management  system  quilt
27022       (https://savannah.nongnu.org/projects/quilt). See Quilt  Support  below
27023       for details.
27024
27025       To load vcs_info:
27026
27027              autoload -Uz vcs_info
27028
27029       It  can be used in any existing prompt, because it does not require any
27030       specific $psvar entries to be available.
27031
27032   Quickstart
27033       To get this feature working quickly (including colors), you can do  the
27034       following (assuming, you loaded vcs_info properly - see above):
27035
27036              zstyle ':vcs_info:*' actionformats \
27037                  '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
27038              zstyle ':vcs_info:*' formats       \
27039                  '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
27040              zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
27041              precmd () { vcs_info }
27042              PS1='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_}%f%# '
27043
27044       Obviously,  the last two lines are there for demonstration. You need to
27045       call vcs_info from your precmd function. Once that is done you  need  a
27046       single quoted '${vcs_info_msg_0_}' in your prompt.
27047
27048       To  be  able  to  use '${vcs_info_msg_0_}' directly in your prompt like
27049       this, you will need to have the PROMPT_SUBST option enabled.
27050
27051       Now call the vcs_info_printsys utility from the command line:
27052
27053              % vcs_info_printsys
27054              ## list of supported version control backends:
27055              ## disabled systems are prefixed by a hash sign (#)
27056              bzr
27057              cdv
27058              cvs
27059              darcs
27060              fossil
27061              git
27062              hg
27063              mtn
27064              p4
27065              svk
27066              svn
27067              tla
27068              ## flavours (cannot be used in the enable or disable styles; they
27069              ## are enabled and disabled with their master [git-svn -> git])
27070              ## they *can* be used in contexts: ':vcs_info:git-svn:*'.
27071              git-p4
27072              git-svn
27073              hg-git
27074              hg-hgsubversion
27075              hg-hgsvn
27076
27077       You may not want all of these because there is no point in running  the
27078       code  to  detect  systems you do not use.  So there is a way to disable
27079       some backends altogether:
27080
27081              zstyle ':vcs_info:*' disable bzr cdv darcs mtn svk tla
27082
27083       You may also pick a few from that list and enable only those:
27084
27085              zstyle ':vcs_info:*' enable git cvs svn
27086
27087       If you rerun vcs_info_printsys after one of these  commands,  you  will
27088       see  the  backends  listed in the disable style (or backends not in the
27089       enable style - if you used that) marked as disabled  by  a  hash  sign.
27090       That  means  the  detection  of these systems is skipped completely. No
27091       wasted time there.
27092
27093   Configuration
27094       The vcs_info feature can be configured via zstyle.
27095
27096       First, the context in which we are working:
27097              :vcs_info:vcs-string:user-context:repo-root-name
27098
27099       vcs-string
27100              is one of: git, git-svn, git-p4,  hg,  hg-git,  hg-hgsubversion,
27101              hg-hgsvn,  darcs,  bzr, cdv, mtn, svn, cvs, svk, tla, p4 or fos‐
27102              sil.  This is followed by `.quilt-quilt-mode' in Quilt mode (see
27103              Quilt  Support  for details) and by `+hook-name' while hooks are
27104              active (see Hooks in vcs_info for details).
27105
27106              Currently, hooks in quilt mode don't add the `.quilt-quilt-mode'
27107              information.  This may change in the future.
27108
27109       user-context
27110              is  a  freely configurable string, assignable by the user as the
27111              first argument to vcs_info (see its description below).
27112
27113       repo-root-name
27114              is the name of a repository in which you want a style to  match.
27115              So,  if  you  want a setting specific to /usr/src/zsh, with that
27116              being a CVS checkout, you can set repo-root-name to zsh to  make
27117              it so.
27118
27119       There  are  three  special  values  for  vcs-string: The first is named
27120       -init-, that is in effect as long as there was  no  decision  what  VCS
27121       backend  to use. The second is -preinit-; it is used before vcs_info is
27122       run, when initializing the data exporting variables. The third  special
27123       value is formats and is used by the vcs_info_lastmsg for looking up its
27124       styles.
27125
27126       The initial value of repo-root-name is -all- and it  is  replaced  with
27127       the actual name, as soon as it is known. Only use this part of the con‐
27128       text for defining the formats, actionformats or branchformat styles, as
27129       it  is  guaranteed  that  repo-root-name  is set up correctly for these
27130       only. For all other styles, just use '*' instead.
27131
27132       There are two pre-defined values for user-context:
27133       default
27134              the one used if none is specified
27135       command
27136              used by vcs_info_lastmsg to lookup its styles
27137
27138       You can of course use ':vcs_info:*' to match all VCSs in all  user-con‐
27139       texts at once.
27140
27141       This is a description of all styles that are looked up.
27142
27143       formats
27144              A list of formats, used when actionformats is not used (which is
27145              most of the time).
27146
27147       actionformats
27148              A list of formats, used if there is a special action going on in
27149              your  current  repository; like an interactive rebase or a merge
27150              conflict.
27151
27152       branchformat
27153              Some backends replace %b in the formats and actionformats styles
27154              above,  not only by a branch name but also by a revision number.
27155              This style lets you modify how that string should look.
27156
27157       nvcsformats
27158              These "formats" are set when we didn't detect a version  control
27159              system  for the current directory or vcs_info was disabled. This
27160              is useful if you want vcs_info to completely take over the  gen‐
27161              eration   of   your   prompt.   You   would  do  something  like
27162              PS1='${vcs_info_msg_0_}' to accomplish that.
27163
27164       hgrevformat
27165              hg uses both a hash and a revision number to  reference  a  spe‐
27166              cific  changeset in a repository. With this style you can format
27167              the revision string (see  branchformat)  to  include  either  or
27168              both. It's only useful when get-revision is true. Note, the full
27169              40-character revision id is not available (except when using the
27170              use-simple  option)  because  executing  hg  more  than once per
27171              prompt is too slow; you may customize this behavior using hooks.
27172
27173       max-exports
27174              Defines the maximum number of vcs_info_msg_*_ variables vcs_info
27175              will set.
27176
27177       enable A  list  of backends you want to use. Checked in the -init- con‐
27178              text. If this list contains an item called NONE  no  backend  is
27179              used  at all and vcs_info will do nothing. If this list contains
27180              ALL, vcs_info will use all known backends. Only with ALL in  en‐
27181              able  will  the  disable style have any effect. ALL and NONE are
27182              case insensitive.
27183
27184       disable
27185              A list of VCSs you don't want vcs_info to test for  repositories
27186              (checked  in  the -init- context, too). Only used if enable con‐
27187              tains ALL.
27188
27189       disable-patterns
27190              A list of patterns that are checked against $PWD. If  a  pattern
27191              matches, vcs_info will be disabled. This style is checked in the
27192              :vcs_info:-init-:*:-all- context.
27193
27194              Say, ~/.zsh is a directory under version control, in  which  you
27195              do not want vcs_info to be active, do:
27196                     zstyle ':vcs_info:*' disable-patterns "${(b)HOME}/.zsh(|/*)"
27197
27198       use-quilt
27199              If  enabled,  the  quilt support code is active in `addon' mode.
27200              See Quilt Support for details.
27201
27202       quilt-standalone
27203              If enabled, `standalone' mode detection is attempted if  no  VCS
27204              is active in a given directory. See Quilt Support for details.
27205
27206       quilt-patch-dir
27207              Overwrite  the value of the $QUILT_PATCHES environment variable.
27208              See Quilt Support for details.
27209
27210       quiltcommand
27211              When quilt itself is called in quilt support, the value of  this
27212              style is used as the command name.
27213
27214       check-for-changes
27215              If  enabled,  this  style causes the %c and %u format escapes to
27216              show when the working directory  has  uncommitted  changes.  The
27217              strings  displayed  by  these  escapes can be controlled via the
27218              stagedstr and unstagedstr styles. The only  backends  that  cur‐
27219              rently  support this option are git, hg, and bzr (the latter two
27220              only support unstaged).
27221
27222              For this style to be evaluated with the hg backend, the  get-re‐
27223              vision  style  needs to be set and the use-simple style needs to
27224              be unset. The latter is the default; the former is not.
27225
27226              With the bzr backend,  lightweight  checkouts  only  honor  this
27227              style if the use-server style is set.
27228
27229              Note, the actions taken if this style is enabled are potentially
27230              expensive (read: they may be slow, depending on how big the cur‐
27231              rent repository is).  Therefore, it is disabled by default.
27232
27233       check-for-staged-changes
27234              This  style  is  like check-for-changes, but it never checks the
27235              worktree files, only the metadata in the  .${vcs}  dir.   There‐
27236              fore, this style initializes only the %c escape (with stagedstr)
27237              but  not  the  %u   escape.    This   style   is   faster   than
27238              check-for-changes.
27239
27240              In  the git backend, this style checks for changes in the index.
27241              Other backends do not currently implement this style.
27242
27243              This style is disabled by default.
27244
27245       stagedstr
27246              This string will be used in the %c escape if  there  are  staged
27247              changes in the repository.
27248
27249       unstagedstr
27250              This  string will be used in the %u escape if there are unstaged
27251              changes in the repository.
27252
27253       command
27254              This style causes vcs_info to use the  supplied  string  as  the
27255              command  to  use as the VCS's binary. Note, that setting this in
27256              ':vcs_info:*' is not a good idea.
27257
27258              If the value of this style is empty (which is the default),  the
27259              used  binary name is the name of the backend in use (e.g. svn is
27260              used in an svn repository).
27261
27262              The repo-root-name part in the context  is  always  the  default
27263              -all- when this style is looked up.
27264
27265              For example, this style can be used to use binaries from non-de‐
27266              fault installation directories.  Assume,  git  is  installed  in
27267              /usr/bin but your sysadmin installed a newer version in /usr/lo‐
27268              cal/bin. Instead of changing the order of your $PATH  parameter,
27269              you can do this:
27270                     zstyle ':vcs_info:git:*:-all-' command /usr/local/bin/git
27271
27272       use-server
27273              This is used by the Perforce backend (p4) to decide if it should
27274              contact the Perforce server to find out if a directory  is  man‐
27275              aged  by Perforce.  This is the only reliable way of doing this,
27276              but runs the risk of a delay if the server name cannot be found.
27277              If  the server (more specifically, the host:port pair describing
27278              the server) cannot be contacted, its name is put into the  asso‐
27279              ciative  array  vcs_info_p4_dead_servers  and  is  not contacted
27280              again during the session until it is removed by hand.  If you do
27281              not  set  this  style, the p4 backend is only usable if you have
27282              set the environment variable P4CONFIG to a file  name  and  have
27283              corresponding  files  in  the  root directories of each Perforce
27284              client.  See comments in  the  function  VCS_INFO_detect_p4  for
27285              more detail.
27286
27287              The  Bazaar  backend  (bzr)  uses  this to permit contacting the
27288              server about lightweight checkouts,  see  the  check-for-changes
27289              style.
27290
27291       use-simple
27292              If  there  are  two different ways of gathering information, you
27293              can select the simpler one by setting this style  to  true;  the
27294              default is to use the not-that-simple code, which is potentially
27295              a lot slower but might be more accurate in all  possible  cases.
27296              This style is used by the bzr and hg backends. In the case of hg
27297              it will invoke the external hexdump program to parse the  binary
27298              dirstate cache file; this method will not return the local revi‐
27299              sion number.
27300
27301       get-revision
27302              If set to true, vcs_info goes the extra mile to figure  out  the
27303              revision  of a repository's work tree (currently for the git and
27304              hg backends, where this kind of information is  not  always  vi‐
27305              tal).  For git, the hash value of the currently checked out com‐
27306              mit is available via the %i expansion. With hg, the local  revi‐
27307              sion  number and the corresponding global hash are available via
27308              %i.
27309
27310       get-mq If set to true, the hg backend will look for a  Mercurial  Queue
27311              (mq) patch directory. Information will be available via the `%m'
27312              replacement.
27313
27314       get-bookmarks
27315              If set to true, the hg backend will try to get a list of current
27316              bookmarks. They will be available via the `%m' replacement.
27317
27318              The  default  is to generate a comma-separated list of all book‐
27319              mark names that refer to the currently checked out revision.  If
27320              a  bookmark  is  active,  its  name  is suffixed an asterisk and
27321              placed first in the list.
27322
27323       use-prompt-escapes
27324              Determines if we assume that the assembled string from  vcs_info
27325              includes prompt escapes. (Used by vcs_info_lastmsg.)
27326
27327       debug  Enable  debugging  output  to track possible problems. Currently
27328              this style is only used by vcs_info's hooks system.
27329
27330       hooks  A list style that defines  hook-function  names.  See  Hooks  in
27331              vcs_info below for details.
27332
27333       patch-format
27334       nopatch-format
27335              This  pair of styles format the patch information used by the %m
27336              expando in formats and actionformats for the git  and  hg  back‐
27337              ends.   The  value  is subject to certain %-expansions described
27338              below.  The expanded value is made available in the global back‐
27339              end_misc   array   as   ${backend_misc[patches]}   (also   if  a
27340              set-patch-format hook is used).
27341
27342       get-unapplied
27343              This boolean style controls whether a backend should attempt  to
27344              gather  a  list of unapplied patches (for example with Mercurial
27345              Queue patches).
27346
27347              Used by the quilt and hg backends.
27348
27349       The default values for these styles in all contexts are:
27350
27351       formats
27352              " (%s)-[%b]%u%c-"
27353       actionformats
27354              " (%s)-[%b|%a]%u%c-"
27355       branchformat
27356              "%b:%r" (for bzr, svn, svk and hg)
27357       nvcsformats
27358              ""
27359       hgrevformat
27360              "%r:%h"
27361       max-exports
27362              2
27363       enable ALL
27364       disable
27365              (empty list)
27366       disable-patterns
27367              (empty list)
27368       check-for-changes
27369              false
27370       check-for-staged-changes
27371              false
27372       stagedstr
27373              (string: "S")
27374       unstagedstr
27375              (string: "U")
27376       command
27377              (empty string)
27378       use-server
27379              false
27380       use-simple
27381              false
27382       get-revision
27383              false
27384       get-mq true
27385       get-bookmarks
27386              false
27387       use-prompt-escapes
27388              true
27389       debug  false
27390       hooks  (empty list)
27391       use-quilt
27392              false
27393       quilt-standalone
27394              false
27395       quilt-patch-dir
27396              empty - use $QUILT_PATCHES
27397       quiltcommand
27398              quilt
27399       patch-format
27400              backend dependent
27401       nopatch-format
27402              backend dependent
27403       get-unapplied
27404              false
27405
27406       In normal formats and  actionformats  the  following  replacements  are
27407       done:
27408
27409       %s     The VCS in use (git, hg, svn, etc.).
27410       %b     Information about the current branch.
27411       %a     An identifier that describes the action. Only makes sense in ac‐
27412              tionformats.
27413       %i     The current revision number or identifier. For hg the  hgrevfor‐
27414              mat style may be used to customize the output.
27415       %c     The  string from the stagedstr style if there are staged changes
27416              in the repository.
27417       %u     The string from the unstagedstr  style  if  there  are  unstaged
27418              changes in the repository.
27419       %R     The base directory of the repository.
27420       %r     The repository name. If %R is /foo/bar/repoXY, %r is repoXY.
27421       %S     A  subdirectory  within  a  repository.  If $PWD is /foo/bar/re‐
27422              poXY/beer/tasty, %S is beer/tasty.
27423       %m     A "misc" replacement. It is at the discretion of the backend  to
27424              decide what this replacement expands to.
27425
27426              The hg and git backends use this expando to display patch infor‐
27427              mation.  hg sources patch information from  the  mq  extensions;
27428              git  from in-progress rebase and cherry-pick operations and from
27429              the stgit extension.  The patch-format and nopatch-format styles
27430              control  the generated string.  The former is used when at least
27431              one patch from the patch queue has been applied, and the  latter
27432              otherwise.
27433
27434              The hg backend displays bookmark information in this expando (in
27435              addition to mq information).  See the get-mq  and  get-bookmarks
27436              styles.   Both  of these styles may be enabled at the same time.
27437              If both are enabled, both resulting strings will be shown  sepa‐
27438              rated by a semicolon (that cannot currently be customized).
27439
27440              The  quilt  `standalone'  backend  sets this expando to the same
27441              value as the %Q expando.
27442
27443       %Q     Quilt series information.  When quilt is used (either in `addon'
27444              mode or as a `standalone' backend), this expando is set to quilt
27445              series' patch-format  string.   The  set-patch-format  hook  and
27446              nopatch-format style are honoured.
27447
27448              See Quilt Support below for details.
27449
27450       In branchformat these replacements are done:
27451
27452       %b     The branch name.
27453       %r     The current revision number or the hgrevformat style for hg.
27454
27455       In hgrevformat these replacements are done:
27456
27457       %r     The current local revision number.
27458       %h     The current global revision identifier.
27459
27460       In patch-format and nopatch-format these replacements are done:
27461
27462       %p     The name of the top-most applied patch; may be overridden by the
27463              applied-string hook.
27464       %u     The number of unapplied patches; may be overridden by the  unap‐
27465              plied-string hook.
27466       %n     The number of applied patches.
27467       %c     The number of unapplied patches.
27468       %a     The number of all patches (%a = %n + %c).
27469       %g     The names of active mq guards (hg backend).
27470       %G     The number of active mq guards (hg backend).
27471
27472       Not  all VCS backends have to support all replacements. For nvcsformats
27473       no replacements are performed at all, it is just a string.
27474
27475   Oddities
27476       If you want to use the %b (bold off) prompt expansion in formats, which
27477       expands  %b  itself, use %%b. That will cause the vcs_info expansion to
27478       replace %%b with %b, so that zsh's prompt expansion mechanism can  han‐
27479       dle  it. Similarly, to hand down %b from branchformat, use %%%%b. Sorry
27480       for this inconvenience, but it cannot be easily avoided. Luckily we  do
27481       not  clash  with  a  lot of prompt expansions and this only needs to be
27482       done for those.
27483
27484       When  one  of   the   gen-applied-string,   gen-unapplied-string,   and
27485       set-patch-format     hooks     is    defined,    applying    %-escaping
27486       (`foo=${foo//'%'/%%}') to the interpolated values for use in the prompt
27487       is  the  responsibility of those hooks (jointly); when neither of those
27488       hooks is defined, vcs_info handles escaping by itself.  We regret  this
27489       coupling, but it was required for backwards compatibility.
27490
27491   Quilt Support
27492       Quilt  is  not  a  version control system, therefore this is not imple‐
27493       mented as a backend. It can help keeping track of a series of  patches.
27494       People use it to keep a set of changes they want to use on top of soft‐
27495       ware packages (which is  tightly  integrated  into  the  package  build
27496       process - the Debian project does this for a large number of packages).
27497       Quilt can also help individual  developers  keep  track  of  their  own
27498       patches on top of real version control systems.
27499
27500       The  vcs_info  integration tries to support both ways of using quilt by
27501       having two slightly different modes  of  operation:  `addon'  mode  and
27502       `standalone' mode).
27503
27504       Quilt  integration  is  off by default; to enable it, set the use-quilt
27505       style, and add %Q to your formats or actionformats style:
27506              zstyle ':vcs_info:*' use-quilt true
27507
27508       Styles   looked   up   from   the   Quilt    support    code    include
27509       `.quilt-quilt-mode'  in  the  vcs-string  part  of  the  context, where
27510       quilt-mode    is    either    addon    or     standalone.      Example:
27511       :vcs_info:git.quilt-addon:default:repo-root-name.
27512
27513       For `addon' mode to become active vcs_info must have already detected a
27514       real version control system controlling the directory. If that  is  the
27515       case,  a  directory  that holds quilt's patches needs to be found. That
27516       directory is configurable via the `QUILT_PATCHES' environment variable.
27517       If  that  variable  exists  its  value  is  used,  otherwise  the value
27518       `patches' is assumed. The value from $QUILT_PATCHES can be  overwritten
27519       using  the  `quilt-patches'  style. (Note: you can use vcs_info to keep
27520       the value of $QUILT_PATCHES correct all the  time  via  the  post-quilt
27521       hook).
27522
27523       When the directory in question is found, quilt is assumed to be active.
27524       To gather more information,  vcs_info  looks  for  a  directory  called
27525       `.pc';  Quilt  uses  that directory to track its current state. If this
27526       directory does not exist we know that quilt has not  done  anything  to
27527       the working directory (read: no patches have been applied yet).
27528
27529       If  patches  are  applied,  vcs_info will try to find out which. If you
27530       want to know which patches of a series are not yet applied, you need to
27531       activate the get-unapplied style in the appropriate context.
27532
27533       vcs_info  allows for very detailed control over how the gathered infor‐
27534       mation is presented (see the Configuration and Hooks in  vcs_info  sec‐
27535       tions),  all  of which are documented below. Note there are a number of
27536       other patch tracking systems that work on top of a certain version con‐
27537       trol  system  (like stgit for git, or mq for hg); the configuration for
27538       systems like that are generally configured the same way  as  the  quilt
27539       support.
27540
27541       If the quilt support is working in `addon' mode, the produced string is
27542       available as a simple format replacement (%Q to be precise), which  can
27543       be used in formats and actionformats; see below for details).
27544
27545       If,  on  the  other  hand,  the support code is working in `standalone'
27546       mode, vcs_info will pretend as if quilt were an actual version  control
27547       system.  That  means  that the version control system identifier (which
27548       otherwise would be something like  `svn'  or  `cvs')  will  be  set  to
27549       `-quilt-'.  This  has implications on the used style context where this
27550       identifier is the second element. vcs_info will have filled in a proper
27551       value  for  the "repository's" root directory and the string containing
27552       the information about quilt's state will be available as the `misc' re‐
27553       placement (and %Q for compatibility with `addon' mode).
27554
27555       What  is  left to discuss is how `standalone' mode is detected. The de‐
27556       tection itself is a series of searches for directories.  You  can  have
27557       this detection enabled all the time in every directory that is not oth‐
27558       erwise under version control. If you know there is only a  limited  set
27559       of  trees  where  you  would like vcs_info to try and look for Quilt in
27560       `standalone' mode to minimise the amount of searching on every call  to
27561       vcs_info, there are a number of ways to do that:
27562
27563       Essentially,  `standalone'  mode  detection  is  controlled  by a style
27564       called `quilt-standalone'. It is a string style and its value can  have
27565       different  effects.  The simplest values are: `always' to run detection
27566       every time vcs_info is run, and `never' to turn the detection  off  en‐
27567       tirely.
27568
27569       If  the  value of quilt-standalone is something else, it is interpreted
27570       differently. If the value is the name of a scalar variable the value of
27571       that  variable  is  checked  and  that  value  is used in the same `al‐
27572       ways'/`never' way as described above.
27573
27574       If the value of quilt-standalone is an array, the elements of that  ar‐
27575       ray  are  used as directory names under which you want the detection to
27576       be active.
27577
27578       If quilt-standalone is an associative array, the keys are taken as  di‐
27579       rectory names under which you want the detection to be active, but only
27580       if the corresponding value is the string `true'.
27581
27582       Last, but not least, if the value of quilt-standalone is the name of  a
27583       function, the function is called without arguments and the return value
27584       decides whether detection should be active. A `0' return value is true;
27585       a non-zero return value is interpreted as false.
27586
27587       Note,  if  there  is  both  a  function  and  a variable by the name of
27588       quilt-standalone, the function will take precedence.
27589
27590   Function Descriptions (Public API)
27591       vcs_info [user-context]
27592              The main function, that runs all backends and assembles all data
27593              into  ${vcs_info_msg_*_}.  This is the function you want to call
27594              from precmd if you want to  include  up-to-date  information  in
27595              your prompt (see Variable Description below).  If an argument is
27596              given, that string will  be  used  instead  of  default  in  the
27597              user-context field of the style context.
27598
27599       vcs_info_hookadd
27600              Statically  registers a number of functions to a given hook. The
27601              hook needs to be given as the first argument; what follows is  a
27602              list  of hook-function names to register to the hook. The `+vi-'
27603              prefix needs to be left out here. See Hooks  in  vcs_info  below
27604              for details.
27605
27606       vcs_info_hookdel
27607              Remove  hook-functions  from  a given hook. The hook needs to be
27608              given as the first non-option argument; what follows is  a  list
27609              of  hook-function names to un-register from the hook. If `-a' is
27610              used as the first argument, all occurrences of the functions are
27611              unregistered.  Otherwise only the last occurrence is removed (if
27612              a function was registered to a hook more than once). The  `+vi-'
27613              prefix  needs  to be left out here.  See Hooks in vcs_info below
27614              for details.
27615
27616       vcs_info_lastmsg
27617              Outputs the last ${vcs_info_msg_*_} value.  Takes  into  account
27618              the  value  of  the  use-prompt-escapes style in ':vcs_info:for‐
27619              mats:command:-all-'. It also only prints max-exports values.
27620
27621       vcs_info_printsys [user-context]
27622              Prints a list of all supported version control  systems.  Useful
27623              to find out possible contexts (and which of them are enabled) or
27624              values for the disable style.
27625
27626       vcs_info_setsys
27627              Initializes vcs_info's internal list of available backends. With
27628              this function, you can add support for new VCSs without restart‐
27629              ing the shell.
27630
27631       All functions named VCS_INFO_* are for internal use only.
27632
27633   Variable Description
27634       ${vcs_info_msg_N_} (Note the trailing underscore)
27635              Where N is an integer, e.g.,  vcs_info_msg_0_.  These  variables
27636              are  the storage for the informational message the last vcs_info
27637              call has assembled. These are strongly connected to the formats,
27638              actionformats  and  nvcsformats  styles  described  above. Those
27639              styles are lists. The first member of that  list  gets  expanded
27640              into  ${vcs_info_msg_0_}, the second into ${vcs_info_msg_1_} and
27641              the Nth into ${vcs_info_msg_N-1_}. (See  the  max-exports  style
27642              above.)
27643
27644       All variables named VCS_INFO_* are for internal use only.
27645
27646   Hooks in vcs_info
27647       Hooks are places in vcs_info where you can run your own code. That code
27648       can communicate with the code that called it and through  that,  change
27649       the system's behaviour.
27650
27651       For configuration, hooks change the style context:
27652              :vcs_info:vcs-string+hook-name:user-context:repo-root-name
27653
27654       To  register  functions  to  a hook, you need to list them in the hooks
27655       style in the appropriate context.
27656
27657       Example:
27658              zstyle ':vcs_info:*+foo:*' hooks bar baz
27659
27660       This registers functions to the hook `foo' for all backends.  In  order
27661       to   avoid  namespace  problems,  all  registered  function  names  are
27662       prepended by a `+vi-', so the actual functions  called  for  the  `foo'
27663       hook are `+vi-bar' and `+vi-baz'.
27664
27665       If  you  would  like to register a function to a hook regardless of the
27666       current context, you may use the vcs_info_hookadd function. To remove a
27667       function that was added like that, the vcs_info_hookdel function can be
27668       used.
27669
27670       If something seems weird, you can enable the `debug' boolean  style  in
27671       the  proper  context and the hook-calling code will print what it tried
27672       to execute and whether the function in question existed.
27673
27674       When you register more than one function to a hook, all  functions  are
27675       executed one after another until one function returns non-zero or until
27676       all functions have been called. Context-sensitive  hook  functions  are
27677       executed   before   statically  registered  ones  (the  ones  added  by
27678       vcs_info_hookadd).
27679
27680       You  may  pass  data  between  functions  via  an  associative   array,
27681       user_data.  For example:
27682              +vi-git-myfirsthook(){
27683                  user_data[myval]=$myval
27684              }
27685              +vi-git-mysecondhook(){
27686                  # do something with ${user_data[myval]}
27687              }
27688
27689       There are a number of variables that are special in hook contexts:
27690
27691       ret    The  return  value  that  the  hooks  system  will return to the
27692              caller. The default is an integer `zero'. If and how  a  changed
27693              ret  value  changes  the  execution of the caller depends on the
27694              specific hook. See the hook documentation below for details.
27695
27696       hook_com
27697              An associated array which is used for  bidirectional  communica‐
27698              tion  from the caller to hook functions. The used keys depend on
27699              the specific hook.
27700
27701       context
27702              The active context of the hook. Functions that  wish  to  change
27703              this variable should make it local scope first.
27704
27705       vcs    The current VCS after it was detected. The same values as in the
27706              enable/disable style are used. Available  in  all  hooks  except
27707              start-up.
27708
27709       Finally, the full list of currently available hooks:
27710
27711       start-up
27712              Called after starting vcs_info but before the VCS in this direc‐
27713              tory is determined. It can be used to deactivate vcs_info tempo‐
27714              rarily  if  necessary. When ret is set to 1, vcs_info aborts and
27715              does nothing; when set to 2, vcs_info sets up everything  as  if
27716              no version control were active and exits.
27717
27718       pre-get-data
27719              Same as start-up but after the VCS was detected.
27720
27721       gen-hg-bookmark-string
27722              Called in the Mercurial backend when a bookmark string is gener‐
27723              ated; the get-revision and get-bookmarks styles must be true.
27724
27725              This hook  gets  the  names  of  the  Mercurial  bookmarks  that
27726              vcs_info collected from `hg'.
27727
27728              If a bookmark is active, the key ${hook_com[hg-active-bookmark]}
27729              is set to its name.  The key is otherwise unset.
27730
27731              When setting ret to non-zero, the string in  ${hook_com[hg-book‐
27732              mark-string]}  will  be used in the %m escape in formats and ac‐
27733              tionformats and will be available in the global backend_misc ar‐
27734              ray as ${backend_misc[bookmarks]}.
27735
27736       gen-applied-string
27737              Called in the git (with stgit or during rebase or merge), and hg
27738              (with mq) backends and in quilt support when the  applied-string
27739              is  generated;  the use-quilt zstyle must be true for quilt (the
27740              mq and stgit backends are active by default).
27741
27742              This hook gets the names of all applied patches  which  vcs_info
27743              collected  so  far  in  the opposite order, which means that the
27744              first argument is the top-most patch and so forth.
27745
27746              When setting ret  to  non-zero,  the  string  in  ${hook_com[ap‐
27747              plied-string]}  will  be available as %p in the patch-format and
27748              nopatch-format  styles.   This  hook   is,   in   concert   with
27749              set-patch-format,  responsible for %-escaping that value for use
27750              in the prompt.  (See the Oddities section.)
27751
27752       gen-unapplied-string
27753              Called in the git (with stgit or during rebase),  and  hg  (with
27754              mq)  backend  and  in quilt support when the unapplied-string is
27755              generated; the get-unapplied style must be true.
27756
27757              This hook gets the names of all unapplied patches which vcs_info
27758              collected  so  far in order, which means that the first argument
27759              is the patch next-in-line to be applied and so forth.
27760
27761              When setting ret to non-zero,  the  string  in  ${hook_com[unap‐
27762              plied-string]}  will  be available as %u in the patch-format and
27763              nopatch-format  styles.   This  hook   is,   in   concert   with
27764              set-patch-format,  responsible for %-escaping that value for use
27765              in the prompt.  (See the Oddities section.)
27766
27767       gen-mqguards-string
27768              Called in the hg backend when guards-string  is  generated;  the
27769              get-mq style must be true (default).
27770
27771              This hook gets the names of any active mq guards.
27772
27773              When    setting    ret    to    non-zero,    the    string    in
27774              ${hook_com[guards-string]} will be used in the %g escape in  the
27775              patch-format and nopatch-format styles.
27776
27777       no-vcs This  hooks  is  called  when  no version control system was de‐
27778              tected.
27779
27780              The `hook_com' parameter is not used.
27781
27782       post-backend
27783              Called as soon as the backend has finished  collecting  informa‐
27784              tion.
27785
27786              The `hook_com' keys available are as for the set-message hook.
27787
27788       post-quilt
27789              Called  after  the quilt support is done. The following informa‐
27790              tion is passed as arguments to the hook:  1.  the  quilt-support
27791              mode  (`addon'  or `standalone'); 2. the directory that contains
27792              the patch series; 3. the directory that holds quilt's status in‐
27793              formation  (the  `.pc' directory) or the string "-nopc-" if that
27794              directory wasn't found.
27795
27796              The `hook_com' parameter is not used.
27797
27798       set-branch-format
27799              Called before `branchformat' is set. The only  argument  to  the
27800              hook is the format that is configured at this point.
27801
27802              The  `hook_com'  keys  considered  are  `branch' and `revision'.
27803              They are set to the values figured out so far  by  vcs_info  and
27804              any  change will be used directly when the actual replacement is
27805              done.
27806
27807              If ret is set to non-zero, the string  in  ${hook_com[branch-re‐
27808              place]}  will  be  used unchanged as the `%b' replacement in the
27809              variables set by vcs_info.
27810
27811       set-hgrev-format
27812              Called before a `hgrevformat' is set. The only argument  to  the
27813              hook is the format that is configured at this point.
27814
27815              The  `hook_com' keys considered are `hash' and `localrev'.  They
27816              are set to the values figured out so far  by  vcs_info  and  any
27817              change  will  be  used  directly  when the actual replacement is
27818              done.
27819
27820              If ret is set to  non-zero,  the  string  in  ${hook_com[rev-re‐
27821              place]}  will  be  used unchanged as the `%i' replacement in the
27822              variables set by vcs_info.
27823
27824       pre-addon-quilt
27825              This hook is used when vcs_info's quilt functionality is  active
27826              in  "addon"  mode  (quilt  used on top of a real version control
27827              system). It is activated right before any quilt specific  action
27828              is taken.
27829
27830              Setting  the  `ret'  variable  in  this hook to a non-zero value
27831              avoids any quilt specific actions from being run at all.
27832
27833       set-patch-format
27834              This hook is used to control some of the possible expansions  in
27835              patch-format  and nopatch-format styles with patch queue systems
27836              such as quilt, mqueue and the like.
27837
27838              This hook is used in the git, hg and quilt backends.
27839
27840              The hook allows the control of the %p (${hook_com[applied]}) and
27841              %u  (${hook_com[unapplied]})  expansion in all backends that use
27842              the   hook.    With    the    mercurial    backend,    the    %g
27843              (${hook_com[guards]})  expansion  is controllable in addition to
27844              that.
27845
27846              If ret is set to non-zero, the  string  in  ${hook_com[patch-re‐
27847              place]}  will  be  used  unchanged instead of an expanded format
27848              from patch-format or nopatch-format.
27849
27850              This hook is, in concert with the gen-applied-string or  gen-un‐
27851              applied-string  hooks if they are defined, responsible for %-es‐
27852              caping the final patch-format value for use in the prompt.  (See
27853              the Oddities section.)
27854
27855       set-message
27856              Called  each time before a `vcs_info_msg_N_' message is set.  It
27857              takes two arguments; the first being  the  `N'  in  the  message
27858              variable name, the second is the currently configured formats or
27859              actionformats.
27860
27861              There are a number of `hook_com' keys, that are used here:  `ac‐
27862              tion',  `branch',  `base', `base-name', `subdir', `staged', `un‐
27863              staged', `revision', `misc', `vcs' and  one  `miscN'  entry  for
27864              each  backend-specific data field (N starting at zero). They are
27865              set to the values figured out so far by vcs_info and any  change
27866              will be used directly when the actual replacement is done.
27867
27868              Since  this hook is triggered multiple times (once for each con‐
27869              figured formats or actionformats), each of the  `hook_com'  keys
27870              mentioned  above  (except  for the miscN entries) has an `_orig'
27871              counterpart, so even if you changed a value to your  liking  you
27872              can  still  get the original value in the next run. Changing the
27873              `_orig' values is probably not a good idea.
27874
27875              If ret is set to non-zero, the  string  in  ${hook_com[message]}
27876              will be used unchanged as the message by vcs_info.
27877
27878       If  all  of  this  sounds rather confusing, take a look at the Examples
27879       section below and also in the Misc/vcs_info-examples file  in  the  Zsh
27880       source.  They contain some explanatory code.
27881
27882   Examples
27883       Don't use vcs_info at all (even though it's in your prompt):
27884              zstyle ':vcs_info:*' enable NONE
27885
27886       Disable the backends for bzr and svk:
27887              zstyle ':vcs_info:*' disable bzr svk
27888
27889       Disable everything but bzr and svk:
27890              zstyle ':vcs_info:*' enable bzr svk
27891
27892       Provide a special formats for git:
27893              zstyle ':vcs_info:git:*' formats       ' GIT, BABY! [%b]'
27894              zstyle ':vcs_info:git:*' actionformats ' GIT ACTION! [%b|%a]'
27895
27896       All  %x  expansion  in  all  sorts  of formats (formats, actionformats,
27897       branchformat, you name it) are done using the  `zformat'  builtin  from
27898       the  `zsh/zutil' module. That means you can do everything with these %x
27899       items what zformat supports. In particular, if you want something  that
27900       is  really  long  to  have  a  fixed  width, like a hash in a mercurial
27901       branchformat, you can do this: %12.12i. That'll shrink the 40 character
27902       hash  to  its  12 leading characters. The form is actually `%min.maxx'.
27903       More is possible.  See the section `The zsh/zutil  Module'  in  zshmod‐
27904       ules(1) for details.
27905
27906       Use the quicker bzr backend
27907              zstyle ':vcs_info:bzr:*' use-simple true
27908
27909       If    you    do    use   use-simple,   please   report   if   it   does
27910       `the-right-thing[tm]'.
27911
27912       Display the revision number in yellow for bzr and svn:
27913              zstyle ':vcs_info:(svn|bzr):*' \
27914                     branchformat '%b%{'${fg[yellow]}'%}:%r'
27915
27916       If you want colors, make sure you enclose the color codes in %{...%} if
27917       you want to use the string provided by vcs_info in prompts.
27918
27919       Here  is  how  to  print  the  VCS  information  as a command (not in a
27920       prompt):
27921              alias vcsi='vcs_info command; vcs_info_lastmsg'
27922
27923       This way,  you  can  even  define  different  formats  for  output  via
27924       vcs_info_lastmsg in the ':vcs_info:*:command:*' namespace.
27925
27926       Now  as promised, some code that uses hooks: say, you'd like to replace
27927       the string `svn' by `subversion' in vcs_info's %s formats replacement.
27928
27929       First, we will tell vcs_info to call a  function  when  populating  the
27930       message variables with the gathered information:
27931              zstyle ':vcs_info:*+set-message:*' hooks svn2subversion
27932
27933       Nothing happens. Which is reasonable, since we didn't define the actual
27934       function yet. To see what the hooks subsystem is trying to  do,  enable
27935       the `debug' style:
27936              zstyle ':vcs_info:*+*:*' debug true
27937
27938       That  should give you an idea what is going on. Specifically, the func‐
27939       tion that we are looking for is `+vi-svn2subversion'. Note, the  `+vi-'
27940       prefix.  So,  everything  is in order, just as documented. When you are
27941       done checking out the debugging output, disable it again:
27942              zstyle ':vcs_info:*+*:*' debug false
27943
27944       Now, let's define the function:
27945              function +vi-svn2subversion() {
27946                  [[ ${hook_com[vcs_orig]} == svn ]] && hook_com[vcs]=subversion
27947              }
27948
27949       Simple enough. And it could have even been simpler, if only we had reg‐
27950       istered our function in a less generic context. If we do it only in the
27951       `svn' backend's context, we don't need to test which the active backend
27952       is:
27953              zstyle ':vcs_info:svn+set-message:*' hooks svn2subversion
27954              function +vi-svn2subversion() {
27955                  hook_com[vcs]=subversion
27956              }
27957
27958       And finally a little more elaborate example, that uses a hook to create
27959       a customised bookmark string for the hg backend.
27960
27961       Again, we start off by registering a function:
27962              zstyle ':vcs_info:hg+gen-hg-bookmark-string:*' hooks hgbookmarks
27963
27964       And then we define the `+vi-hgbookmarks' function:
27965              function +vi-hgbookmarks() {
27966                  # The default is to connect all bookmark names by
27967                  # commas. This mixes things up a little.
27968                  # Imagine, there's one type of bookmarks that is
27969                  # special to you. Say, because it's *your* work.
27970                  # Those bookmarks look always like this: "sh/*"
27971                  # (because your initials are sh, for example).
27972                  # This makes the bookmarks string use only those
27973                  # bookmarks. If there's more than one, it
27974                  # concatenates them using commas.
27975                  # The bookmarks returned by `hg' are available in
27976                  # the function's positional parameters.
27977                  local s="${(Mj:,:)@:#sh/*}"
27978                  # Now, the communication with the code that calls
27979                  # the hook functions is done via the hook_com[]
27980                  # hash. The key at which the `gen-hg-bookmark-string'
27981                  # hook looks is `hg-bookmark-string'. So:
27982                  hook_com[hg-bookmark-string]=$s
27983                  # And to signal that we want to use the string we
27984                  # just generated, set the special variable `ret' to
27985                  # something other than the default zero:
27986                  ret=1
27987                  return 0
27988              }
27989
27990       Some longer examples and code snippets which might be useful are avail‐
27991       able  in the examples file located at Misc/vcs_info-examples in the Zsh
27992       source directory.
27993
27994       This concludes our guided tour through zsh's vcs_info.
27995

PROMPT THEMES

27997   Installation
27998       You should make sure all the functions from the  Functions/Prompts  di‐
27999       rectory  of  the source distribution are available; they all begin with
28000       the string `prompt_' except for the special function`promptinit'.   You
28001       also   need  the  `colors'  and  `add-zsh-hook'  functions  from  Func‐
28002       tions/Misc.  All these functions may already be installed on your  sys‐
28003       tem;  if  not, you will need to find them and copy them.  The directory
28004       should appear as one of the elements of the fpath  array  (this  should
28005       already  be the case if they were installed), and at least the function
28006       promptinit should be autoloaded; it will autoload the  rest.   Finally,
28007       to  initialize  the  use  of the system you need to call the promptinit
28008       function.  The following code in your .zshrc will arrange for this; as‐
28009       sume the functions are stored in the directory ~/myfns:
28010
28011              fpath=(~/myfns $fpath)
28012              autoload -U promptinit
28013              promptinit
28014
28015   Theme Selection
28016       Use  the  prompt  command to select your preferred theme.  This command
28017       may be added to your .zshrc following the call to promptinit  in  order
28018       to start zsh with a theme already selected.
28019
28020       prompt [ -c | -l ]
28021       prompt [ -p | -h ] [ theme ... ]
28022       prompt [ -s ] theme [ arg ... ]
28023              Set  or  examine  the prompt theme.  With no options and a theme
28024              argument, the theme with that name is set as the current  theme.
28025              The  available themes are determined at run time; use the -l op‐
28026              tion to see a list.  The special theme `random' selects at  ran‐
28027              dom one of the available themes and sets your prompt to that.
28028
28029              In  some  cases  the  theme may be modified by one or more argu‐
28030              ments, which should be given after the theme name.  See the help
28031              for each theme for descriptions of these arguments.
28032
28033              Options are:
28034
28035              -c     Show  the currently selected theme and its parameters, if
28036                     any.
28037              -l     List all available prompt themes.
28038              -p     Preview the theme named by theme, or  all  themes  if  no
28039                     theme is given.
28040              -h     Show help for the theme named by theme, or for the prompt
28041                     function if no theme is given.
28042              -s     Set theme as the current theme and save state.
28043
28044       prompt_theme_setup
28045              Each available theme has a setup function which is called by the
28046              prompt function to install that theme.  This function may define
28047              other functions as necessary to maintain the  prompt,  including
28048              functions  used  to  preview  the prompt or provide help for its
28049              use.  You should not normally call a theme's setup function  di‐
28050              rectly.
28051
28052   Utility Themes
28053       prompt off
28054              The  theme `off' sets all the prompt variables to minimal values
28055              with no special effects.
28056
28057       prompt default
28058              The theme `default' sets all prompt variables to the same  state
28059              as  if  an  interactive  zsh  was started with no initialization
28060              files.
28061
28062       prompt restore
28063              The special theme `restore' erases all theme settings  and  sets
28064              prompt  variables  to  their  state  before  the  first time the
28065              `prompt' function was run, provided each theme has properly  de‐
28066              fined its cleanup (see below).
28067
28068              Note  that  you  can undo `prompt off' and `prompt default' with
28069              `prompt restore', but a second restore does not undo the first.
28070
28071   Writing Themes
28072       The first step for adding your own theme is to choose a  name  for  it,
28073       and  create  a  file  `prompt_name_setup' in a directory in your fpath,
28074       such as ~/myfns in the example above.  The file should at minimum  con‐
28075       tain  assignments  for  the  prompt variables that your theme wishes to
28076       modify.  By convention, themes use PS1, PS2, RPS1,  etc.,  rather  than
28077       the longer PROMPT and RPROMPT.
28078
28079       The  file  is autoloaded as a function in the current shell context, so
28080       it may contain any necessary commands to customize your theme,  includ‐
28081       ing  defining additional functions.  To make some complex tasks easier,
28082       your setup function may also do any of the following:
28083
28084       Assign prompt_opts
28085              The array prompt_opts may be assigned any of "bang", "cr", "per‐
28086              cent",  "sp",  and/or  "subst" as values.  The corresponding se‐
28087              topts (promptbang, etc.) are turned on, all other prompt-related
28088              options are turned off.  The prompt_opts array preserves setopts
28089              even beyond the scope of localoptions, should your function need
28090              that.
28091
28092       Modify precmd and preexec
28093              Use  of  add-zsh-hook  is  recommended.   The precmd and preexec
28094              hooks are automatically adjusted if the prompt theme changes  or
28095              is disabled.
28096
28097       Declare cleanup
28098              If  your  function makes any other changes that should be undone
28099              when the theme is disabled, your setup function may call
28100              prompt_cleanup command
28101       where command should be suitably quoted.  If your theme  is  ever  dis‐
28102       abled  or  replaced by another, command is executed with eval.  You may
28103       declare more than one such cleanup hook.
28104
28105       Define preview
28106              Define or autoload a function prompt_name_preview to  display  a
28107              simulated version of your prompt.  A simple default previewer is
28108              defined by promptinit for themes that do not define  their  own.
28109              This preview function is called by `prompt -p'.
28110
28111       Provide help
28112              Define  or autoload a function prompt_name_help to display docu‐
28113              mentation or help text for your theme.  This  help  function  is
28114              called by `prompt -h'.
28115

ZLE FUNCTIONS

28117   Widgets
28118       These  functions all implement user-defined ZLE widgets (see zshzle(1))
28119       which can be bound to keystrokes in interactive shells.  To  use  them,
28120       your .zshrc should contain lines of the form
28121
28122              autoload function
28123              zle -N function
28124
28125       followed  by  an  appropriate bindkey command to associate the function
28126       with a key sequence.  Suggested bindings are described below.
28127
28128       bash-style word functions
28129              If you are looking for functions to implement  moving  over  and
28130              editing  words  in  the  manner of bash, where only alphanumeric
28131              characters are considered word characters, you can use the func‐
28132              tions  described  in  the next section.  The following is suffi‐
28133              cient:
28134
28135                     autoload -U select-word-style
28136                     select-word-style bash
28137
28138       forward-word-match, backward-word-match
28139       kill-word-match, backward-kill-word-match
28140       transpose-words-match, capitalize-word-match
28141       up-case-word-match, down-case-word-match
28142       delete-whole-word-match, select-word-match
28143       select-word-style, match-word-context, match-words-by-style
28144              The first eight `-match' functions are drop-in replacements  for
28145              the  builtin widgets without the suffix.  By default they behave
28146              in a similar way.  However, by the use of styles and  the  func‐
28147              tion  select-word-style,  the  way  words are matched can be al‐
28148              tered. select-word-match is intended to be used as a text object
28149              in vi mode but with custom word styles. For comparison, the wid‐
28150              gets described in zshzle(1) under Text Objects use fixed defini‐
28151              tions of words, compatible with the vim editor.
28152
28153              The  simplest  way  of  configuring  the functions is to use se‐
28154              lect-word-style, which can either be called as a normal function
28155              with the appropriate argument, or invoked as a user-defined wid‐
28156              get that will prompt for the first character of the  word  style
28157              to  be  used.   The  first  time  it is invoked, the first eight
28158              -match functions will automatically  replace  the  builtin  ver‐
28159              sions, so they do not need to be loaded explicitly.
28160
28161              The  word styles available are as follows.  Only the first char‐
28162              acter is examined.
28163
28164              bash   Word characters are alphanumeric characters only.
28165
28166              normal As in normal shell operation:  word  characters  are  al‐
28167                     phanumeric  characters plus any characters present in the
28168                     string given by the parameter $WORDCHARS.
28169
28170              shell  Words are complete shell command arguments, possibly  in‐
28171                     cluding complete quoted strings, or any tokens special to
28172                     the shell.
28173
28174              whitespace
28175                     Words are any set of characters delimited by whitespace.
28176
28177              default
28178                     Restore the default settings; this is usually the same as
28179                     `normal'.
28180
28181              All but `default' can be input as an upper case character, which
28182              has the same effect but with subword  matching  turned  on.   In
28183              this  case,  words  with  upper case characters are treated spe‐
28184              cially: each separate run of upper case characters, or an  upper
28185              case  character  followed  by any number of other characters, is
28186              considered a word.  The style subword-range can supply an alter‐
28187              native  character range to the default `[:upper:]'; the value of
28188              the style is treated as the contents of a `[...]' pattern  (note
28189              that  the outer brackets should not be supplied, only those sur‐
28190              rounding named ranges).
28191
28192              More control can be obtained using the zstyle  command,  as  de‐
28193              scribed  in  zshmodules(1).  Each style is looked up in the con‐
28194              text :zle:widget where widget is the name  of  the  user-defined
28195              widget,  not the name of the function implementing it, so in the
28196              case of the definitions supplied by select-word-style the appro‐
28197              priate  contexts are :zle:forward-word, and so on.  The function
28198              select-word-style itself always defines styles for  the  context
28199              `:zle:*'  which can be overridden by more specific (longer) pat‐
28200              terns as well as explicit contexts.
28201
28202              The style word-style specifies the rules to use.  This may  have
28203              the following values.
28204
28205              normal Use  the  standard  shell  rules,  i.e. alphanumerics and
28206                     $WORDCHARS, unless overridden by the styles word-chars or
28207                     word-class.
28208
28209              specified
28210                     Similar to normal, but only the specified characters, and
28211                     not also alphanumerics, are considered word characters.
28212
28213              unspecified
28214                     The negation of  specified.   The  given  characters  are
28215                     those which will not be considered part of a word.
28216
28217              shell  Words  are obtained by using the syntactic rules for gen‐
28218                     erating shell command arguments.   In  addition,  special
28219                     tokens which are never command arguments such as `()' are
28220                     also treated as words.
28221
28222              whitespace
28223                     Words are whitespace-delimited strings of characters.
28224
28225              The first three of those rules usually use $WORDCHARS,  but  the
28226              value   in   the  parameter  can  be  overridden  by  the  style
28227              word-chars, which works in exactly the same way  as  $WORDCHARS.
28228              In addition, the style word-class uses character class syntax to
28229              group characters and takes precedence over  word-chars  if  both
28230              are  set.  The word-class style does not include the surrounding
28231              brackets of the character class; for example, `-:[:alnum:]' is a
28232              valid  word-class  to include all alphanumerics plus the charac‐
28233              ters `-' and `:'.  Be careful including  `]',  `^'  and  `-'  as
28234              these are special inside character classes.
28235
28236              word-style  may  also  have  `-subword' appended to its value to
28237              turn on subword matching, as described above.
28238
28239              The style skip-chars is mostly useful  for  transpose-words  and
28240              similar  functions.   If  set,  it  gives  a count of characters
28241              starting at the cursor position which  will  not  be  considered
28242              part  of  the  word and are treated as space, regardless of what
28243              they actually are.  For example, if
28244
28245                     zstyle ':zle:transpose-words' skip-chars 1
28246
28247              has been set, and transpose-words-match is called with the  cur‐
28248              sor  on the X of fooXbar, where X can be any character, then the
28249              resulting expression is barXfoo.
28250
28251              Finer grained control can  be  obtained  by  setting  the  style
28252              word-context  to an array of pairs of entries.  Each pair of en‐
28253              tries consists of a pattern and a subcontext.  The  shell  argu‐
28254              ment  the  cursor  is on is matched against each pattern in turn
28255              until one matches; if it does, the  context  is  extended  by  a
28256              colon  and  the corresponding subcontext.  Note that the test is
28257              made against the original word on the line, with no stripping of
28258              quotes.   Special  handling  is  done between words: the current
28259              context is examined and if it contains the  string  between  the
28260              word is set to a single space; else if it is contains the string
28261              back, the word before the cursor is considered,  else  the  word
28262              after cursor is considered. Some examples are given below.
28263
28264              The  style  skip-whitespace-first  is  only  used  with the for‐
28265              ward-word widget.  If it is set to true, then forward-word skips
28266              any  non-word-characters,  followed  by any non-word-characters:
28267              this is similar to the behaviour of other  word-orientated  wid‐
28268              gets,  and  also  that used by other editors, however it differs
28269              from the standard zsh behaviour.  When  using  select-word-style
28270              the  widget  is  set  in  the context :zle:* to true if the word
28271              style is bash and false otherwise.  It may be overridden by set‐
28272              ting it in the more specific context :zle:forward-word*.
28273
28274              It  is  possible  to  create  widgets with specific behaviour by
28275              defining a new widget implemented  by  the  appropriate  generic
28276              function,  then  setting a style for the context of the specific
28277              widget.  For example,  the  following  defines  a  widget  back‐
28278              ward-kill-space-word using backward-kill-word-match, the generic
28279              widget implementing backward-kill-word  behaviour,  and  ensures
28280              that the new widget always implements space-delimited behaviour.
28281
28282                     zle -N backward-kill-space-word backward-kill-word-match
28283                     zstyle :zle:backward-kill-space-word word-style space
28284
28285              The widget backward-kill-space-word can now be bound to a key.
28286
28287              Here  are  some  further examples of use of the styles, actually
28288              taken from the simplified interface in select-word-style:
28289
28290                     zstyle ':zle:*' word-style standard
28291                     zstyle ':zle:*' word-chars ''
28292
28293              Implements bash-style word handling for all widgets,  i.e.  only
28294              alphanumerics are word characters; equivalent to setting the pa‐
28295              rameter WORDCHARS empty for the given context.
28296
28297                     style ':zle:*kill*' word-style space
28298
28299              Uses space-delimited words for widgets with the word  `kill'  in
28300              the  name.   Neither  of the styles word-chars nor word-class is
28301              used in this case.
28302
28303              Here are some examples of use of the word-context style  to  ex‐
28304              tend the context.
28305
28306                     zstyle ':zle:*' word-context \
28307                            "*/*" filename "[[:space:]]" whitespace
28308                     zstyle ':zle:transpose-words:whitespace' word-style shell
28309                     zstyle ':zle:transpose-words:filename' word-style normal
28310                     zstyle ':zle:transpose-words:filename' word-chars ''
28311
28312              This  provides  two  different ways of using transpose-words de‐
28313              pending on whether the cursor is on whitespace between words  or
28314              on  a  filename,  here  any word containing a /.  On whitespace,
28315              complete arguments as defined by standard shell  rules  will  be
28316              transposed.   In  a  filename, only alphanumerics will be trans‐
28317              posed.  Elsewhere, words will be transposed  using  the  default
28318              style for :zle:transpose-words.
28319
28320              The word matching and all the handling of zstyle settings is ac‐
28321              tually implemented by the function  match-words-by-style.   This
28322              can  be  used  to  create new user-defined widgets.  The calling
28323              function should set the local parameter curcontext to  :zle:wid‐
28324              get,   create   the   local  parameter  matched_words  and  call
28325              match-words-by-style   with   no    arguments.     On    return,
28326              matched_words will be set to an array with the elements: (1) the
28327              start of the line  (2)  the  word  before  the  cursor  (3)  any
28328              non-word  characters  between  that  word and the cursor (4) any
28329              non-word character at the cursor  position  plus  any  remaining
28330              non-word  characters before the next word, including all charac‐
28331              ters specified by the skip-chars style, (5) the word at or  fol‐
28332              lowing  the  cursor  (6)  any non-word characters following that
28333              word (7) the remainder of the line.  Any of the elements may  be
28334              an  empty  string;  the calling function should test for this to
28335              decide whether it can perform its function.
28336
28337              If the variable  matched_words  is  defined  by  the  caller  to
28338              match-words-by-style   as   an   associative   array  (local  -A
28339              matched_words), then the seven values given above should be  re‐
28340              trieved  from  it  as  elements named start, word-before-cursor,
28341              ws-before-cursor,  ws-after-cursor,  word-after-cursor,   ws-af‐
28342              ter-word,  and  end.  In addition the element is-word-start is 1
28343              if the cursor is on the start of a word or subword, or on  white
28344              space  before  it (the cases can be distinguished by testing the
28345              ws-after-cursor element) and 0 otherwise.  This form  is  recom‐
28346              mended for future compatibility.
28347
28348              It   is   possible   to   pass   options   with   arguments   to
28349              match-words-by-style to override the use of styles.  The options
28350              are:
28351              -w     word-style
28352              -s     skip-chars
28353              -c     word-class
28354              -C     word-chars
28355              -r     subword-range
28356
28357              For  example,  match-words-by-style -w shell -c 0 may be used to
28358              extract the command argument around the cursor.
28359
28360              The  word-context  style  is   implemented   by   the   function
28361              match-word-context.   This  should not usually need to be called
28362              directly.
28363
28364       bracketed-paste-magic
28365              The bracketed-paste widget (see subsection Miscellaneous in zsh‐
28366              zle(1))  inserts  pasted  text  literally into the editor buffer
28367              rather than interpret it as keystrokes.  This disables some com‐
28368              mon  usages where the self-insert widget is replaced in order to
28369              accomplish some extra processing.  An example is the contributed
28370              url-quote-magic widget described below.
28371
28372              The  bracketed-paste-magic  widget  is  meant  to replace brack‐
28373              eted-paste with a wrapper that re-enables these self-insert  ac‐
28374              tions, and other actions as selected by zstyles.  Therefore this
28375              widget is installed with
28376
28377                     autoload -Uz bracketed-paste-magic
28378                     zle -N bracketed-paste bracketed-paste-magic
28379
28380              Other   than   enabling   some   widget    processing,    brack‐
28381              eted-paste-magic attempts to replicate bracketed-paste as faith‐
28382              fully as possible.
28383
28384              The following zstyles may be set to control processing of pasted
28385              text.    All   are   looked   up   in   the   context   `:brack‐
28386              eted-paste-magic'.
28387
28388              active-widgets
28389                     A list of patterns matching widget names that  should  be
28390                     activated  during the paste.  All other key sequences are
28391                     processed as self-insert-unmeta.  The default is `self-*'
28392                     so  any  user-defined  widgets named with that prefix are
28393                     active along with the builtin self-insert.
28394
28395                     If this style is not set (explicitly deleted) or  set  to
28396                     an empty value, no widgets are active and the pasted text
28397                     is inserted literally.   If  the  value  includes  `unde‐
28398                     fined-key',  any unknown sequences are discarded from the
28399                     pasted text.
28400
28401              inactive-keys
28402                     The inverse of active-widgets, a list  of  key  sequences
28403                     that  always use self-insert-unmeta even when bound to an
28404                     active widget.  Note that this is a list of  literal  key
28405                     sequences, not patterns.
28406
28407              paste-init
28408                     A  list  of function names, called in widget context (but
28409                     not as widgets).  The functions are called in order until
28410                     one  of  them  returns  a non-zero status.  The parameter
28411                     `PASTED' contains the initial state of the  pasted  text.
28412                     All other ZLE parameters such as `BUFFER' have their nor‐
28413                     mal values and side-effects, and full history  is  avail‐
28414                     able,  so for example paste-init functions may move words
28415                     from BUFFER into PASTED to make those  words  visible  to
28416                     the active-widgets.
28417
28418                     A  non-zero  return  from  a paste-init function does not
28419                     prevent the paste itself from proceeding.
28420
28421                     Loading   bracketed-paste-magic   defines    backward-ex‐
28422                     tend-paste, a helper function for use in paste-init.
28423
28424                            zstyle :bracketed-paste-magic paste-init \
28425                                   backward-extend-paste
28426
28427                     When  a  paste  would insert into the middle of a word or
28428                     append text to a word already on the  line,  backward-ex‐
28429                     tend-paste  moves  the prefix from LBUFFER into PASTED so
28430                     that the active-widgets see the full word so  far.   This
28431                     may be useful with url-quote-magic.
28432
28433              paste-finish
28434                     Another  list of function names called in order until one
28435                     returns non-zero.  These functions are called  after  the
28436                     pasted text has been processed by the active-widgets, but
28437                     before it is inserted into `BUFFER'.  ZLE parameters have
28438                     their normal values and side-effects.
28439
28440                     A  non-zero  return from a paste-finish function does not
28441                     prevent the paste itself from proceeding.
28442
28443                     Loading bracketed-paste-magic also defines quote-paste, a
28444                     helper function for use in paste-finish.
28445
28446                            zstyle :bracketed-paste-magic paste-finish \
28447                                   quote-paste
28448                            zstyle :bracketed-paste-magic:finish quote-style \
28449                                   qqq
28450
28451                     When  the  pasted  text  is  inserted  into BUFFER, it is
28452                     quoted per the quote-style value.  To forcibly  turn  off
28453                     the  built-in  numeric prefix quoting of bracketed-paste,
28454                     use:
28455
28456                            zstyle :bracketed-paste-magic:finish quote-style \
28457                                   none
28458
28459              Important: During active-widgets processing of the paste  (after
28460              paste-init  and  before  paste-finish),  BUFFER starts empty and
28461              history is restricted, so cursor motions,  etc.,  may  not  pass
28462              outside  of  the pasted content.  Text assigned to BUFFER by the
28463              active widgets is copied back into PASTED before paste-finish.
28464
28465       copy-earlier-word
28466              This widget works like a  combination  of  insert-last-word  and
28467              copy-prev-shell-word.   Repeated  invocations  of the widget re‐
28468              trieve earlier words on the relevant history line.  With  a  nu‐
28469              meric  argument  N, insert the Nth word from the history line; N
28470              may be negative to count from the end of the line.
28471
28472              If insert-last-word has been used to retrieve the last word on a
28473              previous  history  line,  repeated invocations will replace that
28474              word with earlier words from the same line.
28475
28476              Otherwise, the widget applies to words on the line currently be‐
28477              ing  edited.  The widget style can be set to the name of another
28478              widget that should be called to  retrieve  words.   This  widget
28479              must accept the same three arguments as insert-last-word.
28480
28481       cycle-completion-positions
28482              After inserting an unambiguous string into the command line, the
28483              new function based completion system  may  know  about  multiple
28484              places  in  this  string  where characters are missing or differ
28485              from at least one of the possible matches.  It will  then  place
28486              the cursor on the position it considers to be the most interest‐
28487              ing one, i.e. the one where one can disambiguate between as many
28488              matches as possible with as little typing as possible.
28489
28490              This  widget  allows  the cursor to be easily moved to the other
28491              interesting spots.  It can be invoked repeatedly  to  cycle  be‐
28492              tween all positions reported by the completion system.
28493
28494       delete-whole-word-match
28495              This  is  another function which works like the -match functions
28496              described immediately above, i.e. using  styles  to  decide  the
28497              word  boundaries.   However, it is not a replacement for any ex‐
28498              isting function.
28499
28500              The basic behaviour is to delete the  word  around  the  cursor.
28501              There  is  no  numeric  argument  handling; only the single word
28502              around the cursor is considered.  If  the  widget  contains  the
28503              string  kill,  the  removed text will be placed in the cutbuffer
28504              for  future  yanking.   This  can  be   obtained   by   defining
28505              kill-whole-word-match as follows:
28506
28507                     zle -N kill-whole-word-match delete-whole-word-match
28508
28509              and then binding the widget kill-whole-word-match.
28510
28511       up-line-or-beginning-search, down-line-or-beginning-search
28512              These   widgets   are   similar   to   the   builtin   functions
28513              up-line-or-search and down-line-or-search:  if  in  a  multiline
28514              buffer  they  move  up or down within the buffer, otherwise they
28515              search for a history line matching  the  start  of  the  current
28516              line.   In  this  case,  however,  they  search for a line which
28517              matches the current line up to the current cursor  position,  in
28518              the  manner  of  history-beginning-search-backward and -forward,
28519              rather than the first word on the line.
28520
28521       edit-command-line
28522              Edit the command line using your visual editor, as in ksh.
28523
28524                     bindkey -M vicmd v edit-command-line
28525
28526       expand-absolute-path
28527              Expand the file name under the cursor to an absolute  path,  re‐
28528              solving  symbolic  links.  Where possible, the initial path seg‐
28529              ment is turned into a named directory or reference to  a  user's
28530              home directory.
28531
28532       history-search-end
28533              This    function    implements    the   widgets   history-begin‐
28534              ning-search-backward-end    and    history-beginning-search-for‐
28535              ward-end.   These commands work by first calling the correspond‐
28536              ing builtin widget (see `History Control' in zshzle(1)) and then
28537              moving  the  cursor to the end of the line.  The original cursor
28538              position is remembered and restored before calling  the  builtin
28539              widget  a  second  time,  so that the same search is repeated to
28540              look farther through the history.
28541
28542              Although you autoload only one function, the commands to use  it
28543              are slightly different because it implements two widgets.
28544
28545                     zle -N history-beginning-search-backward-end \
28546                            history-search-end
28547                     zle -N history-beginning-search-forward-end \
28548                            history-search-end
28549                     bindkey '\e^P' history-beginning-search-backward-end
28550                     bindkey '\e^N' history-beginning-search-forward-end
28551
28552       history-beginning-search-menu
28553              This  function implements yet another form of history searching.
28554              The text before the cursor is used to select lines from the his‐
28555              tory,  as  for history-beginning-search-backward except that all
28556              matches are shown in a numbered menu.   Typing  the  appropriate
28557              digits  inserts the full history line.  Note that leading zeroes
28558              must be typed (they are only shown when necessary  for  removing
28559              ambiguity).   The  entire  history is searched; there is no dis‐
28560              tinction between forwards and backwards.
28561
28562              With a numeric argument, the search is not anchored to the start
28563              of  the line; the string typed by the use may appear anywhere in
28564              the line in the history.
28565
28566              If the widget name contains `-end' the cursor is  moved  to  the
28567              end  of the line inserted.  If the widget name contains `-space'
28568              any space in the text typed is treated as  a  wildcard  and  can
28569              match  anything (hence a leading space is equivalent to giving a
28570              numeric argument).  Both forms can be combined, for example:
28571
28572                     zle -N history-beginning-search-menu-space-end \
28573                            history-beginning-search-menu
28574
28575       history-pattern-search
28576              The function  history-pattern-search  implements  widgets  which
28577              prompt  for a pattern with which to search the history backwards
28578              or forwards.  The pattern is in the usual  zsh  format,  however
28579              the  first  character may be ^ to anchor the search to the start
28580              of the line, and the last character  may  be  $  to  anchor  the
28581              search  to  the end of the line.  If the search was not anchored
28582              to the end of the line the cursor is positioned just  after  the
28583              pattern found.
28584
28585              The  commands to create bindable widgets are similar to those in
28586              the example immediately above:
28587
28588                     autoload -U history-pattern-search
28589                     zle -N history-pattern-search-backward history-pattern-search
28590                     zle -N history-pattern-search-forward history-pattern-search
28591
28592       incarg Typing the keystrokes for this widget with the cursor placed  on
28593              or  to  the  left of an integer causes that integer to be incre‐
28594              mented by one.  With a numeric argument, the  number  is  incre‐
28595              mented by the amount of the argument (decremented if the numeric
28596              argument is negative).  The shell parameter incarg may be set to
28597              change the default increment to something other than one.
28598
28599                     bindkey '^X+' incarg
28600
28601       incremental-complete-word
28602              This  allows  incremental  completion of a word.  After starting
28603              this command, a list of completion choices can  be  shown  after
28604              every  character  you type, which you can delete with ^H or DEL.
28605              Pressing return accepts the completion so far and returns you to
28606              normal editing (that is, the command line is not immediately ex‐
28607              ecuted).  You can hit TAB to do normal completion, ^G  to  abort
28608              back to the state when you started, and ^D to list the matches.
28609
28610              This works only with the new function based completion system.
28611
28612                     bindkey '^Xi' incremental-complete-word
28613
28614       insert-composed-char
28615              This function allows you to compose characters that don't appear
28616              on the keyboard to be inserted into the command line.  The  com‐
28617              mand  is  followed by two keys corresponding to ASCII characters
28618              (there is no prompt).  For accented characters, the two keys are
28619              a  base  character  followed by a code for the accent, while for
28620              other special characters the two characters together form a mne‐
28621              monic for the character to be inserted.  The two-character codes
28622              are a subset of  those  given  by  RFC  1345  (see  for  example
28623              http://www.faqs.org/rfcs/rfc1345.html).
28624
28625              The  function may optionally be followed by up to two characters
28626              which replace one or both of the characters read from  the  key‐
28627              board;  if  both characters are supplied, no input is read.  For
28628              example, insert-composed-char a: can be used within a widget  to
28629              insert an a with umlaut into the command line.  This has the ad‐
28630              vantages over use of a literal character that it is more  porta‐
28631              ble.
28632
28633              For  best  results  zsh  should have been built with support for
28634              multibyte characters (configured with --enable-multibyte);  how‐
28635              ever,  the  function  works  for the limited range of characters
28636              available in single-byte character sets such as ISO-8859-1.
28637
28638              The character is converted into the local representation and in‐
28639              serted  into the command line at the cursor position.  (The con‐
28640              version is done within the shell, using whatever facilities  the
28641              C library provides.)  With a numeric argument, the character and
28642              its code are previewed in the status line
28643
28644              The function may be run outside zle in which case it prints  the
28645              character  (together  with a newline) to standard output.  Input
28646              is still read from keystrokes.
28647
28648              See insert-unicode-char for an alternative way of inserting Uni‐
28649              code characters using their hexadecimal character number.
28650
28651              The set of accented characters is reasonably complete up to Uni‐
28652              code character U+0180, the set of special  characters  less  so.
28653              However,  it is very sporadic from that point.  Adding new char‐
28654              acters is easy, however; see the function define-composed-chars.
28655              Please send any additions to zsh-workers@zsh.org.
28656
28657              The codes for the second character when used to accent the first
28658              are as follows.  Note that not every character  can  take  every
28659              accent.
28660              !      Grave.
28661              '      Acute.
28662              >      Circumflex.
28663              ?      Tilde.   (This  is not ~ as RFC 1345 does not assume that
28664                     character is present on the keyboard.)
28665              -      Macron.  (A horizontal bar over the base character.)
28666              (      Breve.  (A shallow dish shape over the base character.)
28667              .      Dot above the base character, or in the case of i no dot,
28668                     or in the case of L and l a centered dot.
28669              :      Diaeresis (Umlaut).
28670              c      Cedilla.
28671              _      Underline,  however  there  are  currently  no underlined
28672                     characters.
28673              /      Stroke through the base character.
28674              "      Double acute (only supported on a few letters).
28675              ;      Ogonek.  (A little forward  facing  hook  at  the  bottom
28676                     right of the character.)
28677              <      Caron.  (A little v over the letter.)
28678              0      Circle over the base character.
28679              2      Hook over the base character.
28680              9      Horn over the base character.
28681
28682              The  most common characters from the Arabic, Cyrillic, Greek and
28683              Hebrew alphabets are available; consult RFC 1345 for the  appro‐
28684              priate sequences.  In addition, a set of two letter codes not in
28685              RFC 1345 are available for the  double-width  characters  corre‐
28686              sponding to ASCII characters from !  to ~ (0x21 to 0x7e) by pre‐
28687              ceding the character with ^, for example ^A for  a  double-width
28688              A.
28689
28690              The following other two-character sequences are understood.
28691
28692              ASCII characters
28693                     These are already present on most keyboards:
28694              <(     Left square bracket
28695              //     Backslash (solidus)
28696              )>     Right square bracket
28697              (!     Left brace (curly bracket)
28698              !!     Vertical bar (pipe symbol)
28699              !)     Right brace (curly bracket)
28700              '?     Tilde
28701
28702              Special letters
28703                     Characters  found in various variants of the Latin alpha‐
28704                     bet:
28705              ss     Eszett (scharfes S)
28706              D-, d- Eth
28707              TH, th Thorn
28708              kk     Kra
28709              'n     'n
28710              NG, ng Ng
28711              OI, oi Oi
28712              yr     yr
28713              ED     ezh
28714
28715              Currency symbols
28716              Ct     Cent
28717              Pd     Pound sterling (also lira and others)
28718              Cu     Currency
28719              Ye     Yen
28720              Eu     Euro (N.B. not in RFC 1345)
28721
28722              Punctuation characters
28723                     References to "right" quotes indicate the shape (like a 9
28724                     rather  than  6) rather than their grammatical use.  (For
28725                     example, a "right" low double quote is used to open  quo‐
28726                     tations in German.)
28727              !I     Inverted exclamation mark
28728              BB     Broken vertical bar
28729              SE     Section
28730              Co     Copyright
28731              -a     Spanish feminine ordinal indicator
28732              <<     Left guillemet
28733              --     Soft hyphen
28734              Rg     Registered trade mark
28735              PI     Pilcrow (paragraph)
28736              -o     Spanish masculine ordinal indicator
28737              >>     Right guillemet
28738              ?I     Inverted question mark
28739              -1     Hyphen
28740              -N     En dash
28741              -M     Em dash
28742              -3     Horizontal bar
28743              :3     Vertical ellipsis
28744              .3     Horizontal midline ellipsis
28745              !2     Double vertical line
28746              =2     Double low line
28747              '6     Left single quote
28748              '9     Right single quote
28749              .9     "Right" low quote
28750              9'     Reversed "right" quote
28751              "6     Left double quote
28752              "9     Right double quote
28753              :9     "Right" low double quote
28754              9"     Reversed "right" double quote
28755              /-     Dagger
28756              /=     Double dagger
28757
28758              Mathematical symbols
28759              DG     Degree
28760              -2, +-, -+
28761                     - sign, +/- sign, -/+ sign
28762              2S     Superscript 2
28763              3S     Superscript 3
28764              1S     Superscript 1
28765              My     Micro
28766              .M     Middle dot
28767              14     Quarter
28768              12     Half
28769              34     Three quarters
28770              *X     Multiplication
28771              -:     Division
28772              %0     Per mille
28773              FA, TE, /0
28774                     For all, there exists, empty set
28775              dP, DE, NB
28776                     Partial derivative, delta (increment), del (nabla)
28777              (-, -) Element of, contains
28778              *P, +Z Product, sum
28779              *-, Ob, Sb
28780                     Asterisk, ring, bullet
28781              RT, 0(, 00
28782                     Root sign, proportional to, infinity
28783
28784              Other symbols
28785              cS, cH, cD, cC
28786                     Card suits: spades, hearts, diamonds, clubs
28787              Md, M8, M2, Mb, Mx, MX
28788                     Musical notation: crotchet (quarter note), quaver (eighth
28789                     note), semiquavers (sixteenth notes), flag sign,  natural
28790                     sign, sharp sign
28791              Fm, Ml Female, male
28792
28793              Accents on their own
28794              '>     Circumflex (same as caret, ^)
28795              '!     Grave (same as backtick, `)
28796              ',     Cedilla
28797              ':     Diaeresis (Umlaut)
28798              'm     Macron
28799              ''     Acute
28800
28801       insert-files
28802              This  function  allows  you type a file pattern, and see the re‐
28803              sults of the expansion at each step.  When you hit  return,  all
28804              expansions are inserted into the command line.
28805
28806                     bindkey '^Xf' insert-files
28807
28808       insert-unicode-char
28809              When  first  executed, the user inputs a set of hexadecimal dig‐
28810              its.  This  is  terminated  with  another  call  to  insert-uni‐
28811              code-char.   The  digits  are then turned into the corresponding
28812              Unicode character.  For example, if the widget is bound to  ^XU,
28813              the character sequence `^XU 4 c ^XU' inserts L (Unicode U+004c).
28814
28815              See insert-composed-char for a way of inserting characters using
28816              a two-character mnemonic.
28817
28818
28819       narrow-to-region [ -p pre ] [ -P post ]
28820                        [ -S statepm | -R statepm | [ -l lbufvar ] [ -r  rbuf‐
28821       var ] ]
28822                        [ -n ] [ start end ]
28823       narrow-to-region-invisible
28824              Narrow  the editable portion of the buffer to the region between
28825              the cursor and the mark, which may be in either order.  The  re‐
28826              gion may not be empty.
28827
28828              narrow-to-region may be used as a widget or called as a function
28829              from a user-defined widget; by default, the text outside the ed‐
28830              itable  area remains visible.  A recursive-edit is performed and
28831              the original widening status is then restored.  Various  options
28832              and arguments are available when it is called as a function.
28833
28834              The  options  -p  pretext and -P posttext may be used to replace
28835              the text before and after the display for the  duration  of  the
28836              function; either or both may be an empty string.
28837
28838              If the option -n is also given, pretext or posttext will only be
28839              inserted if there is text before or  after  the  region  respec‐
28840              tively which will be made invisible.
28841
28842              Two numeric arguments may be given which will be used instead of
28843              the cursor and mark positions.
28844
28845              The option -S statepm is used to narrow according to  the  other
28846              options  while  saving  the original state in the parameter with
28847              name statepm, while the option -R statepm is used to restore the
28848              state from the parameter; note in both cases the name of the pa‐
28849              rameter is required.  In the second case, other options and  ar‐
28850              guments  are  irrelevant.   When  this method is used, no recur‐
28851              sive-edit is performed; the  calling  widget  should  call  this
28852              function with the option -S, perform its own editing on the com‐
28853              mand line or pass control to the user via `zle  recursive-edit',
28854              then  call  this  function  with  the  option  -R.  The argument
28855              statepm must be a suitable name for an ordinary  parameter,  ex‐
28856              cept  that  parameters  beginning  with the prefix _ntr_ are re‐
28857              served for use within narrow-to-region.  Typically the parameter
28858              will be local to the calling function.
28859
28860              The options -l lbufvar and -r rbufvar may be used to specify pa‐
28861              rameters where the widget will store the resulting text from the
28862              operation.  The parameter lbufvar will contain LBUFFER and rbuf‐
28863              var will contain RBUFFER.  Neither of these two options  may  be
28864              used with -S or -R.
28865
28866              narrow-to-region-invisible  is  a simple widget which calls nar‐
28867              row-to-region with arguments which replace any text outside  the
28868              region with `...'.  It does not take any arguments.
28869
28870              The  display  is  restored (and the widget returns) upon any zle
28871              command which would usually cause the line  to  be  accepted  or
28872              aborted.  Hence an additional such command is required to accept
28873              or abort the current line.
28874
28875              The return status of both widgets is zero if the  line  was  ac‐
28876              cepted, else non-zero.
28877
28878              Here is a trivial example of a widget using this feature.
28879                     local state
28880                     narrow-to-region -p $'Editing restricted region\n' \
28881                       -P '' -S state
28882                     zle recursive-edit
28883                     narrow-to-region -R state
28884
28885       predict-on
28886              This set of functions implements predictive typing using history
28887              search.  After predict-on, typing characters causes  the  editor
28888              to  look  backward  in  the history for the first line beginning
28889              with what you have typed so far.  After predict-off, editing re‐
28890              turns  to  normal  for the line found.  In fact, you often don't
28891              even need to use predict-off, because if the line doesn't  match
28892              something in the history, adding a key performs standard comple‐
28893              tion, and then inserts itself  if  no  completions  were  found.
28894              However,  editing  in  the middle of a line is liable to confuse
28895              prediction; see the toggle style below.
28896
28897              With the function based completion system (which is  needed  for
28898              this), you should be able to type TAB at almost any point to ad‐
28899              vance the cursor to the next ``interesting'' character  position
28900              (usually the end of the current word, but sometimes somewhere in
28901              the middle of the word).  And of course as soon  as  the  entire
28902              line is what you want, you can accept with return, without need‐
28903              ing to move the cursor to the end first.
28904
28905              The first time predict-on is used, it creates several additional
28906              widget functions:
28907
28908              delete-backward-and-predict
28909                     Replaces  the  backward-delete-char  widget.   You do not
28910                     need to bind this yourself.
28911              insert-and-predict
28912                     Implements predictive typing by replacing the self-insert
28913                     widget.  You do not need to bind this yourself.
28914              predict-off
28915                     Turns off predictive typing.
28916
28917              Although you autoload only the predict-on function, it is neces‐
28918              sary to create a keybinding for predict-off as well.
28919
28920                     zle -N predict-on
28921                     zle -N predict-off
28922                     bindkey '^X^Z' predict-on
28923                     bindkey '^Z' predict-off
28924
28925       read-from-minibuffer
28926              This is most useful when called as a function from inside a wid‐
28927              get,  but  will work correctly as a widget in its own right.  It
28928              prompts for a value below the current command line; a value  may
28929              be  input  using  all  of  the  standard zle operations (and not
28930              merely the restricted set available when executing, for example,
28931              execute-named-cmd).   The  value is then returned to the calling
28932              function in the parameter $REPLY and the editing buffer restored
28933              to  its  previous  state.  If the read was aborted by a keyboard
28934              break (typically ^G), the function returns status 1  and  $REPLY
28935              is not set.
28936
28937              If  one  argument  is  supplied to the function it is taken as a
28938              prompt, otherwise `? ' is used.  If two arguments are  supplied,
28939              they  are the prompt and the initial value of $LBUFFER, and if a
28940              third argument is given it is the  initial  value  of  $RBUFFER.
28941              This  provides  a  default  value and starting cursor placement.
28942              Upon return the entire buffer is the value of $REPLY.
28943
28944              One option is available: `-k num' specifies that num  characters
28945              are  to be read instead of a whole line.  The line editor is not
28946              invoked recursively in this case, so depending on  the  terminal
28947              settings  the  input may not be visible, and only the input keys
28948              are placed in $REPLY, not the entire buffer.  Note  that  unlike
28949              the read builtin num must be given; there is no default.
28950
28951              The  name  is  a  slight  misnomer,  as  in fact the shell's own
28952              minibuffer is not used.  Hence it is still possible to call exe‐
28953              cuted-named-cmd and similar functions while reading a value.
28954
28955       replace-argument, replace-argument-edit
28956              The  function  replace-argument can be used to replace a command
28957              line argument in the current command line  or,  if  the  current
28958              command  line  is  empty, in the last command line executed (the
28959              new command line is not executed).  Arguments are  as  delimited
28960              by standard shell syntax,
28961
28962              If  a  numeric argument is given, that specifies the argument to
28963              be replaced.  0 means the command name, as in history expansion.
28964              A negative numeric argument counts backward from the last word.
28965
28966              If  no  numeric  argument  is given, the current argument is re‐
28967              placed; this is the last argument if the previous  history  line
28968              is being used.
28969
28970              The function prompts for a replacement argument.
28971
28972              If  the  widget contains the string edit, for example is defined
28973              as
28974
28975                     zle -N replace-argument-edit replace-argument
28976
28977              then the function presents the current value of the argument for
28978              editing,  otherwise  the  editing  buffer for the replacement is
28979              initially empty.
28980
28981       replace-string, replace-pattern
28982       replace-string-again, replace-pattern-again
28983              The function replace-string implements three  widgets.   If  de‐
28984              fined  under  the  same name as the function, it prompts for two
28985              strings; the first (source) string will be replaced by the  sec‐
28986              ond everywhere it occurs in the line editing buffer.
28987
28988              If  the  widget name contains the word `pattern', for example by
28989              defining the widget using the command  `zle  -N  replace-pattern
28990              replace-string',  then  the matching is performed using zsh pat‐
28991              terns.  All zsh extended globbing patterns can be  used  in  the
28992              source  string; note that unlike filename generation the pattern
28993              does not need to match an entire word, nor  do  glob  qualifiers
28994              have  any  effect.  In addition, the replacement string can con‐
28995              tain parameter or command substitutions.  Furthermore, a `&'  in
28996              the  replacement string will be replaced with the matched source
28997              string, and a backquoted digit `\N' will be replaced by the  Nth
28998              parenthesised  expression  matched.  The form `\{N}' may be used
28999              to protect the digit from following digits.
29000
29001              If the widget instead contains the word `regex'  (or  `regexp'),
29002              then  the  matching  is performed using regular expressions, re‐
29003              specting the setting of the option RE_MATCH_PCRE  (see  the  de‐
29004              scription  of  the  function regexp-replace below).  The special
29005              replacement facilities described above for pattern matching  are
29006              available.
29007
29008              By default the previous source or replacement string will not be
29009              offered for editing.  However, this feature can be activated  by
29010              setting  the style edit-previous in the context :zle:widget (for
29011              example, :zle:replace-string) to true.  In addition, a  positive
29012              numeric  argument  forces  the  previous values to be offered, a
29013              negative or zero argument forces them not to be.
29014
29015              The function replace-string-again can be used to repeat the pre‐
29016              vious   replacement;   no   prompting  is  done.   As  with  re‐
29017              place-string, if the name of the widget contains the word  `pat‐
29018              tern' or `regex', pattern or regular expression matching is per‐
29019              formed, else a literal string replacement.  Note that the previ‐
29020              ous  source  and  replacement text are the same whether pattern,
29021              regular expression or string matching is used.
29022
29023              In addition, replace-string shows the previous replacement above
29024              the prompt, so long as there was one during the current session;
29025              if the source string is empty, that replacement will be repeated
29026              without the widget prompting for a replacement string.
29027
29028              For example, starting from the line:
29029
29030                     print This line contains fan and fond
29031
29032              and  invoking replace-pattern with the source string `f(?)n' and
29033              the replacement string `c\1r' produces the not very useful line:
29034
29035                     print This line contains car and cord
29036
29037              The range of the replacement string can be limited by using  the
29038              narrow-to-region-invisible  widget.   One limitation of the cur‐
29039              rent version is that undo will cycle through changes to the  re‐
29040              placement  and source strings before undoing the replacement it‐
29041              self.
29042
29043       send-invisible
29044              This is similar to read-from-minibuffer in that it may be called
29045              as  a  function from a widget or as a widget of its own, and in‐
29046              teractively reads input from the keyboard.  However,  the  input
29047              being  typed  is  concealed  and  a string of asterisks (`*') is
29048              shown instead.  The value is saved in the  parameter  $INVISIBLE
29049              to  which a reference is inserted into the editing buffer at the
29050              restored cursor position.  If the read was aborted by a keyboard
29051              break  (typically  ^G)  or  another  escape from editing such as
29052              push-line, $INVISIBLE is set to empty and the original buffer is
29053              restored unchanged.
29054
29055              If  one  argument  is  supplied to the function it is taken as a
29056              prompt, otherwise `Non-echoed text: ' is used (as in emacs).  If
29057              a  second and third argument are supplied they are used to begin
29058              and end the reference to $INVISIBLE that is  inserted  into  the
29059              buffer.   The  default  is  to open with ${, then INVISIBLE, and
29060              close with }, but many other effects are possible.
29061
29062       smart-insert-last-word
29063              This function may replace the insert-last-word widget, like so:
29064
29065                     zle -N insert-last-word smart-insert-last-word
29066
29067              With a numeric argument, or when passed command  line  arguments
29068              in a call from another widget, it behaves like insert-last-word,
29069              except that words in comments are ignored when  INTERACTIVE_COM‐
29070              MENTS is set.
29071
29072              Otherwise,  the rightmost ``interesting'' word from the previous
29073              command is found and inserted.  The default definition of  ``in‐
29074              teresting''  is  that  the word contains at least one alphabetic
29075              character, slash, or backslash.  This definition may be overrid‐
29076              den  by use of the match style.  The context used to look up the
29077              style is the  widget  name,  so  usually  the  context  is  :in‐
29078              sert-last-word.   However, you can bind this function to differ‐
29079              ent widgets to use different patterns:
29080
29081                     zle -N insert-last-assignment smart-insert-last-word
29082                     zstyle :insert-last-assignment match '[[:alpha:]][][[:alnum:]]#=*'
29083                     bindkey '\e=' insert-last-assignment
29084
29085              If no interesting word is found and the auto-previous  style  is
29086              set  to  a  true  value, the search continues upward through the
29087              history.  When auto-previous is unset or  false  (the  default),
29088              the widget must be invoked repeatedly in order to search earlier
29089              history lines.
29090
29091       transpose-lines
29092              Only useful with a multi-line editing buffer; the lines here are
29093              lines  within  the  current on-screen buffer, not history lines.
29094              The effect is similar to the function of the same name in Emacs.
29095
29096              Transpose the current line with the previous line and  move  the
29097              cursor to the start of the next line.  Repeating this (which can
29098              be done by providing a positive numeric argument) has the effect
29099              of moving the line above the cursor down by a number of lines.
29100
29101              With  a  negative numeric argument, requires two lines above the
29102              cursor.  These two lines are transposed and the cursor moved  to
29103              the  start  of the previous line.  Using a numeric argument less
29104              than -1 has the effect of moving the line above the cursor up by
29105              minus that number of lines.
29106
29107       url-quote-magic
29108              This  widget replaces the built-in self-insert to make it easier
29109              to type URLs as command line arguments.  As you type, the  input
29110              character  is  analyzed and, if it may need quoting, the current
29111              word is checked for a URI scheme.  If one is found and the  cur‐
29112              rent  word is not already in quotes, a backslash is inserted be‐
29113              fore the input character.
29114
29115              Styles to control quoting behavior:
29116
29117              url-metas
29118                     This   style   is    looked    up    in    the    context
29119                     `:url-quote-magic:scheme'  (where  scheme  is that of the
29120                     current URL, e.g. "ftp").  The value is a string  listing
29121                     the  characters  to be treated as globbing metacharacters
29122                     when appearing in a URL using that scheme.   The  default
29123                     is to quote all zsh extended globbing characters, exclud‐
29124                     ing '<' and '>' but including braces (as in brace  expan‐
29125                     sion).  See also url-seps.
29126
29127              url-seps
29128                     Like  url-metas, but lists characters that should be con‐
29129                     sidered command separators, redirections, history  refer‐
29130                     ences,  etc.  The default is to quote the standard set of
29131                     shell separators, excluding those that overlap  with  the
29132                     extended  globbing  characters, but including '<' and '>'
29133                     and the first character of $histchars.
29134
29135              url-globbers
29136                     This   style   is    looked    up    in    the    context
29137                     `:url-quote-magic'.   The  values  form a list of command
29138                     names that are expected to do their own globbing  on  the
29139                     URL  string.   This  implies that they are aliased to use
29140                     the `noglob' modifier.  When the first word on  the  line
29141                     matches  one  of the values and the URL refers to a local
29142                     file (see url-local-schema), only the url-seps characters
29143                     are  quoted;  the url-metas are left alone, allowing them
29144                     to affect command-line parsing, completion, etc.  The de‐
29145                     fault  values  are  a  literal  `noglob'  plus  (when the
29146                     zsh/parameter module is available) any  commands  aliased
29147                     to   the   helper  function  `urlglobber'  or  its  alias
29148                     `globurl'.
29149
29150              url-local-schema
29151                     This style is always looked up in the context  `:urlglob‐
29152                     ber',  even though it is used by both url-quote-magic and
29153                     urlglobber.  The values form a list of  URI  schema  that
29154                     should  be  treated  as referring to local files by their
29155                     real local path names, as  opposed  to  files  which  are
29156                     specified relative to a web-server-defined document root.
29157                     The defaults are "ftp" and "file".
29158
29159              url-other-schema
29160                     Like url-local-schema, but lists  all  other  URI  schema
29161                     upon which urlglobber and url-quote-magic should act.  If
29162                     the URI on the command line does not have  a  scheme  ap‐
29163                     pearing either in this list or in url-local-schema, it is
29164                     not magically quoted.  The  default  values  are  "http",
29165                     "https",  and "ftp".  When a scheme appears both here and
29166                     in url-local-schema, it is quoted  differently  depending
29167                     on whether the command name appears in url-globbers.
29168
29169              Loading url-quote-magic also defines a helper function `urlglob‐
29170              ber' and aliases `globurl' to `noglob urlglobber'.   This  func‐
29171              tion  takes a local URL apart, attempts to pattern-match the lo‐
29172              cal file portion of the URL path, and then puts the results back
29173              into URL format again.
29174
29175       vi-pipe
29176              This  function  reads  a  movement command from the keyboard and
29177              then prompts for an external command. The  part  of  the  buffer
29178              covered  by  the  movement  is piped to the external command and
29179              then replaced by the command's output. If the  movement  command
29180              is bound to vi-pipe, the current line is used.
29181
29182              The function serves as an example for reading a vi movement com‐
29183              mand from within a user-defined widget.
29184
29185       which-command
29186              This function is a drop-in replacement for  the  builtin  widget
29187              which-command.   It has enhanced behaviour, in that it correctly
29188              detects whether or not the command word needs to be expanded  as
29189              an  alias; if so, it continues tracing the command word from the
29190              expanded alias until it reaches the command that  will  be  exe‐
29191              cuted.
29192
29193              The  style whence is available in the context :zle:$WIDGET; this
29194              may be set to an array to give the command and options that will
29195              be  used  to investigate the command word found.  The default is
29196              whence -c.
29197
29198       zcalc-auto-insert
29199              This function is useful together with  the  zcalc  function  de‐
29200              scribed  in  the  section  Mathematical Functions.  It should be
29201              bound to a key representing a binary operator such as `+',  `-',
29202              `*'  or  `/'.   When  running in zcalc, if the key occurs at the
29203              start of the line or immediately following an open  parenthesis,
29204              the text "ans " is inserted before the representation of the key
29205              itself.  This allows easy use of the answer  from  the  previous
29206              calculation in the current line.  The text to be inserted before
29207              the symbol  typed  can  be  modified  by  setting  the  variable
29208              ZCALC_AUTO_INSERT_PREFIX.
29209
29210              Hence,  for  example, typing `+12' followed by return adds 12 to
29211              the previous result.
29212
29213              If zcalc is in RPN mode (-r option) the effect of  this  binding
29214              is  automatically  suppressed  as  operators alone on a line are
29215              meaningful.
29216
29217              When not in zcalc, the key simply inserts the symbol itself.
29218
29219   Utility Functions
29220       These functions are useful in constructing  widgets.   They  should  be
29221       loaded  with  `autoload  -U  function'  and  called  as  indicated from
29222       user-defined widgets.
29223
29224       split-shell-arguments
29225              This function splits the line currently being edited into  shell
29226              arguments and whitespace.  The result is stored in the array re‐
29227              ply.  The array contains all the parts of  the  line  in  order,
29228              starting with any whitespace before the first argument, and fin‐
29229              ishing with any whitespace after the last argument.   Hence  (so
29230              long as the option KSH_ARRAYS is not set) whitespace is given by
29231              odd indices in the array and arguments by  even  indices.   Note
29232              that  no  stripping  of quotes is done; joining together all the
29233              elements of reply in order is guaranteed to produce the original
29234              line.
29235
29236              The  parameter  REPLY  is  set to the index of the word in reply
29237              which contains the character after the cursor, where  the  first
29238              element  has  index 1.  The parameter REPLY2 is set to the index
29239              of the character under the cursor in that word, where the  first
29240              character has index 1.
29241
29242              Hence  reply,  REPLY  and REPLY2 should all be made local to the
29243              enclosing function.
29244
29245              See the function modify-current-argument, described  below,  for
29246              an example of how to call this function.
29247
29248       modify-current-argument [ expr-using-$ARG | func ]
29249              This  function provides a simple method of allowing user-defined
29250              widgets to modify the command line argument under the cursor (or
29251              immediately  to  the left of the cursor if the cursor is between
29252              arguments).
29253
29254              The argument can be an expression which when evaluated  operates
29255              on the shell parameter ARG, which will have been set to the com‐
29256              mand line argument under the cursor.  The expression  should  be
29257              suitably quoted to prevent it being evaluated too early.
29258
29259              Alternatively,  if the argument does not contain the string ARG,
29260              it is assumed to be a shell function, to which the current  com‐
29261              mand line argument is passed as the only argument.  The function
29262              should set the variable REPLY to the new value for  the  command
29263              line argument.  If the function returns non-zero status, so does
29264              the calling function.
29265
29266              For example, a user-defined widget containing the following code
29267              converts  the  characters  in the argument under the cursor into
29268              all upper case:
29269
29270                     modify-current-argument '${(U)ARG}'
29271
29272              The following strips any quoting from the current word  (whether
29273              backslashes  or  one  of  the styles of quotes), and replaces it
29274              with single quoting throughout:
29275
29276                     modify-current-argument '${(qq)${(Q)ARG}}'
29277
29278              The following performs directory expansion on the  command  line
29279              argument and replaces it by the absolute path:
29280
29281                     expand-dir() {
29282                       REPLY=${~1}
29283                       REPLY=${REPLY:a}
29284                     }
29285                     modify-current-argument expand-dir
29286
29287              In  practice  the  function expand-dir would probably not be de‐
29288              fined within the widget where modify-current-argument is called.
29289
29290   Styles
29291       The behavior of several of the above widgets can be controlled  by  the
29292       use of the zstyle mechanism.  In particular, widgets that interact with
29293       the completion system pass along their context to any completions  that
29294       they invoke.
29295
29296       break-keys
29297              This  style is used by the incremental-complete-word widget. Its
29298              value should be a pattern, and all keys  matching  this  pattern
29299              will cause the widget to stop incremental completion without the
29300              key having any further effect. Like all styles used directly  by
29301              incremental-complete-word,  this  style  is  looked up using the
29302              context `:incremental'.
29303
29304       completer
29305              The incremental-complete-word and insert-and-predict widgets set
29306              up their top-level context name before calling completion.  This
29307              allows one to define different sets of completer  functions  for
29308              normal  completion  and  for these widgets.  For example, to use
29309              completion, approximation and correction for normal  completion,
29310              completion  and  correction  for incremental completion and only
29311              completion for prediction one could use:
29312
29313                     zstyle ':completion:*' completer \
29314                             _complete _correct _approximate
29315                     zstyle ':completion:incremental:*' completer \
29316                             _complete _correct
29317                     zstyle ':completion:predict:*' completer \
29318                             _complete
29319
29320              It is a good idea to restrict the completers used in prediction,
29321              because  they  may  be  automatically  invoked as you type.  The
29322              _list and _menu completers should never be used with prediction.
29323              The  _approximate,  _correct, _expand, and _match completers may
29324              be used, but be aware that they may change  characters  anywhere
29325              in  the  word  behind the cursor, so you need to watch carefully
29326              that the result is what you intended.
29327
29328       cursor The insert-and-predict widget uses this style,  in  the  context
29329              `:predict', to decide where to place the cursor after completion
29330              has been tried.  Values are:
29331
29332              complete
29333                     The cursor is left where it was when completion finished,
29334                     but only if it is after a character equal to the one just
29335                     inserted by the user.  If it is after another  character,
29336                     this value is the same as `key'.
29337
29338              key    The  cursor is left after the nth occurrence of the char‐
29339                     acter just inserted, where n is the number of times  that
29340                     character  appeared in the word before completion was at‐
29341                     tempted.  In short, this has the effect  of  leaving  the
29342                     cursor after the character just typed even if the comple‐
29343                     tion code found out that no other characters need  to  be
29344                     inserted at that position.
29345
29346              Any other value for this style unconditionally leaves the cursor
29347              at the position where the completion code left it.
29348
29349       list   When using the incremental-complete-word widget, this style says
29350              if  the matches should be listed on every key press (if they fit
29351              on the screen).  Use the context  prefix  `:completion:incremen‐
29352              tal'.
29353
29354              The  insert-and-predict  widget uses this style to decide if the
29355              completion should be shown even if there is  only  one  possible
29356              completion.   This  is  done  if  the value of this style is the
29357              string always.  In this case  the  context  is  `:predict'  (not
29358              `:completion:predict').
29359
29360       match  This  style  is used by smart-insert-last-word to provide a pat‐
29361              tern (using full EXTENDED_GLOB syntax) that matches an interest‐
29362              ing  word.   The  context  is  the  name  of the widget to which
29363              smart-insert-last-word is bound (see above).  The default behav‐
29364              ior of smart-insert-last-word is equivalent to:
29365
29366                     zstyle :insert-last-word match '*[[:alpha:]/\\]*'
29367
29368              However, you might want to include words that contain spaces:
29369
29370                     zstyle :insert-last-word match '*[[:alpha:][:space:]/\\]*'
29371
29372              Or  include  numbers as long as the word is at least two charac‐
29373              ters long:
29374
29375                     zstyle :insert-last-word match '*([[:digit:]]?|[[:alpha:]/\\])*'
29376
29377              The above example causes redirections like "2>" to be included.
29378
29379       prompt The incremental-complete-word widget shows  the  value  of  this
29380              style  in  the  status  line during incremental completion.  The
29381              string value may contain any of the following substrings in  the
29382              manner of the PS1 and other prompt parameters:
29383
29384              %c     Replaced  by the name of the completer function that gen‐
29385                     erated the matches (without the leading underscore).
29386
29387              %l     When the list style is set, replaced by `...' if the list
29388                     of  matches  is too long to fit on the screen and with an
29389                     empty string otherwise.  If the list style is `false'  or
29390                     not set, `%l' is always removed.
29391
29392              %n     Replaced by the number of matches generated.
29393
29394              %s     Replaced  by  `-no  match-',  `-no  prefix-', or an empty
29395                     string if there is no completion matching the word on the
29396                     line, if the matches have no common prefix different from
29397                     the word on the line, or if there is such a  common  pre‐
29398                     fix, respectively.
29399
29400              %u     Replaced by the unambiguous part of all matches, if there
29401                     is any, and if it is different from the word on the line.
29402
29403              Like `break-keys', this uses the `:incremental' context.
29404
29405       stop-keys
29406              This style is used by the incremental-complete-word widget.  Its
29407              value  is  treated similarly to the one for the break-keys style
29408              (and uses the same context: `:incremental').  However,  in  this
29409              case  all keys matching the pattern given as its value will stop
29410              incremental completion and will then execute their  usual  func‐
29411              tion.
29412
29413       toggle This boolean style is used by predict-on and its related widgets
29414              in the context `:predict'.  If set to one of the standard `true'
29415              values, predictive typing is automatically toggled off in situa‐
29416              tions where it is unlikely to be useful, such as when editing  a
29417              multi-line  buffer or after moving into the middle of a line and
29418              then deleting a character.  The default is to  leave  prediction
29419              turned on until an explicit call to predict-off.
29420
29421       verbose
29422              This boolean style is used by predict-on and its related widgets
29423              in the context `:predict'.  If set to one of the standard `true'
29424              values,  these  widgets  display a message below the prompt when
29425              the predictive state is toggled.  This is most useful in  combi‐
29426              nation  with  the  toggle  style.   The default does not display
29427              these messages.
29428
29429       widget This style is similar to the command style: For widget functions
29430              that  use zle to call other widgets, this style can sometimes be
29431              used to override the widget which is called.   The  context  for
29432              this  style  is  the name of the calling widget (not the name of
29433              the calling function, because one function may be bound to  mul‐
29434              tiple widget names).
29435
29436                     zstyle :copy-earlier-word widget smart-insert-last-word
29437
29438              Check  the  documentation  for the calling widget or function to
29439              determine whether the widget style is used.
29440

EXCEPTION HANDLING

29442       Two functions are provided to enable zsh to provide exception  handling
29443       in a form that should be familiar from other languages.
29444
29445       throw exception
29446              The  function  throw throws the named exception.  The name is an
29447              arbitrary string and is only used by the throw and  catch  func‐
29448              tions.   An exception is for the most part treated the same as a
29449              shell error, i.e. an unhandled exception will cause the shell to
29450              abort  all  processing  in a function or script and to return to
29451              the top level in an interactive shell.
29452
29453       catch exception-pattern
29454              The function catch returns  status  zero  if  an  exception  was
29455              thrown and the pattern exception-pattern matches its name.  Oth‐
29456              erwise it returns status 1.   exception-pattern  is  a  standard
29457              shell  pattern,  respecting  the  current  setting  of  the  EX‐
29458              TENDED_GLOB option.  An alias catch is also defined  to  prevent
29459              the  argument  to  the function from matching filenames, so pat‐
29460              terns may be used unquoted.  Note that  as  exceptions  are  not
29461              fundamentally  different  from other shell errors it is possible
29462              to catch shell errors by using an empty string as the  exception
29463              name.   The shell variable CAUGHT is set by catch to the name of
29464              the exception caught.  It is possible to rethrow an exception by
29465              calling  the  throw  function  again  once an exception has been
29466              caught.
29467
29468       The functions are designed to be used together  with  the  always  con‐
29469       struct  described  in  zshmisc(1).  This is important as only this con‐
29470       struct provides the required support for exceptions.  A typical example
29471       is as follows.
29472
29473              {
29474                # "try" block
29475                # ... nested code here calls "throw MyExcept"
29476              } always {
29477                # "always" block
29478                if catch MyExcept; then
29479                  print "Caught exception MyExcept"
29480                elif catch ''; then
29481                  print "Caught a shell error.  Propagating..."
29482                  throw ''
29483                fi
29484                # Other exceptions are not handled but may be caught further
29485                # up the call stack.
29486              }
29487
29488       If  all  exceptions  should  be  caught,  the  following idiom might be
29489       preferable.
29490
29491              {
29492                # ... nested code here throws an exception
29493              } always {
29494                if catch *; then
29495                  case $CAUGHT in
29496                    (MyExcept)
29497                    print "Caught my own exception"
29498                    ;;
29499                    (*)
29500                    print "Caught some other exception"
29501                    ;;
29502                  esac
29503                fi
29504              }
29505
29506       In common with exception handling in other languages, the exception may
29507       be  thrown by code deeply nested inside the `try' block.  However, note
29508       that it must be thrown inside the current  shell,  not  in  a  subshell
29509       forked  for  a pipeline, parenthesised current-shell construct, or some
29510       form of command or process substitution.
29511
29512       The system internally uses the shell variable EXCEPTION to  record  the
29513       name  of  the exception between throwing and catching.  One drawback of
29514       this scheme is that if the exception is not handled the variable EXCEP‐
29515       TION  remains  set  and may be incorrectly recognised as the name of an
29516       exception if a shell error subsequently occurs.  Adding unset EXCEPTION
29517       at  the  start  of  the outermost layer of any code that uses exception
29518       handling will eliminate this problem.
29519

MIME FUNCTIONS

29521       Three functions are available to provide handling of  files  recognised
29522       by extension, for example to dispatch a file text.ps when executed as a
29523       command to an appropriate viewer.
29524
29525       zsh-mime-setup [ -fv ] [ -l [ suffix ... ] ]
29526       zsh-mime-handler [ -l ] command argument ...
29527              These  two   functions   use   the   files   ~/.mime.types   and
29528              /etc/mime.types,  which  associate types and extensions, as well
29529              as ~/.mailcap and /etc/mailcap files, which associate types  and
29530              the  programs that handle them.  These are provided on many sys‐
29531              tems with the Multimedia Internet Mail Extensions.
29532
29533              To enable the system, the function zsh-mime-setup should be  au‐
29534              toloaded  and  run.   This  allows  files  with extensions to be
29535              treated as executable; such files be completed by  the  function
29536              completion  system.   The  function  zsh-mime-handler should not
29537              need to be called by the user.
29538
29539              The system works by setting up suffix aliases with  `alias  -s'.
29540              Suffix  aliases  already installed by the user will not be over‐
29541              written.
29542
29543              For suffixes defined in lower case,  upper  case  variants  will
29544              also automatically be handled (e.g. PDF is automatically handled
29545              if handling for the suffix pdf is defined), but not vice versa.
29546
29547              Repeated calls to zsh-mime-setup do not  override  the  existing
29548              mapping  between suffixes and executable files unless the option
29549              -f is given.  Note, however, that this does not override  exist‐
29550              ing suffix aliases assigned to handlers other than zsh-mime-han‐
29551              dler.
29552
29553              Calling zsh-mime-setup with the option  -l  lists  the  existing
29554              mappings  without  altering  them.   Suffixes to list (which may
29555              contain pattern characters that should be quoted from  immediate
29556              interpretation  on  the command line) may be given as additional
29557              arguments, otherwise all suffixes are listed.
29558
29559              Calling zsh-mime-setup with the option -v causes verbose  output
29560              to be shown during the setup operation.
29561
29562              The  system  respects  the mailcap flags needsterminal and copi‐
29563              ousoutput, see mailcap(4).
29564
29565              The functions use the following styles, which are  defined  with
29566              the  zstyle builtin command (see zshmodules(1)).  They should be
29567              defined before zsh-mime-setup is run.   The  contexts  used  all
29568              start with :mime:, with additional components in some cases.  It
29569              is recommended that a trailing * (suitably quoted)  be  appended
29570              to  style  patterns  in  case  the system is extended in future.
29571              Some examples are given below.
29572
29573              For files that have multiple suffixes, e.g. .pdf.gz,  where  the
29574              context  includes  the suffix it will be looked up starting with
29575              the longest possible suffix until  a  match  for  the  style  is
29576              found.   For  example,  if .pdf.gz produces a match for the han‐
29577              dler, that will be used; otherwise the handler for .gz  will  be
29578              used.   Note  that,  owing to the way suffix aliases work, it is
29579              always required that there be a handler for the shortest  possi‐
29580              ble  suffix,  so  in this example .pdf.gz can only be handled if
29581              .gz is also handled (though not necessarily in  the  same  way).
29582              Alternatively, if no handling for .gz on its own is needed, sim‐
29583              ply adding the command
29584
29585                     alias -s gz=zsh-mime-handler
29586
29587              to the initialisation code is sufficient; .gz will not  be  han‐
29588              dled on its own, but may be in combination with other suffixes.
29589
29590              current-shell
29591                     If  this  boolean  style is true, the mailcap handler for
29592                     the context in question is run using the eval builtin in‐
29593                     stead  of by starting a new sh process.  This is more ef‐
29594                     ficient, but may not work in the occasional  cases  where
29595                     the mailcap handler uses strict POSIX syntax.
29596
29597              disown If  this  boolean style is true, mailcap handlers started
29598                     in the background will be disowned, i.e. not  subject  to
29599                     job  control  within  the  parent  shell.   Such handlers
29600                     nearly always produce their  own  windows,  so  the  only
29601                     likely  harmful  side effect of setting the style is that
29602                     it becomes harder to kill jobs from within the shell.
29603
29604              execute-as-is
29605                     This style gives a list of patterns to be matched against
29606                     files  passed  for  execution with a handler program.  If
29607                     the file matches the pattern, the entire command line  is
29608                     executed  in  its current form, with no handler.  This is
29609                     useful for files which might have suffixes  but  nonethe‐
29610                     less  be  executable in their own right.  If the style is
29611                     not set, the pattern *(*) *(/) is used; hence  executable
29612                     files  are executed directly and not passed to a handler,
29613                     and the option AUTO_CD may be used to change to  directo‐
29614                     ries that happen to have MIME suffixes.
29615
29616              execute-never
29617                     This  style  is useful in combination with execute-as-is.
29618                     It is set to an array of patterns corresponding  to  full
29619                     paths  to  files  that  should  never  be treated as exe‐
29620                     cutable, even if the file  passed  to  the  MIME  handler
29621                     matches  execute-as-is.   This is useful for file systems
29622                     that don't handle execute permission or that contain exe‐
29623                     cutables  from another operating system.  For example, if
29624                     /mnt/windows is a Windows mount, then
29625
29626                            zstyle ':mime:*' execute-never '/mnt/windows/*'
29627
29628                     will ensure that any files found in that area will be ex‐
29629                     ecuted  as  MIME  types  even if they are executable.  As
29630                     this example shows, the complete  file  name  is  matched
29631                     against  the  pattern,  regardless  of  how  the file was
29632                     passed to the handler.  The file is resolved  to  a  full
29633                     path  using  the  :P modifier described in the subsection
29634                     Modifiers in zshexpn(1); this means that  symbolic  links
29635                     are  resolved  where  possible,  so that links into other
29636                     file systems behave in the correct fashion.
29637
29638              file-path
29639                     Used if the style find-file-in-path is true for the  same
29640                     context.   Set  to  an array of directories that are used
29641                     for searching for the file to be handled; the default  is
29642                     the  command  path  given  by the special parameter path.
29643                     The shell option PATH_DIRS is respected; if that is  set,
29644                     the appropriate path will be searched even if the name of
29645                     the file to be handled as it appears on the command  line
29646                     contains  a  `/'.  The full context is :mime:.suffix:, as
29647                     described for the style handler.
29648
29649              find-file-in-path
29650                     If set, allows files whose names do not contain  absolute
29651                     paths  to be searched for in the command path or the path
29652                     specified by the file-path style.  If  the  file  is  not
29653                     found  in  the path, it is looked for locally (whether or
29654                     not the current directory is in the path); if it  is  not
29655                     found  locally,  the  handler  will abort unless the han‐
29656                     dle-nonexistent style is set.  Files found  in  the  path
29657                     are tested as described for the style execute-as-is.  The
29658                     full context is  :mime:.suffix:,  as  described  for  the
29659                     style handler.
29660
29661              flags  Defines flags to go with a handler; the context is as for
29662                     the handler style, and the format is as for the flags  in
29663                     mailcap.
29664
29665              handle-nonexistent
29666                     By  default, arguments that don't correspond to files are
29667                     not passed to the MIME handler in  order  to  prevent  it
29668                     from  intercepting commands found in the path that happen
29669                     to have suffixes.  This style may be set to an  array  of
29670                     extended  glob patterns for arguments that will be passed
29671                     to the handler even if they don't exist.  If  it  is  not
29672                     explicitly  set  it defaults to [[:alpha:]]#:/* which al‐
29673                     lows URLs to be passed to the MIME  handler  even  though
29674                     they  don't exist in that format in the file system.  The
29675                     full context is  :mime:.suffix:,  as  described  for  the
29676                     style handler.
29677
29678              handler
29679                     Specifies  a handler for a suffix; the suffix is given by
29680                     the context as :mime:.suffix:, and the format of the han‐
29681                     dler  is exactly that in mailcap.  Note in particular the
29682                     `.' and trailing colon to distinguish  this  use  of  the
29683                     context.   This  overrides  any  handler specified by the
29684                     mailcap files.  If the handler requires a  terminal,  the
29685                     flags style should be set to include the word needstermi‐
29686                     nal, or if the output is to be displayed through a  pager
29687                     (but not if the handler is itself a pager), it should in‐
29688                     clude copiousoutput.
29689
29690              mailcap
29691                     A  list  of  files  in  the  format  of  ~/.mailcap   and
29692                     /etc/mailcap  to  be read during setup, replacing the de‐
29693                     fault list which consists of those two files.   The  con‐
29694                     text  is :mime:.  A + in the list will be replaced by the
29695                     default files.
29696
29697              mailcap-priorities
29698                     This style is used to resolve  multiple  mailcap  entries
29699                     for  the  same MIME type.  It consists of an array of the
29700                     following elements,  in  descending  order  of  priority;
29701                     later  entries will be used if earlier entries are unable
29702                     to resolve the entries being compared.  If  none  of  the
29703                     tests resolve the entries, the first entry encountered is
29704                     retained.
29705
29706                     files  The order of files (entries in the mailcap  style)
29707                            read.   Earlier  files  are preferred.  (Note this
29708                            does not resolve entries in the same file.)
29709
29710                     priority
29711                            The priority flag from  the  mailcap  entry.   The
29712                            priority  is  an  integer from 0 to 9 with the de‐
29713                            fault value being 5.
29714
29715                     flags  The test given by the mailcap-prio-flags option is
29716                            used to resolve entries.
29717
29718                     place  Later  entries  are  preferred; as the entries are
29719                            strictly ordered, this test always succeeds.
29720
29721                     Note that as this style is handled during initialisation,
29722                     the  context  is always :mime:, with no discrimination by
29723                     suffix.
29724
29725              mailcap-prio-flags
29726                     This style is used when the keyword flags is  encountered
29727                     in  the list of tests specified by the mailcap-priorities
29728                     style.  It should be set to a list of patterns,  each  of
29729                     which  is tested against the flags specified in the mail‐
29730                     cap entry (in other words, the sets of assignments  found
29731                     with some entries in the mailcap file).  Earlier patterns
29732                     in the list are preferred to later ones, and matched pat‐
29733                     terns are preferred to unmatched ones.
29734
29735              mime-types
29736                     A  list  of  files  in  the  format  of ~/.mime.types and
29737                     /etc/mime.types to be read during  setup,  replacing  the
29738                     default list which consists of those two files.  The con‐
29739                     text is :mime:.  A + in the list will be replaced by  the
29740                     default files.
29741
29742              never-background
29743                     If  this  boolean style is set, the handler for the given
29744                     context is always run in  the  foreground,  even  if  the
29745                     flags  provided  in the mailcap entry suggest it need not
29746                     be (for example, it doesn't require a terminal).
29747
29748              pager  If set, will be used instead of $PAGER or more to  handle
29749                     suffixes  where  the copiousoutput flag is set.  The con‐
29750                     text is as for handler, i.e. :mime:.suffix: for  handling
29751                     a file with the given suffix.
29752
29753              Examples:
29754
29755                     zstyle ':mime:*' mailcap ~/.mailcap /usr/local/etc/mailcap
29756                     zstyle ':mime:.txt:' handler less %s
29757                     zstyle ':mime:.txt:' flags needsterminal
29758
29759              When  zsh-mime-setup is subsequently run, it will look for mail‐
29760              cap entries in the two files given.  Files of suffix  .txt  will
29761              be  handled  by running `less file.txt'.  The flag needsterminal
29762              is set to show that this program must run attached to  a  termi‐
29763              nal.
29764
29765              As there are several steps to dispatching a command, the follow‐
29766              ing should be checked if attempting to execute a file by  exten‐
29767              sion .ext does not have the expected effect.
29768
29769              The  command  `alias  -s ext' should show `ps=zsh-mime-handler'.
29770              If it shows something else, another suffix alias was already in‐
29771              stalled  and  was not overwritten.  If it shows nothing, no han‐
29772              dler was installed:  this is most likely because no handler  was
29773              found in the .mime.types and mailcap combination for .ext files.
29774              In  that  case,  appropriate  handling  should   be   added   to
29775              ~/.mime.types and mailcap.
29776
29777              If  the extension is handled by zsh-mime-handler but the file is
29778              not opened correctly, either the handler defined for the type is
29779              incorrect,  or  the flags associated with it are in appropriate.
29780              Running zsh-mime-setup -l will show the handler  and,  if  there
29781              are any, the flags.  A %s in the handler is replaced by the file
29782              (suitably quoted if necessary).  Check that the handler  program
29783              listed  lists  and can be run in the way shown.  Also check that
29784              the flags needsterminal or copiousoutput are set if the  handler
29785              needs to be run under a terminal; the second flag is used if the
29786              output should be sent to a pager.   An  example  of  a  suitable
29787              mailcap entry for such a program is:
29788
29789                     text/html; /usr/bin/lynx '%s'; needsterminal
29790
29791              Running  `zsh-mime-handler  -l  command line' prints the command
29792              line that would be executed, simplified to remove the effect  of
29793              any  flags,  and  quoted so that the output can be run as a com‐
29794              plete zsh command line.  This is used by the  completion  system
29795              to   decide   how   to   complete   after   a  file  handled  by
29796              zsh-mime-setup.
29797
29798       pick-web-browser
29799              This function is separate from the two MIME functions  described
29800              above and can be assigned directly to a suffix:
29801
29802                     autoload -U pick-web-browser
29803                     alias -s html=pick-web-browser
29804
29805              It  is  provided  as  an intelligent front end to dispatch a web
29806              browser.  It may be run as either a function or a shell  script.
29807              The status 255 is returned if no browser could be started.
29808
29809              Various   styles  are  available  to  customize  the  choice  of
29810              browsers:
29811
29812              browser-style
29813                     The value of the style is an array giving preferences  in
29814                     decreasing  order  for  the  type of browser to use.  The
29815                     values of elements may be
29816
29817                     running
29818                            Use a GUI browser that is already running when  an
29819                            X  Window  display  is  available.   The  browsers
29820                            listed in the x-browsers style are tried in  order
29821                            until  one  is  found;  if it is, the file will be
29822                            displayed in that browser, so the user may need to
29823                            check  whether  it  has  appeared.   If no running
29824                            browser is found, one is  not  started.   Browsers
29825                            other  than  Firefox,  Opera and Konqueror are as‐
29826                            sumed to understand the Mozilla syntax for opening
29827                            a URL remotely.
29828
29829                     x      Start  a  new GUI browser when an X Window display
29830                            is available.  Search for the availability of  one
29831                            of the browsers listed in the x-browsers style and
29832                            start the first one that is found.   No  check  is
29833                            made for an already running browser.
29834
29835                     tty    Start  a  terminal-based  browser.  Search for the
29836                            availability of one of the browsers listed in  the
29837                            tty-browsers style and start the first one that is
29838                            found.
29839
29840                     If the style is not set the  default  running  x  tty  is
29841                     used.
29842
29843              x-browsers
29844                     An array in decreasing order of preference of browsers to
29845                     use when running under the X Window  System.   The  array
29846                     consists  of  the  command  name under which to start the
29847                     browser.  They are looked up in the context :mime: (which
29848                     may  be  extended  in  future, so appending `*' is recom‐
29849                     mended).  For example,
29850
29851                            zstyle ':mime:*' x-browsers opera konqueror firefox
29852
29853                     specifies that pick-web-browser should first look  for  a
29854                     running  instance of Opera, Konqueror or Firefox, in that
29855                     order, and if it fails to  find  any  should  attempt  to
29856                     start  Opera.   The  default  is firefox mozilla netscape
29857                     opera konqueror.
29858
29859              tty-browsers
29860                     An array similar to  x-browsers,  except  that  it  gives
29861                     browsers  to  use  when no X Window display is available.
29862                     The default is elinks links lynx.
29863
29864              command
29865                     If it is set this style is used to pick the command  used
29866                     to   open   a   page  for  a  browser.   The  context  is
29867                     :mime:browser:new:$browser: to start  a  new  browser  or
29868                     :mime:browser:running:$browser:   to  open  a  URL  in  a
29869                     browser already running on the current X  display,  where
29870                     $browser  is  the  value  matched  in  the  x-browsers or
29871                     tty-browsers  style.   The  escape  sequence  %b  in  the
29872                     style's  value  will be replaced by the browser, while %u
29873                     will be replaced by the URL.  If the style  is  not  set,
29874                     the  default for all new instances is equivalent to %b %u
29875                     and the defaults for using running browsers  are  equiva‐
29876                     lent  to  the  values kfmclient openURL %u for Konqueror,
29877                     firefox -new-tab %u for Firefox, opera  -newpage  %u  for
29878                     Opera, and %b -remote "openUrl(%u)" for all others.
29879

MATHEMATICAL FUNCTIONS

29881       zcalc [ -erf ] [ expression ... ]
29882              A reasonably powerful calculator based on zsh's arithmetic eval‐
29883              uation facility.  The syntax is similar to that of  formulae  in
29884              most  programming languages; see the section `Arithmetic Evalua‐
29885              tion' in zshmisc(1) for details.
29886
29887              Non-programmers should note that, as in many  other  programming
29888              languages,  expressions  involving  only  integers (whether con‐
29889              stants without a `.', variables  containing  such  constants  as
29890              strings,  or  variables  declared to be integers) are by default
29891              evaluated using integer arithmetic, which is not how an ordinary
29892              desk  calculator  operates.   To force floating point operation,
29893              pass the option -f; see further notes below.
29894
29895              If the file ~/.zcalcrc exists it  will  be  sourced  inside  the
29896              function  once  it  is  set  up and about to process the command
29897              line.  This can be used, for example, to set shell options; emu‐
29898              late -L zsh and setopt extendedglob are in effect at this point.
29899              Any failure to source the file if it exists is treated as fatal.
29900              As  with  other  initialisation files, the directory $ZDOTDIR is
29901              used instead of $HOME if it is set.
29902
29903              The mathematical library zsh/mathfunc will be loaded  if  it  is
29904              available;  see the section `The zsh/mathfunc Module' in zshmod‐
29905              ules(1).  The mathematical functions correspond to the raw  sys‐
29906              tem  libraries,  so  trigonometric functions are evaluated using
29907              radians, and so on.
29908
29909              Each line typed is evaluated as an expression.  The prompt shows
29910              a  number, which corresponds to a positional parameter where the
29911              result of that calculation is stored.  For example,  the  result
29912              of the calculation on the line preceded by `4> ' is available as
29913              $4.  The last value calculated is available as ans.   Full  com‐
29914              mand  line  editing,  including the history of previous calcula‐
29915              tions,  is  available;  the  history  is  saved  in   the   file
29916              ~/.zcalc_history.   To  exit, enter a blank line or type `:q' on
29917              its own (`q' is allowed for historical compatibility).
29918
29919              A line ending with a single backslash is  treated  in  the  same
29920              fashion  as it is in command line editing:  the backslash is re‐
29921              moved, the function prompts for more input (the prompt  is  pre‐
29922              ceded  by  `...'  to  indicate this), and the lines are combined
29923              into one to get the final result.  In addition, if the input  so
29924              far  contains more open than close parentheses zcalc will prompt
29925              for more input.
29926
29927              If arguments are given to zcalc on start up, they  are  used  to
29928              prime  the first few positional parameters.  A visual indication
29929              of this is given when the calculator starts.
29930
29931              The constants PI (3.14159...) and E (2.71828...)  are  provided.
29932              Parameter  assignment  is possible, but note that all parameters
29933              will be put into the global namespace unless the :local  special
29934              command  is  used.   The  function creates local variables whose
29935              names start with _, so users should avoid doing so.   The  vari‐
29936              ables  ans  (the  last answer) and stack (the stack in RPN mode)
29937              may be referred to directly; stack is an array but  elements  of
29938              it  are  numeric.   Various other special variables are used lo‐
29939              cally with their  standard  meaning,  for  example  compcontext,
29940              match, mbegin, mend, psvar.
29941
29942              The  output  base  can  be  initialised  by  passing  the option
29943              `-#base', for example `zcalc -#16'  (the  `#'  may  have  to  be
29944              quoted, depending on the globbing options set).
29945
29946              If  the option `-e' is set, the function runs non-interactively:
29947              the arguments are treated as expressions to be evaluated  as  if
29948              entered interactively line by line.
29949
29950              If  the  option `-f' is set, all numbers are treated as floating
29951              point, hence for example the expression `3/4' evaluates to  0.75
29952              rather than 0.  Options must appear in separate words.
29953
29954              If the option `-r' is set, RPN (Reverse Polish Notation) mode is
29955              entered.  This has various additional properties:
29956              Stack  Evaluated values are maintained in a stack; this is  con‐
29957                     tained in an array named stack with the most recent value
29958                     in ${stack[1]}.
29959
29960              Operators and functions
29961                     If the line entered matches an operator (+, -, *, /,  **,
29962                     ^, | or &) or a function supplied by the zsh/mathfunc li‐
29963                     brary, the bottom element or elements of  the  stack  are
29964                     popped  to  use as the argument or arguments.  The higher
29965                     elements of stack (least recent) are used as earlier  ar‐
29966                     guments.  The result is then pushed into ${stack[1]}.
29967
29968              Expressions
29969                     Other  expressions  are  evaluated normally, printed, and
29970                     added to the stack as numeric values.  The syntax  within
29971                     expressions  on  a single line is normal shell arithmetic
29972                     (not RPN).
29973
29974              Stack listing
29975                     If an integer follows the option -r with no  space,  then
29976                     on  every  evaluation  that  many  elements of the stack,
29977                     where available, are printed instead of just the most re‐
29978                     cent   result.   Hence,  for  example,  zcalc  -r4  shows
29979                     $stack[4] to $stack[1] each time results are printed.
29980
29981              Duplication: =
29982                     The pseudo-operator = causes the most recent  element  of
29983                     the stack to be duplicated onto the stack.
29984
29985              pop    The pseudo-function pop causes the most recent element of
29986                     the stack to be popped.  A `>' on its own  has  the  same
29987                     effect.
29988
29989              >ident The  expression  >  followed  (with  no space) by a shell
29990                     identifier causes the most recent element of the stack to
29991                     be  popped  and  assigned to the variable with that name.
29992                     The variable is local to the zcalc function.
29993
29994              <ident The expression < followed (with  no  space)  by  a  shell
29995                     identifier  causes  the  value  of the variable with that
29996                     name to be pushed onto the stack.  ident may be an  inte‐
29997                     ger,  in  which case the previous result with that number
29998                     (as shown before the > in the standard zcalc  prompt)  is
29999                     put on the stack.
30000
30001              Exchange: xy
30002                     The  pseudo-function  xy  causes the most recent two ele‐
30003                     ments of the stack to be exchanged.  `<>'  has  the  same
30004                     effect.
30005
30006              The  prompt is configurable via the parameter ZCALCPROMPT, which
30007              undergoes standard prompt expansion.  The index of  the  current
30008              entry is stored locally in the first element of the array psvar,
30009              which can be referred to in ZCALCPROMPT as `%1v'.   The  default
30010              prompt is `%1v> '.
30011
30012              The  variable ZCALC_ACTIVE is set within the function and can be
30013              tested by nested functions; it has the value rpn if RPN mode  is
30014              active, else 1.
30015
30016              A  few special commands are available; these are introduced by a
30017              colon.  For backward compatibility, the colon may be omitted for
30018              certain  commands.  Completion is available if compinit has been
30019              run.
30020
30021              The output precision may be specified within  zcalc  by  special
30022              commands familiar from many calculators.
30023              :norm  The  default output format.  It corresponds to the printf
30024                     %g specification.  Typically this shows six decimal  dig‐
30025                     its.
30026
30027              :sci digits
30028                     Scientific  notation, corresponding to the printf %g out‐
30029                     put format with the precision given by digits.  This pro‐
30030                     duces  either fixed point or exponential notation depend‐
30031                     ing on the value output.
30032
30033              :fix digits
30034                     Fixed point notation, corresponding to the printf %f out‐
30035                     put format with the precision given by digits.
30036
30037              :eng digits
30038                     Exponential notation, corresponding to the printf %E out‐
30039                     put format with the precision given by digits.
30040
30041              :raw   Raw output:  this is the default form of the output  from
30042                     a math evaluation.  This may show more precision than the
30043                     number actually possesses.
30044
30045              Other special commands:
30046              :!line...
30047                     Execute line... as a normal  shell  command  line.   Note
30048                     that  it is executed in the context of the function, i.e.
30049                     with local variables.  Space is optional after :!.
30050
30051              :local arg ...
30052                     Declare variables local to the function.  Other variables
30053                     may be used, too, but they will be taken from or put into
30054                     the global scope.
30055
30056              :function name [ body ]
30057                     Define a mathematical function or (with no  body)  delete
30058                     it.   :function may be abbreviated to :func or simply :f.
30059                     The name may contain the same characters as a shell func‐
30060                     tion  name.   The function is defined using zmathfuncdef,
30061                     see below.
30062
30063                     Note that zcalc takes care of all quoting.  Hence for ex‐
30064                     ample:
30065
30066                            :f cube $1 * $1 * $1
30067
30068                     defines  a function to cube the sole argument.  Functions
30069                     so defined, or indeed any functions defined  directly  or
30070                     indirectly  using  functions -M, are available to execute
30071                     by typing only the name on the line  in  RPN  mode;  this
30072                     pops the appropriate number of arguments off the stack to
30073                     pass to the function, i.e. 1 in the case of  the  example
30074                     cube  function.  If there are optional arguments only the
30075                     mandatory arguments are supplied by this means.
30076
30077              [#base]
30078                     This is not a special  command,  rather  part  of  normal
30079                     arithmetic  syntax;  however, when this form appears on a
30080                     line by itself the default output radix is set  to  base.
30081                     Use,  for  example, `[#16]' to display hexadecimal output
30082                     preceded by an indication of the base, or  `[##16]'  just
30083                     to display the raw number in the given base.  Bases them‐
30084                     selves are always specified in  decimal.  `[#]'  restores
30085                     the  normal  output  format.  Note that setting an output
30086                     base suppresses floating point output; use `[#]'  to  re‐
30087                     turn to normal operation.
30088
30089              $var   Print out the value of var literally; does not affect the
30090                     calculation.  To use the value of var, omit  the  leading
30091                     `$'.
30092
30093              See the comments in the function for a few extra tips.
30094
30095       min(arg, ...)
30096       max(arg, ...)
30097       sum(arg, ...)
30098       zmathfunc
30099              The  function zmathfunc defines the three mathematical functions
30100              min, max, and sum.  The functions min and max take one  or  more
30101              arguments.   The function sum takes zero or more arguments.  Ar‐
30102              guments can be of different types (ints and floats).
30103
30104              Not to be confused with the zsh/mathfunc  module,  described  in
30105              the section `The zsh/mathfunc Module' in zshmodules(1).
30106
30107       zmathfuncdef [ mathfunc [ body ] ]
30108              A convenient front end to functions -M.
30109
30110              With  two  arguments, define a mathematical function named math‐
30111              func which can be used in any  form  of  arithmetic  evaluation.
30112              body is a mathematical expression to implement the function.  It
30113              may contain references to position parameters $1,  $2,  ...   to
30114              refer  to  mandatory parameters and ${1:-defvalue} ...  to refer
30115              to optional parameters.  Note that the forms  must  be  strictly
30116              adhered  to  for the function to calculate the correct number of
30117              arguments.  The implementation is held in a shell function named
30118              zsh_math_func_mathfunc;  usually the user will not need to refer
30119              to the shell function directly.  Any existing  function  of  the
30120              same name is silently replaced.
30121
30122              With  one argument, remove the mathematical function mathfunc as
30123              well as the shell function implementation.
30124
30125              With no arguments, list all mathfunc functions in a  form  suit‐
30126              able  for restoring the definition.  The functions have not nec‐
30127              essarily been defined by zmathfuncdef.
30128

USER CONFIGURATION FUNCTIONS

30130       The zsh/newuser module comes with a  function  to  aid  in  configuring
30131       shell options for new users.  If the module is installed, this function
30132       can also be run by hand.  It is available even if the module's  default
30133       behaviour,  namely running the function for a new user logging in with‐
30134       out startup files, is inhibited.
30135
30136       zsh-newuser-install [ -f ]
30137              The function presents the user with  various  options  for  cus‐
30138              tomizing  their initialization scripts.  Currently only ~/.zshrc
30139              is handled.  $ZDOTDIR/.zshrc is used instead  if  the  parameter
30140              ZDOTDIR  is set; this provides a way for the user to configure a
30141              file without altering an existing .zshrc.
30142
30143              By default the function exits immediately if it finds any of the
30144              files  .zshenv, .zprofile, .zshrc, or .zlogin in the appropriate
30145              directory.  The option -f is required  in  order  to  force  the
30146              function  to  continue.  Note this may happen even if .zshrc it‐
30147              self does not exist.
30148
30149              As currently configured, the function will exit  immediately  if
30150              the  user has root privileges; this behaviour cannot be overrid‐
30151              den.
30152
30153              Once activated, the  function's  behaviour  is  supposed  to  be
30154              self-explanatory.   Menus are present allowing the user to alter
30155              the value of options and parameters.  Suggestions  for  improve‐
30156              ments are always welcome.
30157
30158              When the script exits, the user is given the opportunity to save
30159              the new file or not; changes are  not  irreversible  until  this
30160              point.   However,  the  script is careful to restrict changes to
30161              the file only to a group marked by the lines `# Lines configured
30162              by  zsh-newuser-install'  and  `#  End  of  lines  configured by
30163              zsh-newuser-install'.  In addition, the old version of .zshrc is
30164              saved to a file with the suffix .zni appended.
30165
30166              If  the  function edits an existing .zshrc, it is up to the user
30167              to ensure that the changes made will take effect.  For  example,
30168              if  control  usually  returns early from the existing .zshrc the
30169              lines will not be executed; or a later initialization  file  may
30170              override  options or parameters, and so on.  The function itself
30171              does not attempt to detect any such conflicts.
30172

OTHER FUNCTIONS

30174       There are a large number of helpful functions in the Functions/Misc di‐
30175       rectory  of  the zsh distribution.  Most are very simple and do not re‐
30176       quire documentation here, but a few are worthy of special mention.
30177
30178   Descriptions
30179       colors This function initializes  several  associative  arrays  to  map
30180              color names to (and from) the ANSI standard eight-color terminal
30181              codes.  These are used by the prompt theme system  (see  above).
30182              You seldom should need to run colors more than once.
30183
30184              The  eight base colors are: black, red, green, yellow, blue, ma‐
30185              genta, cyan, and white.  Each of these has codes for  foreground
30186              and  background.   In  addition  there  are  seven intensity at‐
30187              tributes: bold, faint, standout, underline, blink, reverse,  and
30188              conceal.   Finally,  there  are  seven  codes used to negate at‐
30189              tributes: none (reset all attributes to  the  defaults),  normal
30190              (neither  bold  nor faint), no-standout, no-underline, no-blink,
30191              no-reverse, and no-conceal.
30192
30193              Some terminals do not support all combinations of colors and in‐
30194              tensities.
30195
30196              The associative arrays are:
30197
30198              color
30199              colour Map all the color names to their integer codes, and inte‐
30200                     ger codes to the color names.  The eight base  names  map
30201                     to  the foreground color codes, as do names prefixed with
30202                     `fg-', such as `fg-red'.  Names prefixed with `bg-', such
30203                     as `bg-blue', refer to the background codes.  The reverse
30204                     mapping from code to color yields  base  name  for  fore‐
30205                     ground codes and the bg- form for backgrounds.
30206
30207                     Although  it  is  a misnomer to call them `colors', these
30208                     arrays also map the other fourteen attributes from  names
30209                     to codes and codes to names.
30210
30211              fg
30212              fg_bold
30213              fg_no_bold
30214                     Map  the  eight basic color names to ANSI terminal escape
30215                     sequences that  set  the  corresponding  foreground  text
30216                     properties.   The  fg  sequences change the color without
30217                     changing the eight intensity attributes.
30218
30219              bg
30220              bg_bold
30221              bg_no_bold
30222                     Map the eight basic color names to ANSI  terminal  escape
30223                     sequences  that  set the corresponding background proper‐
30224                     ties.  The bg sequences change the color without changing
30225                     the eight intensity attributes.
30226
30227              In  addition,  the  scalar parameters reset_color and bold_color
30228              are set to the ANSI terminal  escapes  that  turn  off  all  at‐
30229              tributes and turn on bold intensity, respectively.
30230
30231       fned [ -x num ] name
30232              Same  as  zed -f.  This function does not appear in the zsh dis‐
30233              tribution, but can be created by linking zed to the name fned in
30234              some directory in your fpath.
30235
30236       is-at-least needed [ present ]
30237              Perform  a  greater-than-or-equal-to  comparison  of two strings
30238              having the format of a zsh version number; that is, a string  of
30239              numbers  and text with segments separated by dots or dashes.  If
30240              the present string is not provided, $ZSH_VERSION is used.   Seg‐
30241              ments  are  paired left-to-right in the two strings with leading
30242              non-number parts ignored.  If one string has fewer segments than
30243              the other, the missing segments are considered zero.
30244
30245              This  is  useful in startup files to set options and other state
30246              that are not available in all versions of zsh.
30247
30248                     is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS
30249                     is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS
30250                     is-at-least 2.6-17 || print "You can't use is-at-least here."
30251
30252       nslookup [ arg ... ]
30253              This wrapper function for  the  nslookup  command  requires  the
30254              zsh/zpty  module  (see  zshmodules(1)).  It behaves exactly like
30255              the standard  nslookup  except  that  it  provides  customizable
30256              prompts  (including  a  right-side  prompt)  and  completion  of
30257              nslookup commands, host  names,  etc.  (if  you  use  the  func‐
30258              tion-based  completion  system).   Completion  styles may be set
30259              with the context prefix `:completion:nslookup'.
30260
30261              See also the pager, prompt and rprompt styles below.
30262
30263       regexp-replace var regexp replace
30264              Use regular expressions to perform a global search  and  replace
30265              operation on a variable.  POSIX extended regular expressions are
30266              used, unless the option RE_MATCH_PCRE has  been  set,  in  which
30267              case Perl-compatible regular expressions are used (this requires
30268              the shell to be linked against the pcre library).
30269
30270              var is the name of the variable  containing  the  string  to  be
30271              matched.   The  variable  will be modified directly by the func‐
30272              tion.  The variables MATCH, MBEGIN, MEND,  match,  mbegin,  mend
30273              should  be  avoided  as these are used by the regular expression
30274              code.
30275
30276              regexp is the regular expression to match against the string.
30277
30278              replace is the replacement text.  This  can  contain  parameter,
30279              command  and  arithmetic expressions which will be replaced:  in
30280              particular, a reference to $MATCH will be replaced by  the  text
30281              matched by the pattern.
30282
30283              The return status is 0 if at least one match was performed, else
30284              1.
30285
30286       run-help cmd
30287              This function is designed to be invoked by the run-help ZLE wid‐
30288              get,  in  place  of  the  default alias.  See `Accessing On-Line
30289              Help' above for setup instructions.
30290
30291              In the discussion which follows, if cmd is a file  system  path,
30292              it is first reduced to its rightmost component (the file name).
30293
30294              Help  is first sought by looking for a file named cmd in the di‐
30295              rectory named by the HELPDIR parameter.  If no file is found, an
30296              assistant  function,  alias,  or  command  named run-help-cmd is
30297              sought.  If found, the assistant is executed with  the  rest  of
30298              the current command line (everything after the command name cmd)
30299              as its arguments.  When neither file nor assistant is found, the
30300              external command `man cmd' is run.
30301
30302              An example assistant for the "ssh" command:
30303
30304                     run-help-ssh() {
30305                         emulate -LR zsh
30306                         local -a args
30307                         # Delete the "-l username" option
30308                         zparseopts -D -E -a args l:
30309                         # Delete other options, leaving: host command
30310                         args=(${@:#-*})
30311                         if [[ ${#args} -lt 2 ]]; then
30312                             man ssh
30313                         else
30314                             run-help $args[2]
30315                         fi
30316                     }
30317
30318              Several  of  these assistants are provided in the Functions/Misc
30319              directory.  These must be autoloaded, or  placed  as  executable
30320              scripts  in  your  search path, in order to be found and used by
30321              run-help.
30322
30323              run-help-git
30324              run-help-ip
30325              run-help-openssl
30326              run-help-p4
30327              run-help-sudo
30328              run-help-svk
30329              run-help-svn
30330                     Assistant functions for the git, ip, openssl,  p4,  sudo,
30331                     svk, and svn, commands.
30332
30333       tetris Zsh  was once accused of not being as complete as Emacs, because
30334              it lacked a Tetris game.  This function was  written  to  refute
30335              this vicious slander.
30336
30337              This function must be used as a ZLE widget:
30338
30339                     autoload -U tetris
30340                     zle -N tetris
30341                     bindkey keys tetris
30342
30343              To  start  a game, execute the widget by typing the keys.  What‐
30344              ever command line you were editing disappears  temporarily,  and
30345              your  keymap  is also temporarily replaced by the Tetris control
30346              keys.  The previous editor state is restored when you  quit  the
30347              game (by pressing `q') or when you lose.
30348
30349              If  you quit in the middle of a game, the next invocation of the
30350              tetris widget will continue where you left off.  If you lost, it
30351              will start a new game.
30352
30353       tetriscurses
30354              This  is  a port of the above to zcurses.  The input handling is
30355              improved a bit so that moving a block sideways doesn't automati‐
30356              cally  advance  a  timestep,  and the graphics use unicode block
30357              graphics.
30358
30359              This version does not save the game state  between  invocations,
30360              and is not invoked as a widget, but rather as:
30361
30362                     autoload -U tetriscurses
30363                     tetriscurses
30364
30365       zargs [ option ... -- ] [ input ... ] [ -- command [ arg ... ] ]
30366              This  function  has  a similar purpose to GNU xargs.  Instead of
30367              reading lines of arguments from the  standard  input,  it  takes
30368              them  from  the command line.  This is useful because zsh, espe‐
30369              cially with recursive glob operators, often can construct a com‐
30370              mand  line  for  a shell function that is longer than can be ac‐
30371              cepted by an external command.
30372
30373              The option list represents options of the zargs command  itself,
30374              which  are  the  same  as those of xargs.  The input list is the
30375              collection of strings (often file names) that become  the  argu‐
30376              ments  of the command, analogous to the standard input of xargs.
30377              Finally, the arg list consists of those arguments  (usually  op‐
30378              tions)  that  are  passed to the command each time it runs.  The
30379              arg list precedes the elements from the input list in each  run.
30380              If no command is provided, then no arg list may be provided, and
30381              in that event the default command is `print' with arguments  `-r
30382              --'.
30383
30384              For  example,  to  get a long ls listing of all non-hidden plain
30385              files in the current directory or its subdirectories:
30386
30387                     autoload -U zargs
30388                     zargs -- **/*(.) -- ls -ld --
30389
30390              The first and third occurrences of `--' are used to mark the end
30391              of  options for zargs and ls respectively to guard against file‐
30392              names starting with `-', while the second is  used  to  separate
30393              the list of files from the command to run (`ls -ld --').
30394
30395              The  first  `--'  would also be needed if there was a chance the
30396              list might be empty as in:
30397
30398                     zargs -r -- ./*.back(#qN) -- rm -f
30399
30400              In the event that the string `--' is or may be an input, the  -e
30401              option  may  be  used  to change the end-of-inputs marker.  Note
30402              that this does not change the end-of-options marker.  For  exam‐
30403              ple, to use `..' as the marker:
30404
30405                     zargs -e.. -- **/*(.) .. ls -ld --
30406
30407              This  is a good choice in that example because no plain file can
30408              be named `..', but the best end-marker depends  on  the  circum‐
30409              stances.
30410
30411              The  options  -i,  -I, -l, -L, and -n differ slightly from their
30412              usage in xargs.  There are no input lines for zargs to count, so
30413              -l and -L count through the input list, and -n counts the number
30414              of arguments passed to each execution of command, including  any
30415              arg  list.   Also, any time -i or -I is used, each input is pro‐
30416              cessed separately as if by `-L 1'.
30417
30418              For details of the other zargs options, see xargs(1)  (but  note
30419              the difference in function between zargs and xargs) or run zargs
30420              with the --help option.
30421
30422       zed [ -f [ -x num ] ] name
30423       zed -b This function uses the ZLE editor to edit a file or function.
30424
30425              Only one name argument is allowed.  If the -f option  is  given,
30426              the  name  is taken to be that of a function; if the function is
30427              marked for autoloading, zed searches for it  in  the  fpath  and
30428              loads  it.   Note  that  functions edited this way are installed
30429              into the current shell, but not written  back  to  the  autoload
30430              file.   In  this  case the -x option specifies that leading tabs
30431              indenting the function according to syntax should  be  converted
30432              into  the  given number of spaces; `-x 2' is consistent with the
30433              layout of functions distributed with the shell.
30434
30435              Without -f, name is the path name of the  file  to  edit,  which
30436              need not exist; it is created on write, if necessary.
30437
30438              While  editing, the function sets the main keymap to zed and the
30439              vi command keymap to zed-vicmd.  These will be copied  from  the
30440              existing  main  and vicmd keymaps if they do not exist the first
30441              time zed is run.  They can be used to provide special key  bind‐
30442              ings used only in zed.
30443
30444              If it creates the keymap, zed rebinds the return key to insert a
30445              line break and `^X^W' to accept the edit in the zed keymap,  and
30446              binds `ZZ' to accept the edit in the zed-vicmd keymap.
30447
30448              The  bindings  alone can be installed by running `zed -b'.  This
30449              is suitable for putting into a startup file.  Note that, if  re‐
30450              run, this will overwrite the existing zed and zed-vicmd keymaps.
30451
30452              Completion  is available, and styles may be set with the context
30453              prefix `:completion:zed'.
30454
30455              A zle widget zed-set-file-name is available.  This can be called
30456              by  name  from  within  zed using `\ex zed-set-file-name' (note,
30457              however, that because of zed's rebindings you will have to  type
30458              ^j  at  the end instead of the return key), or can be bound to a
30459              key in either of the zed or zed-vicmd keymaps after `zed -b' has
30460              been  run.  When the widget is called, it prompts for a new name
30461              for the file being edited.  When zed  exits  the  file  will  be
30462              written  under  that  name  and  the  original file will be left
30463              alone.  The widget has no effect with `zed -f'.
30464
30465              While zed-set-file-name is running, zed uses the keymap zed-nor‐
30466              mal-keymap,  which  is  linked from the main keymap in effect at
30467              the time zed initialised its bindings.  (This is to make the re‐
30468              turn  key  operate  normally.)   The  result is that if the main
30469              keymap has been changed, the widget won't notice.  This is not a
30470              concern for most users.
30471
30472       zcp [ -finqQvwW ] srcpat dest
30473       zln [ -finqQsvwW ] srcpat dest
30474              Same as zmv -C and zmv -L, respectively.  These functions do not
30475              appear in the zsh distribution, but can be  created  by  linking
30476              zmv to the names zcp and zln in some directory in your fpath.
30477
30478       zkbd   See `Keyboard Definition' above.
30479
30480
30481       zmv [ -finqQsvwW ] [ -C | -L | -M | -{p|P} program ] [ -o optstring ]
30482           srcpat dest
30483              Move (usually, rename) files matching the pattern srcpat to cor‐
30484              responding files having names of the form given by  dest,  where
30485              srcpat  contains  parentheses surrounding patterns which will be
30486              replaced in turn by $1, $2, ... in dest.  For example,
30487
30488                     zmv '(*).lis' '$1.txt'
30489
30490              renames   `foo.lis'   to   `foo.txt',   `my.old.stuff.lis'    to
30491              `my.old.stuff.txt', and so on.
30492
30493              The  pattern is always treated as an EXTENDED_GLOB pattern.  Any
30494              file whose name is not changed by the substitution is simply ig‐
30495              nored.   Any  error (a substitution resulted in an empty string,
30496              two substitutions gave the same result, the destination  was  an
30497              existing  regular  file  and -f was not given) causes the entire
30498              function to abort without doing anything.
30499
30500              In addition to pattern replacement, the variable $f can  be  re‐
30501              ferrred  to in the second (replacement) argument.  This makes it
30502              possible to use variable substitution to alter the argument; see
30503              examples below.
30504
30505              Options:
30506
30507              -f     Force  overwriting  of  destination files.  Not currently
30508                     passed down to the mv/cp/ln command due  to  vagaries  of
30509                     implementations (but you can use -o-f to do that).
30510              -i     Interactive:  show  each  line to be executed and ask the
30511                     user whether to execute it.  `Y' or `y' will execute  it,
30512                     anything  else  will skip it.  Note that you just need to
30513                     type one character.
30514              -n     No execution: print what would happen, but don't do it.
30515              -q     Turn bare glob qualifiers off: now assumed by default, so
30516                     this has no effect.
30517              -Q     Force bare glob qualifiers on.  Don't turn this on unless
30518                     you are actually using glob qualifiers in a pattern.
30519              -s     Symbolic, passed down to ln; only works with -L.
30520              -v     Verbose: print each command as it's being executed.
30521              -w     Pick out wildcard parts  of  the  pattern,  as  described
30522                     above,  and  implicitly  add parentheses for referring to
30523                     them.
30524              -W     Just like -w, with the addition of turning  wildcards  in
30525                     the replacement pattern into sequential ${1} .. ${N} ref‐
30526                     erences.
30527              -C
30528              -L
30529              -M     Force cp, ln or mv, respectively, regardless of the  name
30530                     of the function.
30531              -p program
30532                     Call  program instead of cp, ln or mv.  Whatever it does,
30533                     it should at least understand the form `program  --  old‐
30534                     name  newname'  where  oldname  and newname are filenames
30535                     generated by zmv.  program will be split into  words,  so
30536                     might  be e.g. the name of an archive tool plus a copy or
30537                     rename subcommand.
30538              -P program
30539                     As -p program, except that program does not accept a fol‐
30540                     lowing  --  to indicate the end of options.  In this case
30541                     filenames must already be in a sane form for the  program
30542                     in question.
30543              -o optstring
30544                     The  optstring is split into words and passed down verba‐
30545                     tim to the cp, ln or mv command  called  to  perform  the
30546                     work.  It should probably begin with a `-'.
30547
30548              Further examples:
30549
30550                     zmv -v '(* *)' '${1// /_}'
30551
30552              For any file in the current directory with at least one space in
30553              the name, replace every space by an underscore and  display  the
30554              commands executed.
30555
30556                     zmv -v '* *' '${f// /_}'
30557
30558              This  does exactly the same by referring to the file name stored
30559              in $f.
30560
30561              For more complete examples and other implementation details, see
30562              the  zmv  source file, usually located in one of the directories
30563              named in your fpath, or in Functions/Misc/zmv in the zsh distri‐
30564              bution.
30565
30566       zrecompile
30567              See `Recompiling Functions' above.
30568
30569       zstyle+ context style value [ + subcontext style value ... ]
30570              This  makes  defining styles a bit simpler by using a single `+'
30571              as a special token that allows you to append a context  name  to
30572              the previously used context name.  Like this:
30573
30574                     zstyle+ ':foo:bar' style1 value1 \
30575                            +':baz'     style2 value2 \
30576                            +':frob'    style3 value3
30577
30578              This  defines  style1  with  value1  for the context :foo:bar as
30579              usual, but it also defines style2 with value2  for  the  context
30580              :foo:bar:baz and style3 with value3 for :foo:bar:frob.  Any sub‐
30581              context may be the empty string to re-use the first context  un‐
30582              changed.
30583
30584   Styles
30585       insert-tab
30586              The  zed function sets this style in context `:completion:zed:*'
30587              to turn off completion when TAB is typed at the beginning  of  a
30588              line.   You may override this by setting your own value for this
30589              context and style.
30590
30591       pager  The nslookup  function  looks  up  this  style  in  the  context
30592              `:nslookup' to determine the program used to display output that
30593              does not fit on a single screen.
30594
30595       prompt
30596       rprompt
30597              The nslookup  function  looks  up  this  style  in  the  context
30598              `:nslookup' to set the prompt and the right-side prompt, respec‐
30599              tively.  The usual expansions for the PS1  and  RPS1  parameters
30600              may be used (see EXPANSION OF PROMPT SEQUENCES in zshmisc(1)).
30601
30602
30603
30604ZSHALL(1)                   General Commands Manual                  ZSHALL(1)
30605
30606
30607

FILES

30609       $ZDOTDIR/.zshenv
30610       $ZDOTDIR/.zprofile
30611       $ZDOTDIR/.zshrc
30612       $ZDOTDIR/.zlogin
30613       $ZDOTDIR/.zlogout
30614       ${TMPPREFIX}*   (default is /tmp/zsh*)
30615       /etc/zshenv
30616       /etc/zprofile
30617       /etc/zshrc
30618       /etc/zlogin
30619       /etc/zlogout    (installation-specific - /etc is the default)
30620

SEE ALSO

30622       sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1)
30623
30624       IEEE  Standard  for  information Technology - Portable Operating System
30625       Interface (POSIX) - Part 2: Shell and Utilities, IEEE Inc,  1993,  ISBN
30626       1-55937-255-9.
30627
30628
30629
30630zsh 5.8.1                      February 12, 2022                     ZSHALL(1)
Impressum