   This is a texinfo version of the man page for the Z Shell, by Paul
Falstad.  It was converted from the original `zsh.1' file distributed
with zsh v2.4.291.  The conversion was done by Jonathan Hardwick,
`jch@cs.cmu.edu', who would love to hear of any errors he introduced or
texinfo rules he broke.  The text remains the work of Paul Falstad.

Conditional Expressions
***********************

A "conditional expression" is used with the `[[' compound command to
test attributes of files and to compare strings.  Each expression can
be constructed from one or more of the following unary or binary
expressions:

`-a FILE'
     True if FILE exists.

`-b FILE'
     True if FILE exists and is a block special file.

`-c FILE'
     True if FILE exists and is a character special file.

`-d FILE'
     True if FILE exists and is a directory.

`-e FILE'
     True if FILE exists.

`-f FILE'
     True if FILE exists and is an ordinary file.

`-g FILE'
     True if FILE exists and has its setgid bit set.

`-h FILE'
     True if FILE exists and is a symbolic link.

`-k FILE'
     True if FILE exists and has its sticky bit set.

`-n STRING'
     True if length of STRING is non-zero.

`-o OPTION'
     True if option named OPTION is on.

`-p FILE'
     True if FILE exists and is a FIFO special file or a pipe.

`-r FILE'
     True if FILE exists and is readable by the current process.

`-s FILE'
     True if FILE exists and has size greater than zero.

`-t FD'
     True if file descriptor number FD is open and associated with a
     terminal device (note: FD is not optional).

`-u FILE'
     True if FILE exists and has its setuid bit set.

`-w FILE'
     True if FILE exists and is writable by current process.

`-x FILE'
     True if FILE exists and is executable by current process.  If FILE
     exists and is a directory, then the current process has permission
     to search in the directory.

`-z STRING'
     True if length of STRING is zero.

`-L FILE'
     True if FILE exists and is a symbolic link.

`-O FILE'
     True if FILE exists and is owned by the effective user id of this
     process.

`-G FILE'
     True if FILE exists and its group matches the effective group id
     of this process.

`-S FILE'
     True if FILE exists and is a socket.

`FILE1 -nt FILE2'
     True if FILE1 exists and is newer than FILE2.

`FILE1 -ot FILE2'
     True if FILE1 exists and is older than FILE2.

`FILE1 -ef FILE2'
     True if FILE1 and FILE2 exist and refer to the same file.

`STRING = PATTERN'
     True if STRING matches PATTERN.

`STRING != PATTERN'
     True if STRING does not match PATTERN.

`STRING1 < STRING2'
     True if STRING1 comes before STRING2 based on ASCII value of their
     characters.

`STRING1 > STRING2'
     True if STRING1 comes after STRING2 based on ASCII value of their
     characters.

`EXP1 -eq EXP2'
     True if EXP1 is equal to EXP2.

`EXP1 -ne EXP2'
     True if EXP1 is not equal to EXP2.

`EXP1 -lt EXP2'
     True if EXP1 is less than EXP2.

`EXP1 -gt EXP2'
     True if EXP1 is greater than EXP2.

`EXP1 -le EXP2'
     True if EXP1 is less than or equal to EXP2.

`EXP1 -ge EXP2'
     True if EXP1 is greater than or equal to EXP2.

`( EXP )'
     True if EXP is true.

`! EXP'
     True if EXP is false.

`EXP1 && EXP2'
     True if EXP1 and EXP2 are both true.

`EXP1 || EXP2'
     True if either EXP1 or EXP2 is true.

In each of the above expressions, if FILE is of the form `/dev/fd/N',
where N is an integer, then the test is applied to the open file whose
descriptor number is N, even if the underlying system does not support
the `/dev/fd' directory.

Zsh Line Editor
***************

If the `ZLE' option is set (it is by default) and the shell input is
attached to the terminal, the user is allowed to edit command lines.

There are two display modes.  The first, multiline mode, is the default.
It only works if the `TERM' parameter is set to a valid terminal type
that can move the cursor up.  The second, single line mode, is used if
`TERM' is invalid or incapable of moving the cursor up, or if the
`SINGLE_LINE_ZLE' option is set.  This mode is similar to ksh, and uses
no termcap sequences.  If `TERM' is `emacs', the `ZLE' option will be
unset by the shell.

Command bindings may be set using the `bindkey' builtin.  There are two
keymaps--the main keymap and the alternate keymap.  The alternate
keymap is bound to vi command mode.  The main keymap is bound to emacs
mode by default.  To bind the main keymap to vi insert mode, use
`bindkey -v'.  However, if either of the `VISUAL' or `EDITOR'
environment variables contains the string `vi' when the shell starts up
the main keymap will be bound to vi insert mode by default.

The following is a list of all the key commands and their default
bindings in emacs and vi command mode.

Movement
========

`vi-backward-blank-word (unbound) (`B')'
     Move backward one word, where a word is defined as a series of
     non-blank characters.

`backward-char (`^B' `ESC-[D') (unbound)'
     Move backward one character.

`vi-backward-char (unbound) (`h')'
     Move backward one character, without changing lines.

`backward-word (`ESC-B' `ESC-b') (unbound)'
     Move to the beginning of the previous word.

`emacs-backward-word'
     Move to the beginning of the previous word.

`vi-backward-word (unbound) (`b')'
     Move to the beginning of the previous word, vi-style.

`beginning-of-line (`^A') (`0')'
     Move to the beginning of the line.  If already at the beginning of
     the line, move to the beginning of the previous line, if any.

`vi-beginning-of-line'
     Move to the beginning of the line, without changing lines.

`end-of-line (`^E')'
     Move to the end of the line.  If already at the end of the line,
     move to the end of the next line, if any.

`vi-end-of-line (unbound) (`$')'
     Move to the end of the line.

`vi-forward-blank-word (unbound) (`W')'
     Move forward one word, where a word is defined as a series of
     non-blank characters.

`vi-forward-blank-word-end (unbound) (`E')'
     Move to the end of the current word, or, if at the end of the
     current word, to the end of the next word, where a word is defined
     as a series of non-blank characters.

`forward-char (`^F' `ESC-[C')'
     Move forward one character.

`vi-forward-char (unbound) (SPACE `l')'
     Move forward one character.

`vi-find-next-char (`^X^F') (`f')'
     Read a character from the keyboard, and move to the next
     occurrence of it in the line.

`vi-find-next-char-skip (unbound) (`t')'
     Read a character from the keyboard, and move to the position just
     before the next occurrence of it in the line.

`vi-find-prev-char (unbound) (`F')'
     Read a character from the keyboard, and move to the previous
     occurrence of it in the line.

`vi-find-prev-char-skip (unbound) (`T')'
     Read a character from the keyboard, and move to the position just
     after the previous occurrence of it in the line.

`vi-first-non-blank (unbound) (`^')'
     Move to the first non-blank character in the line.

`vi-forward-word (unbound) (`w')'
     Move forward one word, vi-style.

`forward-word (`ESC-F' `ESC-f') (unbound)'
     Move to the beginning of the next word.  The editor's idea of a
     word is specified with the `WORDCHARS' parameter.

`emacs-forward-word'
     Move to the end of the next word.

`vi-forward-word-end (unbound) (`e')'
     Move to the end of the next word.

`vi-goto-column (`ESC-|') (`|')'
     Move to the column specified by the numeric argument.

`vi-goto-mark (unbound) (``')'
     Move to the specified mark.

`vi-goto-mark-line (unbound) (`'')'
     Move to the beginning of the line containing the specified mark.

`vi-repeat-find (unbound) (`;')'
     Repeat the last `vi-find' command.

`vi-rev-repeat-find (unbound) (`,')'
     Repeat the last `vi-find' command in the opposite direction.

History Control
===============

`beginning-of-buffer-or-history (`ESC-<')'
     Move to the beginning of the buffer, or if already there, move to
     the first event in the history list.

`beginning-of-line-hist'
     Move to the beginning of the line.  If already at the beginning of
     the buffer, move to the previous history line.

`beginning-of-history'
     Move to the first event in the history list.

`down-line-or-history (`^N' `ESC-[B') (`+' `j')'
     Move down a line in the buffer, or if already at the bottom line,
     move to the next event in the history list.

`down-line-or-search'
     Move down a line in the buffer, or if already at the bottom line,
     search forward in the history for a line beginning with the first
     word in the buffer.

`down-history (unbound) (`^N')'
     Move to the next event in the history list.

`history-beginning-search-backward'
     Search backward in the history for a line beginning with the
     current line up to the cursor.  This leaves the cursor in its
     original position.

`end-of-buffer-or-history (`ESC->')'
     Move to the end of the buffer, or if already there, move to the
     last event in the history list.

`end-of-line-hist'
     Move to the end of the line.  If already at the end of the buffer,
     move to the next history line.

`end-of-history'
     Move to the last event in the history list.

`vi-fetch-history (unbound) (`G')'
     Fetch the history line specified by the numeric argument.

`history-incremental-search-backward (`^R' `^Xr')'
     Search backward incrementally for a specified string.  The string
     may begin with `^' to anchor the search to the beginning of the
     line.  A restricted set of editing functions is available in the
     mini-buffer.  An interrupt signal, as defined by the stty setting,
     will stop the search and go back to the original line.  An
     undefined key will have the same effect.  The supported functions
     are: `backward-delete-char', `quoted-insert', `accept-and-hold',
     `accept-and-infer-next-history', `accept-line' and
     `accept-line-and-down-history'; `magic-space' just inserts a
     space.  Any string that is bound to an out-string (via `bindkey
     -s') will behave as if out-string were typed directly.  Typing the
     binding of `history-incremental-search-backward' will get the next
     occurrence of the contents of the mini-buffer.  Typing the binding
     of `history-incremental-search-forward' inverts the sense of the
     search.  The direction of the search is indicated in the
     mini-buffer.  Any multi-character string that is not bound to one
     of the above functions will beep and interrupt the search, leaving
     the last found line in the buffer.  Any single character that is
     not bound to one of the above functions, or `self-insert' or
     `self-insert-unmeta', will have the same effect but the function
     will be executed.

`history-incremental-search-forward (`^S' `^Xs')'
     Search forward incrementally for a specified string.  The string
     may begin with `^' to anchor the search to the beginning of the
     line.  The functions available in the mini-buffer are the same as
     for `history-incremental-search-backward'.

`history-search-backward (`ESC-P' `ESC-p') (`K')'
     Search backward in the history for a line beginning with the first
     word in the buffer.

`vi-history-search-backward (unbound) (`/')'
     Search backward in the history for a specified string.  The string
     may begin with `^' to anchor the search to the beginning of the
     line.  A restricted set of editing functions is available in the
     mini-buffer.  An interrupt signal, as defined by the stty setting,
     will stop the search, as will a character bound to `vi-cmd-mode'.
     The functions available in the mini-buffer are: `accept-line',
     `backward-delete-char', `vi-backward-delete-char' and
     `quoted-insert'.  Any string that is bound to an out-string (via
     bindkey -s) will behave as if out-string were typed directly.  Any
     other character that is not bound to `self-insert' or
     `self-insert-unmeta' will beep and be ignored.  If the function is
     called from vi command mode, the bindings of vi insert mode will be
     used.

`history-search-forward (`ESC-N' `ESC-n') (`J')'
     Search forward in the history for a line beginning with the first
     word in the buffer.

`vi-history-search-forward (unbound) (`?')'
     Search forward in the history for a specified string.  The string
     may begin with `^' to anchor the search to the beginning of the
     line.  The functions available in the mini-buffer are the same as
     for `vi-history-search-backward'.

`infer-next-history (`^X^N')'
     Search in the history for a line matching the current one and
     fetch the event following it.

`insert-last-word (`ESC-_' `ESC-.')'
     Insert the last word from the previous history event at the cursor
     position.

`vi-repeat-search (unbound) (`n')'
     Repeat the last vi history search.

`vi-rev-repeat-search (unbound) (`N')'
     Repeat the last vi history search, but in reverse.

`toggle-literal-history (`ESC-R' `ESC-r')'
     Toggle between literal and lexical history.  The default is lexical
     history unless the `HIST_LIT' option is set.

`up-line-or-history (`^P' `ESC-[A') (`-' `k')'
     Move up a line in the buffer, or if already at the top line, move
     to the previous event in the history list.

`up-line-or-search'
     Move up a line in the buffer, or if already at the top line, search
     backward in the history for a line beginning with the first word
     in the buffer.

`up-history (unbound) (`^P')'
     Move to the previous event in the history list.

`history-beginning-search-forward'
     Search forward in the history for a line beginning with the
     current line up to the cursor.  This leaves the cursor at its
     original position.

Modifying Text
==============

`vi-add-eol (unbound) (`A')'
     Move to the end of the line and enter insert mode.

`vi-add-next (unbound) (`a')'
     Move forward one character and enter insert mode.

`backward-delete-char (`^H' `^?') (`^?')'
     Delete the character behind the cursor.

`vi-backward-delete-char (unbound) (`X')'
     Delete the character behind the cursor, without changing lines.

`backward-delete-word'
     Delete the word behind the cursor.

`backward-kill-line'
     Kill from the beginning of the line to the cursor position.

`backward-kill-word (`^W' `ESC-^H' `ESC-^?')'
     Kill the word behind the cursor.

`vi-backward-kill-word (unbound) (`^W')'
     Kill the word behind the cursor.

`capitalize-word (`ESC-C' `ESC-c')'
     Capitalize the current word and move past it.

`vi-change (unbound) (`c')'
     Read a movement command from the keyboard, and kill from the cursor
     position to the endpoint of the movement.  Then enter insert mode.
     If the command is `vi-change', kill the current line.

`vi-change-eol (unbound) (`C')'
     Kill to the end of the line and enter insert mode.

`vi-change-whole-line (unbound) (`S' `s')'
     Kill the current line and enter insert mode.

`copy-region-as-kill (`ESC-W' `ESC-w')'
     Copy the area from the cursor to the mark to the kill buffer.

`copy-prev-word (`ESC-^_')'
     Duplicate the word behind the cursor.

`vi-delete (unbound) (`d')'
     Read a movement command from the keyboard, and kill from the cursor
     position to the endpoint of the movement.  If the command is
     `vi-delete', kill the current line.

`delete-char (unbound) (`x')'
     Delete the character under the cursor.

`vi-delete-char (unbound) (`x')'
     Delete the character under the cursor.

`delete-word (`ESC-D' `ESC-d')'
     Delete the current word.

`down-case-word (`ESC-L' `ESC-l')'
     Convert the current word to all lowercase and move past it.

`kill-word'
     Kill the current word.

`gosmacs-transpose-chars'
     Exchange the two characters behind the cursor.

`vi-indent (unbound) (`>')'
     Indent a number of lines.

`vi-insert (unbound) (`i')'
     Enter insert mode.

`vi-insert-bol (unbound) (`I')'
     Move to the beginning of the line and enter insert mode.

`vi-join (`^X^J')'
     Join the current line with the next one.

`kill-line (`^K') (`D')'
     Kill from the cursor to the end of the line.

`kill-region'
     Kill from the cursor to the mark.

`kill-buffer (`^X^K') (`^U')'
     Kill the entire buffer.

`kill-whole-line (`^U') (unbound)'
     Kill the current line.

`vi-match-bracket (`^X^B') (`%')'
     Move to the bracket character (one of `{}', `()', or `[]') that
     matches the one under the cursor.

`vi-open-line-above (unbound) (`O')'
     Open a line above the cursor and enter insert mode.

`vi-open-line-below (unbound) (`o')'
     Open a line below the cursor and enter insert mode.

`vi-oper-swap-case'
     Read a movement command from the keyboard, and swap the case of all
     characters from the cursor position to the endpoint of the
     movement.  If the movement command is `vi-oper-swap-case', swap
     the case of all characters on the current line.

`overwrite-mode (`^X^O')'
     Toggle between overwrite mode and insert mode.

`vi-put-after (unbound) (`p')'
     Insert the contents of the kill buffer after the cursor.

`quoted-insert (`^V')'
     Insert the next character typed into the buffer literally.

`quote-line (`ESC-'')'
     Quote the current line; that is, put a `'' character at the
     beginning and the end, and convert all `'' characters to `\''.

`quote-region (`ESC-"')'
     Quote the region from the cursor to the mark.

`vi-replace (unbound) (`R')'
     Enter overwrite mode.

`vi-repeat-change (unbound) (`.')'
     Repeat the last vi mode text modification.

`vi-replace-chars (unbound) (`r')'
     Replace the character under the cursor with a character read from
     the keyboard.

`self-insert (printable characters)'
     Put a character in the buffer at the cursor position.

`self-insert-unmeta (`ESC-^I' `ESC-^J' `ESC-^M')'
     Put a character in the buffer after stripping the meta bit and
     converting `^M' to `^J'.

`vi-substitute (unbound) (`s')'
     Substitute the next character(s).

`vi-swap-case (unbound) (`~')'
     Swap the case of the character under the cursor and move past it.

`transpose-chars (`^T')'
     Exchange the two characters to the left of the cursor if at end of
     line, else exchange the character under the cursor with the
     character to the left.

`transpose-words (`ESC-T' `ESC-t')'
     Exchange the current word with the one before it.

`vi-unindent (unbound) (`<')'
     Unindent a number of lines.

`up-case-word (`ESC-U' `ESC-u')'
     Convert the current word to all caps and move past it.

`yank (`^Y') (`P')'
     Insert the contents of the kill buffer at the cursor position.

`yank-pop (`ESC-y') (unbound)'
     Remove the text just yanked, rotate the kill-ring, and yank the
     new top.  Only works following `yank' or `yank-pop'.

`vi-yank (unbound) (`y')'
     Read a movement command from the keyboard, and copy the region
     from the cursor position to the endpoint of the movement into the
     kill buffer.  If the command is `vi-yank', copy the current line.

`vi-yank-eol (unbound) (`Y')'
     Copy the region from the cursor position to the end of the line
     into the kill buffer.

Arguments
=========

`digit-argument (`ESC-0'...`ESC-9') (0-9)'
     Start a new numeric argument, or add to the current one.

`neg-argument (`ESC--') (unbound)'
     Changes the sign of the following argument.

`universal-argument'
     Multiply the argument of the next command by 4.

Completion
==========

`accept-and-menu-complete'
     In a menu completion, insert the current completion into the
     buffer, and advance to the next possible completion.

`complete-word (unbound) (`\')'
     Attempt completion on the current word.

`delete-char-or-list (`^D')'
     Delete the character under the cursor.  If the cursor is at the
     end of the line, list possible completions for the current word.

`execute-named-cmd (`ESC-x')'
     Read the name of a editor command and execute it.  A restricted
     set of editing functions is available in the mini-buffer.  An
     interrupt signal, as defined by the stty setting, will abort the
     function.  The allowed functions are: `backward-delete-char',
     `vi-backward-delete-char', `kill-region' (kills the last word),
     `backward-kill-word', `vi-backward-kill-word', `kill-whole-line',
     `vi-kill-line', `backward-kill-line' and `accept-line'.  The SPACE
     and TAB keys, if not bound to one of these functions, will
     complete the name and then list the possibilities.

`execute-last-named-cmd (`ESC-z')'
     Redo the last function executed with `execute-named-cmd'.

`expand-cmd-path'
     Expand the current command to its full pathname.

`expand-or-complete (TAB) (TAB `^X')'
     Attempt shell expansion on the current word.  If that fails,
     attempt completion.

`expand-or-complete-prefix'
     Attempt shell expansion on the current word up to the cursor.

`expand-history (`ESC-SPACE' `ESC-!')'
     Perform history expansion on the edit buffer.

`expand-word (`^X*')'
     Attempt shell expansion on the current word.

`list-choices (`ESC-^D') (`^D=')'
     List possible completions for the current word.

`list-expand (`^Xg' `^XG') (`^G')'
     List the expansion of the current word.

`magic-space'
     Perform history expansion and insert a space into the buffer.
     This is intended to be bound to SPACE.

`menu-complete'
     Like `complete-word', except that menu completion is used.  See
     Options, for the `MENU_COMPLETE' option.

`menu-expand-or-complete'
     Like `expand-or-complete', except that menu completion is used.

`reverse-menu-complete'
     See Options, for the `MENU_COMPLETE' option.

Miscellaneous
=============

`accept-and-hold (`ESC-A' `ESC-a')'
     Push the contents of the buffer on the buffer stack and execute it.

`accept-and-infer-next-history'
     Execute the contents of the buffer.  Then search the history list
     for a line matching the current one and push the event following
     onto the buffer stack.

`accept-line (`^J' `^M')'
     Execute the contents of the buffer.

`accept-line-and-down-history (`^O')'
     Execute the current line, and push the next history event on the
     the buffer stack.

`vi-cmd-mode (`^X^V') (`^[')'
     Enter command mode; that is, use the alternate keymap.  Yes, this
     is bound by default in emacs mode.

`vi-caps-lock-panic (unbound) (`H' `K')'
     Hang until any lowercase key is pressed.  This is for vi users
     without the mental capacity to keep track of their caps lock key
     (like the author).

`clear-screen (`^L' `ESC-^L')'
     Clear the screen and redraw the prompt.

`exchange-point-and-mark (`^X^X')'
     Exchange the cursor position with the position of the mark.

`get-line (`ESC-G' `ESC-g')'
     Pop the top line off the buffer stack and insert it at the cursor
     position.

`pound-insert (unbound) (`#')'
     If there is no `#' character at the beginning of the current line,
     add one.  If there is one, remove it.  In either case, accept the
     current line.  The `INTERACTIVE_COMMENTS' option must be set for
     this to have any usefulness.

`push-input'
     Push the entire current multiline construct onto the buffer stack
     and return to the top-level (`PS1') prompt.  If the current parser
     construct is only a single line, this is exactly like `push-line'.
     Next time the editor starts up or is popped with `get-line', the
     construct will be popped off the top of the buffer stack and
     loaded into the editing buffer.

`push-line (`^Q' `ESC-Q' `ESC-q')'
     Push the current buffer onto the buffer stack and clear the buffer.
     Next time the editor starts up, the buffer will be popped off the
     top of the buffer stack and loaded into the editing buffer.

`push-line-or-edit'
     At the top-level (`PS1') prompt, equivalent to `push-line'.  At a
     secondary (`PS2') prompt, move the entire current multiline
     construct into the editor buffer.  The latter is equivalent to
     `push-line' followed by `get-line'.

`redisplay (unbound) (`^R')'
     Redisplays the edit buffer.

`run-help (`ESC-H' `ESC-h')'
     Push the buffer onto the buffer stack, and execute the command
     `run-help CMD', where CMD is the current command.  `run-help' is
     normally aliased to `man'.

`send-break (`^C')'
     Abort the current editor function, e.g. `execute-named-command', or
     the editor itself, e.g. if you are in `vared'.  Otherwise abort the
     parsing of the current line.

`vi-set-buffer (unbound) (`"')'
     Specify a buffer to be used in the following command.

`vi-set-mark (unbound) (`m')'
     Set the specified mark at the cursor position.

`set-mark-command (`^@')'
     Set the mark at the cursor position.

`spell-word (`ESC-$' `ESC-S' `ESC-s')'
     Attempt spelling correction on the current word.

`undefined-key'
     Beep.

`undo (`^_' `^X^U' `^Xu' (`u')'
     Incrementally undo the last text modification.

`which-command (`ESC-?')'
     Push the buffer onto the buffer stack, and execute the command
     `which-command CMD', where CMD is the current command.
     `which-command' is normally aliased to `whence'.

Parameters
**********

A parameter has a name, a value, and a number of attributes.  A name may
be any sequence of alphanumeric characters and `_''s, or the single
characters `*', `@', `#', `?', `-', `$', or `!'.  The value may be
either a scalar (a string), an integer, or an array.  To assign a
scalar or integer value to a parameter, use the `typeset' builtin.  To
assign an array value, use `set -A NAME VALUE ...'.  The value of a
parameter may also be assigned by writing:

   `NAME=VALUE ...'

If the integer attribute, `-i', is set for NAME, the VALUE is subject
to arithmetic evaluation.

Array Parameters
================

The value of an array parameter may be assigned by writing:

   NAME=(VALUE ...) ...

Individual elements of an array may be selected using a subscript.  A
subscript of the form `[EXP]' selects the single element EXP, where EXP
is an arithmetic expression.  The elements are numbered beginning with
1.  A subscript of the form `[*]' or `[@]' evaluates to all elements of
an array; there is no difference between the two except when they
appear within double quotes.  `"$foo[*]"' evaluates to `"$foo[1]
$foo[2] ..."', while `"$foo[@]"' evaluates to `"$foo[1]"' `"$foo[2]"',
etc.  A subscript of the form `[EXP1,EXP2]' selects all elements in the
range EXP1 to EXP2, inclusive.  If one of the subscripts evaluates to a
negative number, say `-N', then the N'th element from the end of the
array is used.  Thus `$foo[-3]' is the third element from the end of
the array `foo', and `$foo[1,-1]' is the same as `$foo[*]'.

Subscripting may also be performed on non-array values, in which case
the subscripts specify a substring to be extracted.  For example, if
`FOO' is set to `foobar', then `echo $FOO[2,5]' prints `ooba'.

If a subscript is used on the left side of an assignment the selected
range is replaced by the expression on the right side.

If the opening bracket or the comma is directly followed by an opening
parenthesis the string up to the matching closing parenthesis is
considered to be a list of flags.  The possible flags are:

`e'
     The argument is expanded using full shell expansion first.

`w'
     If the parameter subscripted is a scalar, make subscription work
     on a per-word basis instead of on a per-character basis.

`s:STRING:'
     Defines the STRING that separates words (for use with the `w'
     flag).

`r'
     The subscript is taken as a pattern, and the result is the first
     matching array element, substring, or word (if the parameter is an
     array, scalar, or a scalar and the `w' flag is given,
     respectively).  Note that this is like giving a number;
     `$foo[(r)??,3]' and `$foo[(r)??,(r)f*]' work.

`R'
     Like `r', but returns the last match.

`i'
     Like `r', but returns the index of the match.  This must not be
     combined with a second argument.

`I'
     Like `i', but returns the index of the last match.

`n:EXPR:'
     If combined with `r', `R', `i', or `I', makes them return the N'th
     or N'th last match (assuming EXPR evaluates to N).

Positional Parameters
=====================

Positional parameters are set by the shell on invocation, by the `set'
builtin, or by direct assignment.  The parameter N, where N is a
number, is the N'th positional parameter.  The parameters `*', `@', and
`argv' are arrays containing all the positional parameters; thus
`argv[N]', is equivalent to simply N.

Parameters Set By The Shell
===========================

The following parameters are automatically set by the shell:

`!'
     The process id of the last background command invoked.

`#'
     The number of positional parameters in decimal.

`ARGC'
     Same as `#'.

`$'
     The process id of this shell.

`-'
     Flags supplied to the shell on invocation or by the `set' or
     `setopt' commands.

`*'
     An array containing the positional parameters.

`argv'
     Same as `*'.

`@'
     Same as `argv[@]'.

`?'
     The exit value returned by the last command.

`status'
     Same as `?'.

`_'
     The last argument of the previous command.  Also, this parameter
     is set in the environment of every command executed to the full
     pathname of the command.

`EGID'
     The effective group id of the shell process.

`EUID'
     The effective user id of the shell process.

`ERRNO'
     The value of `errno' as set by the most recently failed system
     call.  This value is system dependent and is intended for debugging
     purposes.

`GID'
     The group id of the shell process.

`HOST'
     The current hostname.

`HOSTTYPE'
     A string corresponding to the type of the host the shell is
     running on.

`LINENO'
     The line number of the current line within the current script being
     executed.

`OLDPWD'
     The previous working directory.

`OPTARG'
     The value of the last option argument processed by the `getopts'
     command.

`OPTIND'
     The index of the last option argument processed by the `getopts'
     command.

`PPID'
     The process id of the parent of the shell.

`PWD'
     The present working directory.

`RANDOM'
     A random integer from 0 to 32767, newly generated each time this
     parameter is referenced.  The random number generator can be
     seeded by assigning a numeric value to `RANDOM'.

`SECONDS'
     The number of seconds since shell invocation.  If this parameter is
     assigned a value, then the value returned upon reference will be
     the value that was assigned plus the number of seconds since the
     assignment.

`SHLVL'
     Incremented by one each time a new shell is started.

`signals'
     An array containing the names of the signals.

`TTY'
     The name of the tty associated with the shell, if any.

`UID'
     The user id of the shell process.

`USERNAME'
`LOGNAME'
     The username corresponding to the user id of the shell process.

`VERSION'
     The version number of this `zsh'.

Parameters Used By The Shell
============================

The following parameters are used by the shell:

`ARGV'
     If exported, its value is used as argv[0] of external commands.
     Usually used in constructs like `ARGV0=emacs nethack'.

`BAUD'
     The baud rate of the current connection.  Used by the line editor
     update mechanism to compensate for a slow terminal by delaying
     updates until necessary.  This may be profitably set to a lower
     value in some circumstances, e.g. for slow modems dialing into a
     communications server which is connected to a host via a fast
     link; in this case, this variable would be set by default to the
     speed of the fast link, and not the modem.  This parameter should
     be set to the baud rate of the slowest part of the link for best
     performance.  The compensation mechanism can be turned off by
     setting the variable to zero.

`cdpath (CDPATH)'
     An array (colon-separated list) of directories specifying the
     search path for the `cd' command.

`COLUMNS'
     The number of columns for this terminal session.  Used for printing
     select lists and for the line editor.

`DIRSTACKSIZE'
     The maximum size of the directory stack.  If the stack gets larger
     than this, it will be truncated automatically.  This is useful
     with the `AUTO_PUSHD' option.

`FCEDIT'
     The default editor for the `fc' builtin.

`fignore (FIGNORE)'
     An array (colon-separated list) containing the suffixes of files
     to be ignored during filename completion.

`fpath (FPATH)'
     An array (colon-separated list) of directories specifying the
     search path for function definitions.  This path is searched when
     a function with the `-u' attribute is referenced.  If an
     executable file is found, then it is read and executed in the
     current environment.

`HISTCHARS'
     Three characters used by the shell's history and lexical analysis
     mechanism.  The first character signals the start of a history
     substitution (default `!').  The second character signals the start
     of a quick history substitution (default `^').  The third character
     is the comment character (default `#').

`HISTFILE'
     The file to save the history in when an interactive shell exits.
     If unset, the history is not saved.

`HISTSIZE'
     The maximum size of the history list.

`HOME'
     The default argument for the `cd' command.

`IFS'
     Internal field separators, normally space, tab, and newline, that
     are used to separate words which result from command or parameter
     substitution and words read by the `read' builtin.

`KEYTIMEOUT'
     The time the shell waits, in hundredths of seconds, for another
     key to be pressed when reading bound multi-character sequences.

`LINES'
     The number of lines for this terminal session.  Used for printing
     select lists and for the line editor.

`LISTMAX'
     In the line editor, the number of filenames to list without asking
     first.  If set to zero, the shell asks only if the listing would
     scroll off the screen.

`LITHISTSIZE'
     The maximum size of the literal history list (before history
     expansion).

`LOGCHECK'
     The interval in seconds between checks for login/logout activity
     using the `watch' parameter.

`MAIL'
     If this parameter is set and `mailpath' is not set, the shell looks
     for mail in the specified file.

`MAILCHECK'
     The interval in seconds between checks for new mail.

`mailpath (MAILPATH)'
     An array (colon-separated list) of filenames to check for new mail.
     Each filename can be followed by a `?' and a message that will be
     printed.  The sequence `$_' in the message will be replaced by the
     name of the mail file.  The default message is `You have new
     mail'.  If an element is a directory instead of a file the shell
     will recursively check every file in every subdirectory of the
     element.

`manpath (MANPATH)'
     An array (colon-separated list) whose value is not used by the
     shell.  The `manpath' array can be useful, however, since setting
     it also sets `MANPATH', and vice versa.

`NULLCMD'
     The command name to assume if a redirection is specified with no
     command.  Defaults to `cat'.  For sh/ksh-like behavior, change this
     to `:'.  For csh-like behavior, unset this parameter; the shell
     will print an error message if null commands are entered.

`path (PATH)'
     An array (colon-separated list) of directories to search for
     commands.  When this parameter is set, each directory is scanned
     and all files found are put in a hash table.

`POSTEDIT'
     This string is output whenever the line editor exits.  It usually
     contains termcap strings to reset the terminal.

`PROMPT'
     The primary prompt string, printed before a command is read; the
     default is `%m%# '.  If the escape sequence takes an optional
     integer, it should appear between the `%' and the next character
     of the sequence.  The following escape sequences are recognized:

    `%d'
    `%/'
          Present working directory (`$PWD').

    `%~'
          `$PWD'.  If it has a named directory as its prefix, that part
          is replaced by a `~' followed by the name of the directory.
          If it starts with `$HOME', that part is replaced by a `~'.

    `%c'
    `%.'
    `%C'
          Trailing component of `$PWD'.  An integer may follow the `%'
          to get more than one component.  Unless `%C' is used, tilde
          expansion is performed first.

    `!'
    `%h'
    `%!'
          Current history event number

    `%M'
          The full machine hostname.

    `%m'
          The hostname up to the first `.'.  An integer may follow the
          `%' to specify how many components of the hostname are
          desired.

    `%S (%s)'
          Start (stop) standout mode.

    `%U (%u)'
          Start (stop) underline mode.

    `%B (%b)'
          Start (stop) boldface mode.

    `%t'
    `%@'
          Current time of day, in 12-hour, am/pm format.

    `%T'
          Current time of day, in 24-hour format.

    `%*'
          Current time of day in 24-hour format, with seconds.

    `%n'
          `$USERNAME'.

    `%w'
          The date in day-dd format.

    `%W'
          The date in mm/dd/yy format.

    `%D'
          The date in yy-mm-dd format.

    `%D{STRING}'
          STRING is formatted using the `strftime' function.  See
          `strftime(3)' for more details, if your system has it.

    `%l'
          The line (tty) the user is logged in on.

    `%?'
          The return code of the last command executed just before the
          prompt.

    `%_'
          The status of the parser, i.e. the shell constructs (like
          `if' and `for') that have been started on the command line.
          If given an integer number, that many strings will be printed.

    `E'
          Clears to end of screen.  Useful with `ALWAYS_LAST_PROMPT'
          set.

    `%#'
          A `#' if the shell is running as root, a `%' if not.
          Equivalent to `%(#.#.%%)'

    `%v'
          The value of the first element of the `psvar' array parameter.
          Following the `%' with an integer gives that element of the
          array.

    `%{...%}'
          Include a string as a literal escape sequence.  The string
          within the braces should not change the cursor position.

    `%(x.TRUE-TEXT.FALSE-TEXT)'
          Specifies a ternary expression.  The character following the
          `x' is arbitrary; the same character is used to separate the
          text for the true result from that for the false result.
          Both the separator and the right parenthesis may be escaped
          with a backslash.  TRUE-TEXT and FALSE-TEXT may both contain
          arbitrarily-nested escape sequences, including further
          ternary expressions.  The left parenthesis may be preceded or
          followed by a positive integer N, which defaults to zero.
          The text character `x' may be any of the following:

         `c'
         `.'
         `~'
               True if the current path, with prefix replacement, has
               at least N elements.

         `/'
         `C'
               True if the current absolute path has at least N
               elements.

         `t'
               True if the time in minutes is equal to N.

         `T'
               True if the time in hours is equal to N.

         `d'
               True if the day of the month is equal to N.

         `D'
               True if the month is equal to N (January = 0).

         `w'
               True if the day of the week is equal to N (Sunday = 0).

         `?'
               True if the exit status of the last command was N.

         `#'
               True if the effective uid of the current process is N.

         `g'
               True if the effective gid of the current process is N.

         `L'
               True if the `SHLVL' parameter is at least N.

         `S'
               True if the `SECONDS' parameter is at least N.

         `v'
               True if the array `psvar' has at least N elements.

         `_'
               True if at least N shell constructs were started.

`PROMPT2'
     The secondary prompt, printed when the shell needs more
     information to complete a command.  Recognizes the same escape
     sequences as `PROMPT'.  The default is `> '.

`PROMPT3'
     Selection prompt used within a `select' loop.  Recognizes the same
     escape sequences as `PROMPT'.  The default is `?# '.

`PROMPT4'
     The execution trace prompt.  Default is `+ '.

`PS1'
`PS2'
`PS3'
`PS4'
     Same as `PROMPT', `PROMPT2', `PROMPT3', and `PROMPT4',
     respectively.

`psvar (PSVAR)'
     An array (colon-separated list) whose first nine values can be
     used in `PROMPT' strings.  Setting `psvar' also sets `PSVAR', and
     vice versa.

`prompt'
     Same as `PROMPT'.

`READNULLCMD'
     The command name to assume if a single input redirection is
     specified with no command.  Defaults to `more'.

`REPORTTIME'
     If nonzero, commands whose combined user and system execution times
     (measured in seconds) are greater than this value have timing
     statistics printed for them.

`RPROMPT'
`RPS1'
     This prompt is displayed on the right-hand side of the screen when
     the primary prompt is being displayed on the left.  This does not
     work if the `SINGLE_LINE_ZLE' option is set.  Recognizes the same
     escape sequences as `PROMPT'.

`SAVEHIST'
     The maximum number of history events to save in the history file.

`SPROMPT'
     The prompt used for spelling correction.  The sequence `%R' expands
     to the string which presumably needs spelling correction, and `%r'
     expands to the proposed correction.  All other `PROMPT' escapes are
     also allowed.

`STTY'
     If this parameter is set in a command's environment, the shell
     runs the `stty' command with the value of this parameter as
     arguments in order to set up the terminal before executing the
     command.  The modes apply only to the command, and are reset when
     it finishes or is suspended.  If the command is suspended and
     continued later with the `fg' or `wait' builtins it will see the
     modes specified by STTY, as if it were not suspended.  This
     (intentionally) does not apply if the command is continued via
     `kill -CONT'.  `STTY' is ignored if the command is run in the
     background, or if it is in the environment of the shell but not
     explicitly assigned to in the input line.  This avoids running
     `stty' at every external command by accidentally exporting it.
     Also note that `STTY' should not be used for window size
     specifications; these will not be local to the command.

`TIMEFMT'
     The format of process time reports with the `time' keyword.  The
     default is `%E real  %U user  %S system  %P %J'.  Recognizes the
     following escape sequences:

    `%U'
          CPU seconds spent in user mode.

    `%S'
          CPU seconds spent in kernel mode.

    `%E'
          Elapsed time in seconds.

    `%P'
          The CPU percentage, computed as (%U+%S)/%E.

    `%W'
          Number of times the process was swapped.

    `%X'
          The average amount of (shared) text space used in Kbytes.

    `%D'
          The average amount of (unshared) data/stack space used in
          Kbytes.

    `%K'
          The total space used (%X+%D) in Kbytes.

    `%M'
          The maximum memory the process had in use at any time in
          Kbytes.

    `%F'
          The number of major page faults (page needed to be brought
          from disk).

    `%R'
          The number of minor page faults.

    `%I'
          The number of input operations.

    `%O'
          The number of output operations.

    `%r'
          The number of socket messages received.

    `%s'
          The number of socket messages sent.

    `%k'
          The number of signals received.

    `%w'
          Number of voluntary context switches (waits).

    `%c'
          Number of involuntary context switches.

    `%J'
          The name of this job.

`TMOUT'
     If this parameter is nonzero, the shell will terminate if a
     command is not entered within the specified number of seconds
     after issuing a prompt.

`TMPPREFIX'
     A pathname prefix which the shell will use for all temporary files.

`watch (WATCH)'
     An array (colon-separated list) of login/logout events to report.
     If it contains the single word `all', then all login/logout events
     are reported.  If it contains the single word `notme', then all
     login/logout events are reported except for those originating from
     `$USERNAME'.  An entry in this list may consist of a username, an
     `@' followed by a remote hostname, and a `%' followed by a line
     (tty).  Any or all of these components may be present in an entry;
     if a login/logout event matches all of them, it is reported.

`WATCHFMT'
     The format of login/logout reports if the `watch' parameter is set.
     Default is `%n has %a %l from %m'.  Recognizes the following escape
     sequences:

    `%n'
          The name of the user that logged in/out.

    `%a'
          The observed action, i.e. `logged on' or `logged off'.

    `%l'
          The line (tty) the user is logged in on.

    `%M'
          The full hostname of the remote host.

    `%m'
          The hostname up to the first `.'.  If only the IP address is
          available or the utmp field contains the name of an X-windows
          display, the whole name is printed.

          NOTE: The `%m' and `%M' escapes will work only if there is a
          host name field in the `utmp' on your machine.  Otherwise
          they are treated as ordinary strings.

    `%S (%s)'
          Start (stop) standout mode.

    `%U (%u)'
          Start (stop) underline mode.

    `%B (%b)'
          Start (stop) boldface mode.

    `%t'
    `%@'
          The time, in 12-hour, am/pm format.

    `%T'
          The time, in 24-hour format.

    `%w'
          The date in day-dd format.

    `%W'
          The date in mm/dd/yy format.

    `%D'
          The date in yy-mm-dd format.

    `%(x:TRUE-TEXT:FALSE-TEXT)'
          Specifies a ternary expression.  The character following the
          `x' is arbitrary; the same character is used to separate the
          text for the true result from that for the false result.
          Both the separator and the right parenthesis may be escaped
          with a backslash.  Ternary expressions may be nested.

          The test character `x' may be any one of `l', `n', `m', or
          `M', which indicate a true result if the corresponding escape
          sequence would return a non-empty value; or it may be `a',
          which indicates a true result if the watched user has logged
          in, or false if he has logged out.  Other characters evaluate
          to neither true nor false; the entire expression is omitted
          in this case.

          If the result is true, then the TRUE-TEXT is formatted
          according to the result above and printed, and the FALSE-TEXT
          is skipped.  If false, the TRUE-TEXT is skipped, and the
          FALSE-TEXT is formatted and printed.  Either or both of the
          branches may be empty, but both separators must always be
          present.

`WORDCHARS'
     A list of nonalphanumeric characters considered part of a word by
     the line editor.

`ZDOTDIR'
     The directory to search for shell startup files (`.zshrc', etc), if
     not `$HOME'.