1ZSHPARAM(1) General Commands Manual ZSHPARAM(1)
2
3
4
6 zshparam - zsh parameters
7
9 A parameter has a name, a value, and a number of attributes. A name
10 may be any sequence of alphanumeric characters and underscores, or the
11 single characters `*', `@', `#', `?', `-', `$', or `!'. A parameter
12 whose name begins with an alphanumeric or underscore is also referred
13 to as a variable.
14
15 The attributes of a parameter determine the type of its value, often
16 referred to as the parameter type or variable type, and also control
17 other processing that may be applied to the value when it is refer‐
18 enced. The value type may be a scalar (a string, an integer, or a
19 floating point number), an array (indexed numerically), or an associa‐
20 tive array (an unordered set of name-value pairs, indexed by name, also
21 referred to as a hash).
22
23 Named scalar parameters may have the exported, -x, attribute, to copy
24 them into the process environment, which is then passed from the shell
25 to any new processes that it starts. Exported parameters are called
26 environment variables. The shell also imports environment variables at
27 startup time and automatically marks the corresponding parameters as
28 exported. Some environment variables are not imported for reasons of
29 security or because they would interfere with the correct operation of
30 other shell features.
31
32 Parameters may also be special, that is, they have a predetermined
33 meaning to the shell. Special parameters cannot have their type
34 changed or their readonly attribute turned off, and if a special param‐
35 eter is unset, then later recreated, the special properties will be
36 retained.
37
38 To declare the type of a parameter, or to assign a string or numeric
39 value to a scalar parameter, use the typeset builtin.
40
41 The value of a scalar parameter may also be assigned by writing:
42
43 name=value
44
45 In scalar assignment, value is expanded as a single string, in which
46 the elements of arrays are joined together; filename expansion is not
47 performed unless the option GLOB_ASSIGN is set.
48
49 When the integer attribute, -i, or a floating point attribute, -E or
50 -F, is set for name, the value is subject to arithmetic evaluation.
51 Furthermore, by replacing `=' with `+=', a parameter can be incremented
52 or appended to. See the section `Array Parameters' and Arithmetic
53 Evaluation (in zshmisc(1)) for additional forms of assignment.
54
55 Note that assignment may implicitly change the attributes of a parame‐
56 ter. For example, assigning a number to a variable in arithmetic eval‐
57 uation may change its type to integer or float, and with GLOB_ASSIGN
58 assigning a pattern to a variable may change its type to an array.
59
60 To reference the value of a parameter, write `$name' or `${name}'. See
61 Parameter Expansion in zshexpn(1) for complete details. That section
62 also explains the effect of the difference between scalar and array
63 assignment on parameter expansion.
64
66 To assign an array value, write one of:
67
68 set -A name value ...
69 name=(value ...)
70 name=([key]=value ...)
71
72 If no parameter name exists, an ordinary array parameter is created.
73 If the parameter name exists and is a scalar, it is replaced by a new
74 array.
75
76 In the third form, key is an expression that will be evaluated in
77 arithmetic context (in its simplest form, an integer) that gives the
78 index of the element to be assigned with value. In this form any ele‐
79 ments not explicitly mentioned that come before the largest index to
80 which a value is assigned are assigned an empty string. The indices
81 may be in any order. Note that this syntax is strict: [ and ]= must
82 not be quoted, and key may not consist of the unquoted string ]=, but
83 is otherwise treated as a simple string. The enhanced forms of sub‐
84 script expression that may be used when directly subscripting a vari‐
85 able name, described in the section Array Subscripts below, are not
86 available.
87
88 The syntaxes with and without the explicit key may be mixed. An
89 implicit key is deduced by incrementing the index from the previously
90 assigned element. Note that it is not treated as an error if latter
91 assignments in this form overwrite earlier assignments.
92
93 For example, assuming the option KSH_ARRAYS is not set, the following:
94
95 array=(one [3]=three four)
96
97 causes the array variable array to contain four elements one, an empty
98 string, three and four, in that order.
99
100 In the forms where only value is specified, full command line expansion
101 is performed.
102
103 In the [key]=value form, both key and value undergo all forms of expan‐
104 sion allowed for single word shell expansions (this does not include
105 filename generation); these are as performed by the parameter expansion
106 flag (e) as described in zshexpn(1). Nested parentheses may surround
107 value and are included as part of the value, which is joined into a
108 plain string; this differs from ksh which allows the values themselves
109 to be arrays. A future version of zsh may support that. To cause the
110 brackets to be interpreted as a character class for filename genera‐
111 tion, and therefore to treat the resulting list of files as a set of
112 values, quote the equal sign using any form of quoting. Example:
113
114 name=([a-z]'='*)
115
116 To append to an array without changing the existing values, use one of
117 the following:
118
119 name+=(value ...)
120 name+=([key]=value ...)
121
122 In the second form key may specify an existing index as well as an
123 index off the end of the old array; any existing value is overwritten
124 by value. Also, it is possible to use [key]+=value to append to the
125 existing value at that index.
126
127 Within the parentheses on the right hand side of either form of the
128 assignment, newlines and semicolons are treated the same as white
129 space, separating individual values. Any consecutive sequence of such
130 characters has the same effect.
131
132 Ordinary array parameters may also be explicitly declared with:
133
134 typeset -a name
135
136 Associative arrays must be declared before assignment, by using:
137
138 typeset -A name
139
140 When name refers to an associative array, the list in an assignment is
141 interpreted as alternating keys and values:
142
143 set -A name key value ...
144 name=(key value ...)
145 name=([key]=value ...)
146
147 Note that only one of the two syntaxes above may be used in any given
148 assignment; the forms may not be mixed. This is unlike the case of
149 numerically indexed arrays.
150
151 Every key must have a value in this case. Note that this assigns to
152 the entire array, deleting any elements that do not appear in the list.
153 The append syntax may also be used with an associative array:
154
155 name+=(key value ...)
156 name+=([key]=value ...)
157
158 This adds a new key/value pair if the key is not already present, and
159 replaces the value for the existing key if it is. In the second form
160 it is also possible to use [key]+=value to append to the existing value
161 at that key. Expansion is performed identically to the corresponding
162 forms for normal arrays, as described above.
163
164 To create an empty array (including associative arrays), use one of:
165
166 set -A name
167 name=()
168
169 Array Subscripts
170 Individual elements of an array may be selected using a subscript. A
171 subscript of the form `[exp]' selects the single element exp, where exp
172 is an arithmetic expression which will be subject to arithmetic expan‐
173 sion as if it were surrounded by `$((...))'. The elements are numbered
174 beginning with 1, unless the KSH_ARRAYS option is set in which case
175 they are numbered from zero.
176
177 Subscripts may be used inside braces used to delimit a parameter name,
178 thus `${foo[2]}' is equivalent to `$foo[2]'. If the KSH_ARRAYS option
179 is set, the braced form is the only one that works, as bracketed
180 expressions otherwise are not treated as subscripts.
181
182 If the KSH_ARRAYS option is not set, then by default accesses to an
183 array element with a subscript that evaluates to zero return an empty
184 string, while an attempt to write such an element is treated as an
185 error. For backward compatibility the KSH_ZERO_SUBSCRIPT option can be
186 set to cause subscript values 0 and 1 to be equivalent; see the
187 description of the option in zshoptions(1).
188
189 The same subscripting syntax is used for associative arrays, except
190 that no arithmetic expansion is applied to exp. However, the parsing
191 rules for arithmetic expressions still apply, which affects the way
192 that certain special characters must be protected from interpretation.
193 See Subscript Parsing below for details.
194
195 A subscript of the form `[*]' or `[@]' evaluates to all elements of an
196 array; there is no difference between the two except when they appear
197 within double quotes. `"$foo[*]"' evaluates to `"$foo[1] $foo[2]
198 ..."', whereas `"$foo[@]"' evaluates to `"$foo[1]" "$foo[2]" ...'. For
199 associative arrays, `[*]' or `[@]' evaluate to all the values, in no
200 particular order. Note that this does not substitute the keys; see the
201 documentation for the `k' flag under Parameter Expansion Flags in zsh‐
202 expn(1) for complete details. When an array parameter is referenced as
203 `$name' (with no subscript) it evaluates to `$name[*]', unless the
204 KSH_ARRAYS option is set in which case it evaluates to `${name[0]}'
205 (for an associative array, this means the value of the key `0', which
206 may not exist even if there are values for other keys).
207
208 A subscript of the form `[exp1,exp2]' selects all elements in the range
209 exp1 to exp2, inclusive. (Associative arrays are unordered, and so do
210 not support ranges.) If one of the subscripts evaluates to a negative
211 number, say -n, then the nth element from the end of the array is used.
212 Thus `$foo[-3]' is the third element from the end of the array foo, and
213 `$foo[1,-1]' is the same as `$foo[*]'.
214
215 Subscripting may also be performed on non-array values, in which case
216 the subscripts specify a substring to be extracted. For example, if
217 FOO is set to `foobar', then `echo $FOO[2,5]' prints `ooba'. Note that
218 some forms of subscripting described below perform pattern matching,
219 and in that case the substring extends from the start of the match of
220 the first subscript to the end of the match of the second subscript.
221 For example,
222
223 string="abcdefghijklm"
224 print ${string[(r)d?,(r)h?]}
225
226 prints `defghi'. This is an obvious generalisation of the rule for
227 single-character matches. For a single subscript, only a single char‐
228 acter is referenced (not the range of characters covered by the match).
229
230 Note that in substring operations the second subscript is handled dif‐
231 ferently by the r and R subscript flags: the former takes the shortest
232 match as the length and the latter the longest match. Hence in the
233 former case a * at the end is redundant while in the latter case it
234 matches the whole remainder of the string. This does not affect the
235 result of the single subscript case as here the length of the match is
236 irrelevant.
237
238 Array Element Assignment
239 A subscript may be used on the left side of an assignment like so:
240
241 name[exp]=value
242
243 In this form of assignment the element or range specified by exp is
244 replaced by the expression on the right side. An array (but not an
245 associative array) may be created by assignment to a range or element.
246 Arrays do not nest, so assigning a parenthesized list of values to an
247 element or range changes the number of elements in the array, shifting
248 the other elements to accommodate the new values. (This is not sup‐
249 ported for associative arrays.)
250
251 This syntax also works as an argument to the typeset command:
252
253 typeset "name[exp]"=value
254
255 The value may not be a parenthesized list in this case; only sin‐
256 gle-element assignments may be made with typeset. Note that quotes are
257 necessary in this case to prevent the brackets from being interpreted
258 as filename generation operators. The noglob precommand modifier could
259 be used instead.
260
261 To delete an element of an ordinary array, assign `()' to that element.
262 To delete an element of an associative array, use the unset command:
263
264 unset "name[exp]"
265
266 Subscript Flags
267 If the opening bracket, or the comma in a range, in any subscript
268 expression is directly followed by an opening parenthesis, the string
269 up to the matching closing one is considered to be a list of flags, as
270 in `name[(flags)exp]'.
271
272 The flags s, n and b take an argument; the delimiter is shown below as
273 `:', but any character, or the matching pairs `(...)', `{...}',
274 `[...]', or `<...>', may be used, but note that `<...>' can only be
275 used if the subscript is inside a double quoted expression or a parame‐
276 ter substitution enclosed in braces as otherwise the expression is
277 interpreted as a redirection.
278
279 The flags currently understood are:
280
281 w If the parameter subscripted is a scalar then this flag makes
282 subscripting work on words instead of characters. The default
283 word separator is whitespace. When combined with the i or I
284 flag, the effect is to produce the index of the first character
285 of the first/last word which matches the given pattern; note
286 that a failed match in this case always yields 0.
287
288 s:string:
289 This gives the string that separates words (for use with the w
290 flag). The delimiter character : is arbitrary; see above.
291
292 p Recognize the same escape sequences as the print builtin in the
293 string argument of a subsequent `s' flag.
294
295 f If the parameter subscripted is a scalar then this flag makes
296 subscripting work on lines instead of characters, i.e. with ele‐
297 ments separated by newlines. This is a shorthand for `pws:\n:'.
298
299 r Reverse subscripting: if this flag is given, the exp is taken as
300 a pattern and the result is the first matching array element,
301 substring or word (if the parameter is an array, if it is a
302 scalar, or if it is a scalar and the `w' flag is given, respec‐
303 tively). The subscript used is the number of the matching ele‐
304 ment, so that pairs of subscripts such as `$foo[(r)??,3]' and
305 `$foo[(r)??,(r)f*]' are possible if the parameter is not an
306 associative array. If the parameter is an associative array,
307 only the value part of each pair is compared to the pattern, and
308 the result is that value.
309
310 If a search through an ordinary array failed, the search sets
311 the subscript to one past the end of the array, and hence
312 ${array[(r)pattern]} will substitute the empty string. Thus the
313 success of a search can be tested by using the (i) flag, for
314 example (assuming the option KSH_ARRAYS is not in effect):
315
316 [[ ${array[(i)pattern]} -le ${#array} ]]
317
318 If KSH_ARRAYS is in effect, the -le should be replaced by -lt.
319
320 R Like `r', but gives the last match. For associative arrays,
321 gives all possible matches. May be used for assigning to ordi‐
322 nary array elements, but not for assigning to associative
323 arrays. On failure, for normal arrays this has the effect of
324 returning the element corresponding to subscript 0; this is
325 empty unless one of the options KSH_ARRAYS or KSH_ZERO_SUBSCRIPT
326 is in effect.
327
328 Note that in subscripts with both `r' and `R' pattern characters
329 are active even if they were substituted for a parameter
330 (regardless of the setting of GLOB_SUBST which controls this
331 feature in normal pattern matching). The flag `e' can be added
332 to inhibit pattern matching. As this flag does not inhibit
333 other forms of substitution, care is still required; using a
334 parameter to hold the key has the desired effect:
335
336 key2='original key'
337 print ${array[(Re)$key2]}
338
339 i Like `r', but gives the index of the match instead; this may not
340 be combined with a second argument. On the left side of an
341 assignment, behaves like `r'. For associative arrays, the key
342 part of each pair is compared to the pattern, and the first
343 matching key found is the result. On failure substitutes the
344 length of the array plus one, as discussed under the description
345 of `r', or the empty string for an associative array.
346
347 I Like `i', but gives the index of the last match, or all possible
348 matching keys in an associative array. On failure substitutes
349 0, or the empty string for an associative array. This flag is
350 best when testing for values or keys that do not exist.
351
352 k If used in a subscript on an associative array, this flag causes
353 the keys to be interpreted as patterns, and returns the value
354 for the first key found where exp is matched by the key. Note
355 this could be any such key as no ordering of associative arrays
356 is defined. This flag does not work on the left side of an
357 assignment to an associative array element. If used on another
358 type of parameter, this behaves like `r'.
359
360 K On an associative array this is like `k' but returns all values
361 where exp is matched by the keys. On other types of parameters
362 this has the same effect as `R'.
363
364 n:expr:
365 If combined with `r', `R', `i' or `I', makes them give the nth
366 or nth last match (if expr evaluates to n). This flag is
367 ignored when the array is associative. The delimiter character
368 : is arbitrary; see above.
369
370 b:expr:
371 If combined with `r', `R', `i' or `I', makes them begin at the
372 nth or nth last element, word, or character (if expr evaluates
373 to n). This flag is ignored when the array is associative. The
374 delimiter character : is arbitrary; see above.
375
376 e This flag causes any pattern matching that would be performed on
377 the subscript to use plain string matching instead. Hence
378 `${array[(re)*]}' matches only the array element whose value is
379 *. Note that other forms of substitution such as parameter sub‐
380 stitution are not inhibited.
381
382 This flag can also be used to force * or @ to be interpreted as
383 a single key rather than as a reference to all values. It may
384 be used for either purpose on the left side of an assignment.
385
386 See Parameter Expansion Flags (zshexpn(1)) for additional ways to
387 manipulate the results of array subscripting.
388
389 Subscript Parsing
390 This discussion applies mainly to associative array key strings and to
391 patterns used for reverse subscripting (the `r', `R', `i', etc. flags),
392 but it may also affect parameter substitutions that appear as part of
393 an arithmetic expression in an ordinary subscript.
394
395 To avoid subscript parsing limitations in assignments to associative
396 array elements, use the append syntax:
397
398 aa+=('key with "*strange*" characters' 'value string')
399
400 The basic rule to remember when writing a subscript expression is that
401 all text between the opening `[' and the closing `]' is interpreted as
402 if it were in double quotes (see zshmisc(1)). However, unlike double
403 quotes which normally cannot nest, subscript expressions may appear
404 inside double-quoted strings or inside other subscript expressions (or
405 both!), so the rules have two important differences.
406
407 The first difference is that brackets (`[' and `]') must appear as bal‐
408 anced pairs in a subscript expression unless they are preceded by a
409 backslash (`\'). Therefore, within a subscript expression (and unlike
410 true double-quoting) the sequence `\[' becomes `[', and similarly `\]'
411 becomes `]'. This applies even in cases where a backslash is not nor‐
412 mally required; for example, the pattern `[^[]' (to match any character
413 other than an open bracket) should be written `[^\[]' in a reverse-sub‐
414 script pattern. However, note that `\[^\[\]' and even `\[^[]' mean the
415 same thing, because backslashes are always stripped when they appear
416 before brackets!
417
418 The same rule applies to parentheses (`(' and `)') and braces (`{' and
419 `}'): they must appear either in balanced pairs or preceded by a back‐
420 slash, and backslashes that protect parentheses or braces are removed
421 during parsing. This is because parameter expansions may be surrounded
422 by balanced braces, and subscript flags are introduced by balanced
423 parentheses.
424
425 The second difference is that a double-quote (`"') may appear as part
426 of a subscript expression without being preceded by a backslash, and
427 therefore that the two characters `\"' remain as two characters in the
428 subscript (in true double-quoting, `\"' becomes `"'). However, because
429 of the standard shell quoting rules, any double-quotes that appear must
430 occur in balanced pairs unless preceded by a backslash. This makes it
431 more difficult to write a subscript expression that contains an odd
432 number of double-quote characters, but the reason for this difference
433 is so that when a subscript expression appears inside true dou‐
434 ble-quotes, one can still write `\"' (rather than `\\\"') for `"'.
435
436 To use an odd number of double quotes as a key in an assignment, use
437 the typeset builtin and an enclosing pair of double quotes; to refer to
438 the value of that key, again use double quotes:
439
440 typeset -A aa
441 typeset "aa[one\"two\"three\"quotes]"=QQQ
442 print "$aa[one\"two\"three\"quotes]"
443
444 It is important to note that the quoting rules do not change when a
445 parameter expansion with a subscript is nested inside another subscript
446 expression. That is, it is not necessary to use additional backslashes
447 within the inner subscript expression; they are removed only once, from
448 the innermost subscript outwards. Parameters are also expanded from
449 the innermost subscript first, as each expansion is encountered left to
450 right in the outer expression.
451
452 A further complication arises from a way in which subscript parsing is
453 not different from double quote parsing. As in true double-quoting,
454 the sequences `\*', and `\@' remain as two characters when they appear
455 in a subscript expression. To use a literal `*' or `@' as an associa‐
456 tive array key, the `e' flag must be used:
457
458 typeset -A aa
459 aa[(e)*]=star
460 print $aa[(e)*]
461
462 A last detail must be considered when reverse subscripting is per‐
463 formed. Parameters appearing in the subscript expression are first
464 expanded and then the complete expression is interpreted as a pattern.
465 This has two effects: first, parameters behave as if GLOB_SUBST were on
466 (and it cannot be turned off); second, backslashes are interpreted
467 twice, once when parsing the array subscript and again when parsing the
468 pattern. In a reverse subscript, it's necessary to use four back‐
469 slashes to cause a single backslash to match literally in the pattern.
470 For complex patterns, it is often easiest to assign the desired pattern
471 to a parameter and then refer to that parameter in the subscript,
472 because then the backslashes, brackets, parentheses, etc., are seen
473 only when the complete expression is converted to a pattern. To match
474 the value of a parameter literally in a reverse subscript, rather than
475 as a pattern, use `${(q)name}' (see zshexpn(1)) to quote the expanded
476 value.
477
478 Note that the `k' and `K' flags are reverse subscripting for an ordi‐
479 nary array, but are not reverse subscripting for an associative array!
480 (For an associative array, the keys in the array itself are interpreted
481 as patterns by those flags; the subscript is a plain string in that
482 case.)
483
484 One final note, not directly related to subscripting: the numeric names
485 of positional parameters (described below) are parsed specially, so for
486 example `$2foo' is equivalent to `${2}foo'. Therefore, to use sub‐
487 script syntax to extract a substring from a positional parameter, the
488 expansion must be surrounded by braces; for example, `${2[3,5]}' evalu‐
489 ates to the third through fifth characters of the second positional
490 parameter, but `$2[3,5]' is the entire second parameter concatenated
491 with the filename generation pattern `[3,5]'.
492
494 The positional parameters provide access to the command-line arguments
495 of a shell function, shell script, or the shell itself; see the section
496 `Invocation', and also the section `Functions'. The parameter n, where
497 n is a number, is the nth positional parameter. The parameter `$0' is
498 a special case, see the section `Parameters Set By The Shell'.
499
500 The parameters *, @ and argv are arrays containing all the positional
501 parameters; thus `$argv[n]', etc., is equivalent to simply `$n'. Note
502 that the options KSH_ARRAYS or KSH_ZERO_SUBSCRIPT apply to these arrays
503 as well, so with either of those options set, `${argv[0]}' is equiva‐
504 lent to `$1' and so on.
505
506 Positional parameters may be changed after the shell or function starts
507 by using the set builtin, by assigning to the argv array, or by direct
508 assignment of the form `n=value' where n is the number of the posi‐
509 tional parameter to be changed. This also creates (with empty values)
510 any of the positions from 1 to n that do not already have values. Note
511 that, because the positional parameters form an array, an array assign‐
512 ment of the form `n=(value ...)' is allowed, and has the effect of
513 shifting all the values at positions greater than n by as many posi‐
514 tions as necessary to accommodate the new values.
515
517 Shell function executions delimit scopes for shell parameters. (Param‐
518 eters are dynamically scoped.) The typeset builtin, and its alterna‐
519 tive forms declare, integer, local and readonly (but not export), can
520 be used to declare a parameter as being local to the innermost scope.
521
522 When a parameter is read or assigned to, the innermost existing parame‐
523 ter of that name is used. (That is, the local parameter hides any
524 less-local parameter.) However, assigning to a non-existent parameter,
525 or declaring a new parameter with export, causes it to be created in
526 the outermost scope.
527
528 Local parameters disappear when their scope ends. unset can be used to
529 delete a parameter while it is still in scope; any outer parameter of
530 the same name remains hidden.
531
532 Special parameters may also be made local; they retain their special
533 attributes unless either the existing or the newly-created parameter
534 has the -h (hide) attribute. This may have unexpected effects: there
535 is no default value, so if there is no assignment at the point the
536 variable is made local, it will be set to an empty value (or zero in
537 the case of integers). The following:
538
539 typeset PATH=/new/directory:$PATH
540
541 is valid for temporarily allowing the shell or programmes called from
542 it to find the programs in /new/directory inside a function.
543
544 Note that the restriction in older versions of zsh that local parame‐
545 ters were never exported has been removed.
546
548 In the parameter lists that follow, the mark `<S>' indicates that the
549 parameter is special. `<Z>' indicates that the parameter does not
550 exist when the shell initializes in sh or ksh emulation mode.
551
552 The following parameters are automatically set by the shell:
553
554 ! <S> The process ID of the last command started in the background
555 with &, put into the background with the bg builtin, or spawned
556 with coproc.
557
558 # <S> The number of positional parameters in decimal. Note that some
559 confusion may occur with the syntax $#param which substitutes
560 the length of param. Use ${#} to resolve ambiguities. In par‐
561 ticular, the sequence `$#-...' in an arithmetic expression is
562 interpreted as the length of the parameter -, q.v.
563
564 ARGC <S> <Z>
565 Same as #.
566
567 $ <S> The process ID of this shell. Note that this indicates the
568 original shell started by invoking zsh; all processes forked
569 from the shells without executing a new program, such as sub‐
570 shells started by (...), substitute the same value.
571
572 - <S> Flags supplied to the shell on invocation or by the set or
573 setopt commands.
574
575 * <S> An array containing the positional parameters.
576
577 argv <S> <Z>
578 Same as *. Assigning to argv changes the local positional
579 parameters, but argv is not itself a local parameter. Deleting
580 argv with unset in any function deletes it everywhere, although
581 only the innermost positional parameter array is deleted (so *
582 and @ in other scopes are not affected).
583
584 @ <S> Same as argv[@], even when argv is not set.
585
586 ? <S> The exit status returned by the last command.
587
588 0 <S> The name used to invoke the current shell, or as set by the -c
589 command line option upon invocation. If the FUNCTION_ARGZERO
590 option is set, $0 is set upon entry to a shell function to the
591 name of the function, and upon entry to a sourced script to the
592 name of the script, and reset to its previous value when the
593 function or script returns.
594
595 status <S> <Z>
596 Same as ?.
597
598 pipestatus <S> <Z>
599 An array containing the exit statuses returned by all commands
600 in the last pipeline.
601
602 _ <S> The last argument of the previous command. Also, this parameter
603 is set in the environment of every command executed to the full
604 pathname of the command.
605
606 CPUTYPE
607 The machine type (microprocessor class or machine model), as
608 determined at run time.
609
610 EGID <S>
611 The effective group ID of the shell process. If you have suffi‐
612 cient privileges, you may change the effective group ID of the
613 shell process by assigning to this parameter. Also (assuming
614 sufficient privileges), you may start a single command with a
615 different effective group ID by `(EGID=gid; command)'
616
617 If this is made local, it is not implicitly set to 0, but may be
618 explicitly set locally.
619
620 EUID <S>
621 The effective user ID of the shell process. If you have suffi‐
622 cient privileges, you may change the effective user ID of the
623 shell process by assigning to this parameter. Also (assuming
624 sufficient privileges), you may start a single command with a
625 different effective user ID by `(EUID=uid; command)'
626
627 If this is made local, it is not implicitly set to 0, but may be
628 explicitly set locally.
629
630 ERRNO <S>
631 The value of errno (see errno(3)) as set by the most recently
632 failed system call. This value is system dependent and is
633 intended for debugging purposes. It is also useful with the
634 zsh/system module which allows the number to be turned into a
635 name or message.
636
637 FUNCNEST <S>
638 Integer. If greater than or equal to zero, the maximum nesting
639 depth of shell functions. When it is exceeded, an error is
640 raised at the point where a function is called. The default
641 value is determined when the shell is configured, but is typi‐
642 cally 500. Increasing the value increases the danger of a run‐
643 away function recursion causing the shell to crash. Setting a
644 negative value turns off the check.
645
646 GID <S>
647 The real group ID of the shell process. If you have sufficient
648 privileges, you may change the group ID of the shell process by
649 assigning to this parameter. Also (assuming sufficient privi‐
650 leges), you may start a single command under a different group
651 ID by `(GID=gid; command)'
652
653 If this is made local, it is not implicitly set to 0, but may be
654 explicitly set locally.
655
656 HISTCMD
657 The current history event number in an interactive shell, in
658 other words the event number for the command that caused
659 $HISTCMD to be read. If the current history event modifies the
660 history, HISTCMD changes to the new maximum history event num‐
661 ber.
662
663 HOST The current hostname.
664
665 LINENO <S>
666 The line number of the current line within the current script,
667 sourced file, or shell function being executed, whichever was
668 started most recently. Note that in the case of shell functions
669 the line number refers to the function as it appeared in the
670 original definition, not necessarily as displayed by the func‐
671 tions builtin.
672
673 LOGNAME
674 If the corresponding variable is not set in the environment of
675 the shell, it is initialized to the login name corresponding to
676 the current login session. This parameter is exported by default
677 but this can be disabled using the typeset builtin. The value
678 is set to the string returned by the getlogin(3) system call if
679 that is available.
680
681 MACHTYPE
682 The machine type (microprocessor class or machine model), as
683 determined at compile time.
684
685 OLDPWD The previous working directory. This is set when the shell ini‐
686 tializes and whenever the directory changes.
687
688 OPTARG <S>
689 The value of the last option argument processed by the getopts
690 command.
691
692 OPTIND <S>
693 The index of the last option argument processed by the getopts
694 command.
695
696 OSTYPE The operating system, as determined at compile time.
697
698 PPID <S>
699 The process ID of the parent of the shell. As for $$, the value
700 indicates the parent of the original shell and does not change
701 in subshells.
702
703 PWD The present working directory. This is set when the shell ini‐
704 tializes and whenever the directory changes.
705
706 RANDOM <S>
707 A pseudo-random integer from 0 to 32767, newly generated each
708 time this parameter is referenced. The random number generator
709 can be seeded by assigning a numeric value to RANDOM.
710
711 The values of RANDOM form an intentionally-repeatable
712 pseudo-random sequence; subshells that reference RANDOM will
713 result in identical pseudo-random values unless the value of
714 RANDOM is referenced or seeded in the parent shell in between
715 subshell invocations.
716
717 SECONDS <S>
718 The number of seconds since shell invocation. If this parameter
719 is assigned a value, then the value returned upon reference will
720 be the value that was assigned plus the number of seconds since
721 the assignment.
722
723 Unlike other special parameters, the type of the SECONDS parame‐
724 ter can be changed using the typeset command. Only integer and
725 one of the floating point types are allowed. For example,
726 `typeset -F SECONDS' causes the value to be reported as a float‐
727 ing point number. The value is available to microsecond accu‐
728 racy, although the shell may show more or fewer digits depending
729 on the use of typeset. See the documentation for the builtin
730 typeset in zshbuiltins(1) for more details.
731
732 SHLVL <S>
733 Incremented by one each time a new shell is started.
734
735 signals
736 An array containing the names of the signals. Note that with
737 the standard zsh numbering of array indices, where the first
738 element has index 1, the signals are offset by 1 from the signal
739 number used by the operating system. For example, on typical
740 Unix-like systems HUP is signal number 1, but is referred to as
741 $signals[2]. This is because of EXIT at position 1 in the
742 array, which is used internally by zsh but is not known to the
743 operating system.
744
745 TRY_BLOCK_ERROR <S>
746 In an always block, indicates whether the preceding list of code
747 caused an error. The value is 1 to indicate an error, 0 other‐
748 wise. It may be reset, clearing the error condition. See Com‐
749 plex Commands in zshmisc(1)
750
751 TRY_BLOCK_INTERRUPT <S>
752 This variable works in a similar way to TRY_BLOCK_ERROR, but
753 represents the status of an interrupt from the signal SIGINT,
754 which typically comes from the keyboard when the user types ^C.
755 If set to 0, any such interrupt will be reset; otherwise, the
756 interrupt is propagated after the always block.
757
758 Note that it is possible that an interrupt arrives during the
759 execution of the always block; this interrupt is also propa‐
760 gated.
761
762 TTY The name of the tty associated with the shell, if any.
763
764 TTYIDLE <S>
765 The idle time of the tty associated with the shell in seconds or
766 -1 if there is no such tty.
767
768 UID <S>
769 The real user ID of the shell process. If you have sufficient
770 privileges, you may change the user ID of the shell by assigning
771 to this parameter. Also (assuming sufficient privileges), you
772 may start a single command under a different user ID by
773 `(UID=uid; command)'
774
775 If this is made local, it is not implicitly set to 0, but may be
776 explicitly set locally.
777
778 USERNAME <S>
779 The username corresponding to the real user ID of the shell
780 process. If you have sufficient privileges, you may change the
781 username (and also the user ID and group ID) of the shell by
782 assigning to this parameter. Also (assuming sufficient privi‐
783 leges), you may start a single command under a different user‐
784 name (and user ID and group ID) by `(USERNAME=username; com‐
785 mand)'
786
787 VENDOR The vendor, as determined at compile time.
788
789 zsh_eval_context <S> <Z> (ZSH_EVAL_CONTEXT <S>)
790 An array (colon-separated list) indicating the context of shell
791 code that is being run. Each time a piece of shell code that is
792 stored within the shell is executed a string is temporarily
793 appended to the array to indicate the type of operation that is
794 being performed. Read in order the array gives an indication of
795 the stack of operations being performed with the most immediate
796 context last.
797
798 Note that the variable does not give information on syntactic
799 context such as pipelines or subshells. Use $ZSH_SUBSHELL to
800 detect subshells.
801
802 The context is one of the following:
803 cmdarg Code specified by the -c option to the command line that
804 invoked the shell.
805
806 cmdsubst
807 Command substitution using the `...` or $(...) construct.
808
809 equalsubst
810 File substitution using the =(...) construct.
811
812 eval Code executed by the eval builtin.
813
814 evalautofunc
815 Code executed with the KSH_AUTOLOAD mechanism in order to
816 define an autoloaded function.
817
818 fc Code from the shell history executed by the -e option to
819 the fc builtin.
820
821 file Lines of code being read directly from a file, for exam‐
822 ple by the source builtin.
823
824 filecode
825 Lines of code being read from a .zwc file instead of
826 directly from the source file.
827
828 globqual
829 Code executed by the e or + glob qualifier.
830
831 globsort
832 Code executed to order files by the o glob qualifier.
833
834 insubst
835 File substitution using the <(...) construct.
836
837 loadautofunc
838 Code read directly from a file to define an autoloaded
839 function.
840
841 outsubst
842 File substitution using the >(...) construct.
843
844 sched Code executed by the sched builtin.
845
846 shfunc A shell function.
847
848 stty Code passed to stty by the STTY environment variable.
849 Normally this is passed directly to the system's stty
850 command, so this value is unlikely to be seen in prac‐
851 tice.
852
853 style Code executed as part of a style retrieved by the zstyle
854 builtin from the zsh/zutil module.
855
856 toplevel
857 The highest execution level of a script or interactive
858 shell.
859
860 trap Code executed as a trap defined by the trap builtin.
861 Traps defined as functions have the context shfunc. As
862 traps are asynchronous they may have a different hierar‐
863 chy from other code.
864
865 zpty Code executed by the zpty builtin from the zsh/zpty mod‐
866 ule.
867
868 zregexparse-guard
869 Code executed as a guard by the zregexparse command from
870 the zsh/zutil module.
871
872 zregexparse-action
873 Code executed as an action by the zregexparse command
874 from the zsh/zutil module.
875
876 ZSH_ARGZERO
877 If zsh was invoked to run a script, this is the name of the
878 script. Otherwise, it is the name used to invoke the current
879 shell. This is the same as the value of $0 when the
880 POSIX_ARGZERO option is set, but is always available.
881
882 ZSH_EXECUTION_STRING
883 If the shell was started with the option -c, this contains the
884 argument passed to the option. Otherwise it is not set.
885
886 ZSH_NAME
887 Expands to the basename of the command used to invoke this
888 instance of zsh.
889
890 ZSH_PATCHLEVEL
891 The output of `git describe --tags --long' for the zsh reposi‐
892 tory used to build the shell. This is most useful in order to
893 keep track of versions of the shell during development between
894 releases; hence most users should not use it and should instead
895 rely on $ZSH_VERSION.
896
897 zsh_scheduled_events
898 See the section `The zsh/sched Module' in zshmodules(1).
899
900 ZSH_SCRIPT
901 If zsh was invoked to run a script, this is the name of the
902 script, otherwise it is unset.
903
904 ZSH_SUBSHELL
905 Readonly integer. Initially zero, incremented each time the
906 shell forks to create a subshell for executing code. Hence
907 `(print $ZSH_SUBSHELL)' and `print $(print $ZSH_SUBSHELL)' out‐
908 put 1, while `( (print $ZSH_SUBSHELL) )' outputs 2.
909
910 ZSH_VERSION
911 The version number of the release of zsh.
912
914 The following parameters are used by the shell. Again, `<S>' indicates
915 that the parameter is special and `<Z>' indicates that the parameter
916 does not exist when the shell initializes in sh or ksh emulation mode.
917
918 In cases where there are two parameters with an upper- and lowercase
919 form of the same name, such as path and PATH, the lowercase form is an
920 array and the uppercase form is a scalar with the elements of the array
921 joined together by colons. These are similar to tied parameters cre‐
922 ated via `typeset -T'. The normal use for the colon-separated form is
923 for exporting to the environment, while the array form is easier to
924 manipulate within the shell. Note that unsetting either of the pair
925 will unset the other; they retain their special properties when recre‐
926 ated, and recreating one of the pair will recreate the other.
927
928 ARGV0 If exported, its value is used as the argv[0] of external com‐
929 mands. Usually used in constructs like `ARGV0=emacs nethack'.
930
931 BAUD The rate in bits per second at which data reaches the terminal.
932 The line editor will use this value in order to compensate for a
933 slow terminal by delaying updates to the display until neces‐
934 sary. If the parameter is unset or the value is zero the com‐
935 pensation mechanism is turned off. The parameter is not set by
936 default.
937
938 This parameter may be profitably set in some circumstances, e.g.
939 for slow modems dialing into a communications server, or on a
940 slow wide area network. It should be set to the baud rate of
941 the slowest part of the link for best performance.
942
943 cdpath <S> <Z> (CDPATH <S>)
944 An array (colon-separated list) of directories specifying the
945 search path for the cd command.
946
947 COLUMNS <S>
948 The number of columns for this terminal session. Used for
949 printing select lists and for the line editor.
950
951 CORRECT_IGNORE
952 If set, is treated as a pattern during spelling correction. Any
953 potential correction that matches the pattern is ignored. For
954 example, if the value is `_*' then completion functions (which,
955 by convention, have names beginning with `_') will never be
956 offered as spelling corrections. The pattern does not apply to
957 the correction of file names, as applied by the CORRECT_ALL
958 option (so with the example just given files beginning with `_'
959 in the current directory would still be completed).
960
961 CORRECT_IGNORE_FILE
962 If set, is treated as a pattern during spelling correction of
963 file names. Any file name that matches the pattern is never
964 offered as a correction. For example, if the value is `.*' then
965 dot file names will never be offered as spelling corrections.
966 This is useful with the CORRECT_ALL option.
967
968 DIRSTACKSIZE
969 The maximum size of the directory stack, by default there is no
970 limit. If the stack gets larger than this, it will be truncated
971 automatically. This is useful with the AUTO_PUSHD option.
972
973 ENV If the ENV environment variable is set when zsh is invoked as sh
974 or ksh, $ENV is sourced after the profile scripts. The value of
975 ENV is subjected to parameter expansion, command substitution,
976 and arithmetic expansion before being interpreted as a pathname.
977 Note that ENV is not used unless the shell is interactive and
978 zsh is emulating sh or ksh.
979
980 FCEDIT The default editor for the fc builtin. If FCEDIT is not set,
981 the parameter EDITOR is used; if that is not set either, a
982 builtin default, usually vi, is used.
983
984 fignore <S> <Z> (FIGNORE <S>)
985 An array (colon separated list) containing the suffixes of files
986 to be ignored during filename completion. However, if comple‐
987 tion only generates files with suffixes in this list, then these
988 files are completed anyway.
989
990 fpath <S> <Z> (FPATH <S>)
991 An array (colon separated list) of directories specifying the
992 search path for function definitions. This path is searched
993 when a function with the -u attribute is referenced. If an exe‐
994 cutable file is found, then it is read and executed in the cur‐
995 rent environment.
996
997 histchars <S>
998 Three characters used by the shell's history and lexical analy‐
999 sis mechanism. The first character signals the start of a his‐
1000 tory expansion (default `!'). The second character signals the
1001 start of a quick history substitution (default `^'). The third
1002 character is the comment character (default `#').
1003
1004 The characters must be in the ASCII character set; any attempt
1005 to set histchars to characters with a locale-dependent meaning
1006 will be rejected with an error message.
1007
1008 HISTCHARS <S> <Z>
1009 Same as histchars. (Deprecated.)
1010
1011 HISTFILE
1012 The file to save the history in when an interactive shell exits.
1013 If unset, the history is not saved.
1014
1015 HISTORY_IGNORE
1016 If set, is treated as a pattern at the time history files are
1017 written. Any potential history entry that matches the pattern
1018 is skipped. For example, if the value is `fc *' then commands
1019 that invoke the interactive history editor are never written to
1020 the history file.
1021
1022 Note that HISTORY_IGNORE defines a single pattern: to specify
1023 alternatives use the `(first|second|...)' syntax.
1024
1025 Compare the HIST_NO_STORE option or the zshaddhistory hook,
1026 either of which would prevent such commands from being added to
1027 the interactive history at all. If you wish to use HIS‐
1028 TORY_IGNORE to stop history being added in the first place, you
1029 can define the following hook:
1030
1031 zshaddhistory() {
1032 emulate -L zsh
1033 ## uncomment if HISTORY_IGNORE
1034 ## should use EXTENDED_GLOB syntax
1035 # setopt extendedglob
1036 [[ $1 != ${~HISTORY_IGNORE} ]]
1037 }
1038
1039 HISTSIZE <S>
1040 The maximum number of events stored in the internal history
1041 list. If you use the HIST_EXPIRE_DUPS_FIRST option, setting
1042 this value larger than the SAVEHIST size will give you the dif‐
1043 ference as a cushion for saving duplicated history events.
1044
1045 If this is made local, it is not implicitly set to 0, but may be
1046 explicitly set locally.
1047
1048 HOME <S>
1049 The default argument for the cd command. This is not set auto‐
1050 matically by the shell in sh, ksh or csh emulation, but it is
1051 typically present in the environment anyway, and if it becomes
1052 set it has its usual special behaviour.
1053
1054 IFS <S>
1055 Internal field separators (by default space, tab, newline and
1056 NUL), that are used to separate words which result from command
1057 or parameter expansion and words read by the read builtin. Any
1058 characters from the set space, tab and newline that appear in
1059 the IFS are called IFS white space. One or more IFS white space
1060 characters or one non-IFS white space character together with
1061 any adjacent IFS white space character delimit a field. If an
1062 IFS white space character appears twice consecutively in the
1063 IFS, this character is treated as if it were not an IFS white
1064 space character.
1065
1066 If the parameter is unset, the default is used. Note this has a
1067 different effect from setting the parameter to an empty string.
1068
1069 KEYBOARD_HACK
1070 This variable defines a character to be removed from the end of
1071 the command line before interpreting it (interactive shells
1072 only). It is intended to fix the problem with keys placed annoy‐
1073 ingly close to return and replaces the SUNKEYBOARDHACK option
1074 which did this for backquotes only. Should the chosen character
1075 be one of singlequote, doublequote or backquote, there must also
1076 be an odd number of them on the command line for the last one to
1077 be removed.
1078
1079 For backward compatibility, if the SUNKEYBOARDHACK option is
1080 explicitly set, the value of KEYBOARD_HACK reverts to backquote.
1081 If the option is explicitly unset, this variable is set to
1082 empty.
1083
1084 KEYTIMEOUT
1085 The time the shell waits, in hundredths of seconds, for another
1086 key to be pressed when reading bound multi-character sequences.
1087
1088 LANG <S>
1089 This variable determines the locale category for any category
1090 not specifically selected via a variable starting with `LC_'.
1091
1092 LC_ALL <S>
1093 This variable overrides the value of the `LANG' variable and the
1094 value of any of the other variables starting with `LC_'.
1095
1096 LC_COLLATE <S>
1097 This variable determines the locale category for character col‐
1098 lation information within ranges in glob brackets and for sort‐
1099 ing.
1100
1101 LC_CTYPE <S>
1102 This variable determines the locale category for character han‐
1103 dling functions. If the MULTIBYTE option is in effect this
1104 variable or LANG should contain a value that reflects the char‐
1105 acter set in use, even if it is a single-byte character set,
1106 unless only the 7-bit subset (ASCII) is used. For example, if
1107 the character set is ISO-8859-1, a suitable value might be
1108 en_US.iso88591 (certain Linux distributions) or en_US.ISO8859-1
1109 (MacOS).
1110
1111 LC_MESSAGES <S>
1112 This variable determines the language in which messages should
1113 be written. Note that zsh does not use message catalogs.
1114
1115 LC_NUMERIC <S>
1116 This variable affects the decimal point character and thousands
1117 separator character for the formatted input/output functions and
1118 string conversion functions. Note that zsh ignores this setting
1119 when parsing floating point mathematical expressions.
1120
1121 LC_TIME <S>
1122 This variable determines the locale category for date and time
1123 formatting in prompt escape sequences.
1124
1125 LINES <S>
1126 The number of lines for this terminal session. Used for print‐
1127 ing select lists and for the line editor.
1128
1129 LISTMAX
1130 In the line editor, the number of matches to list without asking
1131 first. If the value is negative, the list will be shown if it
1132 spans at most as many lines as given by the absolute value. If
1133 set to zero, the shell asks only if the top of the listing would
1134 scroll off the screen.
1135
1136 LOGCHECK
1137 The interval in seconds between checks for login/logout activity
1138 using the watch parameter.
1139
1140 MAIL If this parameter is set and mailpath is not set, the shell
1141 looks for mail in the specified file.
1142
1143 MAILCHECK
1144 The interval in seconds between checks for new mail.
1145
1146 mailpath <S> <Z> (MAILPATH <S>)
1147 An array (colon-separated list) of filenames to check for new
1148 mail. Each filename can be followed by a `?' and a message that
1149 will be printed. The message will undergo parameter expansion,
1150 command substitution and arithmetic expansion with the variable
1151 $_ defined as the name of the file that has changed. The
1152 default message is `You have new mail'. If an element is a
1153 directory instead of a file the shell will recursively check
1154 every file in every subdirectory of the element.
1155
1156 manpath <S> <Z> (MANPATH <S> <Z>)
1157 An array (colon-separated list) whose value is not used by the
1158 shell. The manpath array can be useful, however, since setting
1159 it also sets MANPATH, and vice versa.
1160
1161 match
1162 mbegin
1163 mend Arrays set by the shell when the b globbing flag is used in pat‐
1164 tern matches. See the subsection Globbing flags in the documen‐
1165 tation for Filename Generation in zshexpn(1).
1166
1167 MATCH
1168 MBEGIN
1169 MEND Set by the shell when the m globbing flag is used in pattern
1170 matches. See the subsection Globbing flags in the documentation
1171 for Filename Generation in zshexpn(1).
1172
1173 module_path <S> <Z> (MODULE_PATH <S>)
1174 An array (colon-separated list) of directories that zmodload
1175 searches for dynamically loadable modules. This is initialized
1176 to a standard pathname, usually `/usr/local/lib/zsh/$ZSH_VER‐
1177 SION'. (The `/usr/local/lib' part varies from installation to
1178 installation.) For security reasons, any value set in the envi‐
1179 ronment when the shell is started will be ignored.
1180
1181 These parameters only exist if the installation supports dynamic
1182 module loading.
1183
1184 NULLCMD <S>
1185 The command name to assume if a redirection is specified with no
1186 command. Defaults to cat. For sh/ksh behavior, change this to
1187 :. For csh-like behavior, unset this parameter; the shell will
1188 print an error message if null commands are entered.
1189
1190 path <S> <Z> (PATH <S>)
1191 An array (colon-separated list) of directories to search for
1192 commands. When this parameter is set, each directory is scanned
1193 and all files found are put in a hash table.
1194
1195 POSTEDIT <S>
1196 This string is output whenever the line editor exits. It usu‐
1197 ally contains termcap strings to reset the terminal.
1198
1199 PROMPT <S> <Z>
1200 PROMPT2 <S> <Z>
1201 PROMPT3 <S> <Z>
1202 PROMPT4 <S> <Z>
1203 Same as PS1, PS2, PS3 and PS4, respectively.
1204
1205 prompt <S> <Z>
1206 Same as PS1.
1207
1208 PROMPT_EOL_MARK
1209 When the PROMPT_CR and PROMPT_SP options are set, the
1210 PROMPT_EOL_MARK parameter can be used to customize how the end
1211 of partial lines are shown. This parameter undergoes prompt
1212 expansion, with the PROMPT_PERCENT option set. If not set, the
1213 default behavior is equivalent to the value `%B%S%#%s%b'.
1214
1215 PS1 <S>
1216 The primary prompt string, printed before a command is read. It
1217 undergoes a special form of expansion before being displayed;
1218 see EXPANSION OF PROMPT SEQUENCES in zshmisc(1). The default is
1219 `%m%# '.
1220
1221 PS2 <S>
1222 The secondary prompt, printed when the shell needs more informa‐
1223 tion to complete a command. It is expanded in the same way as
1224 PS1. The default is `%_> ', which displays any shell constructs
1225 or quotation marks which are currently being processed.
1226
1227 PS3 <S>
1228 Selection prompt used within a select loop. It is expanded in
1229 the same way as PS1. The default is `?# '.
1230
1231 PS4 <S>
1232 The execution trace prompt. Default is `+%N:%i> ', which dis‐
1233 plays the name of the current shell structure and the line num‐
1234 ber within it. In sh or ksh emulation, the default is `+ '.
1235
1236 psvar <S> <Z> (PSVAR <S>)
1237 An array (colon-separated list) whose elements can be used in
1238 PROMPT strings. Setting psvar also sets PSVAR, and vice versa.
1239
1240 READNULLCMD <S>
1241 The command name to assume if a single input redirection is
1242 specified with no command. Defaults to more.
1243
1244 REPORTMEMORY
1245 If nonnegative, commands whose maximum resident set size
1246 (roughly speaking, main memory usage) in kilobytes is greater
1247 than this value have timing statistics reported. The format
1248 used to output statistics is the value of the TIMEFMT parameter,
1249 which is the same as for the REPORTTIME variable and the time
1250 builtin; note that by default this does not output memory usage.
1251 Appending " max RSS %M" to the value of TIMEFMT causes it to
1252 output the value that triggered the report. If REPORTTIME is
1253 also in use, at most a single report is printed for both trig‐
1254 gers. This feature requires the getrusage() system call, com‐
1255 monly supported by modern Unix-like systems.
1256
1257 REPORTTIME
1258 If nonnegative, commands whose combined user and system execu‐
1259 tion times (measured in seconds) are greater than this value
1260 have timing statistics printed for them. Output is suppressed
1261 for commands executed within the line editor, including comple‐
1262 tion; commands explicitly marked with the time keyword still
1263 cause the summary to be printed in this case.
1264
1265 REPLY This parameter is reserved by convention to pass string values
1266 between shell scripts and shell builtins in situations where a
1267 function call or redirection are impossible or undesirable. The
1268 read builtin and the select complex command may set REPLY, and
1269 filename generation both sets and examines its value when evalu‐
1270 ating certain expressions. Some modules also employ REPLY for
1271 similar purposes.
1272
1273 reply As REPLY, but for array values rather than strings.
1274
1275 RPROMPT <S>
1276 RPS1 <S>
1277 This prompt is displayed on the right-hand side of the screen
1278 when the primary prompt is being displayed on the left. This
1279 does not work if the SINGLE_LINE_ZLE option is set. It is
1280 expanded in the same way as PS1.
1281
1282 RPROMPT2 <S>
1283 RPS2 <S>
1284 This prompt is displayed on the right-hand side of the screen
1285 when the secondary prompt is being displayed on the left. This
1286 does not work if the SINGLE_LINE_ZLE option is set. It is
1287 expanded in the same way as PS2.
1288
1289 SAVEHIST
1290 The maximum number of history events to save in the history
1291 file.
1292
1293 If this is made local, it is not implicitly set to 0, but may be
1294 explicitly set locally.
1295
1296 SPROMPT <S>
1297 The prompt used for spelling correction. The sequence `%R'
1298 expands to the string which presumably needs spelling correc‐
1299 tion, and `%r' expands to the proposed correction. All other
1300 prompt escapes are also allowed.
1301
1302 The actions available at the prompt are [nyae]:
1303 n (`no') (default)
1304 Discard the correction and run the command.
1305 y (`yes')
1306 Make the correction and run the command.
1307 a (`abort')
1308 Discard the entire command line without running it.
1309 e (`edit')
1310 Resume editing the command line.
1311
1312 STTY If this parameter is set in a command's environment, the shell
1313 runs the stty command with the value of this parameter as argu‐
1314 ments in order to set up the terminal before executing the com‐
1315 mand. The modes apply only to the command, and are reset when it
1316 finishes or is suspended. If the command is suspended and con‐
1317 tinued later with the fg or wait builtins it will see the modes
1318 specified by STTY, as if it were not suspended. This (inten‐
1319 tionally) does not apply if the command is continued via `kill
1320 -CONT'. STTY is ignored if the command is run in the back‐
1321 ground, or if it is in the environment of the shell but not
1322 explicitly assigned to in the input line. This avoids running
1323 stty at every external command by accidentally exporting it.
1324 Also note that STTY should not be used for window size specifi‐
1325 cations; these will not be local to the command.
1326
1327 TERM <S>
1328 The type of terminal in use. This is used when looking up term‐
1329 cap sequences. An assignment to TERM causes zsh to re-initial‐
1330 ize the terminal, even if the value does not change (e.g.,
1331 `TERM=$TERM'). It is necessary to make such an assignment upon
1332 any change to the terminal definition database or terminal type
1333 in order for the new settings to take effect.
1334
1335 TERMINFO <S>
1336 A reference to your terminfo database, used by the `terminfo'
1337 library when the system has it; see terminfo(5). If set, this
1338 causes the shell to reinitialise the terminal, making the work‐
1339 around `TERM=$TERM' unnecessary.
1340
1341 TERMINFO_DIRS <S>
1342 A colon-seprarated list of terminfo databases, used by the `ter‐
1343 minfo' library when the system has it; see terminfo(5). This
1344 variable is only used by certain terminal libraries, in particu‐
1345 lar ncurses; see terminfo(5) to check support on your system.
1346 If set, this causes the shell to reinitialise the terminal, mak‐
1347 ing the workaround `TERM=$TERM' unnecessary. Note that unlike
1348 other colon-separated arrays this is not tied to a zsh array.
1349
1350 TIMEFMT
1351 The format of process time reports with the time keyword. The
1352 default is `%J %U user %S system %P cpu %*E total'. Recognizes
1353 the following escape sequences, although not all may be avail‐
1354 able on all systems, and some that are available may not be use‐
1355 ful:
1356
1357 %% A `%'.
1358 %U CPU seconds spent in user mode.
1359 %S CPU seconds spent in kernel mode.
1360 %E Elapsed time in seconds.
1361 %P The CPU percentage, computed as 100*(%U+%S)/%E.
1362 %W Number of times the process was swapped.
1363 %X The average amount in (shared) text space used in kilo‐
1364 bytes.
1365 %D The average amount in (unshared) data/stack space used in
1366 kilobytes.
1367 %K The total space used (%X+%D) in kilobytes.
1368 %M The maximum memory the process had in use at any time in
1369 kilobytes.
1370 %F The number of major page faults (page needed to be
1371 brought from disk).
1372 %R The number of minor page faults.
1373 %I The number of input operations.
1374 %O The number of output operations.
1375 %r The number of socket messages received.
1376 %s The number of socket messages sent.
1377 %k The number of signals received.
1378 %w Number of voluntary context switches (waits).
1379 %c Number of involuntary context switches.
1380 %J The name of this job.
1381
1382 A star may be inserted between the percent sign and flags print‐
1383 ing time (e.g., `%*E'); this causes the time to be printed in
1384 `hh:mm:ss.ttt' format (hours and minutes are only printed if
1385 they are not zero). Alternatively, `m' or `u' may be used
1386 (e.g., `%mE') to produce time output in milliseconds or
1387 microseconds, respectively.
1388
1389 TMOUT If this parameter is nonzero, the shell will receive an ALRM
1390 signal if a command is not entered within the specified number
1391 of seconds after issuing a prompt. If there is a trap on
1392 SIGALRM, it will be executed and a new alarm is scheduled using
1393 the value of the TMOUT parameter after executing the trap. If
1394 no trap is set, and the idle time of the terminal is not less
1395 than the value of the TMOUT parameter, zsh terminates. Other‐
1396 wise a new alarm is scheduled to TMOUT seconds after the last
1397 keypress.
1398
1399 TMPPREFIX
1400 A pathname prefix which the shell will use for all temporary
1401 files. Note that this should include an initial part for the
1402 file name as well as any directory names. The default is
1403 `/tmp/zsh'.
1404
1405 TMPSUFFIX
1406 A filename suffix which the shell will use for temporary files
1407 created by process substitutions (e.g., `=(list)'). Note that
1408 the value should include a leading dot `.' if intended to be
1409 interpreted as a file extension. The default is not to append
1410 any suffix, thus this parameter should be assigned only when
1411 needed and then unset again.
1412
1413 watch <S> <Z> (WATCH <S>)
1414 An array (colon-separated list) of login/logout events to
1415 report.
1416
1417 If it contains the single word `all', then all login/logout
1418 events are reported. If it contains the single word `notme',
1419 then all events are reported as with `all' except $USERNAME.
1420
1421 An entry in this list may consist of a username, an `@' followed
1422 by a remote hostname, and a `%' followed by a line (tty). Any
1423 of these may be a pattern (be sure to quote this during the
1424 assignment to watch so that it does not immediately perform file
1425 generation); the setting of the EXTENDED_GLOB option is
1426 respected. Any or all of these components may be present in an
1427 entry; if a login/logout event matches all of them, it is
1428 reported.
1429
1430 For example, with the EXTENDED_GLOB option set, the following:
1431
1432 watch=('^(pws|barts)')
1433
1434 causes reports for activity associated with any user other than
1435 pws or barts.
1436
1437 WATCHFMT
1438 The format of login/logout reports if the watch parameter is
1439 set. Default is `%n has %a %l from %m'. Recognizes the follow‐
1440 ing escape sequences:
1441
1442 %n The name of the user that logged in/out.
1443
1444 %a The observed action, i.e. "logged on" or "logged off".
1445
1446 %l The line (tty) the user is logged in on.
1447
1448 %M The full hostname of the remote host.
1449
1450 %m The hostname up to the first `.'. If only the IP address
1451 is available or the utmp field contains the name of an
1452 X-windows display, the whole name is printed.
1453
1454 NOTE: The `%m' and `%M' escapes will work only if there
1455 is a host name field in the utmp on your machine. Other‐
1456 wise they are treated as ordinary strings.
1457
1458 %S (%s)
1459 Start (stop) standout mode.
1460
1461 %U (%u)
1462 Start (stop) underline mode.
1463
1464 %B (%b)
1465 Start (stop) boldface mode.
1466
1467 %t
1468 %@ The time, in 12-hour, am/pm format.
1469
1470 %T The time, in 24-hour format.
1471
1472 %w The date in `day-dd' format.
1473
1474 %W The date in `mm/dd/yy' format.
1475
1476 %D The date in `yy-mm-dd' format.
1477
1478 %D{string}
1479 The date formatted as string using the strftime function,
1480 with zsh extensions as described by EXPANSION OF PROMPT
1481 SEQUENCES in zshmisc(1).
1482
1483 %(x:true-text:false-text)
1484 Specifies a ternary expression. The character following
1485 the x is arbitrary; the same character is used to sepa‐
1486 rate the text for the "true" result from that for the
1487 "false" result. Both the separator and the right paren‐
1488 thesis may be escaped with a backslash. Ternary expres‐
1489 sions may be nested.
1490
1491 The test character x may be any one of `l', `n', `m' or
1492 `M', which indicate a `true' result if the corresponding
1493 escape sequence would return a non-empty value; or it may
1494 be `a', which indicates a `true' result if the watched
1495 user has logged in, or `false' if he has logged out.
1496 Other characters evaluate to neither true nor false; the
1497 entire expression is omitted in this case.
1498
1499 If the result is `true', then the true-text is formatted
1500 according to the rules above and printed, and the
1501 false-text is skipped. If `false', the true-text is
1502 skipped and the false-text is formatted and printed.
1503 Either or both of the branches may be empty, but both
1504 separators must be present in any case.
1505
1506 WORDCHARS <S>
1507 A list of non-alphanumeric characters considered part of a word
1508 by the line editor.
1509
1510 ZBEEP If set, this gives a string of characters, which can use all the
1511 same codes as the bindkey command as described in the zsh/zle
1512 module entry in zshmodules(1), that will be output to the termi‐
1513 nal instead of beeping. This may have a visible instead of an
1514 audible effect; for example, the string `\e[?5h\e[?5l' on a
1515 vt100 or xterm will have the effect of flashing reverse video on
1516 and off (if you usually use reverse video, you should use the
1517 string `\e[?5l\e[?5h' instead). This takes precedence over the
1518 NOBEEP option.
1519
1520 ZDOTDIR
1521 The directory to search for shell startup files (.zshrc, etc),
1522 if not $HOME.
1523
1524 zle_bracketed_paste
1525 Many terminal emulators have a feature that allows applications
1526 to identify when text is pasted into the terminal rather than
1527 being typed normally. For ZLE, this means that special charac‐
1528 ters such as tabs and newlines can be inserted instead of invok‐
1529 ing editor commands. Furthermore, pasted text forms a single
1530 undo event and if the region is active, pasted text will replace
1531 the region.
1532
1533 This two-element array contains the terminal escape sequences
1534 for enabling and disabling the feature. These escape sequences
1535 are used to enable bracketed paste when ZLE is active and dis‐
1536 able it at other times. Unsetting the parameter has the effect
1537 of ensuring that bracketed paste remains disabled.
1538
1539 zle_highlight
1540 An array describing contexts in which ZLE should highlight the
1541 input text. See Character Highlighting in zshzle(1).
1542
1543 ZLE_LINE_ABORTED
1544 This parameter is set by the line editor when an error occurs.
1545 It contains the line that was being edited at the point of the
1546 error. `print -zr -- $ZLE_LINE_ABORTED' can be used to recover
1547 the line. Only the most recent line of this kind is remembered.
1548
1549 ZLE_REMOVE_SUFFIX_CHARS
1550 ZLE_SPACE_SUFFIX_CHARS
1551 These parameters are used by the line editor. In certain cir‐
1552 cumstances suffixes (typically space or slash) added by the com‐
1553 pletion system will be removed automatically, either because the
1554 next editing command was not an insertable character, or because
1555 the character was marked as requiring the suffix to be removed.
1556
1557 These variables can contain the sets of characters that will
1558 cause the suffix to be removed. If ZLE_REMOVE_SUFFIX_CHARS is
1559 set, those characters will cause the suffix to be removed; if
1560 ZLE_SPACE_SUFFIX_CHARS is set, those characters will cause the
1561 suffix to be removed and replaced by a space.
1562
1563 If ZLE_REMOVE_SUFFIX_CHARS is not set, the default behaviour is
1564 equivalent to:
1565
1566 ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'
1567
1568 If ZLE_REMOVE_SUFFIX_CHARS is set but is empty, no characters
1569 have this behaviour. ZLE_SPACE_SUFFIX_CHARS takes precedence,
1570 so that the following:
1571
1572 ZLE_SPACE_SUFFIX_CHARS=$'&|'
1573
1574 causes the characters `&' and `|' to remove the suffix but to
1575 replace it with a space.
1576
1577 To illustrate the difference, suppose that the option
1578 AUTO_REMOVE_SLASH is in effect and the directory DIR has just
1579 been completed, with an appended /, following which the user
1580 types `&'. The default result is `DIR&'. With ZLE_REMOVE_SUF‐
1581 FIX_CHARS set but without including `&' the result is `DIR/&'.
1582 With ZLE_SPACE_SUFFIX_CHARS set to include `&' the result is
1583 `DIR &'.
1584
1585 Note that certain completions may provide their own suffix
1586 removal or replacement behaviour which overrides the values
1587 described here. See the completion system documentation in zsh‐
1588 compsys(1).
1589
1590 ZLE_RPROMPT_INDENT <S>
1591 If set, used to give the indentation between the right hand side
1592 of the right prompt in the line editor as given by RPS1 or
1593 RPROMPT and the right hand side of the screen. If not set, the
1594 value 1 is used.
1595
1596 Typically this will be used to set the value to 0 so that the
1597 prompt appears flush with the right hand side of the screen.
1598 This is not the default as many terminals do not handle this
1599 correctly, in particular when the prompt appears at the extreme
1600 bottom right of the screen. Recent virtual terminals are more
1601 likely to handle this case correctly. Some experimentation is
1602 necessary.
1603
1604
1605
1606zsh 5.8 February 14, 2020 ZSHPARAM(1)