15.6 Parameters Used By The Shell

The following parameters are used by the shell. Again, ‘<S>’ indicates that the parameter is special and ‘<Z>’ indicates that the parameter does not exist when the shell initializes in sh or ksh emulation mode.

In cases where there are two parameters with an upper- and lowercase form of the same name, such as path and PATH, the lowercase form is an array and the uppercase form is a scalar with the elements of the array joined together by colons. These are similar to tied parameters created via ‘typeset -T’. The normal use for the colon-separated form is for exporting to the environment, while the array form is easier to manipulate within the shell. Note that unsetting either of the pair will unset the other; they retain their special properties when recreated, and recreating one of the pair will recreate the other.

ARGV0

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

BAUD

The rate in bits per second at which data reaches the terminal. The line editor will use this value in order to compensate for a slow terminal by delaying updates to the display until necessary. If the parameter is unset or the value is zero the compensation mechanism is turned off. The parameter is not set by default.

This parameter may be profitably set in some circumstances, e.g. for slow modems dialing into a communications server, or on a slow wide area network. It should be set to the baud rate of the slowest part of the link for best performance.

cdpath <S> <Z> (CDPATH <S>)

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

COLUMNS <S>

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

CORRECT_IGNORE

If set, is treated as a pattern during spelling correction. Any potential correction that matches the pattern is ignored. For example, if the value is ‘_*’ then completion functions (which, by convention, have names beginning with ‘_’) will never be offered as spelling corrections. The pattern does not apply to the correction of file names, as applied by the CORRECT_ALL option (so with the example just given files beginning with ‘_’ in the current directory would still be completed).

CORRECT_IGNORE_FILE

If set, is treated as a pattern during spelling correction of file names. Any file name that matches the pattern is never offered as a correction. For example, if the value is ‘.*’ then dot file names will never be offered as spelling corrections. This is useful with the CORRECT_ALL option.

DIRSTACKSIZE

The maximum size of the directory stack, by default there is no limit. If the stack gets larger than this, it will be truncated automatically. This is useful with the AUTO_PUSHD option.

ENV

If the ENV environment variable is set when zsh is invoked as sh or ksh, $ENV is sourced after the profile scripts. The value of ENV is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. Note that ENV is not used unless the shell is interactive and zsh is emulating sh or ksh.

FCEDIT

The default editor for the fc builtin. If FCEDIT is not set, the parameter EDITOR is used; if that is not set either, a builtin default, usually vi, is used.

fignore <S> <Z> (FIGNORE <S>)

An array (colon separated list) containing the suffixes of files to be ignored during filename completion. However, if completion only generates files with suffixes in this list, then these files are completed anyway.

fpath <S> <Z> (FPATH <S>)

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 <S>

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

The characters must be in the ASCII character set; any attempt to set histchars to characters with a locale-dependent meaning will be rejected with an error message.

HISTCHARS <S> <Z>

Same as histchars. (Deprecated.)

HISTFILE

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

HISTORY_IGNORE

If set, is treated as a pattern at the time history files are written. Any potential history entry that matches the pattern is skipped. For example, if the value is ‘fc *’ then commands that invoke the interactive history editor are never written to the history file.

Note that HISTORY_IGNORE defines a single pattern: to specify alternatives use the ‘(first|second|...)’ syntax.

Compare the HIST_NO_STORE option or the zshaddhistory hook, either of which would prevent such commands from being added to the interactive history at all. If you wish to use HISTORY_IGNORE to stop history being added in the first place, you can define the following hook:

zshaddhistory() {
  emulate -L zsh
  ## uncomment if HISTORY_IGNORE
  ## should use EXTENDED_GLOB syntax
  # setopt extendedglob
  [[ $1 != ${~HISTORY_IGNORE} ]]
}
HISTSIZE <S>

The maximum number of events stored in the internal history list. If you use the HIST_EXPIRE_DUPS_FIRST option, setting this value larger than the SAVEHIST size will give you the difference as a cushion for saving duplicated history events.

If this is made local, it is not implicitly set to 0, but may be explicitly set locally.

HOME <S>

The default argument for the cd command. This is not set automatically by the shell in sh, ksh or csh emulation, but it is typically present in the environment anyway, and if it becomes set it has its usual special behaviour.

IFS <S>

Internal field separators (by default space, tab, newline and NUL), that are used to separate words which result from command or parameter expansion and words read by the read builtin. Any characters from the set space, tab and newline that appear in the IFS are called IFS white space. One or more IFS white space characters or one non-IFS white space character together with any adjacent IFS white space character delimit a field. If an IFS white space character appears twice consecutively in the IFS, this character is treated as if it were not an IFS white space character.

If the parameter is unset, the default is used. Note this has a different effect from setting the parameter to an empty string.

KEYBOARD_HACK

This variable defines a character to be removed from the end of the command line before interpreting it (interactive shells only). It is intended to fix the problem with keys placed annoyingly close to return and replaces the SUNKEYBOARDHACK option which did this for backquotes only. Should the chosen character be one of singlequote, doublequote or backquote, there must also be an odd number of them on the command line for the last one to be removed.

For backward compatibility, if the SUNKEYBOARDHACK option is explicitly set, the value of KEYBOARD_HACK reverts to backquote. If the option is explicitly unset, this variable is set to empty.

KEYTIMEOUT

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

LANG <S>

This variable determines the locale category for any category not specifically selected via a variable starting with ‘LC_’.

LC_ALL <S>

This variable overrides the value of the ‘LANG’ variable and the value of any of the other variables starting with ‘LC_’.

LC_COLLATE <S>

This variable determines the locale category for character collation information within ranges in glob brackets and for sorting.

LC_CTYPE <S>

This variable determines the locale category for character handling functions. If the MULTIBYTE option is in effect this variable or LANG should contain a value that reflects the character set in use, even if it is a single-byte character set, unless only the 7-bit subset (ASCII) is used. For example, if the character set is ISO-8859-1, a suitable value might be en_US.iso88591 (certain Linux distributions) or en_US.ISO8859-1 (MacOS).

LC_MESSAGES <S>

This variable determines the language in which messages should be written. Note that zsh does not use message catalogs.

LC_NUMERIC <S>

This variable affects the decimal point character and thousands separator character for the formatted input/output functions and string conversion functions. Note that zsh ignores this setting when parsing floating point mathematical expressions.

LC_TIME <S>

This variable determines the locale category for date and time formatting in prompt escape sequences.

LINES <S>

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 matches to list without asking first. If the value is negative, the list will be shown if it spans at most as many lines as given by the absolute value. If set to zero, the shell asks only if the top of the listing would scroll off the screen.

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 <S> <Z> (MAILPATH <S>)

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 message will undergo parameter expansion, command substitution and arithmetic expansion with the variable $_ defined as the name of the file that has changed. 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 <S> <Z> (MANPATH <S> <Z>)

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.

match
mbegin
mend

Arrays set by the shell when the b globbing flag is used in pattern matches. See the subsection Globbing flags in Filename Generation.

MATCH
MBEGIN
MEND

Set by the shell when the m globbing flag is used in pattern matches. See the subsection Globbing flags in Filename Generation.

module_path <S> <Z> (MODULE_PATH <S>)

An array (colon-separated list) of directories that zmodload searches for dynamically loadable modules. This is initialized to a standard pathname, usually ‘/usr/local/lib/zsh/$ZSH_VERSION’. (The ‘/usr/local/lib’ part varies from installation to installation.) For security reasons, any value set in the environment when the shell is started will be ignored.

These parameters only exist if the installation supports dynamic module loading.

NULLCMD <S>

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

path <S> <Z> (PATH <S>)

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 <S>

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

PROMPT <S> <Z>
PROMPT2 <S> <Z>
PROMPT3 <S> <Z>
PROMPT4 <S> <Z>

Same as PS1, PS2, PS3 and PS4, respectively.

prompt <S> <Z>

Same as PS1.

PROMPT_EOL_MARK

When the PROMPT_CR and PROMPT_SP options are set, the PROMPT_EOL_MARK parameter can be used to customize how the end of partial lines are shown. This parameter undergoes prompt expansion, with the PROMPT_PERCENT option set. If not set, the default behavior is equivalent to the value ‘%B%S%#%s%b’.

PS1 <S>

The primary prompt string, printed before a command is read. It undergoes a special form of expansion before being displayed; see Prompt Expansion. The default is ‘%m%# ’.

PS2 <S>

The secondary prompt, printed when the shell needs more information to complete a command. It is expanded in the same way as PS1. The default is ‘%_> ’, which displays any shell constructs or quotation marks which are currently being processed.

PS3 <S>

Selection prompt used within a select loop. It is expanded in the same way as PS1. The default is ‘?# ’.

PS4 <S>

The execution trace prompt. Default is ‘+%N:%i> ’, which displays the name of the current shell structure and the line number within it. In sh or ksh emulation, the default is ‘+ ’.

psvar <S> <Z> (PSVAR <S>)

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

READNULLCMD <S>

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

REPORTMEMORY

If nonnegative, commands whose maximum resident set size (roughly speaking, main memory usage) in kilobytes is greater than this value have timing statistics reported. The format used to output statistics is the value of the TIMEFMT parameter, which is the same as for the REPORTTIME variable and the time builtin; note that by default this does not output memory usage. Appending " max RSS %M" to the value of TIMEFMT causes it to output the value that triggered the report. If REPORTTIME is also in use, at most a single report is printed for both triggers. This feature requires the getrusage() system call, commonly supported by modern Unix-like systems.

REPORTTIME

If nonnegative, commands whose combined user and system execution times (measured in seconds) are greater than this value have timing statistics printed for them. Output is suppressed for commands executed within the line editor, including completion; commands explicitly marked with the time keyword still cause the summary to be printed in this case.

REPLY

This parameter is reserved by convention to pass string values between shell scripts and shell builtins in situations where a function call or redirection are impossible or undesirable. The read builtin and the select complex command may set REPLY, and filename generation both sets and examines its value when evaluating certain expressions. Some modules also employ REPLY for similar purposes.

reply

As REPLY, but for array values rather than strings.

RPROMPT <S>
RPS1 <S>

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. It is expanded in the same way as PS1.

RPROMPT2 <S>
RPS2 <S>

This prompt is displayed on the right-hand side of the screen when the secondary prompt is being displayed on the left. This does not work if the SINGLE_LINE_ZLE option is set. It is expanded in the same way as PS2.

SAVEHIST

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

If this is made local, it is not implicitly set to 0, but may be explicitly set locally.

SPROMPT <S>

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.

The actions available at the prompt are [nyae]:

n (‘no’) (default)

Discard the correction and run the command.

y (‘yes’)

Make the correction and run the command.

a (‘abort’)

Discard the entire command line without running it.

e (‘edit’)

Resume editing the command line.

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.

If the parameter is set and empty, all of the above applies except that stty is not run. This can be useful as a way to freeze the tty around a single command, blocking its changes to tty settings, similar to the ttyctl builtin.

TERM <S>

The type of terminal in use. This is used when looking up termcap sequences. An assignment to TERM causes zsh to re-initialize the terminal, even if the value does not change (e.g., ‘TERM=$TERM’). It is necessary to make such an assignment upon any change to the terminal definition database or terminal type in order for the new settings to take effect.

TERMINFO <S>

A reference to your terminfo database, used by the ‘terminfo’ library when the system has it; see terminfo(5). If set, this causes the shell to reinitialise the terminal, making the workaround ‘TERM=$TERM’ unnecessary.

TERMINFO_DIRS <S>

A colon-seprarated list of terminfo databases, used by the ‘terminfo’ library when the system has it; see terminfo(5). This variable is only used by certain terminal libraries, in particular ncurses; see terminfo(5) to check support on your system. If set, this causes the shell to reinitialise the terminal, making the workaround ‘TERM=$TERM’ unnecessary. Note that unlike other colon-separated arrays this is not tied to a zsh array.

TIMEFMT

The format of process time reports with the time keyword. The default is ‘%J %U user %S system %P cpu %*E total’. Recognizes the following escape sequences, although not all may be available on all systems, and some that are available may not be useful:

%%

A ‘%’.

%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 100*(%U+%S)/%E.

%W

Number of times the process was swapped.

%X

The average amount in (shared) text space used in kilobytes.

%D

The average amount in (unshared) data/stack space used in kilobytes.

%K

The total space used (%X+%D) in kilobytes.

%M

The maximum memory the process had in use at any time in kilobytes.

%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.

A star may be inserted between the percent sign and flags printing time (e.g., ‘%*E’); this causes the time to be printed in ‘hh:mm:ss.ttt’ format (hours and minutes are only printed if they are not zero). Alternatively, ‘m’ or ‘u’ may be used (e.g., ‘%mE’) to produce time output in milliseconds or microseconds, respectively.

TMOUT

If this parameter is nonzero, the shell will receive an ALRM signal if a command is not entered within the specified number of seconds after issuing a prompt. If there is a trap on SIGALRM, it will be executed and a new alarm is scheduled using the value of the TMOUT parameter after executing the trap. If no trap is set, and the idle time of the terminal is not less than the value of the TMOUT parameter, zsh terminates. Otherwise a new alarm is scheduled to TMOUT seconds after the last keypress.

TMPPREFIX

A pathname prefix which the shell will use for all temporary files. Note that this should include an initial part for the file name as well as any directory names. The default is ‘/tmp/zsh’.

TMPSUFFIX

A filename suffix which the shell will use for temporary files created by process substitutions (e.g., ‘=(list)’). Note that the value should include a leading dot ‘.’ if intended to be interpreted as a file extension. The default is not to append any suffix, thus this parameter should be assigned only when needed and then unset again.

WORDCHARS <S>

A list of non-alphanumeric characters considered part of a word by the line editor.

ZBEEP

If set, this gives a string of characters, which can use all the same codes as the bindkey command as described in The zsh/zle Module, that will be output to the terminal instead of beeping. This may have a visible instead of an audible effect; for example, the string ‘\e[?5h\e[?5l’ on a vt100 or xterm will have the effect of flashing reverse video on and off (if you usually use reverse video, you should use the string ‘\e[?5l\e[?5h’ instead). This takes precedence over the NOBEEP option.

ZDOTDIR

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

zle_bracketed_paste

Many terminal emulators have a feature that allows applications to identify when text is pasted into the terminal rather than being typed normally. For ZLE, this means that special characters such as tabs and newlines can be inserted instead of invoking editor commands. Furthermore, pasted text forms a single undo event and if the region is active, pasted text will replace the region.

This two-element array contains the terminal escape sequences for enabling and disabling the feature. These escape sequences are used to enable bracketed paste when ZLE is active and disable it at other times. Unsetting the parameter has the effect of ensuring that bracketed paste remains disabled.

zle_highlight

An array describing contexts in which ZLE should highlight the input text. See Character Highlighting.

ZLE_LINE_ABORTED

This parameter is set by the line editor when an error occurs. It contains the line that was being edited at the point of the error. ‘print -zr -- $ZLE_LINE_ABORTED’ can be used to recover the line. Only the most recent line of this kind is remembered.

ZLE_REMOVE_SUFFIX_CHARS
ZLE_SPACE_SUFFIX_CHARS

These parameters are used by the line editor. In certain circumstances suffixes (typically space or slash) added by the completion system will be removed automatically, either because the next editing command was not an insertable character, or because the character was marked as requiring the suffix to be removed.

These variables can contain the sets of characters that will cause the suffix to be removed. If ZLE_REMOVE_SUFFIX_CHARS is set, those characters will cause the suffix to be removed; if ZLE_SPACE_SUFFIX_CHARS is set, those characters will cause the suffix to be removed and replaced by a space.

If ZLE_REMOVE_SUFFIX_CHARS is not set, the default behaviour is equivalent to:

ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'

If ZLE_REMOVE_SUFFIX_CHARS is set but is empty, no characters have this behaviour. ZLE_SPACE_SUFFIX_CHARS takes precedence, so that the following:

ZLE_SPACE_SUFFIX_CHARS=$'&|'

causes the characters ‘&’ and ‘|’ to remove the suffix but to replace it with a space.

To illustrate the difference, suppose that the option AUTO_REMOVE_SLASH is in effect and the directory DIR has just been completed, with an appended /, following which the user types ‘&’. The default result is ‘DIR&’. With ZLE_REMOVE_SUFFIX_CHARS set but without including ‘&’ the result is ‘DIR/&’. With ZLE_SPACE_SUFFIX_CHARS set to include ‘&’ the result is ‘DIR &’.

Note that certain completions may provide their own suffix removal or replacement behaviour which overrides the values described here. See the completion system documentation in Completion System.

ZLE_RPROMPT_INDENT <S>

If set, used to give the indentation between the right hand side of the right prompt in the line editor as given by RPS1 or RPROMPT and the right hand side of the screen. If not set, the value 1 is used.

Typically this will be used to set the value to 0 so that the prompt appears flush with the right hand side of the screen. This is not the default as many terminals do not handle this correctly, in particular when the prompt appears at the extreme bottom right of the screen. Recent virtual terminals are more likely to handle this case correctly. Some experimentation is necessary.