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       zshroadmap   Informal introduction to the manual
14       zshmisc      Anything not fitting into the other sections
15       zshexpn      Zsh command and parameter expansion
16       zshparam     Zsh parameters
17       zshoptions   Zsh options
18       zshbuiltins  Zsh built-in functions
19       zshzle       Zsh command line editing
20       zshcompwid   Zsh completion widgets
21       zshcompsys   Zsh completion system
22       zshcompctl   Zsh completion control
23       zshmodules   Zsh loadable modules
24       zshcalsys    Zsh built-in calendar functions
25       zshtcpsys    Zsh built-in TCP functions
26       zshzftpsys   Zsh built-in FTP client
27       zshcontrib   Additional zsh functions and utilities
28

DESCRIPTION

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

AUTHOR

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

AVAILABILITY

49       Zsh is available from the following HTTP and anonymous FTP site.
50
51       ftp://ftp.zsh.org/pub/
52       https://www.zsh.org/pub/
53       )
54
55       The up-to-date source code is available via Git from Sourceforge.   See
56       https://sourceforge.net/projects/zsh/   for   details.   A  summary  of
57       instructions  for  the  archive  can  be  found  at  http://zsh.source
58       forge.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
145       described 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,
174       `--option-name'.  When this is done, `-' characters in the option  name
175       are permitted: they are translated into `_', and thus ignored.  So, for
176       example, `zsh  --sh-word-split'  invokes  zsh  with  the  SH_WORD_SPLIT
177       option  turned  on.   Like other option syntaxes, options can be turned
178       off by replacing the initial `-' with a `+'; thus `+-sh-word-split'  is
179       equivalent  to  `--no-sh-word-split'.   Unlike  other  option syntaxes,
180       GNU-style long options cannot be stacked with any other options, so for
181       example  `-x-shwordsplit'  is  an error, rather than being treated like
182       `-x --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,
232       SH_OPTION_LETTERS,   SH_WORD_SPLIT.    Additionally  the  BSD_ECHO  and
233       IGNORE_BRACES options are set if zsh  is  invoked  as  sh.   Also,  the
234       KSH_OPTION_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
274       RESTRICTED option.   This  immediately  enables  all  the  restrictions
275       described  above  even if the shell still has not processed all startup
276       files.
277

STARTUP/SHUTDOWN FILES

279       Commands are first read from /etc/zshenv; this  cannot  be  overridden.
280       Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the
281       former affects all startup files, while the second only affects  global
282       startup  files  (those  shown here with an path starting with a /).  If
283       one of the options is  unset  at  any  point,  any  subsequent  startup
284       file(s)  of the corresponding type will not be read.  It is also possi‐
285       ble for a file in  $ZDOTDIR  to  re-enable  GLOBAL_RCS.  Both  RCS  and
286       GLOBAL_RCS are set by default.
287
288       Commands  are then read from $ZDOTDIR/.zshenv.  If the shell is a login
289       shell, commands are read from /etc/zprofile  and  then  $ZDOTDIR/.zpro‐
290       file.   Then,  if  the  shell  is  interactive,  commands are read from
291       /etc/zshrc and then $ZDOTDIR/.zshrc.  Finally, if the shell is a  login
292       shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
293
294       When  a  login  shell  exits,  the  files  $ZDOTDIR/.zlogout  and  then
295       /etc/zlogout are read.  This happens with either an explicit  exit  via
296       the exit or logout commands, or an implicit exit by reading end-of-file
297       from the terminal.  However, if the shell terminates  due  to  exec'ing
298       another  process,  the  logout  files  are  not  read.   These are also
299       affected by the RCS and GLOBAL_RCS options.  Note  also  that  the  RCS
300       option  affects  the saving of history files, i.e. if RCS is unset when
301       the shell exits, no history file will be saved.
302
303       If ZDOTDIR is unset, HOME is used instead.  Files listed above as being
304       in /etc may be in another directory, depending on the installation.
305
306       As /etc/zshenv is run for all instances of zsh, it is important that it
307       be kept as small as possible.  In particular, it is a good idea to  put
308       code  that does not need to be run for every single shell behind a test
309       of the form `if [[ -o rcs ]]; then ...' so that it will not be executed
310       when zsh is invoked with the `-f' option.
311
312       Any  of  these files may be pre-compiled with the zcompile builtin com‐
313       mand (see zshbuiltins(1)).  If a compiled file exists  (named  for  the
314       original  file plus the .zwc extension) and it is newer than the origi‐
315       nal file, the compiled file will be used instead.
316
317
318
319ZSHROADMAP(1)               General Commands Manual              ZSHROADMAP(1)
320
321
322

NAME

324       zshroadmap - informal introduction to the zsh manual  The  Zsh  Manual,
325       like the shell itself, is large and often complicated.  This section of
326       the manual provides some pointers to areas of the shell that are likely
327       to  be  of particular interest to new users, and indicates where in the
328       rest of the manual the documentation is to be found.
329

WHEN THE SHELL STARTS

331       When it starts, the shell reads commands from various files.  These can
332       be  created  or  edited  to  customize  the  shell.   See  the  section
333       Startup/Shutdown Files in zsh(1).
334
335       If no personal initialization files exist for the current user, a func‐
336       tion  is  run  to help you change some of the most common settings.  It
337       won't appear if your administrator has disabled the zsh/newuser module.
338       The  function  is  designed  to be self-explanatory.  You can run it by
339       hand with `autoload -Uz zsh-newuser-install;  zsh-newuser-install  -f'.
340       See also the section User Configuration Functions in zshcontrib(1).
341

INTERACTIVE USE

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

OPTIONS

423       The  shell  has  a  large number of options for changing its behaviour.
424       These cover all aspects of the shell; browsing the  full  documentation
425       is  the only good way to become acquainted with the many possibilities.
426       See zshoptions(1).
427

PATTERN MATCHING

429       The shell has a rich set of  patterns  which  are  available  for  file
430       matching  (described  in the documentation as `filename generation' and
431       also known for historical reasons as `globbing') and for use when  pro‐
432       gramming.   These are described in the section `Filename Generation' in
433       zshexpn(1).
434
435       Of particular interest are the following patterns that are not commonly
436       supported by other systems of pattern matching:
437
438       **     for matching over multiple directories
439
440       |      for matching either of two alternatives
441
442       ~, ^   the   ability   to  exclude  patterns  from  matching  when  the
443              EXTENDED_GLOB option is set
444
445       (...)  glob qualifiers, included in parentheses at the end of the  pat‐
446              tern,  which  select  files  by  type  (such  as directories) or
447              attribute (such as size).
448

GENERAL COMMENTS ON SYNTAX

450       Although the syntax of zsh is in ways similar to the  Korn  shell,  and
451       therefore  more  remotely to the original UNIX shell, the Bourne shell,
452       its default behaviour does not entirely  correspond  to  those  shells.
453       General  shell  syntax  is introduced in the section `Shell Grammar' in
454       zshmisc(1).
455
456       One commonly encountered difference is that variables substituted  onto
457       the  command line are not split into words.  See the description of the
458       shell option SH_WORD_SPLIT in the section `Parameter Expansion' in zsh‐
459       expn(1).  In zsh, you can either explicitly request the splitting (e.g.
460       ${=foo}) or use an array when you want a variable  to  expand  to  more
461       than one word.  See the section `Array Parameters' in zshparam(1).
462

PROGRAMMING

464       The  most  convenient  way of adding enhancements to the shell is typi‐
465       cally  by  writing  a  shell  function  and  arranging  for  it  to  be
466       autoloaded.  Functions are described in the section `Functions' in zsh‐
467       misc(1).  Users changing from the C  shell  and  its  relatives  should
468       notice that aliases are less used in zsh as they don't perform argument
469       substitution, only simple text replacement.
470
471       A few general functions, other than those for the line editor described
472       above,  are provided with the shell and are described in zshcontrib(1).
473       Features include:
474
475       promptinit
476              a prompt theme system for changing prompts easily, see the  sec‐
477              tion `Prompt Themes'
478
479
480       zsh-mime-setup
481              a  MIME-handling  system  which dispatches commands according to
482              the suffix of a file as done by graphical file managers
483
484       zcalc  a calculator
485
486       zargs  a version of xargs that makes the find command redundant
487
488       zmv    a command for renaming files by means of shell patterns.
489
490
491
492ZSHALL(1)                   General Commands Manual                  ZSHALL(1)
493
494
495

FILES

497       $ZDOTDIR/.zshenv
498       $ZDOTDIR/.zprofile
499       $ZDOTDIR/.zshrc
500       $ZDOTDIR/.zlogin
501       $ZDOTDIR/.zlogout
502       ${TMPPREFIX}*   (default is /tmp/zsh*)
503       /etc/zshenv
504       /etc/zprofile
505       /etc/zshrc
506       /etc/zlogin
507       /etc/zlogout    (installation-specific - /etc is the default)
508

SEE ALSO

510       sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1)
511
512       IEEE Standard for information Technology -  Portable  Operating  System
513       Interface  (POSIX)  - Part 2: Shell and Utilities, IEEE Inc, 1993, ISBN
514       1-55937-255-9.
515
516
517
518zsh 5.7.1                      February 3, 2019                      ZSHALL(1)
Impressum