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       Zsh has command line editing, builtin spelling correction, programmable
34       command completion, shell functions (with autoloading), a history mech‐
35       anism, and a host of other features.
36

AUTHOR

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

AVAILABILITY

46       Zsh  is available from the following anonymous FTP sites.  These mirror
47       sites are kept frequently up to date.  The sites marked with (H) may be
48       mirroring ftp.cs.elte.hu instead of the primary site.
49
50       Primary site
51              ftp://ftp.zsh.org/pub/
52              http://www.zsh.org/pub/
53
54       Australia
55              ftp://ftp.zsh.org/pub/
56              http://www.zsh.org/pub/
57              http://mirror.dejanseo.com.au/pub/zsh/
58
59       Hungary
60              ftp://ftp.cs.elte.hu/pub/zsh/
61              http://www.cs.elte.hu/pub/zsh/
62
63       The  up-to-date source code is available via Git from Sourceforge.  See
64       http://sourceforge.net/projects/zsh/  for  details.    A   summary   of
65       instructions  for  the  archive  can  be  found  at  http://zsh.source
66       forge.net/.
67

MAILING LISTS

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

THE ZSH FAQ

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

THE ZSH WEB PAGE

114       Zsh  has  a  web page which is located at http://www.zsh.org/.  This is
115       maintained by Karsten Thygesen <karthy@zsh.org>,  of  SunSITE  Denmark.
116       The contact address for web-related matters is <webmaster@zsh.org>.
117

THE ZSH USERGUIDE

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

THE ZSH WIKI

128       A  `wiki'  website for zsh has been created at http://www.zshwiki.org/.
129       This is a site which can be added to and  modified  directly  by  users
130       without any special permission.  You can add your own zsh tips and con‐
131       figurations.
132

INVOCATION

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

COMPATIBILITY

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

RESTRICTED SHELL

252       When the basename of the command used to invoke  zsh  starts  with  the
253       letter  `r'  or the `-r' command line option is supplied at invocation,
254       the shell becomes  restricted.   Emulation  mode  is  determined  after
255       stripping  the  letter `r' from the invocation name.  The following are
256       disabled in restricted mode:
257
258       ·      changing directories with the cd builtin
259
260       ·      changing or unsetting the EGID, EUID, GID,  HISTFILE,  HISTSIZE,
261              IFS,   LD_AOUT_LIBRARY_PATH,  LD_AOUT_PRELOAD,  LD_LIBRARY_PATH,
262              LD_PRELOAD, MODULE_PATH, module_path, PATH, path, SHELL, UID and
263              USERNAME parameters
264
265       ·      specifying command names containing /
266
267       ·      specifying command pathnames using hash
268
269       ·      redirecting output to files
270
271       ·      using the exec builtin command to replace the shell with another
272              command
273
274       ·      using jobs -Z to overwrite the shell process' argument and envi‐
275              ronment space
276
277       ·      using  the ARGV0 parameter to override argv[0] for external com‐
278              mands
279
280       ·      turning off restricted mode with set +r or unsetopt RESTRICTED
281
282       These restrictions are enforced after  processing  the  startup  files.
283       The  startup  files  should set up PATH to point to a directory of com‐
284       mands which can be safely invoked in the restricted environment.   They
285       may also add further restrictions by disabling selected builtins.
286
287       Restricted  mode  can  also  be  activated  any  time  by  setting  the
288       RESTRICTED option.   This  immediately  enables  all  the  restrictions
289       described  above  even if the shell still has not processed all startup
290       files.
291

STARTUP/SHUTDOWN FILES

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

NAME

336       zshroadmap - informal introduction to the zsh manual  The  Zsh  Manual,
337       like the shell itself, is large and often complicated.  This section of
338       the manual provides some pointers to areas of the shell that are likely
339       to  be  of particular interest to new users, and indicates where in the
340       rest of the manual the documentation is to be found.
341

WHEN THE SHELL STARTS

343       When it starts, the shell reads commands from various files.  These can
344       be  created  or  edited  to  customize  the  shell.   See  the  section
345       Startup/Shutdown Files in zsh(1).
346
347       If no personal initialization files exist for the current user, a func‐
348       tion  is  run  to help you change some of the most common settings.  It
349       won't appear if your administrator has disabled the zsh/newuser module.
350       The  function  is  designed  to be self-explanatory.  You can run it by
351       hand with `autoload -Uz zsh-newuser-install;  zsh-newuser-install  -f'.
352       See also the section User Configuration Functions in zshcontrib(1).
353

INTERACTIVE USE

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

OPTIONS

435       The  shell  has  a  large number of options for changing its behaviour.
436       These cover all aspects of the shell; browsing the  full  documentation
437       is  the only good way to become acquainted with the many possibilities.
438       See zshoptions(1).
439

PATTERN MATCHING

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

GENERAL COMMENTS ON SYNTAX

462       Although the syntax of zsh is in ways similar to the  Korn  shell,  and
463       therefore  more  remotely to the original UNIX shell, the Bourne shell,
464       its default behaviour does not entirely  correspond  to  those  shells.
465       General  shell  syntax  is introduced in the section `Shell Grammar' in
466       zshmisc(1).
467
468       One commonly encountered difference is that variables substituted  onto
469       the  command line are not split into words.  See the description of the
470       shell option SH_WORD_SPLIT in the section `Parameter Expansion' in zsh‐
471       expn(1).  In zsh, you can either explicitly request the splitting (e.g.
472       ${=foo}) or use an array when you want a variable  to  expand  to  more
473       than one word.  See the section `Array Parameters' in zshparam(1).
474

PROGRAMMING

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

FILES

509       $ZDOTDIR/.zshenv
510       $ZDOTDIR/.zprofile
511       $ZDOTDIR/.zshrc
512       $ZDOTDIR/.zlogin
513       $ZDOTDIR/.zlogout
514       ${TMPPREFIX}*   (default is /tmp/zsh*)
515       /etc/zshenv
516       /etc/zprofile
517       /etc/zshrc
518       /etc/zlogin
519       /etc/zlogout    (installation-specific - /etc is the default)
520

SEE ALSO

522       sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1)
523
524       IEEE Standard for information Technology -  Portable  Operating  System
525       Interface  (POSIX)  - Part 2: Shell and Utilities, IEEE Inc, 1993, ISBN
526       1-55937-255-9.
527
528
529
530zsh 5.5.1                       April 16, 2018                       ZSHALL(1)
Impressum