zsh.1   [plain text]

.TH "ZSH" "1" "December 20, 2010" "zsh 4\&.3\&.11"
zsh \- the Z shell
.\" Yodl file: Zsh/intro.yo
Because zsh contains many features, the zsh manual has been split into
a number of sections:
.PD 0
\fIzsh\fP          Zsh overview (this section)
\fIzshroadmap\fP   Informal introduction to the manual
\fIzshmisc\fP      Anything not fitting into the other sections
\fIzshexpn\fP      Zsh command and parameter expansion
\fIzshparam\fP     Zsh parameters
\fIzshoptions\fP   Zsh options
\fIzshbuiltins\fP  Zsh built\-in functions
\fIzshzle\fP       Zsh command line editing
\fIzshcompwid\fP   Zsh completion widgets
\fIzshcompsys\fP   Zsh completion system
\fIzshcompctl\fP   Zsh completion control
\fIzshmodules\fP   Zsh loadable modules
\fIzshtcpsys\fP    Zsh built\-in TCP functions
\fIzshzftpsys\fP   Zsh built\-in FTP client
\fIzshcontrib\fP   Additional zsh functions and utilities
\fIzshall\fP       Meta\-man page containing all of the above
Zsh is a UNIX command interpreter (shell) usable as an interactive
login shell and as a shell script command processor\&.  Of the standard shells,
zsh most closely resembles \fBksh\fP but includes many enhancements\&.  Zsh
has command line editing, builtin spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and a host of other features\&.
.\" Yodl file: Zsh/metafaq.yo
Zsh was originally written by Paul Falstad \fB<pf@zsh\&.org>\fP\&.
Zsh is now maintained by the members of the zsh\-workers mailing
list \fB<zsh\-workers@zsh\&.org>\fP\&.  The development is currently
coordinated by Peter Stephenson \fB<pws@zsh\&.org>\fP\&.  The coordinator
can be contacted at \fB<coordinator@zsh\&.org>\fP, but matters relating to
the code should generally go to the mailing list\&.
Zsh is available from the following anonymous FTP sites\&.  These mirror
sites are kept frequently up to date\&.  The sites marked with \fI(H)\fP may be
mirroring \fBftp\&.cs\&.elte\&.hu\fP instead of the primary site\&.
.PD 0
Primary site
\fBftp://ftp\&.fu\-berlin\&.de/pub/unix/shells/zsh/\fP  \fI(H)\fP
The up\-to\-date source code is available via anonymous CVS and Git from
Sourceforge\&.  See \fBhttp://sourceforge\&.net/projects/zsh/\fP for details\&.
A summary of instructions for the CVS and Git archives can be found at
Zsh has 3 mailing lists:
.PD 0
Announcements about releases, major changes in the shell and the
monthly posting of the Zsh FAQ\&.  (moderated)
User discussions\&.
Hacking, development, bug reports and patches\&.
To subscribe or unsubscribe, send mail
to the associated administrative address for the mailing list\&.
.PD 0
All submissions to \fBzsh\-announce\fP are automatically forwarded to
\fBzsh\-users\fP\&.  All submissions to \fBzsh\-users\fP are automatically
forwarded to \fBzsh\-workers\fP\&.
If you have problems subscribing/unsubscribing to any of the mailing
lists, send mail to \fB<listmaster@zsh\&.org>\fP\&.  The mailing lists are
maintained by Karsten Thygesen \fB<karthy@kom\&.auc\&.dk>\fP\&.
The mailing lists are archived; the archives can be accessed via the
administrative addresses listed above\&.  There is also a hypertext
archive, maintained by Geoff Wing \fB<gcw@zsh\&.org>\fP, available at
Zsh has a list of Frequently Asked Questions (FAQ), maintained by
Peter Stephenson \fB<pws@zsh\&.org>\fP\&.  It is regularly posted to the
newsgroup \fBcomp\&.unix\&.shell\fP and the \fBzsh\-announce\fP mailing list\&.
The latest version can be found at any of the Zsh FTP sites, or at
\fBhttp://www\&.zsh\&.org/FAQ/\fP\&.  The contact address for FAQ\-related matters
is \fB<faqmaster@zsh\&.org>\fP\&.
Zsh has a web page which is located at \fBhttp://www\&.zsh\&.org/\fP\&.  This is
maintained by Karsten Thygesen \fB<karthy@zsh\&.org>\fP, of SunSITE Denmark\&.
The contact address for web\-related matters is \fB<webmaster@zsh\&.org>\fP\&.
A userguide is currently in preparation\&.  It is intended to complement the
manual, with explanations and hints on issues where the manual can be
cabbalistic, hierographic, or downright mystifying (for example, the word
`hierographic\&' does not exist)\&.  It can be viewed in its current state at
\fBhttp://zsh\&.sourceforge\&.net/Guide/\fP\&.  At the time of writing, chapters
dealing with startup files and their contents and the new completion system
were essentially complete\&.
A `wiki\&' website for zsh has been created at \fBhttp://www\&.zshwiki\&.org/\fP\&.
This is a site which can be added to and modified directly by users without
any special permission\&.  You can add your own zsh tips and configurations\&.
.\" Yodl file: Zsh/invoke.yo
The following flags are interpreted by the shell when invoked to determine
where the shell will read commands from:
.PD 0
Take the first argument as a command to execute, rather than reading commands
from a script or standard input\&.  If any further arguments are given, the
first one is assigned to \fB$0\fP, rather than being used as a positional
Force shell to be interactive\&.  It is still possible to specify a
script to execute\&.
Force shell to read commands from the standard input\&.
If the \fB\-s\fP flag is not present and an argument is given,
the first argument is taken to be the pathname of a script to
If there are any remaining arguments after option processing, and neither
of the options \fB\-c\fP or \fB\-s\fP was supplied, the first argument is taken
as the file name of a script containing shell commands to be executed\&.  If
the option \fBPATH_SCRIPT\fP is set, and the file name does not contain a
directory path (i\&.e\&. there is no `\fB/\fP\&' in the name), first the current
directory and then the command path given by the variable \fBPATH\fP are
searched for the script\&.  If the option is not set or the file name
contains a `\fB/\fP\&' it is used directly\&.
After the first one or two arguments have been appropriated as described above,
the remaining arguments are assigned to the positional parameters\&.
For further options, which are common to invocation and the \fBset\fP
builtin, see
Options may be specified by name using the \fB\-o\fP option\&.  \fB\-o\fP acts like
a single\-letter option, but takes a following string as the option name\&.
For example,
\fBzsh \-x \-o shwordsplit scr\fP
runs the script \fBscr\fP, setting the \fBXTRACE\fP option by the corresponding
letter `\fB\-x\fP\&' and the \fBSH_WORD_SPLIT\fP option by name\&.
Options may be turned \fIoff\fP by name by using \fB+o\fP instead of \fB\-o\fP\&.
\fB\-o\fP can be stacked up with preceding single\-letter options, so for example
`\fB\-xo shwordsplit\fP\&' or `\fB\-xoshwordsplit\fP' is equivalent to
`\fB\-x \-o shwordsplit\fP\&'\&.
Options may also be specified by name in GNU long option style,
`\fB\-\fP\fB\-\fP\fIoption\-name\fP\&'\&.  When this is done, `\fB\-\fP' characters in the
option name are permitted: they are translated into `\fB_\fP\&', and thus ignored\&.
So, for example, `\fBzsh \-\fP\fB\-sh\-word\-split\fP\&' invokes zsh with the
\fBSH_WORD_SPLIT\fP option turned on\&.  Like other option syntaxes, options can
be turned off by replacing the initial `\fB\-\fP\&' with a `\fB+\fP'; thus
`\fB+\-sh\-word\-split\fP\&' is equivalent to `\fB\-\fP\fB\-no\-sh\-word\-split\fP'\&.
Unlike other option syntaxes, GNU\-style long options cannot be stacked with
any other options, so for example `\fB\-x\-shwordsplit\fP\&' is an error,
rather than being treated like `\fB\-x \-\fP\fB\-shwordsplit\fP\&'\&.
The special GNU\-style option `\fB\-\fP\fB\-version\fP\&' is handled; it sends to
standard output the shell\&'s version information, then exits successfully\&.
`\fB\-\fP\fB\-help\fP\&' is also handled; it sends to standard output a list of
options that can be used when invoking the shell, then exits successfully\&.
Option processing may be finished, allowing following arguments that start with
`\fB\-\fP\&' or `\fB+\fP' to be treated as normal arguments, in two ways\&.
Firstly, a lone `\fB\-\fP\&' (or `\fB+\fP') as an argument by itself ends
option processing\&.  Secondly, a special option `\fB\-\fP\fB\-\fP\&' (or
`\fB+\-\fP\&'), which may be specified on its own (which is the standard
POSIX usage) or may be stacked with preceding options (so `\fB\-x\-\fP\&' is
equivalent to `\fB\-x \-\fP\fB\-\fP\&')\&.  Options are not permitted to be stacked
after `\fB\-\fP\fB\-\fP\&' (so `\fB\-x\-f\fP' is an error), but note the GNU\-style
option form discussed above, where `\fB\-\fP\fB\-shwordsplit\fP\&' is permitted
and does not end option processing\&.
Except when the \fBsh\fP/\fBksh\fP emulation single\-letter options are in effect,
the option `\fB\-b\fP\&' (or `\fB+b\fP') ends option processing\&.
`\fB\-b\fP\&' is like `\fB\-\fP\fB\-\fP', except that further single\-letter options
can be stacked after the `\fB\-b\fP\&' and will take effect as normal\&.
.\" Yodl file: Zsh/compat.yo
Zsh tries to emulate \fBsh\fP or \fBksh\fP when it is invoked as
\fBsh\fP or \fBksh\fP respectively; more precisely, it looks at the first
letter of the name by which it was invoked, excluding any initial `\fBr\fP\&'
(assumed to stand for `restricted\&'), and if that is `\fBs\fP' or `\fBk\fP' it
will emulate \fBsh\fP or \fBksh\fP\&.  Furthermore, if invoked as \fBsu\fP (which
happens on certain systems when the shell is executed by the \fBsu\fP
command), the shell will try to find an alternative name from the \fBSHELL\fP
environment variable and perform emulation based on that\&.
In \fBsh\fP and \fBksh\fP compatibility modes the following
parameters are not special and not initialized by the shell:
The usual zsh startup/shutdown scripts are not executed\&.  Login shells
source \fB/etc/profile\fP followed by \fB$HOME/\&.profile\fP\&.  If the
\fBENV\fP environment variable is set on invocation, \fB$ENV\fP is sourced
after the profile scripts\&.  The value of \fBENV\fP is subjected to
parameter expansion, command substitution, and arithmetic expansion
before being interpreted as a pathname\&.  Note that the \fBPRIVILEGED\fP
option also affects the execution of startup files\&.
The following options are set if the shell is invoked as \fBsh\fP or
Additionally the \fBBSD_ECHO\fP and \fBIGNORE_BRACES\fP
options are set if zsh is invoked as \fBsh\fP\&.
Also, the
options are set if zsh is invoked as \fBksh\fP\&.
.\" Yodl file: Zsh/restricted.yo
When the basename of the command used to invoke zsh starts with the letter
`\fBr\fP\&' or the `\fB\-r\fP' command line option is supplied at invocation, the
shell becomes restricted\&.  Emulation mode is determined after stripping the
letter `\fBr\fP\&' from the invocation name\&.  The following are disabled in
restricted mode:
.PD 0
changing directories with the \fBcd\fP builtin
changing or unsetting the \fBPATH\fP, \fBpath\fP, \fBMODULE_PATH\fP,
\fBmodule_path\fP, \fBSHELL\fP, \fBHISTFILE\fP, \fBHISTSIZE\fP, \fBGID\fP, \fBEGID\fP,
specifying command names containing \fB/\fP
specifying command pathnames using \fBhash\fP
redirecting output to files
using the \fBexec\fP builtin command to replace the shell with another
using \fBjobs \-Z\fP to overwrite the shell process\&' argument and
environment space
using the \fBARGV0\fP parameter to override \fBargv[0]\fP for external
turning off restricted mode with \fBset +r\fP or \fBunsetopt
These restrictions are enforced after processing the startup files\&.  The
startup files should set up \fBPATH\fP to point to a directory of commands
which can be safely invoked in the restricted environment\&.  They may also
add further restrictions by disabling selected builtins\&.
Restricted mode can also be activated any time by setting the
\fBRESTRICTED\fP option\&.  This immediately enables all the restrictions
described above even if the shell still has not processed all startup
.\" Yodl file: Zsh/files.yo
Commands are first read from \fB/etc/zshenv\fP; this cannot be overridden\&.
Subsequent behaviour is modified by the \fBRCS\fP and
\fBGLOBAL_RCS\fP options; the former affects all startup files, while the
second only affects global startup files (those shown here with an
path starting with a \fB/\fP)\&.  If one of the options
is unset at any point, any subsequent startup file(s)
of the corresponding
type will not be read\&.  It is also possible for a file in \fB$ZDOTDIR\fP to
re\-enable \fBGLOBAL_RCS\fP\&. Both \fBRCS\fP and \fBGLOBAL_RCS\fP are set by
Commands are then read from \fB$ZDOTDIR/\&.zshenv\fP\&.
If the shell is a login shell, commands
are read from \fB/etc/zprofile\fP and then \fB$ZDOTDIR/\&.zprofile\fP\&.
Then, if the shell is interactive,
commands are read from \fB/etc/zshrc\fP and then \fB$ZDOTDIR/\&.zshrc\fP\&.
Finally, if the shell is a login shell, \fB/etc/zlogin\fP and
\fB$ZDOTDIR/\&.zlogin\fP are read\&.
When a login shell exits, the files \fB$ZDOTDIR/\&.zlogout\fP and then
\fB/etc/zlogout\fP are read\&.  This happens with either an explicit exit
via the \fBexit\fP or \fBlogout\fP commands, or an implicit exit by reading
end\-of\-file from the terminal\&.  However, if the shell terminates due
to \fBexec\fP\&'ing another process, the logout files are not read\&.
These are also affected by the \fBRCS\fP and \fBGLOBAL_RCS\fP options\&.
Note also that the \fBRCS\fP option affects the saving of history files,
i\&.e\&. if \fBRCS\fP is unset when the shell exits, no history file will be
If \fBZDOTDIR\fP is unset, \fBHOME\fP is used instead\&.
Files listed above as being in \fB/etc\fP may be in another
directory, depending on the installation\&.
As \fB/etc/zshenv\fP is run for all instances of zsh, it is important that
it be kept as small as possible\&.  In particular, it is a good idea to
put code that does not need to be run for every single shell behind
a test of the form `\fBif [[ \-o rcs ]]; then \&.\&.\&.\fP\&' so that it will not
be executed when zsh is invoked with the `\fB\-f\fP\&' option\&.
Any of these files may be pre\-compiled with the \fBzcompile\fP builtin
command (see \fIzshbuiltins\fP(1))\&.  If a compiled file exists (named for the original file plus the
\fB\&.zwc\fP extension) and it is newer than the original file, the compiled
file will be used instead\&.
.\" Yodl file: Zsh/filelist.yo
.PD 0
\fB${TMPPREFIX}*\fP   (default is /tmp/zsh*)
\fB/etc/zlogout\fP    (installation\-specific \- \fB/etc\fP is the default)
.\" Yodl file: Zsh/seealso.yo
\fBIEEE Standard for information Technology \-
Portable Operating System Interface (POSIX) \-
Part 2: Shell and Utilities\fP,
IEEE Inc, 1993, ISBN 1\-55937\-255\-9\&.