Manual Pages for UNIX Darwin command on man zshall
MyWebUniversity

Manual Pages for UNIX Darwin command on man zshall

ZSHALL(1) ZSHALL(1)

NAME

zshall - the Z shell meta-man page

OOVVEERRVVIIEEWW Because zsh contains many features, the zsh manual has been split into

a number of sections. This manual page includes all the separate man-

ual pages in the following order: zshmisc Anything not fitting into the other sections zshexpn Zsh command and parameter expansion zshparam Zsh parameters zshoptions Zsh options

zshbuiltins Zsh built-in functions

zshzle Zsh command line editing zshcompwid Zsh completion widgets zshcompsys Zsh completion system zshcompctl Zsh completion control zshmodules Zsh loadable modules

zshzftpsys Zsh built-in FTP client

DESCRIPTION

Zsh is a UNIX command interpreter (shell) usable as an interactive login shell and as a shell script command processor. Of the standard shells, zsh most closely resembles kksshh but includes many enhancements. Zsh has command line editing, builtin spelling correction, programmable

command completion, shell functions (with autoloading), a history mech-

anism, and a host of other features. AUTHOR Zsh was originally written by Paul Falstad <>. Zsh is now

maintained by the members of the zsh-workers mailing list < eerrss@@ssuunnssiittee..ddkk>>. The development is currently coordinated by Peter

Stephenson <>. The coordinator can be contacted at < nnaattoorr@@zzsshh..oorrgg>>, but matters relating to the code should generally go to the mailing list. AVAILABILITY Zsh is available from the following anonymous FTP sites. These mirror sites are kept frequently up to date. The sites marked with (H) may be mirroring ffttpp..ccss..eellttee..hhuu instead of the primary site. Primary site ffttpp::////ffttpp..zzsshh..oorrgg//ppuubb//zzsshh// hhttttpp::////wwwwww..zzsshh..oorrgg//ppuubb//zzsshh// Australia ffttpp::////ffttpp..zzsshh..oorrgg//ppuubb//zzsshh// hhttttpp::////wwwwww..zzsshh..oorrgg//ppuubb//zzsshh// Denmark ffttpp::////ssuunnssiittee..ddkk//ppuubb//uunniixx//sshheellllss//zzsshh// Finland ffttpp::////ffttpp..ffuunneett..ffii//ppuubb//uunniixx//sshheellllss//zzsshh// Germany

ffttpp::////ffttpp..ffuu-bbeerrlliinn..ddee//ppuubb//uunniixx//sshheellllss//zzsshh// (H)

ffttpp::////ffttpp..ggmmdd..ddee//ppaacckkaaggeess//zzsshh//

ffttpp::////ffttpp..uunnii-ttrriieerr..ddee//ppuubb//uunniixx//sshheellll//zzsshh//

Hungary ffttpp::////ffttpp..ccss..eellttee..hhuu//ppuubb//zzsshh// hhttttpp::////wwwwww..ccss..eellttee..hhuu//ppuubb//zzsshh// ffttpp::////ffttpp..kkffkkii..hhuu//ppuubb//ppaacckkaaggeess//zzsshh// Israel ffttpp::////ffttpp..mmaatthh..tteecchhnniioonn..aacc..iill//ppuubb//zzsshh// hhttttpp::////wwwwww..mmaatthh..tteecchhnniioonn..aacc..iill//ppuubb//zzsshh// Japan ffttpp::////ffttpp..wwiinn..nnee..jjpp//ppuubb//sshheellll//zzsshh// ffttpp::////ffttpp..aayyaammuurraa..oorrgg//ppuubb//zzsshh// Korea ffttpp::////lliinnuuxx..ssaarraanngg..nneett//mmiirrrroorr//ssyysstteemm//sshheellll//zzsshh// Netherlands ffttpp::////ffttpp..ddeemmoonn..nnll//ppuubb//mmiirrrroorrss//zzsshh// Norway ffttpp::////ffttpp..uuiitt..nnoo//ppuubb//uunniixx//sshheellllss//zzsshh// Poland ffttpp::////ssuunnssiittee..iiccmm..eedduu..ppll//ppuubb//uunniixx//sshheellllss//zzsshh// Romania ffttpp::////ffttpp..rrooeedduu..nneett//ppuubb//mmiirrrroorrss//ffttpp..zzsshh..oorrgg//ppuubb//zzsshh// ffttpp::////ffttpp..kkaappppaa..rroo//ppuubb//mmiirrrroorrss//ffttpp..zzsshh..oorrgg//ppuubb//zzsshh// Slovenia ffttpp::////ffttpp..ssiiooll..nneett//mmiirrrroorrss//zzsshh// Sweden ffttpp::////ffttpp..llyyssaattoorr..lliiuu..ssee//ppuubb//uunniixx//zzsshh// UK ffttpp::////ffttpp..nneett..lluutt..aacc..uukk//zzsshh// ffttpp::////ssuunnssiittee..oorrgg..uukk//ppaacckkaaggeess//zzsshh// USA ffttpp::////uuiiaarrcchhiivvee..uuiiuucc..eedduu//mmiirrrroorrss//ffttpp//ffttpp..zzsshh..oorrgg//ppuubb// ffttpp::////ffttpp..rrggee..ccoomm//ppuubb//sshheellllss//zzsshh// hhttttpp::////zzsshh..ddiissiilllluussiioonn..oorrgg// hhttttpp::////ffooaadd..oorrgg//zzsshh//

The up-to-date source code is available via anonymous CVS from Source-

forge. See hhttttpp::////ssoouurrcceeffoorrggee..nneett//pprroojjeeccttss//zzsshh// for details. MMAAIILLIINNGG LLIISSTTSS Zsh has 3 mailing lists:

<>

Announcements about releases, major changes in the shell and the monthly posting of the Zsh FAQ. (moderated)

<>

User discussions.

<>

Hacking, development, bug reports and patches. To subscribe or unsubscribe, send mail to the associated administrative address for the mailing list.

<>

<>

<>

<>

<>

<>

YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED. All

submissions to zzsshh-aannnnoouunnccee are automatically forwarded to zzsshh-uusseerrss.

All submissions to zzsshh-uusseerrss are automatically forwarded to zzsshh-wwoorrkk-

eerrss. If you have problems subscribing/unsubscribing to any of the mailing

lists, send mail to <>. The mailing lists are main-

tained by Karsten Thygesen <>. The mailing lists are archived; the archives can be accessed via the

administrative addresses listed above. There is also a hypertext ar-

chive, maintained by Geoff Wing <>, available at hhttttpp::////wwwwww..zzsshh..oorrgg//mmllaa//. TTHHEE ZZSSHH FFAAQQ Zsh has a list of Frequently Asked Questions (FAQ), maintained by Peter Stephenson <>. It is regularly posted to the newsgroup

ccoommpp..uunniixx..sshheellll and the zzsshh-aannnnoouunnccee mailing list. The latest version

can be found at any of the Zsh FTP sites, or at

hhttttpp::////wwwwww..zzsshh..oorrgg//FFAAQQ//. The contact address for FAQ-related matters

is <>. TTHHEE ZZSSHH WWEEBB PPAAGGEE Zsh has a web page which is located at hhttttpp::////wwwwww..zzsshh..oorrgg//. This is maintained by Karsten Thygesen <>, of SunSITE Denmark.

The contact address for web-related matters is <>.

TTHHEE ZZSSHH UUSSEERRGGUUIIDDEE A userguide is currently in preparation. It is intended to complement the manual, with explanations and hints on issues where the manual can be cabbalistic, hierographic, or downright mystifying (for example, the word `hierographic' does not exist). It can be viewed in its current

state at hhttttpp::////zzsshh..ssuunnssiittee..ddkk//GGuuiiddee//. At the time of writing, chap-

ters dealing with startup files and their contents and the new comple-

tion system were essentially complete. TTHHEE ZZSSHH WWIIKKII A `wiki' website for zsh has been created at hhttttpp::////wwwwww..zzsshhwwiikkii..oorrgg//. This is a site which can be added to and modified directly by users

without any special permission. You can add your own zsh tips and con-

figurations. IINNVVOOCCAATTIIOONN OOPPTTIIOONNSS

The following flags are interpreted by the shell when invoked to deter-

mine where the shell will read commands from:

-cc Take the first argument as a command to execute, rather than

reading commands from a script or standard input. If any fur-

ther arguments are given, the first one is assigned to $$00,

rather than being used as a positional parameter.

-ii Force shell to be interactive.

-ss Force shell to read commands from the standard input. If the -ss

flag is not present and an argument is given, the first argument is taken to be the pathname of a script to execute. After the first one or two arguments have been appropriated as described above, the remaining arguments are assigned to the positional parameters. For further options, which are common to invocation and the sseett builtin, see zshoptions(1).

Options may be specified by name using the -oo option. -oo acts like a

single-letter option, but takes a following string as the option name.

For example,

zzsshh -xx -oo sshhwwoorrddsspplliitt ssccrr

runs the script ssccrr, setting the XXTTRRAACCEE option by the corresponding

letter `-xx' and the SSHHWWOORRDDSSPPLLIITT option by name. Options may be

turned off by name by using ++oo instead of -oo. -oo can be stacked up

with preceding single-letter options, so for example `-xxoo sshhwwoorrddsspplliitt'

or `-xxoosshhwwoorrddsspplliitt' is equivalent to `-xx -oo sshhwwoorrddsspplliitt'.

Options may also be specified by name in GNU long option style,

`--option-name'. When this is done, `-' characters in the option name

are permitted: they are translated into `', and thus ignored. So, for

example, `zzsshh --sshh-wwoorrdd-sspplliitt' invokes zsh with the SSHHWWOORRDDSSPPLLIITT

option turned on. Like other option syntaxes, options can be turned

off by replacing the initial `-' with a `++'; thus `++-sshh-wwoorrdd-sspplliitt' is

equivalent to `--nnoo-sshh-wwoorrdd-sspplliitt'. Unlike other option syntaxes,

GNU-style long options cannot be stacked with any other options, so for

example `-xx-sshhwwoorrddsspplliitt' is an error, rather than being treated like

`-xx --sshhwwoorrddsspplliitt'.

The special GNU-style option `--vveerrssiioonn' is handled; it sends to stan-

dard output the shell's version information, then exits successfully.

`--hheellpp' is also handled; it sends to standard output a list of options

that can be used when invoking the shell, then exits successfully. Option processing may be finished, allowing following arguments that

start with `-' or `++' to be treated as normal arguments, in two ways.

Firstly, a lone `-' (or `++') as an argument by itself ends option pro-

cessing. Secondly, a special option `--' (or `++-'), which may be spec-

ified on its own (which is the standard POSIX usage) or may be stacked

with preceding options (so `-xx-' is equivalent to `-xx --'). Options

are not permitted to be stacked after `--' (so `-xx-ff' is an error), but

note the GNU-style option form discussed above, where `--sshhwwoorrddsspplliitt'

is permitted and does not end option processing.

Except when the sshh/kksshh emulation single-letter options are in effect,

the option `-bb' (or `++bb') ends option processing. `-bb' is like `--',

except that further single-letter options can be stacked after the `-bb'

and will take effect as normal. CCOOMMPPAATTIIBBIILLIITTYY

Zsh tries to emulate sshh or kksshh when it is invoked as sshh or kksshh respec-

tively; more precisely, it looks at the first letter of the name by which it was invoked, excluding any initial `rr' (assumed to stand for `restricted'), and if that is `ss' or `kk' it will emulate sshh or kksshh. Furthermore, if invoked as ssuu (which happens on certain systems when the shell is executed by the ssuu command), the shell will try to find an

alternative name from the SSHHEELLLL environment variable and perform emula-

tion based on that.

In sshh and kksshh compatibility modes the following parameters are not spe-

cial and not initialized by the shell: AARRGGCC, aarrggvv, ccddppaatthh, ffiiggnnoorree, ffppaatthh, HHIISSTTCCHHAARRSS, mmaaiillppaatthh, MMAANNPPAATTHH, mmaannppaatthh, ppaatthh, pprroommpptt, PPRROOMMPPTT, PPRROOMMPPTT22, PPRROOMMPPTT33, PPRROOMMPPTT44, ppssvvaarr, ssttaattuuss, wwaattcchh. The usual zsh startup/shutdown scripts are not executed. Login shells

source //eettcc//pprrooffiillee followed by $$HHOOMMEE//..pprrooffiillee. If the EENNVV environment

variable is set on invocation, $$EENNVV is sourced after the profile

scripts. The value of EENNVV is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. Note that the PPRRIIVVIILLEEGGEEDD option also affects the execution of startup files. The following options are set if the shell is invoked as sshh or kksshh:

NNOOBBAADDPPAATTTTEERRNN, NNOOBBAANNGGHHIISSTT, NNOOBBGGNNIICCEE, NNOOEEQQUUAALLSS, NNOOFFUUNNCC-

TTIIOONNAARRGGZZEERROO, GGLLOOBBSSUUBBSSTT, NNOOGGLLOOBBAALLEEXXPPOORRTT, NNOOHHUUPP, IINNTTEERRAACCTTIIVVEECCOOMM-

MMEENNTTSS, KKSSHHAARRRRAAYYSS, NNOOMMUULLTTIIOOSS, NNOONNOOMMAATTCCHH, NNOONNOOTTIIFFYY, PPOOSSIIXXBBUUIILLTTIINNSS, NNOOPPRROOMMPPTTPPEERRCCEENNTT, RRMMSSTTAARRSSIILLEENNTT, SSHHFFIILLEEEEXXPPAANNSSIIOONN, SSHHGGLLOOBB, SSHHOOPPTTIIOONNLLEETTTTEERRSS, SSHHWWOORRDDSSPPLLIITT. Additionally the BBSSDDEECCHHOO and IIGGNNOORREEBBRRAACCEESS options are set if zsh is invoked as sshh. Also, the

KKSSHHOOPPTTIIOONNPPRRIINNTT, LLOOCCAALLOOPPTTIIOONNSS, PPRROOMMPPTTBBAANNGG, PPRROOMMPPTTSSUUBBSSTT and SSIINN-

GGLLEELLIINNEEZZLLEE options are set if zsh is invoked as kksshh. RREESSTTRRIICCTTEEDD SSHHEELLLL When the basename of the command used to invoke zsh starts with the

letter `rr' or the `-rr' command line option is supplied at invocation,

the shell becomes restricted. Emulation mode is determined after stripping the letter `rr' from the invocation name. The following are disabled in restricted mode: +o changing directories with the ccdd builtin +o changing or unsetting the PPAATTHH, ppaatthh, MMOODDUULLEEPPAATTHH, mmoodduulleeppaatthh,

SHELL HISTFILE, HISTSIZE GID, EGID UID, EUID USERNAME,

LLDDLLIIBBRRAARRYYPPAATTHH, LLDDAAOOUUTTLLIIBBRRAARRYYPPAATTHH, LLDDPPRREELLOOAADD and LLDDAAOOUUTTPPRREELLOOAADD parameters +o specifying command names containing // +o specifying command pathnames using hhaasshh +o redirecting output to files +o using the eexxeecc builtin command to replace the shell with another command

+o using jjoobbss -ZZ to overwrite the shell process' argument and envi-

ronment space

+o using the AARRGGVV00 parameter to override aarrggvv[[00]] for external com-

mands +o turning off restricted mode with sseett ++rr or uunnsseettoopptt RREESSTTRRIICCTTEEDD These restrictions are enforced after processing the startup files.

The startup files should set up PPAATTHH to point to a directory of com-

mands which can be safely invoked in the restricted environment. They may also add further restrictions by disabling selected builtins. Restricted mode can also be activated any time by setting the RREESSTTRRIICCTTEEDD option. This immediately enables all the restrictions described above even if the shell still has not processed all startup files. STARTUP/SHUTDOWN FILES Commands are first read from //eettcc//zzsshheennvv; this cannot be overridden. Subsequent behaviour is modified by the RRCCSS and GGLLOOBBAALLRRCCSS options; the former affects all startup files, while the second only affects those in the //eettcc directory. If one of the options is unset at any point, any subsequent startup file(s) of the corresponding type will not be

read. It is also possible for a file in $$ZZDDOOTTDDIIRR to re-enable

GGLLOOBBAALLRRCCSS. Both RRCCSS and GGLLOOBBAALLRRCCSS are set by default.

Commands are then read from $$ZZDDOOTTDDIIRR//..zzsshheennvv. If the shell is a login

shell, commands are read from //eettcc//zzpprrooffiillee and then $$ZZDDOOTTDDIIRR//..zzpprroo-

ffiillee. Then, if the shell is interactive, commands are read from

//eettcc//zzsshhrrcc and then $$ZZDDOOTTDDIIRR//..zzsshhrrcc. Finally, if the shell is a login

shell, //eettcc//zzllooggiinn and $$ZZDDOOTTDDIIRR//..zzllooggiinn are read.

When a login shell exits, the files $$ZZDDOOTTDDIIRR//..zzllooggoouutt and then

//eettcc//zzllooggoouutt are read. This happens with either an explicit exit via

the eexxiitt or llooggoouutt commands, or an implicit exit by reading end-of-file

from the terminal. However, if the shell terminates due to eexxeecc'ing another process, the logout files are not read. These are also affected by the RRCCSS and GGLLOOBBAALLRRCCSS options. Note also that the RRCCSS option affects the saving of history files, i.e. if RRCCSS is unset when the shell exits, no history file will be saved. If ZZDDOOTTDDIIRR is unset, HHOOMMEE is used instead. Those files listed above as

being in //eettcc may be in another directory, depending on the installa-

tion. As //eettcc//zzsshheennvv is run for all instances of zsh, it is important that it be kept as small as possible. In particular, it is a good idea to put code that does not need to be run for every single shell behind a test

of the form `iiff [[[[ -oo rrccss ]]]];; tthheenn ......' so that it will not be executed

when zsh is invoked with the `-ff' option.

Any of these files may be pre-compiled with the zzccoommppiillee builtin com-

mand (see zshbuiltins(1)). If a compiled file exists (named for the

original file plus the ..zzwwcc extension) and it is newer than the origi-

nal file, the compiled file will be used instead. ZSHMISC(1) ZSHMISC(1)

NAME

zshmisc - everything and then some

SSIIMMPPLLEE CCOOMMMMAANNDDSS && PPIIPPEELLIINNEESS

A simple command is a sequence of optional parameter assignments fol-

lowed by blank-separated words, with optional redirections inter-

spersed. The first word is the command to be executed, and the remain-

ing words, if any, are arguments to the command. If a command name is given, the parameter assignments modify the environment of the command when it is executed. The value of a simple command is its exit status, or 128 plus the signal number if terminated by a signal. For example, eecchhoo ffoooo is a simple command with arguments. A pipeline is either a simple command, or a sequence of two or more simple commands where each command is separated from the next by `||' or `||&&'. Where commands are separated by `||', the standard output of the first command is connected to the standard input of the next. `||&&' is shorthand for `22>>&&11 ||', which connects both the standard output and the standard error of the command to the standard input of the next. The

value of a pipeline is the value of the last command, unless the pipe-

line is preceded by `!!' in which case the value is the logical inverse of the value of the last command. For example, eecchhoo ffoooo || sseedd ''ss//ffoooo//bbaarr//'' is a pipeline, where the output (`ffoooo' plus a newline) of the first command will be passed to the input of the second. If a pipeline is preceded by `ccoopprroocc', it is executed as a coprocess; a

two-way pipe is established between it and the parent shell. The shell

can read from or write to the coprocess by means of the `>>&&pp' and `<<&&pp'

redirection operators or with `pprriinntt -pp' and `rreeaadd -pp'. A pipeline

cannot be preceded by both `ccoopprroocc' and `!!'. If job control is active,

the coprocess can be treated in other than input and output as an ordi-

nary background job. A sublist is either a single pipeline, or a sequence of two or more pipelines separated by `&&&&' or `||||'. If two pipelines are separated by `&&&&', the second pipeline is executed only if the first succeeds (returns a zero value). If two pipelines are separated by `||||', the second is executed only if the first fails (returns a nonzero value). Both operators have equal precedence and are left associative. The value of the sublist is the value of the last pipeline executed. For example, ddmmeessgg || ggrreepp ppaanniicc &&&& pprriinntt yyeess

is a sublist consisting of two pipelines, the second just a simple com-

mand which will be executed if and only if the ggrreepp command returns a zero value. If it does not, the value of the sublist is that return value, else it is the value returned by the pprriinntt (almost certainly zero). A list is a sequence of zero or more sublists, in which each sublist is terminated by `;;', `&&', `&&||', `&&!!', or a newline. This terminator may optionally be omitted from the last sublist in the list when the list

appears as a complex command inside `((...))' or `{{...}}'. When a sub-

list is terminated by `;;' or newline, the shell waits for it to finish before executing the next sublist. If a sublist is terminated by a `&&', `&&||', or `&&!!', the shell executes the last pipeline in it in the background, and does not wait for it to finish (note the difference from other shells which execute the whole sublist in the background). A backgrounded pipeline returns a status of zero.

More generally, a list can be seen as a set of any shell commands what-

soever, including the complex commands below; this is implied wherever

the word `list' appears in later descriptions. For example, the com-

mands in a shell function form a special sort of list. PPRREECCOOMMMMAANNDD MMOODDIIFFIIEERRSS A simple command may be preceded by a precommand modifier, which will alter how the command is interpreted. These modifiers are shell builtin commands with the exception of nnooccoorrrreecctt which is a reserved word.

- The command is executed with a `-' prepended to its aarrggvv[[00]]

string. nnoogglloobb Filename generation (globbing) is not performed on any of the words. nnooccoorrrreecctt Spelling correction is not done on any of the words. This must

appear before any other precommand modifier, as it is inter-

preted immediately, before any parsing is done. It has no

effect in non-interactive shells.

eexxeecc The command is executed in the parent shell without forking. ccoommmmaanndd The command word is taken to be the name of an external command, rather than a shell function or builtin. bbuuiillttiinn The command word is taken to be the name of a builtin command, rather than a shell function or external command. CCOOMMPPLLEEXX CCOOMMMMAANNDDSS A complex command in zsh is one of the following: iiff list tthheenn list [ eelliiff list tthheenn list ] ... [ eellssee list ] ffii The iiff list is executed, and if it returns a zero exit status, the tthheenn list is executed. Otherwise, the eelliiff list is executed and if its value is zero, the tthheenn list is executed. If each eelliiff list returns nonzero, the eellssee list is executed. ffoorr name ... [ iinn word ... ] term ddoo list ddoonnee where term is at least one newline or ;;. Expand the list of

words, and set the parameter name to each of them in turn, exe-

cuting list each time. If the iinn word is omitted, use the posi-

tional parameters instead of the words. More than one parameter name can appear before the list of words. If N names are given, then on each execution of the loop the next NN words are assigned to the corresponding parameters. If there are more names than remaining words, the remaining parameters are each set to the empty string. Execution of the loop ends when there is no remaining word to assign to the first name. It is only possible for iinn to appear as the first name in the list, else it will be treated as marking the end of the list. ffoorr (((( [expr1] ;; [expr2] ;; [expr3] )))) ddoo list ddoonnee

The arithmetic expression expr1 is evaluated first (see the sec-

tion `Arithmetic Evaluation'). The arithmetic expression expr2 is repeatedly evaluated until it evaluates to zero and when

non-zero, list is executed and the arithmetic expression expr3

evaluated. If any expression is omitted, then it behaves as if it evaluated to 1. wwhhiillee list ddoo list ddoonnee Execute the ddoo list as long as the wwhhiillee list returns a zero exit status. uunnttiill list ddoo list ddoonnee Execute the ddoo list as long as uunnttiill list returns a nonzero exit status. rreeppeeaatt word ddoo list ddoonnee word is expanded and treated as an arithmetic expression, which must evaluate to a number n. list is then executed n times. ccaassee word iinn [ [((] pattern [ || pattern ] ... )) list (;;;;|;;&&) ] ... eessaacc Execute the list associated with the first pattern that matches word, if any. The form of the patterns is the same as that used for filename generation. See the section `Filename Generation'. If the list that is executed is terminated with ;;&& rather than ;;;;, the following list is also executed. This continues until either a list is terminated with ;;;; or the eessaacc is reached. sseelleecctt name [ iinn word ... term ] ddoo list ddoonnee where term is one or more newline or ;; to terminate the words. Print the set of words, each preceded by a number. If the iinn word is omitted, use the positional parameters. The PPRROOMMPPTT33 prompt is printed and a line is read from the line editor if the shell is interactive and that is active, or else standard input. If this line consists of the number of one of the listed words, then the parameter name is set to the word corresponding to this number. If this line is empty, the selection list is printed again. Otherwise, the value of the parameter name is set to null. The contents of the line read from standard input is

saved in the parameter RREEPPLLYY. list is executed for each selec-

tion until a break or end-of-file is encountered.

(( list )) Execute list in a subshell. Traps set by the ttrraapp builtin are reset to their default values while executing list. {{ list }} Execute list.

{{ try-list }} aallwwaayyss {{ always-list }}

First execute try-list. Regardless of errors, or bbrreeaakk, ccoonn-

ttiinnuuee, or rreettuurrnn commands encountered within try-list, execute

always-list. Execution then continues from the result of the

execution of try-list; in other words, any error, or bbrreeaakk, ccoonn-

ttiinnuuee, or rreettuurrnn command is treated in the normal way, as if

always-list were not present. The two chunks of code are

referred to as the `try block' and the `always block'. Optional newlines or semicolons may appear after the aallwwaayyss; note, however, that they may not appear between the preceeding closing brace and the aallwwaayyss. An `error' in this context is a condition such as a syntax error

which causes the shell to abort execution of the current func-

tion, script, or list. Syntax errors encountered while the

shell is parsing the code do not cause the always-list to be

executed. For example, an erroneously constructed iiff block in

ttrryy-lliisstt would cause the shell to abort during parsing, so that

aallwwaayyss-lliisstt would not be executed, while an erroneous substitu-

tion such as $${{**ffoooo**}} would cause a run-time error, after which

aallwwaayyss-lliisstt would be executed.

An error condition can be tested and reset with the special

integer variable TTRRYYBBLLOOCCKKEERRRROORR. Outside an aallwwaayyss-lliisstt the

value is irrelevant, but it is initialised to -11. Inside

aallwwaayyss-lliisstt, the value is 1 if an error occurred in the

ttrryy-lliisstt, else 0. If TTRRYYBBLLOOCCKKEERRRROORR is set to 0 during the

aallwwaayyss-lliisstt, the error condition caused by the ttrryy-lliisstt is

reset, and shell execution continues normally after the end of

aallwwaayyss-lliisstt. Altering the value during the ttrryy-lliisstt is not use-

ful (unless this forms part of an enclosing aallwwaayyss block).

Regardless of TTRRYYBBLLOOCCKKEERRRROORR, after the end of aallwwaayyss-lliisstt the

normal shell status $$?? is the value returned from aallwwaayyss-lliisstt.

This will be non-zero if there was an error, even if

TTRRYYBBLLOOCCKKEERRRROORR was set to zero. The following executes the given code, ignoring any errors it

causes. This is an alternative to the usual convention of pro-

tecting code by executing it in a subshell. {{

## ccooddee wwhhiicchh mmaayy ccaauussee aann eerrrroorr

}} aallwwaayyss {{

## TThhiiss ccooddee iiss eexxeeccuutteedd rreeggaarrddlleessss ooff tthhee eerrrroorr..

(((( TTRRYYBBLLOOCCKKEERRRROORR == 00 )))) }}

# The error condition has been reset.

An eexxiitt command encountered in ttrryy-lliisstt does not cause the exe-

cution of always-list. Instead, the shell exits immediately

after any EEXXIITT trap has been executed. ffuunnccttiioonn word ... [ (()) ] [ term ] {{ list }} word ... (()) [ term ] {{ list }} word ... (()) [ term ] command where term is one or more newline or ;;. Define a function which is referenced by any one of word. Normally, only one word is provided; multiple words are usually only useful for setting traps. The body of the function is the list between the {{ and }}. See the section `Functions'. If the option SSHHGGLLOOBB is set for compatibility with other shells, then whitespace may appear between between the left and right parentheses when there is a single word; otherwise, the parentheses will be treated as forming a globbing pattern in that case. ttiimmee [ pipeline ] The pipeline is executed, and timing statistics are reported on

the standard error in the form specified by the TTIIMMEEFFMMTT parame-

ter. If pipeline is omitted, print statistics about the shell process and its children. [[[[ exp ]]]] Evaluates the conditional expression exp and return a zero exit status if it is true. See the section `Conditional Expressions' for a description of exp. AALLTTEERRNNAATTEE FFOORRMMSS FFOORR CCOOMMPPLLEEXX CCOOMMMMAANNDDSS Many of zsh's complex commands have alternate forms. These particular versions of complex commands should be considered deprecated and may be removed in the future. The versions in the previous section should be preferred instead. The short versions below only work if sublist is of the form `{{ list }}'

or if the SSHHOORRTTLLOOOOPPSS option is set. For the iiff, wwhhiillee and uunnttiill com-

mands, in both these cases the test part of the loop must also be suit-

ably delimited, such as by `[[[[ ...... ]]]]' or `(((( ...... ))))', else the end of the test will not be recognized. For the ffoorr, rreeppeeaatt, ccaassee and sseelleecctt commands no such special form for the arguments is necessary, but the other condition (the special form of sublist or use of the SSHHOORRTTLLOOOOPPSS option) still applies. iiff list {{ list }} [ eelliiff list {{ list }} ] ... [ eellssee {{ list }} ] An alternate form of iiff. The rules mean that

iiff [[[[ -oo iiggnnoorreebbrraacceess ]]]] {{

pprriinntt yyeess }} works, but

iiff ttrruuee {{ ## DDooeess nnoott wwoorrkk!!

pprriinntt yyeess }} does not, since the test is not suitably delimited. iiff list sublist A short form of the alternate `if'. The same limitations on the form of list apply as for the previous form. ffoorr name ... (( word ... )) sublist A short form of ffoorr. ffoorr name ... [ iinn word ... ] term sublist where term is at least one newline or ;;. Another short form of ffoorr. ffoorr (((( [expr1] ;; [expr2] ;; [expr3] )))) sublist A short form of the arithmetic ffoorr command. ffoorreeaacchh name ... (( word ... )) list eenndd Another form of ffoorr. wwhhiillee list {{ list }} An alternative form of wwhhiillee. Note the limitations on the form of list mentioned above. uunnttiill list {{ list }} An alternative form of uunnttiill. Note the limitations on the form of list mentioned above. rreeppeeaatt word sublist This is a short form of rreeppeeaatt. ccaassee word {{ [ [((] pattern [ || pattern ] ... )) list (;;;;|;;&&) ] ... }} An alternative form of ccaassee. sseelleecctt name [ iinn word term ] sublist where term is at least one newline or ;;. A short form of sseelleecctt. RREESSEERRVVEEDD WWOORRDDSS The following words are recognized as reserved words when used as the

first word of a command unless quoted or disabled using ddiissaabbllee -rr:

ddoo ddoonnee eessaacc tthheenn eelliiff eellssee ffii ffoorr ccaassee iiff wwhhiillee ffuunnccttiioonn rreeppeeaatt ttiimmee uunnttiill sseelleecctt ccoopprroocc nnooccoorrrreecctt ffoorreeaacchh eenndd !! [[[[ {{ }} Additionally, `}}' is recognized in any position if the IIGGNNOORREEBBRRAACCEESS option is not set. CCOOMMMMEENNTTSS

In noninteractive shells, or in interactive shells with the IINNTTEERRAACC-

TTIIVVEECCOOMMMMEENNTTSS option set, a word beginning with the third character of

the hhiissttcchhaarrss parameter (`##' by default) causes that word and all the

following characters up to a newline to be ignored. AALLIIAASSIINNGG Every token in the shell input is checked to see if there is an alias defined for it. If so, it is replaced by the text of the alias if it

is in command position (if it could be the first word of a simple com-

mand), or if the alias is global. If the text ends with a space, the next word in the shell input is treated as though it were in command position for purposes of alias expansion. An alias is defined using

the aalliiaass builtin; global aliases may be defined using the -gg option to

that builtin. Alias expansion is done on the shell input before any other expansion except history expansion. Therefore, if an alias is defined for the word ffoooo, alias expansion may be avoided by quoting part of the word, e.g. \\ffoooo. But there is nothing to prevent an alias being defined for \\ffoooo as well. QQUUOOTTIINNGG

A character may be quoted (that is, made to stand for itself) by pre-

ceding it with a `\\'. `\\' followed by a newline is ignored.

A string enclosed between `$$''' and `''' is processed the same way as the

string arguments of the pprriinntt builtin, and the resulting string is con-

sidered to be entirely quoted. A literal `''' character can be included in the string by using the `\\''' escape. All characters enclosed between a pair of single quotes ('''') that is

not preceded by a `$$' are quoted. A single quote cannot appear within

single quotes unless the option RRCCQQUUOOTTEESS is set, in which case a pair of single quotes are turned into a single quote. For example, pprriinntt '''''''' outputs nothing apart from a newline if RRCCQQUUOOTTEESS is not set, but one single quote if it is set. Inside double quotes (""""), parameter and command substitution occur,

and `\\' quotes the characters `\\', ```', `""', and `$$'.

RREEDDIIRREECCTTIIOONN If a command is followed by && and job control is not active, then the default standard input for the command is the empty file //ddeevv//nnuullll. Otherwise, the environment for the execution of a command contains the file descriptors of the invoking shell as modified by input/output specifications. The following may appear anywhere in a simple command or may precede or follow a complex command. Expansion occurs before word or digit is

used except as noted below. If the result of substitution on word pro-

duces more than one filename, redirection occurs for each separate filename in turn. << word Open file word for reading as standard input. <<>> word Open file word for reading and writing as standard input. If the file does not exist then it is created. >> word Open file word for writing as standard output. If the file does

not exist then it is created. If the file exists, and the CCLLOOBB-

BBEERR option is unset, this causes an error; otherwise, it is truncated to zero length. >>|| word >>!! word Same as >>, except that the file is truncated to zero length if it exists, even if CCLLOOBBBBEERR is unset. >>>> word Open file word for writing in append mode as standard output. If the file does not exist, and the CCLLOOBBBBEERR option is unset, this causes an error; otherwise, the file is created. >>>>|| word >>>>!! word Same as >>>>, except that the file is created if it does not exist, even if CCLLOOBBBBEERR is unset.

<<<<[-] word

The shell input is read up to a line that is the same as word,

or to an end-of-file. No parameter expansion, command substitu-

tion or filename generation is performed on word. The resulting

document, called a here-document, becomes the standard input.

If any character of word is quoted with single or double quotes or a `\\', no interpretation is placed upon the characters of the document. Otherwise, parameter and command substitution occurs, `\\' followed by a newline is removed, and `\\' must be used to

quote the characters `\\', `$$', ```' and the first character of

word.

Note that word itself does not undergo shell expansion. Back-

quotes in word do not have their usual effect; instead they behave similarly to double quotes, except that the backquotes themselves are passed through unchanged. (This information is given for completeness and it is not recommended that backquotes

be used.) Quotes in the form $$''...'' have their standard effect

of expanding backslashed references to special characters.

If <<<<- is used, then all leading tabs are stripped from word and

from the document. <<<<<< word Perform shell expansion on word and pass the result to standard

input. This is known as a here-string. Compare the use of word

in here-documents above, where word does not undergo shell

expansion. <<&& number >>&& number The standard input/output is duplicated from file descriptor number (see dup2(2)).

<<&& -

>>&& - Close the standard input/output.

<<&& pp >>&& pp The input/output from/to the coprocess is moved to the standard input/output. >>&& word &&>> word (Except where `>>&& word' matches one of the above syntaxes; `&&>>' can always be used to avoid this ambiguity.) Redirects both standard output and standard error (file descriptor 2) in the manner of `>> word'. Note that this does not have the same

effect as `>> word 22>>&&11' in the presence of multios (see the sec-

tion below). >>&&|| word >>&&!! word &&>>|| word &&>>!! word

Redirects both standard output and standard error (file descrip-

tor 2) in the manner of `>>|| word'. >>>>&& word &&>>>> word

Redirects both standard output and standard error (file descrip-

tor 2) in the manner of `>>>> word'. >>>>&&|| word >>>>&&!! word &&>>>>|| word &&>>>>!! word

Redirects both standard output and standard error (file descrip-

tor 2) in the manner of `>>>>|| word'. If one of the above is preceded by a digit, then the file descriptor referred to is that specified by the digit instead of the default 0 or 1. The order in which redirections are specified is significant. The shell evaluates each redirection in terms of the (file descriptor, file) association at the time of evaluation. For example: ... 11>>fname 22>>&&11 first associates file descriptor 1 with file fname. It then associates file descriptor 2 with the file associated with file descriptor 1 (that

is, fname). If the order of redirections were reversed, file descrip-

tor 2 would be associated with the terminal (assuming file descriptor 1 had been) and then file descriptor 1 would be associated with file fname. The `||&&' command separator described in Simple Commands & Pipelines in zshmisc(1) is a shorthand for `22>>&&11 ||'. For output redirections only, if word is of the form `>>((list))' then the

output is piped to the command represented by list. See Process Sub-

stitution in zshexpn(1). MMUULLTTIIOOSS If the user tries to open a file descriptor for writing more than once, the shell opens the file descriptor as a pipe to a process that copies its input to all the specified outputs, similar to tteeee, provided the MMUULLTTIIOOSS option is set, as it is by default. Thus: ddaattee >>ffoooo >>bbaarr writes the date to two files, named `ffoooo' and `bbaarr'. Note that a pipe is an implicit redirection; thus ddaattee >>ffoooo || ccaatt writes the date to the file `ffoooo', and also pipes it to cat. If the MMUULLTTIIOOSS option is set, the word after a redirection operator is also subjected to filename generation (globbing). Thus :: >> ** will truncate all files in the current directory, assuming there's at least one. (Without the MMUULLTTIIOOSS option, it would create an empty file called `**'.) Similarly, you can do eecchhoo eexxiitt 00 >>>> **..sshh If the user tries to open a file descriptor for reading more than once, the shell opens the file descriptor as a pipe to a process that copies all the specified inputs to its output in the order specified, similar to ccaatt, provided the MMUULLTTIIOOSS option is set. Thus ssoorrtt <> bbaarr >> bbaazz when MMUULLTTIIOOSS is unset will truncate bar, and write `ffoooo' into baz. There is a problem when an output multio is attached to an external program. A simple example shows this: ccaatt ffiillee >>ffiillee11 >>ffiillee22 ccaatt ffiillee11 ffiillee22 Here, it is possible that the second `ccaatt' will not display the full contents of ffiillee11 and ffiillee22 (i.e. the original contents of ffiillee repeated twice). The reason for this is that the multios are spawned after the ccaatt process is forked from the parent shell, so the parent shell does not wait for the multios to finish writing data. This means the command as shown can exit before ffiillee11 and ffiillee22 are completely written. As a workaround, it is possible to run the ccaatt process as part of a job in the current shell: {{ ccaatt ffiillee }} >>ffiillee >>ffiillee22 Here, the {{...}} job will pause to wait for both files to be written. RREEDDIIRREECCTTIIOONNSS WWIITTHH NNOO CCOOMMMMAANNDD When a simple command consists of one or more redirection operators and zero or more parameter assignments, but no command name, zsh can behave in several ways. If the parameter NNUULLLLCCMMDD is not set or the option CCSSHHNNUULLLLCCMMDD is set, an error is caused. This is the ccsshh behavior and CCSSHHNNUULLLLCCMMDD is set by default when emulating ccsshh.

If the option SSHHNNUULLLLCCMMDD is set, the builtin `::' is inserted as a com-

mand with the given redirections. This is the default when emulating sshh or kksshh. Otherwise, if the parameter NNUULLLLCCMMDD is set, its value will be used as a command with the given redirections. If both NNUULLLLCCMMDD and RREEAADDNNUULLLLCCMMDD are set, then the value of the latter will be used instead of that of the former when the redirection is an input. The default for NNUULLLLCCMMDD is `ccaatt' and for RREEAADDNNUULLLLCCMMDD is `mmoorree'. Thus << ffiillee shows the contents of ffiillee on standard output, with paging if that is a terminal. NNUULLLLCCMMDD and RREEAADDNNUULLLLCCMMDD may refer to shell functions. CCOOMMMMAANNDD EEXXEECCUUTTIIOONN If a command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, the function is invoked as described in the section `Functions'. If there exists a shell builtin by that name, the builtin is invoked.

Otherwise, the shell searches each element of $$ppaatthh for a directory

containing an executable file by that name. If the search is unsuc-

cessful, the shell prints an error message and returns a nonzero exit status. If execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script. //bbiinn//sshh is spawned to execute it. If the program is a file beginning

with `##!!', the remainder of the first line specifies an interpreter for

the program. The shell will execute the specified interpreter on oper-

ating systems that do not handle this executable format in the kernel. FFUUNNCCTTIIOONNSS

Shell functions are defined with the ffuunnccttiioonn reserved word or the spe-

cial syntax `funcname (())'. Shell functions are read in and stored

internally. Alias names are resolved when the function is read. Func-

tions are executed like commands with the arguments passed as posi-

tional parameters. (See the section `Command Execution'.) Functions execute in the same process as the caller and share all files and present working directory with the caller. A trap on EEXXIITT set

inside a function is executed after the function completes in the envi-

ronment of the caller. The rreettuurrnn builtin is used to return from function calls.

Function identifiers can be listed with the ffuunnccttiioonnss builtin. Func-

tions can be undefined with the uunnffuunnccttiioonn builtin. AAUUTTOOLLOOAADDIINNGG FFUUNNCCTTIIOONNSS A function can be marked as undefined using the aauuttoollooaadd builtin (or

`ffuunnccttiioonnss -uu' or `ttyyppeesseett -ffuu'). Such a function has no body. When

the function is first executed, the shell searches for its definition using the elements of the ffppaatthh variable. Thus to define functions for autoloading, a typical sequence is:

ffppaatthh==((~~//mmyyffuunnccss $$ffppaatthh))

aauuttoollooaadd mmyyffuunncc11 mmyyffuunncc22 ...... The usual alias expansion during reading will be suppressed if the

aauuttoollooaadd builtin or its equivalent is given the option -UU. This is rec-

ommended for the use of functions supplied with the zsh distribution. Note that for functions precompiled with the zzccoommppiillee builtin command

the flag -UU must be provided when the ..zzwwcc file is created, as the cor-

responding information is compiled into the latter. For each element in ffppaatthh, the shell looks for three possible files, the newest of which is used to load the definition for the function: element..zzwwcc A file created with the zzccoommppiillee builtin command, which is expected to contain the definitions for all functions in the directory named element. The file is treated in the same manner as a directory containing files for functions and is searched for the definition of the function. If the definition is not found, the search for a definition proceeds with the other two possibilities described below. If element already includes a ..zzwwcc extension (i.e. the extension was explicitly given by the user), element is searched for the definition of the function without comparing its age to that of other files; in fact, there does not need to be any directory named element without the suffix. Thus including an element such as `//uussrr//llooccaall//ffuunnccss..zzwwcc' in ffppaatthh will speed up the search for functions, with the disadvantage that functions included must be explicitly recompiled by hand before the shell notices any changes. element//function..zzwwcc A file created with zzccoommppiillee, which is expected to contain the

definition for function. It may include other function defini-

tions as well, but those are neither loaded nor executed; a file

found in this way is searched only for the definition of func-

tion. element//function

A file of zsh command text, taken to be the definition for func-

tion.

In summary, the order of searching is, first, in the parents of direc-

tories in ffppaatthh for the newer of either a compiled directory or a

directory in ffppaatthh; second, if more than one of these contains a defi-

nition for the function that is sought, the leftmost in the ffppaatthh is chosen; and third, within a directory, the newer of either a compiled function or an ordinary function definition is used. If the KKSSHHAAUUTTOOLLOOAADD option is set, or the file contains only a simple definition of the function, the file's contents will be executed. This will normally define the function in question, but may also perform

initialization, which is executed in the context of the function execu-

tion, and may therefore define local parameters. It is an error if the function is not defined by loading the file. Otherwise, the function body (with no surrounding `funcname(()) {{...}}') is taken to be the complete contents of the file. This form allows the file to be used directly as an executable shell script. If processing

of the file results in the function being re-defined, the function

itself is not re-executed. To force the shell to perform initializa-

tion and then call the function defined, the file should contain ini-

tialization code (which will be executed then discarded) in addition to a complete function definition (which will be retained for subsequent calls to the function), and a call to the shell function, including any arguments, at the end. For example, suppose the autoload file ffuunncc contains ffuunncc(()) {{ pprriinntt TThhiiss iiss ffuunncc;; }} pprriinntt ffuunncc iiss iinniittiiaalliizzeedd then `ffuunncc;; ffuunncc' with KKSSHHAAUUTTOOLLOOAADD set will produce both messages on the first call, but only the message `TThhiiss iiss ffuunncc' on the second and

subsequent calls. Without KKSSHHAAUUTTOOLLOOAADD set, it will produce the ini-

tialization message on the first call, and the other message on the second and subsequent calls. It is also possible to create a function that is not marked as autoloaded, but which loads its own definition by searching ffppaatthh, by

using `aauuttoollooaadd -XX' within a shell function. For example, the follow-

ing are equivalent: mmyyffuunncc(()) {{

aauuttoollooaadd -XX

}} mmyyffuunncc aarrggss...... and

uunnffuunnccttiioonn mmyyffuunncc ## iiff mmyyffuunncc wwaass ddeeffiinneedd

aauuttoollooaadd mmyyffuunncc mmyyffuunncc aarrggss......

In fact, the ffuunnccttiioonnss command outputs `bbuuiillttiinn aauuttoollooaadd -XX' as the

body of an autoloaded function. This is done so that

eevvaall ""$$((ffuunnccttiioonnss))""

produces a reasonable result. A true autoloaded function can be iden-

tified by the presence of the comment `## uunnddeeffiinneedd' in the body,

because all comments are discarded from defined functions.

To load the definition of an autoloaded function mmyyffuunncc without execut-

ing mmyyffuunncc, use: aauuttoollooaadd ++XX mmyyffuunncc SSPPEECCIIAALL FFUUNNCCTTIIOONNSS The following functions, if defined, have special meaning to the shell: cchhppwwdd Executed whenever the current working directory is changed. ppeerriiooddiicc If the parameter PPEERRIIOODD is set, this function is executed every

$$PPEERRIIOODD seconds, just before a prompt.

pprreeccmmdd Executed before each prompt. pprreeeexxeecc Executed just after a command has been read and is about to be executed. If the history mechanism is active (and the line was not discarded from the history buffer), the string that the user typed is passed as the first argument, otherwise it is an empty string. The actual command that will be executed (including expanded aliases) is passed in two different forms: the second

argument is a single-line, size-limited version of the command

(with things like function bodies elided); the third argument contains the full text that is being executed. TTRRAAPPNAL

If defined and non-null, this function will be executed whenever

the shell catches a signal SSIIGGNAL, where NAL is a signal name as specified for the kkiillll builtin. The signal number will be passed as the first parameter to the function. If a function of this form is defined and null, the shell and processes spawned by it will ignore SSIIGGNAL. The return value from the function is handled specially. If it

is zero, the signal is assumed to have been handled, and execu-

tion continues normally. Otherwise, the normal effect of the signal is produced; if this causes execution to terminate, the status returned to the shell is the status returned from the function. Programs terminated by uncaught signals typically return the status 128 plus the signal number. Hence the following causes the handler for SSIIGGIINNTT to print a message, then mimic the usual effect of the signal. TTRRAAPPIINNTT(()) {{ pprriinntt ""CCaauugghhtt SSIIGGIINNTT,, aabboorrttiinngg..""

rreettuurrnn $$(((( 112288 ++ $$11 ))))

}}

The functions TTRRAAPPZZEERRRR, TTRRAAPPDDEEBBUUGG and TTRRAAPPEEXXIITT are never exe-

cuted inside other traps. TTRRAAPPDDEEBBUUGG Executed after each command. TTRRAAPPEEXXIITT Executed when the shell exits, or when the current function exits if defined inside a function. TTRRAAPPZZEERRRR

Executed whenever a command has a non-zero exit status. How-

ever, the function is not executed if the command occurred in a sublist followed by `&&&&' or `||||'; only the final command in a sublist of this type causes the trap to be executed. The functions beginning `TTRRAAPP' may alternatively be defined with the ttrraapp builtin: this may be preferable for some uses, as they are then run in the environment of the calling process, rather than in their own function environment. Apart from the difference in calling procedure and the fact that the function form appears in lists of functions, the forms TTRRAAPPNNAALL(()) {{

## ccooddee

}} and ttrraapp ''

## ccooddee

are equivalent. JJOOBBSS If the MMOONNIITTOORR option is set, an interactive shell associates a job with each pipeline. It keeps a table of current jobs, printed by the jjoobbss command, and assigns them small integer numbers. When a job is started asynchronously with `&&', the shell prints a line to standard error which looks like: [[11]] 11223344 indicating that the job which was started asynchronously was job number

1 and had one (top-level) process, whose process ID was 1234.

If a job is started with `&&||' or `&&!!', then that job is immediately disowned. After startup, it does not have a place in the job table, and is not subject to the job control features described here. If you are running a job and wish to do something else you may hit the

key ^Z (control-Z) which sends a TTSSTTPP signal to the current job: this

key may be redefined by the ssuusspp option of the external ssttttyy command.

The shell will then normally indicate that the job has been `sus-

pended', and print another prompt. You can then manipulate the state of this job, putting it in the background with the bbgg command, or run some other commands and then eventually bring the job back into the

foreground with the foreground command ffgg. A ^Z takes effect immedi-

ately and is like an interrupt in that pending output and unread input are discarded when it is typed. A job being run in the background will suspend if it tries to read from the terminal. Background jobs are normally allowed to produce output, but this can be disabled by giving the command `ssttttyy ttoossttoopp'. If you set this tty option, then background jobs will suspend when they try to produce output like they do when they try to read input. When a command is suspended and continued later with the ffgg or wwaaiitt

builtins, zsh restores tty modes that were in effect when it was sus-

pended. This (intentionally) does not apply if the command is contin-

ued via `kkiillll -CCOONNTT', nor when it is continued with bbgg.

There are several ways to refer to jobs in the shell. A job can be referred to by the process ID of any process of the job or by one of the following:

%%number

The job with the given number.

%%string

Any job whose command line begins with string.

%%??string

Any job whose command line contains string.

%%%% Current job.

%%++ Equivalent to `%%%%'.

%%- Previous job.

The shell learns immediately whenever a process changes state. It nor-

mally informs you whenever a job becomes blocked so that no further progress is possible. If the NNOOTTIIFFYY option is not set, it waits until

just before it prints a prompt before it informs you. All such notifi-

cations are sent directly to the terminal, not to the standard output or standard error.

When the monitor mode is on, each background job that completes trig-

gers any trap set for CCHHLLDD. When you try to leave the shell while jobs are running or suspended, you will be warned that `You have suspended (running) jobs'. You may

use the jjoobbss command to see what they are. If you do this or immedi-

ately try to exit again, the shell will not warn you a second time; the suspended jobs will be terminated, and the running jobs will be sent a SSIIGGHHUUPP signal, if the HHUUPP option is set. To avoid having the shell terminate the running jobs, either use the nnoohhuupp command (see nohup(1)) or the ddiissoowwnn builtin. SSIIGGNNAALLSS

The IINNTT and QQUUIITT signals for an invoked command are ignored if the com-

mand is followed by `&&' and the MMOONNIITTOORR option is not active. Other-

wise, signals have the values inherited by the shell from its parent (but see the TTRRAAPPNAL special functions in the section `Functions'). AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN The shell can perform integer and floating point arithmetic, either

using the builtin lleett, or via a substitution of the form $$((((......)))). For

integers, the shell is usually compiled to use 8-byte precision where

this is available, otherwise precision is 4 bytes. This can be tested,

for example, by giving the command `pprriinntt - $$(((( 1122334455667788990011 ))))'; if the

number appears unchanged, the precision is at least 8 bytes. Floating point arithmetic is always double precision. The lleett builtin command takes arithmetic expressions as arguments; each is evaluated separately. Since many of the arithmetic operators, as well as spaces, require quoting, an alternative form is provided: for

any command which begins with a `((((', all the characters until a match-

ing `))))' are treated as a quoted expression and arithmetic expansion performed as for an argument of lleett. More precisely, `((((...))))' is equivalent to `lleett ""...""'. For example, the following statement (((( vvaall == 22 ++ 11 )))) is equivalent to lleett ""vvaall == 22 ++ 11"" both assigning the value 3 to the shell variable vvaall and returning a zero status. Integers can be in bases other than 10. A leading `00xx' or `00XX' denotes

hexadecimal. Integers may also be of the form `base##n', where base is

a decimal number between two and thirty-six representing the arithmetic

base and n is a number in that base (for example, `1166##ffff' is 255 in

hexadecimal). The base## may also be omitted, in which case base 10 is

used. For backwards compatibility the form `[[base]]n' is also accepted. It is also possible to specify a base to be used for output in the form

`[[##base]]', for example `[[##1166]]'. This is used when outputting arith-

metical substitutions or when assigning to scalar parameters, but an explicitly defined integer or floating point parameter will not be

affected. If an integer variable is implicitly defined by an arith-

metic expression, any base specified in this way will be set as the

variable's output arithmetic base as if the option `-ii base' to the

ttyyppeesseett builtin had been used. The expression has no precedence and if

it occurs more than once in a mathematical expression, the last encoun-

tered is used. For clarity it is recommended that it appear at the beginning of an expression. As an example:

ttyyppeesseett -ii 1166 yy

pprriinntt $$(((( [[##88]] xx == 3322,, yy == 3322 ))))

pprriinntt $$xx $$yy

outputs first `88##4400', the rightmost value in the given output base, and

then `88##4400 1166##2200', because yy has been explicitly declared to have out-

put base 16, while xx (assuming it does not already exist) is implicitly typed by the arithmetic evaluation, where it acquires the output base 8. If the CCBBAASSEESS option is set, hexadecimal numbers in the standard C

format, for example 00xxFFFF instead of the usual `1166##FFFF'. If the option

OOCCTTAALLZZEERROOEESS is also set (it is not by default), octal numbers will be

treated similarly and hence appear as `007777' instead of `88##7777'. This

option has no effect on the output of bases other than hexadecimal and octal, and these formats are always understood on input.

When an output base is specified using the `[[##base]]' syntax, an appro-

priate base prefix will be output if necessary, so that the value out-

put is valid syntax for input. If the ## is doubled, for example

`[[####1166]]', then no base prefix is output.

Floating point constants are recognized by the presence of a decimal point or an exponent. The decimal point may be the first character of the constant, but the exponent character ee or EE may not, as it will be taken for a parameter name. An arithmetic expression uses nearly the same syntax, precedence, and

associativity of expressions in C. The following operators are sup-

ported (listed in decreasing order of precedence):

++ - !! ~~ ++++ --

unary plus/minus, logical NOT, complement, {pre,post}{in,de}cre-

ment <<<< >>>> bitwise shift left, right && bitwise AND ^^ bitwise XOR || bitwise OR **** exponentiation

** // %% multiplication, division, modulus (remainder)

++ - addition, subtraction

<< >> <<== >>== comparison ==== !!== equality and inequality &&&& logical AND |||| ^^^^ logical OR, XOR ?? :: ternary operator

== ++== -== **== //== %%== &&== ^^== ||== <<<<== >>>>== &&&&== ||||== ^^^^== ****==

assignment ,, comma operator

The operators `&&&&', `||||', `&&&&==', and `||||==' are short-circuiting, and

only one of the latter two expressions in a ternary operator is evalu-

ated. Note the precedence of the bitwise AND, OR, and XOR operators. Mathematical functions can be called with the syntax `func((args))', where the function decides if the args is used as a string or a

comma-separated list of arithmetic expressions. The shell currently

defines no mathematical functions by default, but the module zzsshh//mmaatthh-

ffuunncc may be loaded with the zzmmooddllooaadd builtin to provide standard float-

ing point mathematical functions.

An expression of the form `####x' where x is any character sequence such

as `aa', `^^AA', or `\\MM-\\CC-xx' gives the ASCII value of this character and

an expression of the form `##foo' gives the ASCII value of the first

character of the value of the parameter foo. Note that this is differ-

ent from the expression `$$##foo', a standard parameter substitution

which gives the length of the parameter foo. `##\\' is accepted instead

of `####', but its use is deprecated.

Named parameters and subscripted arrays can be referenced by name within an arithmetic expression without using the parameter expansion syntax. For example, ((((vvaall22 == vvaall11 ** 22))))

assigns twice the value of $$vvaall11 to the parameter named vvaall22.

An internal integer representation of a named parameter can be speci-

fied with the iinntteeggeerr builtin. Arithmetic evaluation is performed on the value of each assignment to a named parameter declared integer in this manner. Assigning a floating point number to an integer results in rounding down to the next integer. Likewise, floating point numbers can be declared with the ffllooaatt builtin; there are two types, differing only in their output format, as described for the ttyyppeesseett builtin. The output format can be bypassed by using arithmetic substitution instead of the parameter substitution,

i.e. `$${{float}}' uses the defined format, but `$$((((float))))' uses a

generic floating point format.

Promotion of integer to floating point values is performed where neces-

sary. In addition, if any operator which requires an integer (`~~',

`&&', `||', `^^', `%%', `<<<<', `>>>>' and their equivalents with assignment)

is given a floating point argument, it will be silently rounded down to the next integer. Scalar variables can hold integer or floating point values at different times; there is no memory of the numeric type in this case. If a variable is first assigned in a numeric context without previously being declared, it will be implicitly typed as iinntteeggeerr or ffllooaatt and retain that type either until the type is explicitly changed or until the end of the scope. This can have unforeseen consequences. For example, in the loop ffoorr (((( ff == 00;; ff << 11;; ff ++== 00..11 ))));; ddoo

## uussee $$ff

ddoonnee if ff has not already been declared, the first assignment will cause it to be created as an integer, and consequently the operation `ff ++== 00..11' will always cause the result to be truncated to zero, so that the loop will fail. A simple fix would be to turn the initialization into `ff == 00..00'. It is therefore best to declare numeric variables with explicit types. CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS A conditional expression is used with the [[[[ compound command to test attributes of files and to compare strings. Each expression can be

constructed from one or more of the following unary or binary expres-

sions:

-aa file

true if file exists.

-bb file

true if file exists and is a block special file.

-cc file

true if file exists and is a character special file.

-dd file

true if file exists and is a directory.

-ee file

true if file exists.

-ff file

true if file exists and is a regular file.

-gg file

true if file exists and has its setgid bit set.

-hh file

true if file exists and is a symbolic link.

-kk file

true if file exists and has its sticky bit set.

-nn string

true if length of string is non-zero.

-oo option

true if option named option is on. option may be a single char-

acter, in which case it is a single letter option name. (See the section `Specifying Options'.)

-pp file

true if file exists and is a FIFO special file (named pipe).

-rr file

true if file exists and is readable by current process.

-ss file

true if file exists and has size greater than zero.

-tt fd true if file descriptor number fd is open and associated with a

terminal device. (note: fd is not optional)

-uu file

true if file exists and has its setuid bit set.

-ww file

true if file exists and is writable by current process.

-xx file

true if file exists and is executable by current process. If file exists and is a directory, then the current process has permission to search in the directory.

-zz string

true if length of string is zero.

-LL file

true if file exists and is a symbolic link.

-OO file

true if file exists and is owned by the effective user ID of this process.

-GG file

true if file exists and its group matches the effective group ID of this process.

-SS file

true if file exists and is a socket.

-NN file

true if file exists and its access time is not newer than its modification time.

file1 -nntt file2

true if file1 exists and is newer than file2.

file1 -oott file2

true if file1 exists and is older than file2.

file1 -eeff file2

true if file1 and file2 exist and refer to the same file. string == pattern string ==== pattern true if string matches pattern. The `====' form is the preferred one. The `==' form is for backward compatibility and should be considered obsolete. string !!== pattern true if string does not match pattern. string1 << string2 true if string1 comes before string2 based on ASCII value of their characters. string1 >> string2 true if string1 comes after string2 based on ASCII value of their characters.

exp1 -eeqq exp2

true if exp1 is numerically equal to exp2.

exp1 -nnee exp2

true if exp1 is numerically not equal to exp2.

exp1 -lltt exp2

true if exp1 is numerically less than exp2.

exp1 -ggtt exp2

true if exp1 is numerically greater than exp2.

exp1 -llee exp2

true if exp1 is numerically less than or equal to exp2.

exp1 -ggee exp2

true if exp1 is numerically greater than or equal to exp2. (( exp )) true if exp is true. !! exp true if exp is false. exp1 &&&& exp2 true if exp1 and exp2 are both true. exp1 |||| exp2 true if either exp1 or exp2 is true. Normal shell expansion is performed on the file, string and pattern

arguments, but the result of each expansion is constrained to be a sin-

gle word, similar to the effect of double quotes. However, pattern metacharacters are active for the pattern arguments; the patterns are the same as those used for filename generation, see zshexpn(1), but there is no special behaviour of `//' nor initial dots, and no glob qualifiers are allowed. In each of the above expressions, if file is of the form `//ddeevv//ffdd//n', where n is an integer, then the test applied to the open file whose descriptor number is n, even if the underlying system does not support the //ddeevv//ffdd directory. In the forms which do numeric comparison, the expressions exp undergo

arithmetic expansion as if they were enclosed in $$((((......)))).

For example, the following:

[[[[ (( -ff ffoooo |||| -ff bbaarr )) &&&& $$rreeppoorrtt == yy** ]]]] &&&& pprriinntt FFiillee eexxiissttss..

tests if either file ffoooo or file bbaarr exists, and if so, if the value of the parameter rreeppoorrtt begins with `yy'; if the complete condition is true, the message `FFiillee eexxiissttss..' is printed. PPRROOMMPPTT EEXXPPAANNSSIIOONN Prompt sequences undergo a special form of expansion. This type of

expansion is also available using the -PP option to the pprriinntt builtin.

If the PPRROOMMPPTTSSUUBBSSTT option is set, the prompt string is first subjected to parameter expansion, command substitution and arithmetic expansion. See zshexpn(1). Certain escape sequences may be recognised in the prompt string. If the PPRROOMMPPTTBBAANNGG option is set, a `!!' in the prompt is replaced by

the current history event number. A literal `!!' may then be repre-

sented as `!!!!'. If the PPRROOMMPPTTPPEERRCCEENNTT option is set, certain escape sequences that

start with `%%' are expanded. Some escapes take an optional integer

argument, which should appear between the `%%' and the next character of

the sequence. The following escape sequences are recognized: SSppeecciiaall cchhaarraacctteerrss

%%%% A `%%'.

%%)) A `))'.

LLooggiinn iinnffoorrmmaattiioonn

%%ll The line (tty) the user is logged in on, without `//ddeevv//' prefix.

If the name starts with `//ddeevv//ttttyy', that prefix is stripped.

%%MM The full machine hostname.

%%mm The hostname up to the first `..'. An integer may follow the `%%'

to specify how many components of the hostname are desired. With a negative integer, trailing components of the hostname are shown.

%n $USERNAME

%%yy The line (tty) the user is logged in on, without `//ddeevv//' prefix.

This does not treat `//ddeevv//ttttyy' names specially. SShheellll ssttaattee

%%## A `##' if the shell is running with privileges, a `%%' if not.

Equivalent to `%%((!!..##..%%%%))'. The definition of `privileged', for

these purposes, is that either the effective user ID is zero, or, if POSIX.1e capabilities are supported, that at least one capability is raised in either the Effective or Inheritable capability vectors.

%%?? The return code of the last command executed just before the

prompt.

%% The status of the parser, i.e. the shell constructs (like `iiff'

and `ffoorr') that have been started on the command line. If given an integer number that many strings will be printed; zero or negative or no integer means print as many as there are. This is most useful in prompts PPSS22 for continuation lines and PPSS44 for debugging with the XXTTRRAACCEE option; in the latter case it will

also work non-interactively.

%%dd

%%// Present working directory ($$PPWWDD). If an integer follows the

`%%', it specifies a number of trailing components of $$PPWWDD to

show; zero means the whole path. A negative integer specifies

leading components, i.e. %%-11dd specifies the first component.

%%~~ As %%dd and %%//, but if $$PPWWDD has a named directory as its prefix,

that part is replaced by a `~~' followed by the name of the

directory. If it starts with $$HHOOMMEE, that part is replaced by a

`~~'.

%%hh

%%!! Current history event number.

%%ii The line number currently being executed in the script, sourced

file, or shell function given by %%NN. This is most useful for

debugging as part of $$PPSS44.

%%jj The number of jobs.

%%LL The current value of $$SSHHLLVVLL.

%%NN The name of the script, sourced file, or shell function that zsh

is currently executing, whichever was started most recently. If

there is none, this is equivalent to the parameter $$00. An inte-

ger may follow the `%%' to specify a number of trailing path com-

ponents to show; zero means the full path. A negative integer specifies leading components.

%%cc

%%..

%%CC Trailing component of $$PPWWDD. An integer may follow the `%%' to

get more than one component. Unless `%%CC' is used, tilde con-

traction is performed first. These are deprecated as %%cc and %%CC

are equivalent to %%11~~ and %%11//, respectively, while explicit pos-

itive integers have the same effect as for the latter two sequences. DDaattee aanndd ttiimmee

%%DD The date in yy-mm-dd format.

%%TT Current time of day, in 24-hour format.

%%tt

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

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

%%ww The date in day-dd format.

%%WW The date in mm//dd//yy format.

%%DD{{string}}

string is formatted using the ssttrrffttiimmee function. See strf-

time(3) for more details. Three additional codes are available:

%%ff prints the day of the month, like %%ee but without any preced-

ing space if the day is a single digit, and %%KK/%%LL correspond to

%%kk/%%ll for the hour of the day (24/12 hour clock) in the same

way. VViissuuaall eeffffeeccttss

%%BB (%%bb)

Start (stop) boldface mode.

%%EE Clear to end of line.

%%UU (%%uu)

Start (stop) underline mode.

%%SS (%%ss)

Start (stop) standout mode.

%%{{...%%}}

Include a string as a literal escape sequence. The string within the braces should not change the cursor position. Brace pairs can nest. CCoonnddiittiioonnaall ssuubbssttrriinnggss

%%vv The value of the first element of the ppssvvaarr array parameter.

Following the `%%' with an integer gives that element of the

array. Negative integers count from the end of the array.

%%((x.true-text.false-text))

Specifies a ternary expression. The character following the x is arbitrary; the same character is used to separate the text for the `true' result from that for the `false' result. This

separator may not appear in the true-text, except as part of a

%-escape sequence. A `))' may appear in the false-text as `%%))'.

true-text and false-text may both contain arbitrarily-nested

escape sequences, including further ternary expressions. The left parenthesis may be preceded or followed by a positive integer n, which defaults to zero. A negative integer will be

multiplied by -1. The test character x may be any of the fol-

lowing: !! True if the shell is running with privileges.

## True if the effective uid of the current process is n.

?? True if the exit status of the last command was n. True if at least n shell constructs were started. CC // True if the current absolute path has at least n elements relative to the root directory, hence // is counted as 0 elements. cc .. ~~ True if the current path, with prefix replacement, has at least n elements relative to the root directory, hence // is counted as 0 elements. DD True if the month is equal to n (January = 0). dd True if the day of the month is equal to n. gg True if the effective gid of the current process is n. jj True if the number of jobs is at least n. LL True if the SSHHLLVVLL parameter is at least n. ll True if at least n characters have already been printed on the current line. SS True if the SSEECCOONNDDSS parameter is at least n. TT True if the time in hours is equal to n. tt True if the time in minutes is equal to n. vv True if the array ppssvvaarr has at least n elements. ww True if the day of the week is equal to n (Sunday = 0).

%%<

%%>>string>>

%%[[xstring]]

Specifies truncation behaviour for the remainder of the prompt string. The third, deprecated, form is equivalent to

`%%xstringx', i.e. x may be `<<' or `>>'. The numeric argument,

which in the third form may appear immediately after the `[[', specifies the maximum permitted length of the various strings

that can be displayed in the prompt. The string will be dis-

played in place of the truncated portion of any string; note this does not undergo prompt expansion. The forms with `<<' truncate at the left of the string, and the

forms with `>>' truncate at the right of the string. For exam-

ple, if the current directory is `//hhoommee//ppiikkee', the prompt

`%%88<<....<<%%//' will expand to `....ee//ppiikkee'. In this string, the ter-

minating character (`<<', `>>' or `]]'), or in fact any character,

may be quoted by a preceding `\\'; note when using pprriinntt -PP, how-

ever, that this must be doubled as the string is also subject to standard pprriinntt processing, in addition to any backslashes removed by a double quoted string: the worst case is therefore

`pprriinntt -PP ""%%<<\\\\\\\\<<<<......""'.

If the string is longer than the specified truncation length, it will appear in full, completely replacing the truncated string. The part of the prompt string to be truncated runs to the end of the string, or to the end of the next enclosing group of the

`%%((' construct, or to the next truncation encountered at the

same grouping level (i.e. truncations inside a `%%((' are sepa-

rate), which ever comes first. In particular, a truncation with

argument zero (e.g. `%%<<<<') marks the end of the range of the

string to be truncated while turning off truncation from there

on. For example, the prompt '%10<...<%~%<<%# ' will print a

truncated representation of the current directory, followed by a

`%%' or `##', followed by a space. Without the `%%<<<<', those two

characters would be included in the string to be truncated. ZSHEXPN(1) ZSHEXPN(1)

NAME

zshexpn - zsh expansion and substitution

DESCRIPTION

The following types of expansions are performed in the indicated order in five steps: History Expansion This is performed only in interactive shells. Alias Expansion Aliases are expanded immediately before the command line is parsed as explained under Aliasing in zshmisc(1). Process Substitution Parameter Expansion Command Substitution Arithmetic Expansion Brace Expansion

These five are performed in one step in left-to-right fashion.

After these expansions, all unquoted occurrences of the charac-

ters `\\', `''' and `""' are removed. Filename Expansion If the SSHHFFIILLEEEEXXPPAANNSSIIOONN option is set, the order of expansion is modified for compatibility with sshh and kksshh. In that case

filename expansion is performed immediately after alias expan-

sion, preceding the set of five expansions mentioned above. Filename Generation This expansion, commonly referred to as gglloobbbbiinngg, is always done last. The following sections explain the types of expansion in detail. HISTORY EXPANSION History expansion allows you to use words from previous command lines

in the command line you are typing. This simplifies spelling correc-

tions and the repetition of complicated commands or arguments. Immedi-

ately before execution, each command is saved in the history list, the size of which is controlled by the HHIISSTTSSIIZZEE parameter. The one most recent command is always retained in any case. Each saved command in the history list is called a history event and is assigned a number, beginning with 1 (one) when the shell starts up. The history number that you may see in your prompt (see Prompt Expansion in zshmisc(1)) is the number that is to be assigned to the next command. OOvveerrvviieeww A history expansion begins with the first character of the hhiissttcchhaarrss

parameter, which is `!!' by default, and may occur anywhere on the com-

mand line; history expansions do not nest. The `!!' can be escaped with `\\' or can be enclosed between a pair of single quotes ('''') to suppress its special meaning. Double quotes will not work for this. Following this history character is an optional event designator (see the section `Event Designators') and then an optional word designator (the section `Word Designators'); if neither of these designators is present, no history expansion occurs. Input lines containing history expansions are echoed after being expanded, but before any other expansions take place and before the command is executed. It is this expanded form that is recorded as the history event for later references. By default, a history reference with no event designator refers to the same event as any preceding history reference on that command line; if

it is the only history reference in a command, it refers to the previ-

u cmad Hwvr i te pin CSHJUNKIEHISTORY s e, hn every history reference with no event specification always refers to the previous command. For example, `!!' is the event designator for the previous command, so `!!!!::11' always refers to the first word of the previous command, and

`!!!!$$' always refers to the last word of the previous command. With

CSHJUNKIEHISTORY e, hn !:1' n `!$ fnto i te ae anr

s !!:1' n `!!$, epciey Cnesl, f CSHJUNKIEHISTORY

is unset, then `!!::11' and `!!$$' refer to the first and last words,

respectively, of the same event referenced by the nearest other history

reference preceding them on the current command line, or to the previ-

ous command if there is no preceding reference. The character sequence `^^foo^^bar' (where `^^' is actually the second

character of the hhiissttcchhaarrss parameter) repeats the last command, replac-

ing the string foo with bar. More precisely, the sequence `^^foo^^bar^^'

is synonymous with `!!!!::ss^^foo^^bar^^', hence other modifiers (see the sec-

tion `Modifiers') may follow the final `^^'. If the shell encounters the character sequence `!!""' in the input, the history mechanism is temporarily disabled until the current list (see zshmisc(1)) is fully parsed. The `!!""' is removed from the input, and any subsequent `!!' characters have no special significance.

A less convenient but more comprehensible form of command history sup-

port is provided by the ffcc builtin. EEvveenntt DDeessiiggnnaattoorrss

An event designator is a reference to a command-line entry in the his-

tory list. In the list below, remember that the initial ``!!'' in each item may be changed to another character by setting the hhiissttcchhaarrss parameter.

!! Start a history expansion, except when followed by a blank, new-

line, `==' or `(('. If followed immediately by a word designator

(see the section `Word Designators'), this forms a history ref-

erence with no event designator (see the section `Overview'). !!!! Refer to the previous command. By itself, this expansion repeats the previous command.

!!n Refer to command-line n.

!!-n Refer to the current command-line minus n.

!!str Refer to the most recent command starting with str. !!??str[??] Refer to the most recent command containing str. The trailing

`??' is necessary if this reference is to be followed by a modi-

fier or followed by any text that is not to be considered part of str.

!!## Refer to the current command line typed in so far. The line is

treated as if it were complete up to and including the word

before the one with the `!!##' reference.

!!{{...}} Insulate a history reference from adjacent characters (if neces-

sary). WWoorrdd DDeessiiggnnaattoorrss A word designator indicates which word or words of a given command line are to be included in a history reference. A `::' usually separates the event specification from the word designator. It may be omitted only

if the word designator begins with a `^^', `$$', `**', `-' or `%%'. Word

designators include: 00 The first input word (command). n The nth argument. ^^ The first argument. That is, 11.

$$ The last argument.

%% The word matched by (the most recent) ??str search.

x-y A range of words; x defaults to 00.

** All the arguments, or a null value if there are none.

x** Abbreviates `x-$$'.

x- Like `x**' but omitting word $$.

Note that a `%%' word designator works only when used in one of `!!%%',

`!!::%%' or `!!??str??::%%', and only when used after a !!?? expansion (possibly

in an earlier command). Anything else results in an error, although the error may not be the most obvious one. MMooddiiffiieerrss After the optional word designator, you can add a sequence of one or

more of the following modifiers, each preceded by a `::'. These modi-

fiers also work on the result of filename generation and parameter expansion, except where noted. hh Remove a trailing pathname component, leaving the head. This works like `ddiirrnnaammee'. rr Remove a filename extension of the form `..xxx', leaving the root name. ee Remove all but the extension. tt Remove all leading pathname components, leaving the tail. This works like `bbaasseennaammee'. pp Print the new command but do not execute it. Only works with history expansion. qq Quote the substituted words, escaping further substitutions. Works with history expansion and parameter expansion, though for parameters it is only useful if the resulting text is to be

re-evaluated such as by eevvaall.

QQ Remove one level of quotes from the substituted words. xx Like qq, but break into words at whitespace. Does not work with parameter expansion. ll Convert the words to all lowercase. uu Convert the words to all uppercase. ss//l//r[//]

Substitute r for l as described below. Unless preceded immedi-

ately by a gg, with no colon between, the substitution is done only for the first string that matches l. For arrays and for filename generation, this applies to each word of the expanded text. && Repeat the previous ss substitution. Like ss, may be preceded immediately by a gg. In parameter expansion the && must appear inside braces, and in filename generation it must be quoted with a backslash.

The ss//ll//rr// substitution works as follows. The left-hand side of sub-

stitutions are not regular expressions, but character strings. Any character can be used as the delimiter in place of `//'. A backslash quotes the delimiter character. The character `&&', in the

right-hand-side r, is replaced by the text from the left-hand-side l.

The `&&' can be quoted with a backslash. A null l uses the previous string either from the previous l or from the contextual scan string s

from `!!??s'. You can omit the rightmost delimiter if a newline immedi-

ately follows r; the rightmost `??' in a context scan can similarly be omitted. Note the same record of the last l and r is maintained across all forms of expansion.

The following ff, FF, ww and WW modifiers work only with parameter expan-

sion and filename generation. They are listed here to provide a single point of reference for all modifiers. ff Repeats the immediately (without a colon) following modifier until the resulting word doesn't change any more. FF::expr::

Like ff, but repeats only n times if the expression expr evalu-

ates to n. Any character can be used instead of the `::'; if `((', `[[', or `{{' is used as the opening delimiter, the closing delimiter should be '))', `]]', or `}}', respectively. ww Makes the immediately following modifier work on each word in the string. WW::sep:: Like ww but words are considered to be the parts of the string that are separated by sep. Any character can be used instead of the `::'; opening parentheses are handled specially, see above. PPRROOCCEESSSS SSUUBBSSTTIITTUUTTIIOONN Each command argument of the form `<<((list))', `>>((list))' or `==((list))' is subject to process substitution. In the case of the << or >> forms, the shell runs process list asynchronously. If the system supports the //ddeevv//ffdd mechanism, the command argument is the name of the device file corresponding to a file descriptor; otherwise, if the system supports named pipes (FIFOs), the command argument will be a named pipe. If the form with >> is selected then writing on this special file will provide input for list. If << is used, then the file passed as an argument will be connected to the output of the list process. For example,

ppaassttee <<((ccuutt -ff11 file1)) <<((ccuutt -ff33 file2)) ||

tteeee >>((process1)) >>((process2)) >>//ddeevv//nnuullll cuts fields 1 and 3 from the files file1 and file2 respectively, pastes the results together, and sends it to the processes process1 and process2.

If ==((...)) is used instead of <<((...)), then the file passed as an argu-

ment will be the name of a temporary file containing the output of the list process. This may be used instead of the << form for a program that expects to lseek (see lseek(2)) on the input file.

The == form is useful as both the //ddeevv//ffdd and the named pipe implementa-

tion of <<((...)) have drawbacks. In the former case, some programmes may automatically close the file descriptor in question before examining the file on the command line, particularly if this is necessary for security reasons such as when the programme is running setuid. In the

second case, if the programme does not actually open the file, the sub-

shell attempting to read from or write to the pipe will (in a typical

implementation, different operating systems may have different behav-

iour) block for ever and have to be killed explicitly. In both cases,

the shell actually supplies the information using a pipe, so that pro-

grammes that expect to lseek (see lseek(2)) on the file will not work.

Also note that the previous example can be more compactly and effi-

ciently written (provided the MMUULLTTIIOOSS option is set) as:

ppaassttee <<((ccuutt -ff11 file1)) <<((ccuutt -ff33 file2)) \\

>> >>((process1)) >> >>((process2)) The shell uses pipes instead of FIFOs to implement the latter two process substitutions in the above example. There is an additional problem with >>((process)); when this is attached to an external command, the parent shell does not wait for process to finish and hence an immediately following command cannot rely on the results being complete. The problem and solution are the same as described in the section MULTIOS in zshmisc(1). Hence in a simplified version of the example above:

ppaassttee <<((ccuutt -ff11 file1)) <<((ccuutt -ff33 file2)) >> >>((process))

(note that no MMUULLTTIIOOSS are involved), process will be run asyn-

chronously. The workaround is:

{{ ppaassttee <<((ccuutt -ff11 file1)) <<((ccuutt -ff33 file2)) }} >> >>((process))

The extra processes here are spawned from the parent shell which will wait for their completion. PPAARRAAMMEETTEERR EEXXPPAANNSSIIOONN

The character `$$' is used to introduce parameter expansions. See zsh-

param(1) for a description of parameters, including arrays, associative arrays, and subscript notation to access individual array elements. Note in particular the fact that words of unquoted parameters are not automatically split on whitespace unless the option SSHHWWOORRDDSSPPLLIITT is set; see references to this option below for more details. This is an important difference from other shells. In the expansions discussed below that require a pattern, the form of the pattern is the same as that used for filename generation; see the section `Filename Generation'. Note that these patterns, along with the replacement text of any substitutions, are themselves subject to parameter expansion, command substitution, and arithmetic expansion. In addition to the following operations, the colon modifiers described in the section `Modifiers' in the section `History Expansion' can be

applied: for example, $${{ii::ss//ffoooo//bbaarr//}} performs string substitution on

the expansion of parameter $$ii.

$${{name}}

The value, if any, of the parameter name is substituted. The

braces are required if the expansion is to be followed by a let-

ter, digit, or underscore that is not to be interpreted as part of name. In addition, more complicated forms of substitution usually require the braces to be present; exceptions, which only

apply if the option KKSSHHAARRRRAAYYSS is not set, are a single sub-

script or any colon modifiers appearing after the name, or any

of the characters `^^', `==', `~~', `##' or `++' appearing before the

name, all of which work with or without braces. If name is an array parameter, and the KKSSHHAARRRRAAYYSS option is not set, then the value of each element of name is substituted, one element per word. Otherwise, the expansion results in one word only; with KKSSHHAARRRRAAYYSS, this is the first element of an array. No field splitting is done on the result unless the SSHHWWOORRDDSSPPLLIITT option is set.

$${{++name}}

If name is the name of a set parameter `11' is substituted, oth-

erwise `00' is substituted.

$${{name::-word}}

If name is set and is non-null then substitute its value; other-

wise substitute word. If name is missing, substitute word.

$${{name::==word}}

$${{name::::==word}}

In the first form, if name is unset or is null then set it to word; in the second form, unconditionally set name to word. In both forms, the value of the parameter is then substituted.

$${{name::??word}}

If name is set and is non-null then substitute its value; other-

wise, print word and exit from the shell. Interactive shells

instead return to the prompt. If word is omitted, then a stan-

dard message is printed.

$${{name::++word}}

If name is set and is non-null then substitute word; otherwise

substitute nothing. If the colon is omitted from one of the above expressions containing a colon, then the shell only checks whether name is set, not whether its value is null.

In the following expressions, when name is an array and the substitu-

tion is not quoted, or if the `((@@))' flag or the name[[@@]] syntax is used, matching and replacement is performed on each array element separately.

$${{name##pattern}}

$${{name####pattern}}

If the pattern matches the beginning of the value of name, then substitute the value of name with the matched portion deleted; otherwise, just substitute the value of name. In the first form, the smallest matching pattern is preferred; in the second form, the largest matching pattern is preferred.

$${{name%%pattern}}

$${{name%%%%pattern}}

If the pattern matches the end of the value of name, then sub-

stitute the value of name with the matched portion deleted; oth-

erwise, just substitute the value of name. In the first form, the smallest matching pattern is preferred; in the second form, the largest matching pattern is preferred.

$${{name::##pattern}}

If the pattern matches the value of name, then substitute the empty string; otherwise, just substitute the value of name. If name is an array the matching array elements are removed (use

the `((MM))' flag to remove the non-matched elements).

$${{name//pattern//repl}}

$${{name////pattern//repl}}

Replace the longest possible match of pattern in the expansion of parameter name by string repl. The first form replaces just the first occurrence, the second form all occurrences. Both

pattern and repl are subject to double-quoted substitution, so

that expressions like $${{nnaammee//$$ooppaatt//$$nnppaatt}} will work, but note

the usual rule that pattern characters in $$ooppaatt are not treated

specially unless either the option GGLLOOBBSSUUBBSSTT is set, or $$ooppaatt

is instead substituted as $${{~~ooppaatt}}.

The pattern may begin with a `##', in which case the pattern must

match at the start of the string, or `%%', in which case it must

match at the end of the string. The repl may be an empty string, in which case the final `//' may also be omitted. To quote the final `//' in other cases it should be preceded by a single backslash; this is not necessary if the `//' occurs inside

a substituted parameter. Note also that the `##' and `%%' are not

active if they occur inside a substituted parameter, even at the start. The first `//' may be preceded by a `::', in which case the match will only succeed if it matches the entire word. Note also the effect of the II and SS parameter expansion flags below; however, the flags MM, RR, BB, EE and NN are not useful. For example, ffoooo==""ttwwiinnkkllee ttwwiinnkkllee lliittttllee ssttaarr"" ssuubb==""tt**ee"" rreepp==""ssppyy""

pprriinntt $${{ffoooo////$${{~~ssuubb}}//$$rreepp}}

pprriinntt $${{((SS))ffoooo////$${{~~ssuubb}}//$$rreepp}}

Here, the `~~' ensures that the text of $$ssuubb is treated as a pat-

tern rather than a plain string. In the first case, the longest match for tt**ee is substituted and the result is `ssppyy ssttaarr', while in the second case, the shortest matches are taken and the result is `ssppyy ssppyy lliissppyy ssttaarr'.

$${{##spec}}

If spec is one of the above substitutions, substitute the length in characters of the result instead of the result itself. If spec is an array expression, substitute the number of elements of the result. Note that `^^', `==', and `~~', below, must appear

to the left of `##' when these forms are combined.

$${{^^spec}}

Turn on the RRCCEEXXPPAANNDDPPAARRAAMM option for the evaluation of spec; if the `^^' is doubled, turn it off. When this option is set,

array expansions of the form foo$${{xx}}bar, where the parameter xx

is set to ((a b c)), are substituted with `fooabar foobbar foocbar' instead of the default `fooa b cbar'. Internally, each such expansion is converted into the equivalent

list for brace expansion. E.g., $${{^^vvaarr}} becomes

{{$$vvaarr[[11]],,$$vvaarr[[22]],,...}}, and is processed as described in the sec-

tion `Brace Expansion' below. If word splitting is also in

effect the $$vvaarr[[N]] may themselves be split into different list

elements.

$${{==spec}}

Perform word splitting using the rules for SSHHWWOORRDDSSPPLLIITT during the evaluation of spec, but regardless of whether the parameter appears in double quotes; if the `==' is doubled, turn it off. This forces parameter expansions to be split into separate words before substitution, using IIFFSS as a delimiter. This is done by default in most other shells. Note that splitting is applied to word in the assignment forms of spec before the assignment to name is performed. This affects the result of array assignments with the AA flag.

$${{~~spec}}

Turn on the GGLLOOBBSSUUBBSSTT option for the evaluation of spec; if the `~~' is doubled, turn it off. When this option is set, the string resulting from the expansion will be interpreted as a pattern anywhere that is possible, such as in filename expansion

and filename generation and pattern-matching contexts like the

right hand side of the `==' and `!!==' operators in conditions.

If a $${{...}} type parameter expression or a $$((...)) type command substi-

tution is used in place of name above, it is expanded first and the result is used as if it were the value of name. Thus it is possible to

perform nested operations: $${{$${{ffoooo##hheeaadd}}%%ttaaiill}} substitutes the value

of $$ffoooo with both `hheeaadd' and `ttaaiill' deleted. The form with $$((...)) is

often useful in combination with the flags described next; see the

examples below. Each name or nested $${{...}} in a parameter expansion

may also be followed by a subscript expression as described in Array Parameters in zshparam(1). Note that double quotes may appear around nested expressions, in which case only the part inside is treated as quoted; for example,

$${{((ff))""$$((ffoooo))""}} quotes the result of $$((ffoooo)), but the flag `((ff))' (see

below) is applied using the rules for unquoted expansions. Note fur-

ther that quotes are themselves nested in this context; for example, in

""$${{((@@ff))""$$((ffoooo))""}}"", there are two sets of quotes, one surrounding the

whole expression, the other (redundant) surrounding the $$((ffoooo)) as

before. PPaarraammeetteerr EExxppaannssiioonn FFllaaggss If the opening brace is directly followed by an opening parenthesis, the string up to the matching closing parenthesis will be taken as a

list of flags. In cases where repeating a flag is meaningful, the rep-

etitions need not be consecutive; for example, `(qq%%qq%%qq)' means the same

thing as the more readable `(%%%%qqqqqq)'. The following flags are sup-

ported:

%% Expand all %% escapes in the resulting words in the same way as

in in prompts (see the section `Prompt Expansion'). If this flag is given twice, full prompt expansion is done on the resulting words, depending on the setting of the PPRROOMMPPTTPPEERRCCEENNTT, PPRROOMMPPTTSSUUBBSSTT and PPRROOMMPPTTBBAANNGG options. @@ In double quotes, array elements are put into separate words.

E.g., `""$${{((@@))ffoooo}}""' is equivalent to `""$${{ffoooo[[@@]]}}""' and

`""$${{((@@))ffoooo[[11,,22]]}}""' is the same as `""$$ffoooo[[11]]"" ""$$ffoooo[[22]]""'. This

is distinct from field splitting by the the ff, ss or zz flags, which still applies within each array element.

AA Create an array parameter with `$${{...==...}}', `$${{...::==...}}' or

`$${{...::::==...}}'. If this flag is repeated (as in `AAAA'), create

an associative array parameter. Assignment is made before sort-

ing or padding. The name part may be a subscripted range for ordinary arrays; the word part must be converted to an array,

for example by using `$${{((AAAA))==name==...}}' to activate field split-

ting, when creating an associative array.

aa With oo or OO, sort in array index order. Note that `ooaa' is there-

fore equivalent to the default but `OOaa' is useful for obtaining an array's elements in reverse order.

cc With $${{##name}}, count the total number of characters in an array,

as if the elements were concatenated with spaces between them. CC Capitalize the resulting words. `Words' in this case refers to

sequences of alphanumeric characters separated by non-alphanu-

merics, not to words that result from field splitting. ee Perform parameter expansion, command substitution and arithmetic expansion on the result. Such expansions can be nested but too deep recursion may have unpredictable effects. ff Split the result of the expansion to lines. This is a shorthand for `ppss::\\nn::'. FF Join the words of arrays together using newline as a separator. This is a shorthand for `ppjj::\\nn::'.

ii With oo or OO, sort case-independently.

kk If name refers to an associative array, substitute the keys (element names) rather than the values of the elements. Used with subscripts (including ordinary arrays), force indices or

keys to be substituted even if the subscript form refers to val-

ues. However, this flag may not be combined with subscript ranges. LL Convert all letters in the result to lower case. nn With oo or OO, sort numerically. oo Sort the resulting words in ascending order. OO Sort the resulting words in descending order. PP This forces the value of the parameter name to be interpreted as

a further parameter name, whose value will be used where appro-

priate. If used with a nested parameter or command substitution, the result of that will be taken as a parameter name in the same way. For example, if you have `ffoooo==bbaarr' and `bbaarr==bbaazz', the

strings $${{((PP))ffoooo}}, $${{((PP))$${{ffoooo}}}}, and $${{((PP))$$((eecchhoo bbaarr))}} will be

expanded to `bbaazz'. qq Quote the resulting words with backslashes. If this flag is given twice, the resulting words are quoted in single quotes and if it is given three times, the words are quoted in double

quotes. If it is given four times, the words are quoted in sin-

gle quotes preceded by a $$.

QQ Remove one level of quotes from the resulting words. tt Use a string describing the type of the parameter where the

value of the parameter would usually appear. This string con-

sists of keywords separated by hyphens (`-'). The first keyword

in the string describes the main type, it can be one of `ssccaallaarr', `aarrrraayy', `iinntteeggeerr', `ffllooaatt' or `aassssoocciiaattiioonn'. The other keywords describe the type in more detail: llooccaall for local parameters lleefftt for left justified parameters rriigghhttbbllaannkkss for right justified parameters with leading blanks rriigghhttzzeerrooss for right justified parameters with leading zeros lloowweerr for parameters whose value is converted to all lower case when it is expanded uuppppeerr for parameters whose value is converted to all upper case when it is expanded rreeaaddoonnllyy for readonly parameters ttaagg for tagged parameters eexxppoorrtt for exported parameters

uunniiqquuee for arrays which keep only the first occurrence of dupli-

cated values hhiiddee for parameters with the `hide' flag ssppeecciiaall for special parameters defined by the shell uu Expand only the first occurrence of each unique word. UU Convert all letters in the result to upper case. vv Used with kk, substitute (as two consecutive words) both the key

and the value of each associative array element. Used with sub-

scripts, force values to be substituted even if the subscript form refers to indices or keys. VV Make any special characters in the resulting words visible.

ww With $${{##name}}, count words in arrays or strings; the ss flag may

be used to set a word delimiter. WW Similar to ww with the difference that empty words between repeated delimiters are also counted. XX With this flag parsing errors occurring with the QQ and ee flags

or the pattern matching forms such as `$${{name##pattern}}' are

reported. Without the flag they are silently ignored. zz Split the result of the expansion into words using shell parsing to find the words, i.e. taking into account any quoting in the value. Note that this is done very late, as for the `((ss))' flag. So to

access single words in the result, one has to use nested expan-

sions as in `$${{$${{((zz))ffoooo}}[[22]]}}'. Likewise, to remove the quotes in

the resulting words one would do: `$${{((QQ))$${{((zz))ffoooo}}}}'.

The following flags (except pp) are followed by one or more arguments as shown. Any character, or the matching pairs `((...))', `{{...}}', `[[...]]', or `<<...>>', may be used in place of a colon as delimiters, but note

that when a flag takes more than one argument, a matched pair of delim-

iters must surround each argument. pp Recognize the same escape sequences as the pprriinntt builtin in string arguments to any of the flags described below. jj::string:: Join the words of arrays together using string as a separator. Note that this occurs before field splitting by the SSHHWWOORRDDSSPPLLIITT option. ll::expr::::string1::::string2::

Pad the resulting words on the left. Each word will be trun-

cated if required and placed in a field expr characters wide. The space to the left will be filled with string1 (concatenated as often as needed) or spaces if string1 is not given. If both string1 and string2 are given, this string is inserted once directly to the left of each word, before padding. rr::expr::::string1::::string2:: As ll, but pad the words on the right and insert string2 on the right. ss::string::

Force field splitting (see the option SSHHWWOORRDDSSPPLLIITT) at the sep-

arator string. Note that a string of two or more characters means all must all match in sequence; this differs from the treatment of two or more characters in the IIFFSS parameter.

The following flags are meaningful with the $${{...##...}} or $${{...%%...}}

forms. The SS and II flags may also be used with the $${{...//...}} forms.

SS Search substrings as well as beginnings or ends; with ## start

from the beginning and with %% start from the end of the string.

With substitution via $${{...//...}} or $${{...////...}}, specifies

non-greedy matching, i.e. that the shortest instead of the long-

est match should be replaced. II::expr:: Search the exprth match (where expr evaluates to a number). This only applies when searching for substrings, either with the

SS flag, or with $${{...//...}} (only the exprth match is substi-

tuted) or $${{...////...}} (all matches from the exprth on are sub-

stituted). The default is to take the first match. The exprth match is counted such that there is either one or zero matches from each starting position in the string, although

for global substitution matches overlapping previous replace-

ments are ignored. With the $${{...%%...}} and $${{...%%%%...}} forms,

the starting position for the match moves backwards from the end

as the index increases, while with the other forms it moves for-

ward from the start. Hence with the string wwhhiicchh sswwiittcchh iiss tthhee rriigghhtt sswwiittcchh ffoorr IIppsswwiicchh??

substitutions of the form $${{(SSII::N::)ssttrriinngg##ww**cchh}} as N increases

from 1 will match and remove `wwhhiicchh', `wwiittcchh', `wwiittcchh' and

`wwiicchh'; the form using `####' will match and remove `wwhhiicchh sswwiittcchh

iiss tthhee rriigghhtt sswwiittcchh ffoorr IIppsswwiicchh', `wwiittcchh iiss tthhee rriigghhtt sswwiittcchh ffoorr

IIppsswwiicchh', `wwiittcchh ffoorr IIppsswwiicchh' and `wwiicchh'. The form using `%%'

will remove the same matches as for `##', but in reverse order,

and the form using `%%%%' will remove the same matches as for `####'

in reverse order. BB Include the index of the beginning of the match in the result. EE Include the index of the end of the match in the result. MM Include the matched portion in the result. NN Include the length of the match in the result. RR Include the unmatched portion in the result (the Rest). RRuulleess Here is a summary of the rules for substitution; this assumes that

braces are present around the substitution, i.e. $${{......}}. Some particu-

lar examples are given below. Note that the Zsh Development Group accepts no responsibility for any brain damage which may occur during the reading of the following rules. 11.. Nested Substitution

If multiple nested $${{......}} forms are present, substitution is

performed from the inside outwards. At each level, the substi-

tution takes account of whether the current value is a scalar or an array, whether the whole substitution is in double quotes,

and what flags are supplied to the current level of substitu-

tion, just as if the nested substitution were the outermost. The flags are not propagated up to enclosing substitutions; the nested substitution will return either a scalar or an array as determined by the flags, possibly adjusted for quoting. All the following steps take place where applicable at all levels of substitution. Note that, unless the `((PP))' flag is present, the flags and any subscripts apply directly to the value of the

nested substitution; for example, the expansion $${{$${{ffoooo}}}}

behaves exactly the same as $${{ffoooo}}.

22.. Parameter Subscripting If the value is a raw parameter reference with a subscript, such

as $${{var[[33]]}}, the effect of subscripting is applied directly to

the parameter. Subscripts are evaluated left to right; subse-

quent subscripts apply to the scalar or array value yielded by

the previous subscript. Thus if vvaarr is an array, $${{vvaarr[[11]][[22]]}}

is the second character of the first word, but $${{vvaarr[[22,,44]][[22]]}} is

the entire third word (the second word of the range of words two through four of the original array). Any number of subscripts may appear. 33.. Parameter Name Replacement The effect of any ((PP)) flag, which treats the value so far as a parameter name and replaces it with the corresponding value, is applied.

44.. Double-Quoted Joining

If the value after this process is an array, and the substitu-

tion appears in double quotes, and no ((@@)) flag is present at the current level, the words of the value are joined with the first

character of the parameter $$IIFFSS, by default a space, between

each word (single word arrays are not modified). If the ((jj))

flag is present, that is used for joining instead of $$IIFFSS.

55.. Nested Subscripting Any remaining subscripts (i.e. of a nested substitution) are evaluated at this point, based on whether the value is an array or a scalar. As with 22.., multiple subscripts can appear. Note

that $${{ffoooo[[22,,44]][[22]]}} is thus equivalent to $${{$${{ffoooo[[22,,44]]}}[[22]]}} and

also to ""$${{$${{((@@))ffoooo[[22,,44]]}}[[22]]}}"" (the nested substitution returns

an array in both cases), but not to ""$${{$${{ffoooo[[22,,44]]}}[[22]]}}"" (the

nested substitution returns a scalar because of the quotes). 66.. Modifiers

Any modifiers, as specified by a trailing `##', `%%', `//' (possi-

bly doubled) or by a set of modifiers of the form ::...... (see the section `Modifiers' in the section `History Expansion'), are applied to the words of the value at this level. 77.. Forced Joining If the `((jj))' flag is present, or no `((jj))' flag is present but

the string is to be split as given by rules 88.. or 99.., and join-

ing did not take place at step 44.., any words in the value are joined together using the given string or the first character of

$$IIFFSS if none. Note that the `((FF))' flag implicitly supplies a

string for joining in this manner. 88.. Forced Splitting If one of the `((ss))', `((ff))' or `((zz))' flags are present, or the

`==' specifier was present (e.g. $${{==var}}), the word is split on

occurrences of the specified string, or (for == with neither of

the two flags present) any of the characters in $$IIFFSS.

99.. Shell Word Splitting If no `((ss))', `((ff))' or `==' was given, but the word is not quoted

and the option SSHHWWOORRDDSSPPLLIITT is set, the word is split on occur-

rences of any of the characters in $$IIFFSS. Note this step, too,

takes place at all levels of a nested substitution.

1100.. Re-Evaluation

Any `((ee))' flag is applied to the value, forcing it to be

re-examined for new parameter substitutions, but also for com-

mand and arithmetic substitutions. 1111.. Padding Any padding of the value by the `((ll..fill..))' or `((rr..fill..))' flags is applied. 1122.. Semantic Joining In contexts where expansion semantics requires a single word to result, all words are rejoined with the first character of IIFFSS

between. So in `$${{((PP))$${{((ff))lliinneess}}}}' the value of $${{lliinneess}} is

split at newlines, but then must be joined again before the PP flag can be applied. If a single word is not required, this rule is skipped. EExxaammpplleess

The flag ff is useful to split a double-quoted substitution line by

line. For example, $${{((ff))""$$((<

divided so that each line is an element of the resulting array. Com-

pare this with the effect of $$((<

by words, or the same inside double quotes, which makes the entire con-

tent of the file a single string. The following illustrates the rules for nested parameter expansions.

Suppose that $$ffoooo contains the array ((bbaarr bbaazz)):

""$${{((@@))$${{ffoooo}}[[11]]}}""

This produces the result bb. First, the inner substitution

""$${{ffoooo}}"", which has no array (@@) flag, produces a single word

result ""bbaarr bbaazz"". The outer substitution ""$${{((@@))......[[11]]}}"" detects

that this is a scalar, so that (despite the `((@@))' flag) the sub-

script picks the first character.

""$${{$${{((@@))ffoooo}}[[11]]}}""

This produces the result `bbaarr'. In this case, the inner substi-

tution ""$${{((@@))ffoooo}}"" produces the array `((bbaarr bbaazz))'. The outer

substitution ""$${{......[[11]]}}"" detects that this is an array and picks

the first word. This is similar to the simple case ""$${{ffoooo[[11]]}}"".

As an example of the rules for word splitting and joining, suppose $$ffoooo

contains the array `((aaxx11 bbxx11))'. Then

$${{((ss//xx//))ffoooo}}

produces the words `aa', `11 bb' and `11'.

$${{((jj//xx//ss//xx//))ffoooo}}

produces `aa', `11', `bb' and `11'.

$${{((ss//xx//))ffoooo%%%%11**}}

produces `aa' and ` bb' (note the extra space). As substitution occurs before either joining or splitting, the operation first generates the modified array ((aaxx bbxx)), which is joined to give ""aaxx bbxx"", and then split to give `aa', ` bb' and `'. The final empty string will then be elided, as it is not in double quotes. CCOOMMMMAANNDD SSUUBBSSTTIITTUUTTIIOONN A command enclosed in parentheses preceded by a dollar sign, like

`$$((...))', or quoted with grave accents, like ```...``', is replaced with

its standard output, with any trailing newlines deleted. If the sub-

stitution is not enclosed in double quotes, the output is broken into

words using the IIFFSS parameter. The substitution `$$((ccaatt foo))' may be

replaced by the equivalent but faster `$$((<

the option GGLLOOBBSSUUBBSSTT is set, the output is eligible for filename gen-

eration. AARRIITTHHMMEETTIICC EEXXPPAANNSSIIOONN

A string of the form `$$[[exp]]' or `$$((((exp))))' is substituted with the

value of the arithmetic expression exp. exp is subjected to parameter expansion, command substitution and arithmetic expansion before it is evaluated. See the section `Arithmetic Evaluation'. BBRRAACCEE EEXXPPAANNSSIIOONN A string of the form `foo{{xx,,yy,,zz}}bar' is expanded to the individual

words `fooxxbar', `fooyybar' and `foozzbar'. Left-to-right order is

preserved. This construct may be nested. Commas may be quoted in order to include them literally in a word. An expression of the form `{{n1....n2}}', where n1 and n2 are integers, is expanded to every number between n1 and n2 inclusive. If either number

begins with a zero, all the resulting numbers will be padded with lead-

ing zeroes to that minimum width. If the numbers are in decreasing order the resulting sequence will also be in decreasing order. If a brace expression matches none of the above forms, it is left unchanged, unless the BBRRAACCEECCCCLL option is set. In that case, it is expanded to a sorted list of the individual characters between the

braces, in the manner of a search set. `-' is treated specially as in

a search set, but `^^' or `!!' as the first character is treated nor-

mally.

Note that brace expansion is not part of filename generation (glob-

bing); an expression such as **//{{ffoooo,,bbaarr}} is split into two separate

words **//ffoooo and **//bbaarr before filename generation takes place. In par-

ticular, note that this is liable to produce a `no match' error if either of the two expressions does not match; this is to be contrasted with **//((ffoooo||bbaarr)), which is treated as a single pattern but otherwise has similar effects.

FILENAME EXPANSION

Each word is checked to see if it begins with an unquoted `~~'. If it does, then the word up to a `//', or the end of the word if there is no `//', is checked to see if it can be substituted in one of the ways described here. If so, then the `~~' and the checked portion are replaced with the appropriate substitute value.

A `~~' by itself is replaced by the value of $$HHOOMMEE. A `~~' followed by a

`++' or a `-' is replaced by the value of $$PPWWDD or $$OOLLDDPPWWDD, respectively.

A `~~' followed by a number is replaced by the directory at that posi-

tion in the directory stack. `~~00' is equivalent to `~~++', and `~~11' is the top of the stack. `~~++' followed by a number is replaced by the directory at that position in the directory stack. `~~++00' is equivalent

to `~~++', and `~~++11' is the top of the stack. `~~-' followed by a number

is replaced by the directory that many positions from the bottom of the

stack. `~~-00' is the bottom of the stack. The PPUUSSHHDDMMIINNUUSS option

exchanges the effects of `~~++' and `~~-' where they are followed by a

number. A `~~' followed by anything not already covered is looked up as a named directory, and replaced by the value of that named directory if found.

Named directories are typically home directories for users on the sys-

tem. They may also be defined if the text after the `~~' is the name of a string shell parameter whose value begins with a `//'. It is also

possible to define directory names using the -dd option to the hhaasshh

builtin. In certain circumstances (in prompts, for instance), when the shell prints a path, the path is checked to see if it has a named directory as its prefix. If so, then the prefix portion is replaced with a `~~' followed by the name of the directory. The shortest way of referring to the directory is used, with ties broken in favour of using a named

directory, except when the directory is // itself. The parameters $$PPWWDD

and $$OOLLDDPPWWDD are never abbreviated in this fashion.

If a word begins with an unquoted `==' and the EEQQUUAALLSS option is set, the remainder of the word is taken as the name of a command. If a command exists by that name, the word is replaced by the full pathname of the command. Filename expansion is performed on the right hand side of a parameter assignment, including those appearing after commands of the ttyyppeesseett family. In this case, the right hand side will be treated as a

colon-separated list in the manner of the PPAATTHH parameter, so that a `~~'

or an `==' following a `::' is eligible for expansion. All such behav-

iour can be disabled by quoting the `~~', the `==', or the whole expres-

sion (but not simply the colon); the EEQQUUAALLSS option is also respected. If the option MMAAGGIICCEEQQUUAALLSSUUBBSSTT is set, any unquoted shell argument in the form `identifier==expression' becomes eligible for file expansion as described in the previous paragraph. Quoting the first `==' also inhibits this.

FILENAME GENERATION

If a word contains an unquoted instance of one of the characters `**', `((', `||', `<<', `[[', or `??', it is regarded as a pattern for filename generation, unless the GGLLOOBB option is unset. If the EEXXTTEENNDDEEDDGGLLOOBB

option is set, the `^^' and `##' characters also denote a pattern; other-

wise they are not treated specially by the shell. The word is replaced with a list of sorted filenames that match the pattern. If no matching pattern is found, the shell gives an error message, unless the NNUULLLLGGLLOOBB option is set, in which case the word is deleted; or unless the NNOOMMAATTCCHH option is unset, in which case the word is left unchanged. In filename generation, the character `//' must be matched explicitly; also, a `..' must be matched explicitly at the beginning of a pattern or

after a `//', unless the GGLLOOBBDDOOTTSS option is set. No filename genera-

tion pattern matches the files `..' or `....'. In other instances of pat-

tern matching, the `//' and `..' are not treated specially. GGlloobb OOppeerraattoorrss ** Matches any string, including the null string. ?? Matches any character. [[...]] Matches any of the enclosed characters. Ranges of characters

can be specified by separating two characters by a `-'. A `-'

or `]]' may be matched by including it as the first character in the list. There are also several named classes of characters, in the form `[[::name::]]' with the following meanings: `[[::aallnnuumm::]]'

alphanumeric, `[[::aallpphhaa::]]' alphabetic, `[[::aasscciiii::]]' 7-bit,

`[[::bbllaannkk::]]' space or tab, `[[::ccnnttrrll::]]' control character, `[[::ddiiggiitt::]]' decimal digit, `[[::ggrraapphh::]]' printable character except whitespace, `[[::lloowweerr::]]' lowercase letter, `[[::pprriinntt::]]' printable character, `[[::ppuunncctt::]]' printable character neither alphanumeric nor whitespace, `[[::ssppaaccee::]]' whitespace character, `[[::uuppppeerr::]]' uppercase letter, `[[::xxddiiggiitt::]]' hexadecimal digit. These use the macros provided by the operating system to test

for the given character combinations, including any modifica-

tions due to local language settings: see ctype(3). Note that the square brackets are additional to those enclosing the whole

set of characters, so to test for a single alphanumeric charac-

ter you need `[[[[::aallnnuumm::]]]]'. Named character sets can be used

alongside other types, e.g. `[[[[::aallpphhaa::]]00-99]]'.

[[^^...]] [[!!...]] Like [[...]], except that it matches any character which is not in the given set.

<<[x]-[y]>>

Matches any number in the range x to y, inclusive. Either of

the numbers may be omitted to make the range open-ended; hence

`<<->>' matches any number. To match individual digits, the [[...]]

form is more efficient. Be careful when using other wildcards adjacent to patterns of

this form; for example, <<00-99>>** will actually match any number

whatsoever at the start of the string, since the `<<00-99>>' will

match the first digit, and the `**' will match any others. This

is a trap for the unwary, but is in fact an inevitable conse-

quence of the rule that the longest possible match always suc-

ceeds. Expressions such as `<<00-99>>[[^^[[::ddiiggiitt::]]]]**' can be used

instead. ((...)) Matches the enclosed pattern. This is used for grouping. If the KKSSHHGGLLOOBB option is set, then a `@@', `**', `++', `??' or `!!' immediately preceding the `((' is treated specially, as detailed below. The option SSHHGGLLOOBB prevents bare parentheses from being used in this way, though the KKSSHHGGLLOOBB option is still available. Note that grouping cannot extend over multiple directories: it is an error to have a `//' within a group (this only applies for patterns used in filename generation). There is one exception:

a group of the form ((pat//))## appearing as a complete path segment

can match a sequence of directories. For example, ffoooo//((aa**//))##bbaarr

matches ffoooo//bbaarr, ffoooo//aannyy//bbaarr, ffoooo//aannyy//aannyyootthheerr//bbaarr, and so on. x||y Matches either x or y. This operator has lower precedence than any other. The `||' character must be within parentheses, to avoid interpretation as a pipeline. ^^x (Requires EEXXTTEENNDDEEDDGGLLOOBB to be set.) Matches anything except the pattern x. This has a higher precedence than `//', so `^^ffoooo//bbaarr' will search directories in `..' except `..//ffoooo' for a file named `bbaarr'. x~~y (Requires EEXXTTEENNDDEEDDGGLLOOBB to be set.) Match anything that matches the pattern x but does not match y. This has lower precedence than any operator except `||', so `**//**~~ffoooo//bbaarr' will search for all files in all directories in `..' and then exclude `ffoooo//bbaarr' if there was such a match. Multiple patterns can be excluded by `foo~~bar~~baz'. In the exclusion pattern (y), `//' and `..' are not treated specially the way they usually are in globbing.

x## (Requires EEXXTTEENNDDEEDDGGLLOOBB to be set.) Matches zero or more occur-

rences of the pattern x. This operator has high precedence;

`1122##' is equivalent to `11((22##))', rather than `((1122))##'. It is an

error for an unquoted `##' to follow something which cannot be

repeated; this includes an empty string, a pattern already fol-

lowed by `####', or parentheses when part of a KKSSHHGGLLOOBB pattern

(for example, `!!((foo))##' is invalid and must be replaced by

`**((!!((foo))))').

x#### (Requires EEXXTTEENNDDEEDDGGLLOOBB to be set.) Matches one or more occur-

rences of the pattern x. This operator has high precedence;

`1122####' is equivalent to `11((22####))', rather than `((1122))####'. No more

than two active `##' characters may appear together.

kksshh-lliikkee GGlloobb OOppeerraattoorrss

If the KKSSHHGGLLOOBB option is set, the effects of parentheses can be modi-

fied by a preceding `@@', `**', `++', `??' or `!!'. This character need not be unquoted to have special effects, but the `((' must be. @@((...)) Match the pattern in the parentheses. (Like `((...))'.)

**((...)) Match any number of occurrences. (Like `((...))##'.)

++((...)) Match at least one occurrence. (Like `((...))####'.)

??((...)) Match zero or one occurrence. (Like `((||...))'.) !!((...)) Match anything but the expression in parentheses. (Like `((^^((...))))'.) PPrreecceeddeennccee The precedence of the operators given above is (highest) `^^', `//', `~~', `||' (lowest); the remaining operators are simply treated from left to

right as part of a string, with `##' and `####' applying to the shortest

possible preceding unit (i.e. a character, `??', `[[...]]', `<<...>>', or a

parenthesised expression). As mentioned above, a `//' used as a direc-

tory separator may not appear inside parentheses, while a `||' must do so; in patterns used in other contexts than filename generation (for example, in ccaassee statements and tests within `[[[[...]]]]'), a `//' is not special; and `//' is also not special after a `~~' appearing outside parentheses in a filename pattern. GGlloobbbbiinngg FFllaaggss There are various flags which affect any text to their right up to the end of the enclosing group or to the end of the pattern; they require

the EEXXTTEENNDDEEDDGGLLOOBB option. All take the form ((##X)) where X may have one

of the following forms: i Case insensitive: upper or lower case characters in the pattern match upper or lower case characters. l Lower case characters in the pattern match upper or lower case characters; upper case characters in the pattern still only match upper case characters. I Case sensitive: locally negates the effect of ii or ll from that point on. b Activate backreferences for parenthesised groups in the pattern; this does not work in filename generation. When a pattern with a set of active parentheses is matched, the strings matched by

the groups are stored in the array $$mmaattcchh, the indices of the

beginning of the matched parentheses in the array $$mmbbeeggiinn, and

the indices of the end in the array $$mmeenndd, with the first ele-

ment of each array corresponding to the first parenthesised group, and so on. These arrays are not otherwise special to the shell. The indices use the same convention as does parameter

substitution, so that elements of $$mmeenndd and $$mmbbeeggiinn may be used

in subscripts; the KKSSHHAARRRRAAYYSS option is respected. Sets of globbing flags are not considered parenthesised groups; only the first nine active parentheses can be referenced. For example, ffoooo==""aa ssttrriinngg wwiitthh aa mmeessssaaggee""

iiff [[[[ $$ffoooo == ((aa||aann))'' ''((##bb))((**))'' ''** ]]]];; tthheenn

pprriinntt $${{ffoooo[[$$mmbbeeggiinn[[11]],,$$mmeenndd[[11]]]]}}

ffii prints `ssttrriinngg wwiitthh aa'. Note that the first parenthesis is

before the ((##bb)) and does not create a backreference.

Backreferences work with all forms of pattern matching other than filename generation, but note that when performing matches

on an entire array, such as $${{array##pattern}}, or a global sub-

stitution, such as $${{param////pat//repl}}, only the data for the

last match remains available. In the case of global replace-

ments this may still be useful. See the example for the mm flag below. The numbering of backreferences strictly follows the order of the opening parentheses from left to right in the pattern string, although sets of parentheses may be nested. There are

special rules for parentheses followed by `##' or `####'. Only the

last match of the parenthesis is remembered: for example, in `[[[[

aabbaabb == ((##bb))(([[aabb]]))## ]]]]', only the final `bb' is stored in

mmaattcchh[[11]]. Thus extra parentheses may be necessary to match the

complete segment: for example, use `XX((((aabb||ccdd))##))YY' to match a

whole string of either `aabb' or `ccdd' between `XX' and `YY', using

the value of $$mmaattcchh[[11]] rather than $$mmaattcchh[[22]].

If the match fails none of the parameters is altered, so in some cases it may be necessary to initialise them beforehand. If

some of the backreferences fail to match -- which happens if

they are in an alternate branch which fails to match, or if they

are followed by ## and matched zero times -- then the matched

string is set to the empty string, and the start and end indices

are set to -1.

Pattern matching with backreferences is slightly slower than without. B Deactivate backreferences, negating the effect of the bb flag from that point on. m Set references to the match data for the entire string matched; this is similar to backreferencing and does not work in filename

generation. The flag must be in effect at the end of the pat-

tern, i.e. not local to a group. The parameters $$MMAATTCCHH, $$MMBBEEGGIINN

and $$MMEENNDD will be set to the string matched and to the indices

of the beginning and end of the string, respectively. This is most useful in parameter substitutions, as otherwise the string matched is obvious. For example, aarrrr==((vveellddtt jjyynnxx ggrriimmppss wwaaqqff zzhhoo bbuucckk))

pprriinntt $${{aarrrr////((##mm))[[aaeeiioouu]]//$${{((UU))MMAATTCCHH}}}}

forces all the matches (i.e. all vowels) into uppercase, print-

ing `vvEEllddtt jjyynnxx ggrrIImmppss wwAAqqff zzhhOO bbUUcckk'. Unlike backreferences, there is no speed penalty for using match references, other than the extra substitutions required for the replacement strings in cases such as the example shown. M Deactivate the mm flag, hence no references to match data will be created. aanum Approximate matching: num errors are allowed in the string matched by the pattern. The rules for this are described in the next subsection. ss, ee Unlike the other flags, these have only a local effect, and each

must appear on its own: `((##ss))' and `((##ee))' are the only valid

forms. The `((##ss))' flag succeeds only at the start of the test

string, and the `((##ee))' flag succeeds only at the end of the test

string; they correspond to `^^' and `$$' in standard regular

expressions. They are useful for matching path segments in pat-

terns other than those in filename generation (where path seg-

ments are in any case treated separately). For example,

`**((((##ss))||//))tteesstt((((##ee))||//))**' matches a path segment `tteesstt' in any of

the following strings: tteesstt, tteesstt//aatt//ssttaarrtt, aatt//eenndd//tteesstt, iinn//tteesstt//mmiiddddllee. Another use is in parameter substitution; for example

`$${{aarrrraayy//((##ss))AA**ZZ((##ee))}}' will remove only elements of an array

which match the complete pattern `AA**ZZ'. There are other ways of performing many operations of this type, however the combination

of the substitution operations `//' and `////' with the `((##ss))' and

`((##ee))' flags provides a single simple and memorable method.

Note that assertions of the form `((^^((##ss))))' also work, i.e. match

anywhere except at the start of the string, although this actu-

ally means `anything except a zero-length portion at the start

of the string'; you need to use `((""""~~((##ss))))' to match a

zero-length portion of the string not at the start.

qq A `qq' and everything up to the closing parenthesis of the glob-

bing flags are ignored by the pattern matching code. This is intended to support the use of glob qualifiers, see below. The

result is that the pattern `((##bb))((**))..cc((##qq..))' can be used both for

globbing and for matching against a string. In the former case,

the `((##qq..))' will be treated as a glob qualifier and the `((##bb))'

will not be useful, while in the latter case the `((##bb))' is use-

ful for backreferences and the `((##qq..))' will be ignored. Note

that colon modifiers in the glob qualifiers are also not applied in ordinary pattern matching. For example, the test string ffooooxxxx can be matched by the pattern

((##ii))FFOOOOXXXX, but not by ((##ll))FFOOOOXXXX, ((##ii))FFOOOO((##II))XXXX or ((((##ii))FFOOOOXX))XX. The

string ((##iiaa22))rreeaaddmmee specifies case-insensitive matching of rreeaaddmmee with

up to two errors. When using the ksh syntax for grouping both KKSSHHGGLLOOBB and EEXXTTEENNDDEEDDGGLLOOBB must be set and the left parenthesis should be preceded by @@. Note also that the flags do not affect letters inside [[......]] groups, in other

words ((##ii))[[aa-zz]] still matches only lowercase letters. Finally, note

that when examining whole paths case-insensitively every directory must

be searched for all files which match, so that a pattern of the form

((##ii))//ffoooo//bbaarr//...... is potentially slow.

AApppprrooxxiimmaattee MMaattcchhiinngg When matching approximately, the shell keeps a count of the errors

found, which cannot exceed the number specified in the ((##aanum)) flags.

Four types of error are recognised: 1. Different characters, as in ffooooxxbbaarr and ffooooyybbaarr. 2. Transposition of characters, as in bbaannaannaa and aabbnnaannaa. 3. A character missing in the target string, as with the pattern rrooaadd and target string rroodd. 4. An extra character appearing in the target string, as with ssttoovvee and ssttrroovvee.

Thus, the pattern ((##aa33))aabbccdd matches ddccbbaa, with the errors occurring by

using the first rule twice and the second once, grouping the string as [[dd]][[ccbb]][[aa]] and [[aa]][[bbcc]][[dd]].

Non-literal parts of the pattern must match exactly, including charac-

ters in character ranges: hence ((##aa11))?????? matches strings of length

four, by applying rule 4 to an empty part of the pattern, but not strings of length two, since all the ?? must match. Other characters which must match exactly are initial dots in filenames (unless the GGLLOOBBDDOOTTSS option is set), and all slashes in filenames, so that aa//bbcc is

two errors from aabb//cc (the slash cannot be transposed with another char-

acter). Similarly, errors are counted separately for non-contiguous

strings in the pattern, so that ((aabb||ccdd))eeff is two errors from aaeebbff. When using exclusion via the ~~ operator, approximate matching is treated entirely separately for the excluded part and must be activated

separately. Thus, ((##aa11))RREEAADDMMEE~~RREEAADDMMEE matches RREEAADD..MMEE but not RREEAADDMMEE,

as the trailing RREEAADDMMEE is matched without approximation. However,

((##aa11))RREEAADDMMEE~~((##aa11))RREEAADDMMEE does not match any pattern of the form RREEAADD?MMEE

as all such forms are now excluded. Apart from exclusions, there is only one overall error count; however, the maximum errors allowed may be altered locally, and this can be

delimited by grouping. For example, ((##aa11))ccaatt((((##aa00))ddoogg))ffooxx allows one

error in total, which may not occur in the ddoogg section, and the pattern

((##aa11))ccaatt((##aa00))ddoogg((##aa11))ffooxx is equivalent. Note that the point at which

an error is first found is the crucial one for establishing whether to

use approximation; for example, ((##aa11))aabbcc((##aa00))xxyyzz will not match

aabbccddxxyyzz, because the error occurs at the `xx', where approximation is turned off. Entire path segments may be matched approximately, so that

`((##aa11))//ffoooo//dd//iiss//aavvaaiillaabbllee//aatt//tthhee//bbaarr' allows one error in any path seg-

ment. This is much less efficient than without the ((##aa11)), however,

since every directory in the path must be scanned for a possible

approximate match. It is best to place the ((##aa11)) after any path seg-

ments which are known to be correct. RReeccuurrssiivvee GGlloobbbbiinngg

A pathname component of the form `((foo//))##' matches a path consisting of

zero or more directories matching the pattern foo.

As a shorthand, `****//' is equivalent to `((**//))##'; note that this there-

fore matches files in the current directory as well as subdirectories. Thus:

llss ((**//))##bbaarr

or llss ****//bbaarr does a recursive directory search for files named `bbaarr' (potentially including the file `bbaarr' in the current directory). This form does not

follow symbolic links; the alternative form `******//' does, but is other-

wise identical. Neither of these can be combined with other forms of globbing within the same path segment; in that case, the `**' operators revert to their usual effect. GGlloobb QQuuaalliiffiieerrss Patterns used for filename generation may end in a list of qualifiers enclosed in parentheses. The qualifiers specify which filenames that otherwise match the given pattern will be inserted in the argument list. If the option BBAARREEGGLLOOBBQQUUAALL is set, then a trailing set of parentheses containing no `||' or `((' characters (or `~~' if it is special) is taken as a set of glob qualifiers. A glob subexpression that would normally be taken as glob qualifiers, for example `((^^xx))', can be forced to be treated as part of the glob pattern by doubling the parentheses, in this case producing `((((^^xx))))'.

If the option EEXXTTEENNDDEEDDGGLLOOBB is set, a different syntax for glob quali-

fiers is available, namely `((##qqxx))' where xx is any of the same glob

qualifiers used in the other format. The qualifiers must still appear at the end of the pattern. However, with this syntax multiple glob qualifiers may be chained together. They are treated as a logical AND of the individual sets of flags. Also, as the syntax is unambiguous, the expression will be treated as glob qualifiers just as long any parentheses contained within it are balanced; appearance of `||', `((' or

`~~' does not negate the effect. Note that qualifiers will be recog-

nised in this form even if a bare glob qualifier exists at the end of

the pattern, for example `**((##qq**))((..))' will recognise executable regular

files if both options are set; however, mixed syntax should probably be avoided for the sake of clarity. A qualifier may be any one of the following: // directories

FF `full' (i.e. non-empty) directories. Note that the opposite

sense ((^^FF)) expands to empty directories and all non-directories.

Use ((//^^FF)) for empty directories .. plain files @@ symbolic links == sockets pp named pipes (FIFOs) ** executable plain files (0100)

%% device files (character or block special)

%%bb block special files

%%cc character special files

rr owner-readable files (0400)

ww owner-writable files (0200)

xx owner-executable files (0100)

AA group-readable files (0040)

II group-writable files (0020)

EE group-executable files (0010)

RR world-readable files (0004)

WW world-writable files (0002)

XX world-executable files (0001)

ss setuid files (04000) SS setgid files (02000) tt files with the sticky bit (01000) ffspec files with access rights matching spec. This spec may be a octal

number optionally preceded by a `==', a `++', or a `-'. If none of

these characters is given, the behavior is the same as for `=='.

The octal number describes the mode bits to be expected, if com-

bined with a `==', the value given must match the file-modes

exactly, with a `++', at least the bits in the given number must

be set in the file-modes, and with a `-', the bits in the number

must not be set. Giving a `??' instead of a octal digit anywhere in the number ensures that the corresponding bits in the

file-modes are not checked, this is only useful in combination

with `=='. If the qualifier `ff' is followed by any other character anything up to the next matching character (`[[', `{{', and `<<' match `]]', `}}', and `>>' respectively, any other character matches itself)

is taken as a list of comma-separated sub-specs. Each sub-spec

may be either an octal number as described above or a list of any of the characters `uu', `gg', `oo', and `aa', followed by a `==',

a `++', or a `-', followed by a list of any of the characters

`rr', `ww', `xx', `ss', and `tt', or an octal digit. The first list of characters specify which access rights are to be checked. If a `uu' is given, those for the owner of the file are used, if a `gg' is given, those of the group are checked, a `oo' means to test those of other users, and the `aa' says to test all three

groups. The `==', `++', and `-' again says how the modes are to be

checked and have the same meaning as described for the first form above. The second list of characters finally says which access rights are to be expected: `rr' for read access, `ww' for write access, `xx' for the right to execute the file (or to search a directory), `ss' for the setuid and setgid bits, and `tt' for the sticky bit. Thus, `**((ff7700??))' gives the files for which the owner has read, write, and execute permission, and for which other group members have no rights, independent of the permissions for other users.

The pattern `**((ff-110000))' gives all files for which the owner does

not have execute permission, and `**((ff::gguu++ww,,oo-rrxx::))' gives the

files for which the owner and the other members of the group have at least write permission, and for which other users don't have read or execute permission. eestring ++cmd The string will be executed as shell code. The filename will be

included in the list if and only if the code returns a zero sta-

tus (usually the status of the last command). The first charac-

ter after the `ee' will be used as a separator and anything up to the next matching separator will be taken as the string; `[[', `{{', and `<<' match `]]', `}}', and `>>', respectively, while any other character matches itself. Note that expansions must be quoted in the string to prevent them from being expanded before globbing is done. During the execution of string the filename currently being tested is available in the parameter RREEPPLLYY; the parameter may be altered to a string to be inserted into the list instead of the original filename. In addition, the parameter rreeppllyy may be set to an array or a string, which overrides the value of RREEPPLLYY. If set to an array, the latter is inserted into the command line word by word. For example, suppose a directory contains a single file

`lloonneellyy'. Then the expression `**((ee::''rreeppllyy==(($${{RREEPPLLYY}}{{11,,22}}))''::))'

will cause the words `lloonneellyy11 lloonneellyy22' to be inserted into the command line. Note the quotation marks. The form ++cmd has the same effect, but no delimiters appear around cmd. Instead, cmd is taken as the longest sequence of characters following the ++ that are alphanumeric or underscore. Typically cmd will be the name of a shell function that contains the appropriate test. For example,

nntt(()) {{ [[[[ $$RREEPPLLYY -nntt $$NNTTRREEFF ]]]] }}

NNTTRREEFF==rreeffffiillee

llss -ll **((++nntt))

lists all files in the directory that have been modified more recently than rreeffffiillee. dddev files on the device dev

ll[-|++]ct

files having a link count less than ct (-), greater than ct (++),

or equal to ct UU files owned by the effective user ID GG files owned by the effective group ID uuid files owned by user ID id if it is a number, if not, than the character after the `uu' will be used as a separator and the string between it and the next matching separator (`[[', `{{', and `<<' match `]]', `}}', and `>>' respectively, any other character matches itself) will be taken as a user name, and the user ID of this user will be taken (e.g. `uu::ffoooo::' or `uu[[ffoooo]]' for user `ffoooo') ggid like uuid but with group IDs or names

aa[MMwwhhmmss][-|++]n

files accessed exactly n days ago. Files accessed within the

last n days are selected using a negative value for n (-n).

Files accessed more than n days ago are selected by a positive n value (++n). Optional unit specifiers `MM', `ww', `hh', `mm' or `ss' (e.g. `aahh55') cause the check to be performed with months (of 30

days), weeks, hours, minutes or seconds instead of days, respec-

tively. For instance, `eecchhoo **((aahh-55))' would echo files accessed

within the last five hours.

mm[MMwwhhmmss][-|++]n

like the file access qualifier, except that it uses the file modification time.

cc[MMwwhhmmss][-|++]n

like the file access qualifier, except that it uses the file inode change time.

LL[++|-]n

files less than n bytes (-), more than n bytes (++), or exactly n

bytes in length. If this flag is directly followed by a `kk'

(`KK'), `mm' (`MM'), or `pp' (`PP') (e.g. `LLkk-5500') the check is per-

formed with kilobytes, megabytes, or blocks (of 512 bytes) instead. ^^ negates all qualifiers following it

- toggles between making the qualifiers work on symbolic links

(the default) and the files they point to MM sets the MMAARRKKDDIIRRSS option for the current pattern TT appends a trailing qualifier mark to the filenames, analogous to the LLIISSTTTTYYPPEESS option, for the current pattern (overrides MM) NN sets the NNUULLLLGGLLOOBB option for the current pattern DD sets the GGLLOOBBDDOOTTSS option for the current pattern nn sets the NNUUMMEERRIICCGGLLOOBBSSOORRTT option for the current pattern ooc specifies how the names of the files should be sorted. If c is nn they are sorted by name (the default); if it is LL they are sorted depending on the size (length) of the files; if ll they are sorted by the number of links; if aa, mm, or cc they are sorted by the time of the last access, modification, or inode change respectively; if dd, files in subdirectories appear before those

in the current directory at each level of the search -- this is

best combined with other criteria, for example `ooddoonn' to sort on names for files within the same directory. Note that aa, mm, and cc compare the age against the current time, hence the first name in the list is the youngest file. Also note that the modifiers ^^

and - are used, so `**((^^-ooLL))' gives a list of all files sorted by

file size in descending order, following any symbolic links. OOc like `oo', but sorts in descending order; i.e. `**((^^oocc))' is the same as `**((OOcc))' and `**((^^OOcc))' is the same as `**((oocc))'; `OOdd' puts files in the current directory before those in subdirectories at each level of the search. [[beg[,,end]]] specifies which of the matched filenames should be included in

the returned list. The syntax is the same as for array sub-

scripts. beg and the optional end may be mathematical expres-

sions. As in parameter subscripting they may be negative to make

them count from the last match backward. E.g.: `**((-OOLL[[11,,33]]))'

gives a list of the names of the three largest files. More than one of these lists can be combined, separated by commas. The whole list matches if at least one of the sublists matches (they are `or'ed, the qualifiers in the sublists are `and'ed). Some qualifiers, however, affect all matches generated, independent of the sublist in which they are given. These are the qualifiers `MM', `TT', `NN', `DD', `nn', `oo', `OO' and the subscripts given in brackets (`[[......]]'). If a `::' appears in a qualifier list, the remainder of the expression

in parenthesis is interpreted as a modifier (see the section `Modi-

fiers' in the section `History Expansion'). Note that each modifier must be introduced by a separate `::'. Note also that the result after modification does not have to be an existing file. The name of any existing file can be followed by a modifier of the form `((::....))' even if no actual filename generation is performed. Thus:

llss **((-//))

lists all directories and symbolic links that point to directories, and

llss **((%%WW))

lists all world-writable device files in the current directory, and

llss **((WW,,XX))

lists all files in the current directory that are world-writable or

world-executable, and

eecchhoo //ttmmpp//ffoooo**((uu00^^@@::tt))

outputs the basename of all root-owned files beginning with the string

`ffoooo' in //ttmmpp, ignoring symlinks, and llss **..**~~((lleexx||ppaarrssee))..[[cchh]]((^^DD^^ll11)) lists all files having a link count of one whose names contain a dot (but not those starting with a dot, since GGLLOOBBDDOOTTSS is explicitly switched off) except for lleexx..cc, lleexx..hh, ppaarrssee..cc and ppaarrssee..hh.

pprriinntt bb**..pprroo((##qq::ss//pprroo//sshhmmoo//))((##qq..::ss//bbuuiillttiinn//sshhmmiillttiinn//))

demonstrates how colon modifiers and other qualifiers may be chained together. The ordinary qualifier `..' is applied first, then the colon modifiers in order from left to right. So if EEXXTTEENNDDEEDDGGLLOOBB is set and the base pattern matches the regular file bbuuiillttiinn..pprroo, the shell will print `sshhmmiillttiinn..sshhmmoo'. ZSHPARAM(1) ZSHPARAM(1)

NAME

zshparam - zsh parameters

DESCRIPTION

A parameter has a name, a value, and a number of attributes. A name may be any sequence of alphanumeric characters and underscores, or the

single characters `**', `@@', `##', `??', `-', `$$', or `!!'. The value may

be a scalar (a string), an integer, an array (indexed numerically), or

an associative array (an unordered set of name-value pairs, indexed by

name). To declare the type of a parameter, or to assign a scalar or integer value to a parameter, use the ttyyppeesseett builtin. The value of a scalar or integer parameter may also be assigned by writing: name==value

If the integer attribute, -ii, is set for name, the value is subject to

arithmetic evaluation. Furthermore, by replacing `==' with `++==', a

parameter can be added or appended to. See the section `Array Parame-

ters' for additional forms of assignment.

To refer to the value of a parameter, write `$$name' or `$${{name}}'. See

Parameter Expansion in zshexpn(1) for complete details. In the parameter lists that follow, the mark `' indicates that the parameter is special. Special parameters cannot have their type

changed or their readonly attribute turned off, and if a special param-

eter is unset, then later recreated, the special properties will be retained. `' indicates that the parameter does not exist when the shell initializes in sshh or kksshh emulation mode. AARRRRAAYY PPAARRAAMMEETTEERRSS To assign an array value, write one of:

sseett -AA name value ...

name==((value ...)) If no parameter name exists, an ordinary array parameter is created. If the parameter name exists and is a scalar, it is replaced by a new array. Ordinary array parameters may also be explicitly declared with:

ttyyppeesseett -aa name

Associative arrays must be declared before assignment, by using:

ttyyppeesseett -AA name

When name refers to an associative array, the list in an assignment is interpreted as alternating keys and values:

set -A name key value ...

name==((key value ...)) Every key must have a value in this case. Note that this assigns to the entire array, deleting any elements that do not appear in the list. To create an empty array (including associative arrays), use one of:

sseett -AA name

name==(()) AArrrraayy SSuubbssccrriippttss Individual elements of an array may be selected using a subscript. A subscript of the form `[[exp]]' selects the single element exp, where exp

is an arithmetic expression which will be subject to arithmetic expan-

sion as if it were surrounded by `$$((((...))))'. The elements are numbered

beginning with 1, unless the KKSSHHAARRRRAAYYSS option is set in which case they are numbered from zero. Subscripts may be used inside braces used to delimit a parameter name,

thus `$${{ffoooo[[22]]}}' is equivalent to `$$ffoooo[[22]]'. If the KKSSHHAARRRRAAYYSS option

is set, the braced form is the only one that works, as bracketed expressions otherwise are not treated as subscripts. The same subscripting syntax is used for associative arrays, except that no arithmetic expansion is applied to exp. However, the parsing rules for arithmetic expressions still apply, which affects the way that certain special characters must be protected from interpretation. See Subscript Parsing below for details. A subscript of the form `[[**]]' or `[[@@]]' evaluates to all elements of an array; there is no difference between the two except when they appear

within double quotes. `""$$ffoooo[[**]]""' evaluates to `""$$ffoooo[[11]] $$ffoooo[[22]]

...""', whereas `""$$ffoooo[[@@]]""' evaluates to `""$$ffoooo[[11]]"" ""$$ffoooo[[22]]"" ...'. For

associative arrays, `[[**]]' or `[[@@]]' evaluate to all the values, in no particular order. Note that this does not substitute the keys; see the

documentation for the `kk' flag under Parameter Expansion Flags in zsh-

expn(1) for complete details. When an array parameter is referenced as

`$$name' (with no subscript) it evaluates to `$$name[[**]]', unless the

KKSSHHAARRRRAAYYSS option is set in which case it evaluates to `$${{name[[00]]}}'

(for an associative array, this means the value of the key `00', which may not exist even if there are values for other keys). A subscript of the form `[[exp1,,exp2]]' selects all elements in the range exp1 to exp2, inclusive. (Associative arrays are unordered, and so do not support ranges.) If one of the subscripts evaluates to a negative

number, say -n, then the nth element from the end of the array is used.

Thus `$$ffoooo[[-33]]' is the third element from the end of the array ffoooo, and

`$$ffoooo[[11,,-11]]' is the same as `$$ffoooo[[**]]'.

Subscripting may also be performed on non-array values, in which case

the subscripts specify a substring to be extracted. For example, if

FFOOOO is set to `ffoooobbaarr', then `eecchhoo $$FFOOOO[[22,,55]]' prints `oooobbaa'.

AArrrraayy EElleemmeenntt AAssssiiggnnmmeenntt A subscript may be used on the left side of an assignment like so: name[[exp]]==value In this form of assignment the element or range specified by exp is replaced by the expression on the right side. An array (but not an associative array) may be created by assignment to a range or element. Arrays do not nest, so assigning a parenthesized list of values to an element or range changes the number of elements in the array, shifting

the other elements to accommodate the new values. (This is not sup-

ported for associative arrays.) This syntax also works as an argument to the ttyyppeesseett command: ttyyppeesseett ""name[[exp]]""==value

The value may not be a parenthesized list in this case; only sin-

gle-element assignments may be made with ttyyppeesseett. Note that quotes are

necessary in this case to prevent the brackets from being interpreted as filename generation operators. The nnoogglloobb precommand modifier could be used instead. To delete an element of an ordinary array, assign `(())' to that element. To delete an element of an associative array, use the uunnsseett command: uunnsseett ""name[[exp]]"" SSuubbssccrriipptt FFllaaggss If the opening bracket, or the comma in a range, in any subscript expression is directly followed by an opening parenthesis, the string up to the matching closing one is considered to be a list of flags, as in `name[[((flags))exp]]'. The flags currently understood are: ww If the parameter subscripted is a scalar than this flag makes subscripting work on words instead of characters. The default word separator is whitespace. ss::string:: This gives the string that separates words (for use with the ww flag). pp Recognize the same escape sequences as the pprriinntt builtin in the string argument of a subsequent `ss' flag. ff If the parameter subscripted is a scalar than this flag makes

subscripting work on lines instead of characters, i.e. with ele-

ments separated by newlines. This is a shorthand for `ppwwss::\\nn::'. rr Reverse subscripting: if this flag is given, the exp is taken as a pattern and the result is the first matching array element, substring or word (if the parameter is an array, if it is a

scalar, or if it is a scalar and the `ww' flag is given, respec-

tively). The subscript used is the number of the matching ele-

ment, so that pairs of subscripts such as `$$ffoooo[[((rr))??,,33]]' and

`$$ffoooo[[((rr))??,,((rr))ff**]]' are possible if the parameter is not an

associative array. If the parameter is an associative array, only the value part of each pair is compared to the pattern, and the result is that value. RR Like `rr', but gives the last match. For associative arrays,

gives all possible matches. May be used for assigning to ordi-

nary array elements, but not for assigning to associative arrays. ii Like `rr', but gives the index of the match instead; this may not be combined with a second argument. On the left side of an assignment, behaves like `rr'. For associative arrays, the key part of each pair is compared to the pattern, and the first matching key found is the result. II Like `ii', but gives the index of the last match, or all possible matching keys in an associative array. kk If used in a subscript on an associative array, this flag causes the keys to be interpreted as patterns, and returns the value for the first key found where exp is matched by the key. This

flag does not work on the left side of an assignment to an asso-

ciative array element. If used on another type of parameter, this behaves like `rr'. KK On an associative array this is like `kk' but returns all values where exp is matched by the keys. On other types of parameters this has the same effect as `RR'. nn::expr:: If combined with `rr', `RR', `ii' or `II', makes them give the nth or nth last match (if expr evaluates to n). This flag is ignored when the array is associative. bb::expr:: If combined with `rr', `RR', `ii' or `II', makes them begin at the nth or nth last element, word, or character (if expr evaluates to n). This flag is ignored when the array is associative. ee This flag has no effect and for ordinary arrays is retained for backward compatibility only. For associative arrays, this flag can be used to force ** or @@ to be interpreted as a single key rather than as a reference to all values. This flag may be used on the left side of an assignment. See Parameter Expansion Flags (zshexpn(1)) for additional ways to manipulate the results of array subscripting. SSuubbssccrriipptt PPaarrssiinngg This discussion applies mainly to associative array key strings and to patterns used for reverse subscripting (the `rr', `RR', `ii', etc. flags), but it may also affect parameter substitutions that appear as part of an arithmetic expression in an ordinary subscript.

It is possible to avoid the use of subscripts in assignments to asso-

ciative array elements by using the syntax: aaaa++==((''kkeeyy wwiitthh ""**ssttrraannggee**"" cchhaarraacctteerrss'' ''vvaalluuee ssttrriinngg'')) This adds a new key/value pair if the key is not already present, and replaces the value for the existing key if it is. The basic rule to remember when writing a subscript expression is that all text between the opening `[[' and the closing `]]' is interpreted as if it were in double quotes (see zshmisc(1)). However, unlike double quotes which normally cannot nest, subscript expressions may appear

inside double-quoted strings or inside other subscript expressions (or

both!), so the rules have two important differences.

The first difference is that brackets (`[[' and `]]') must appear as bal-

anced pairs in a subscript expression unless they are preceded by a backslash (`\\'). Therefore, within a subscript expression (and unlike

true double-quoting) the sequence `\\[[' becomes `[[', and similarly `\\]]'

becomes `]]'. This applies even in cases where a backslash is not nor-

mally required; for example, the pattern `[[^^[[]]' (to match any character

other than an open bracket) should be written `[[^^\\[[]]' in a reverse-sub-

script pattern. However, note that `\\[[^^\\[[\\]]' and even `\\[[^^[[]]' mean the same thing, because backslashes are always stripped when they appear before brackets! The same rule applies to parentheses (`((' and `))') and braces (`{{' and

`}}'): they must appear either in balanced pairs or preceded by a back-

slash, and backslashes that protect parentheses or braces are removed during parsing. This is because parameter expansions may be surrounded

balanced braces, and subscript flags are introduced by balanced paren-

thesis.

The second difference is that a double-quote (`""') may appear as part

of a subscript expression without being preceded by a backslash, and therefore that the two characters `\\""' remain as two characters in the

subscript (in true double-quoting, `\\""' becomes `""'). However, because

of the standard shell quoting rules, any double-quotes that appear must

occur in balanced pairs unless preceded by a backslash. This makes it more difficult to write a subscript expression that contains an odd

number of double-quote characters, but the reason for this difference

is so that when a subscript expression appears inside true dou-

ble-quotes, one can still write `\\""' (rather than `\\\\\\""') for `""'.

To use an odd number of double quotes as a key in an assignment, use the ttyyppeesseett builtin and an enclosing pair of double quotes; to refer to the value of that key, again use double quotes:

ttyyppeesseett -AA aaaa

ttyyppeesseett ""aaaa[[oonnee\\""ttwwoo\\""tthhrreeee\\""qquuootteess]]""==QQQQQQ

pprriinntt ""$$aaaa[[oonnee\\""ttwwoo\\""tthhrreeee\\""qquuootteess]]""

It is important to note that the quoting rules do not change when a parameter expansion with a subscript is nested inside another subscript expression. That is, it is not necessary to use additional backslashes within the inner subscript expression; they are removed only once, from the innermost subscript outwards. Parameters are also expanded from the innermost subscript first, as each expansion is encountered left to right in the outer expression. A further complication arises from a way in which subscript parsing is

not different from double quote parsing. As in true double-quoting,

the sequences `\\**', and `\\@@' remain as two characters when they appear

in a subscript expression. To use a literal `**' or `@@' as an associa-

tive array key, the `ee' flag must be used:

ttyyppeesseett -AA aaaa

aaaa[[((ee))**]]==ssttaarr

pprriinntt $$aaaa[[((ee))**]]

A last detail must be considered when reverse subscripting is per-

formed. Parameters appearing in the subscript expression are first expanded and then the complete expression is interpreted as a pattern. This has two effects: first, parameters behave as if GGLLOOBBSSUUBBSSTT were on (and it cannot be turned off); second, backslashes are interpreted twice, once when parsing the array subscript and again when parsing the

pattern. In a reverse subscript, it's necessary to use four back-

slashes to cause a single backslash to match literally in the pattern. For complex patterns, it is often easiest to assign the desired pattern to a parameter and then refer to that parameter in the subscript, because then the backslashes, brackets, parentheses, etc., are seen only when the complete expression is converted to a pattern. To match the value of a parameter literally in a reverse subscript, rather than

as a pattern, use `$${{((qq))name}}' (see zshexpn(1)) to quote the expanded

value.

Note that the `kk' and `KK' flags are reverse subscripting for an ordi-

nary array, but are not reverse subscripting for an associative array! (For an associative array, the keys in the array itself are interpreted as patterns by those flags; the subscript is a plain string in that case.) One final note, not directly related to subscripting: the numeric names of positional parameters (described below) are parsed specially, so for

example `$$22ffoooo' is equivalent to `$${{22}}ffoooo'. Therefore, to use sub-

script syntax to extract a substring from a positional parameter, the

expansion must be surrounded by braces; for example, `$${{22[[33,,55]]}}' evalu-

ates to the third through fifth characters of the second positional

parameter, but `$$22[[33,,55]]' is the entire second parameter concatenated

with the filename generation pattern `[[33,,55]]'. PPOOSSIITTIIOONNAALL PPAARRAAMMEETTEERRSS

The positional parameters provide access to the command-line arguments

of a shell function, shell script, or the shell itself; see the section `Invocation', and also the section `Functions'. The parameter n, where n is a number, is the nth positional parameter. The parameters **, @@ and aarrggvv are arrays containing all the positional parameters; thus

`$$aarrggvv[[n]]', etc., is equivalent to simply `$$n'.

Positional parameters may be changed after the shell or function starts by using the sseett builtin, by assigning to the aarrggvv array, or by direct

assignment of the form `n==value' where n is the number of the posi-

tional parameter to be changed. This also creates (with empty values) any of the positions from 1 to n that do not already have values. Note

that, because the positional parameters form an array, an array assign-

ment of the form `n==((value ...))' is allowed, and has the effect of

shifting all the values at positions greater than n by as many posi-

tions as necessary to accommodate the new values. LLOOCCAALL PPAARRAAMMEETTEERRSS

Shell function executions delimit scopes for shell parameters. (Param-

eters are dynamically scoped.) The ttyyppeesseett builtin, and its alterna-

tive forms ddeeccllaarree, iinntteeggeerr, llooccaall and rreeaaddoonnllyy (but not eexxppoorrtt), can be used to declare a parameter as being local to the innermost scope.

When a parameter is read or assigned to, the innermost existing parame-

ter of that name is used. (That is, the local parameter hides any

less-local parameter.) However, assigning to a non-existent parameter,

or declaring a new parameter with eexxppoorrtt, causes it to be created in the outermost scope. Local parameters disappear when their scope ends. uunnsseett can be used to delete a parameter while it is still in scope; any outer parameter of the same name remains hidden. Special parameters may also be made local; they retain their special

attributes unless either the existing or the newly-created parameter

has the -hh (hide) attribute. This may have unexpected effects: there

is no default value, so if there is no assignment at the point the variable is made local, it will be set to an empty value (or zero in the case of integers). The following:

ttyyppeesseett PPAATTHH==//nneeww//ddiirreeccttoorryy::$$PPAATTHH

is valid for temporarily allowing the shell or programmes called from it to find the programs in //nneeww//ddiirreeccttoorryy inside a function.

Note that the restriction in older versions of zsh that local parame-

ters were never exported has been removed. PPAARRAAMMEETTEERRSS SSEETT BBYY TTHHEE SSHHEELLLL The following parameters are automatically set by the shell: !! The process ID of the last background command invoked.

## The number of positional parameters in decimal. Note that some

confusion may occur with the syntax $$##param which substitutes

the length of param. Use $${{##}} to resolve ambiguities. In par-

ticular, the sequence `$$##-...' in an arithmetic expression is

interpreted as the length of the parameter -, q.v.

AARRGGCC

Same as ##.

$$ The process ID of this shell.

- Flags supplied to the shell on invocation or by the sseett or

sseettoopptt commands. ** An array containing the positional parameters. aarrggvv Same as **. Assigning to aarrggvv changes the local positional parameters, but aarrggvv is not itself a local parameter. Deleting aarrggvv with uunnsseett in any function deletes it everywhere, although only the innermost positional parameter array is deleted (so ** and @@ in other scopes are not affected). @@ Same as aarrggvv[[@@]], even when aarrggvv is not set. ?? The exit value returned by the last command.

00 The name used to invoke the current shell. If the FFUUNNCC-

TTIIOONNAARRGGZZEERROO option is set, this is set temporarily within a shell function to the name of the function, and within a sourced script to the name of the script. ssttaattuuss Same as ??. ppiippeessttaattuuss An array containing the exit values returned by all commands in the last pipeline. The last argument of the previous command. Also, this parameter is set in the environment of every command executed to the full pathname of the command. CCPPUUTTYYPPEE The machine type (microprocessor class or machine model), as determined at run time. EEGGIIDD

The effective group ID of the shell process. If you have suffi-

cient privileges, you may change the effective group ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command with a different effective group ID by `((EEGGIIDD==gid;; ccoommmmaanndd))' EEUUIIDD

The effective user ID of the shell process. If you have suffi-

cient privileges, you may change the effective user ID of the shell process by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command with a different effective user ID by `((EEUUIIDD==uid;; ccoommmmaanndd))' EERRRRNNOO The value of errno (see errno(3)) as set by the most recently failed system call. This value is system dependent and is intended for debugging purposes. It is also useful with the zzsshh//ssyysstteemm module which allows the number to be turned into a name or message. GGIIDD The real group ID of the shell process. If you have sufficient privileges, you may change the group ID of the shell process by

assigning to this parameter. Also (assuming sufficient privi-

leges), you may start a single command under a different group ID by `((GGIIDD==gid;; ccoommmmaanndd))' HHIISSTTCCMMDD The current history line number in an interactive shell, in

other words the line number for the command that caused $$HHIISSTTCCMMDD

to be read. HHOOSSTT The current hostname. LLIINNEENNOO The line number of the current line within the current script, sourced file, or shell function being executed, whichever was started most recently. Note that in the case of shell functions the line number refers to the function as it appeared in the

original definition, not necessarily as displayed by the ffuunncc-

ttiioonnss builtin.

LOGNAME

If the corresponding variable is not set in the environment of the shell, it is initialized to the login name corresponding to the current login session. This parameter is exported by default but this can be disabled using the ttyyppeesseett builtin. MMAACCHHTTYYPPEE The machine type (microprocessor class or machine model), as determined at compile time.

OOLLDDPPWWDD The previous working directory. This is set when the shell ini-

tializes and whenever the directory changes. OOPPTTAARRGG The value of the last option argument processed by the ggeettooppttss command. OOPPTTIINNDD The index of the last option argument processed by the ggeettooppttss command. OOSSTTYYPPEE The operating system, as determined at compile time. PPPPIIDD The process ID of the parent of the shell.

PPWWDD The present working directory. This is set when the shell ini-

tializes and whenever the directory changes. RRAANNDDOOMM

A pseudo-random integer from 0 to 32767, newly generated each

time this parameter is referenced. The random number generator can be seeded by assigning a numeric value to RRAANNDDOOMM.

The values of RRAANNDDOOMM form an intentionally-repeatable

pseudo-random sequence; subshells that reference RRAANNDDOOMM will

result in identical pseudo-random values unless the value of

RRAANNDDOOMM is referenced or seeded in the parent shell in between subshell invocations. SSEECCOONNDDSS The number of seconds since shell invocation. If this parameter is assigned a value, then the value returned upon reference will be the value that was assigned plus the number of seconds since the assignment.

Unlike other special parameters, the type of the SSEECCOONNDDSS parame-

ter can be changed using the ttyyppeesseett command. Only integer and one of the floating point types are allowed. For example,

`ttyyppeesseett -FF SSEECCOONNDDSS' causes the value to be reported as a float-

ing point number. The precision is six decimal places, although not all places may be useful. SSHHLLVVLL Incremented by one each time a new shell is started. ssiiggnnaallss An array containing the names of the signals. TTRRYYBBLLOOCCKKEERRRROORR In an aallwwaayyss block, indicates whether the preceding list of code

caused an error. The value is 1 to indicate an error, 0 other-

wise. It may be reset, clearing the error condition. See Com-

plex Commands in zshmisc(1) TTTTYY The name of the tty associated with the shell, if any. TTTTYYIIDDLLEE The idle time of the tty associated with the shell in seconds or

-1 if there is no such tty.

UUIIDD The real user ID of the shell process. If you have sufficient privileges, you may change the user ID of the shell by assigning to this parameter. Also (assuming sufficient privileges), you may start a single command under a different user ID by `((UUIIDD==uid;; ccoommmmaanndd))'

USERNAME S

The username corresponding to the real user ID of the shell process. If you have sufficient privileges, you may change the username (and also the user ID and group ID) of the shell by

assigning to this parameter. Also (assuming sufficient privi-

leges), you may start a single command under a different user-

ae ad sr D n gop D b `(USERNAME=srae; com

mmaanndd))' VVEENNDDOORR The vendor, as determined at compile time.

ZSHNAME

Expands to the basename of the command used to invoke this instance of zsh. ZZSSHHVVEERRSSIIOONN The version number of this zsh. PPAARRAAMMEETTEERRSS UUSSEEDD BBYY TTHHEE SSHHEELLLL The following parameters are used by the shell.

In cases where there are two parameters with an upper- and lowercase

form of the same name, such as ppaatthh and PPAATTHH, 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 cre-

ated via `ttyyppeesseett -TT'. 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 recre-

ated, and recreating one of the pair will recreate the other.

AARRGGVV00 If exported, its value is used as the aarrggvv[[00]] of external com-

mands. Usually used in constructs like `AARRGGVV00==eemmaaccss nneetthhaacckk'.

BBAAUUDD The baud rate of the current connection. Used by the line edi-

tor update mechanism to compensate for a slow terminal by delay-

ing updates until necessary. This may be profitably set to a lower value in some circumstances, e.g. for slow modems dialing into a communications server which is connected to a host via a fast link; in this case, this variable would be set by default

to the speed of the fast link, and not the modem. This parame-

ter should be set to the baud rate of the slowest part of the link for best performance. The compensation mechanism can be turned off by setting the variable to zero. ccddppaatthh (CCDDPPAATTHH )

An array (colon-separated list) of directories specifying the

search path for the ccdd command. CCOOLLUUMMNNSS The number of columns for this terminal session. Used for printing select lists and for the line editor. DDIIRRSSTTAACCKKSSIIZZEE The maximum size of the directory stack. If the stack gets larger than this, it will be truncated automatically. This is useful with the AAUUTTOOPPUUSSHHDD option. EENNVV If the EENNVV environment variable is set when zsh is invoked as sshh

or kksshh, $$EENNVV is sourced after the profile scripts. The value of

EENNVV is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a pathname. Note that EENNVV is not used unless zsh is emulating sshh or kksshh. FFCCEEDDIITT The default editor for the ffcc builtin. ffiiggnnoorree (FFIIGGNNOORREE ) An array (colon separated list) containing the suffixes of files

to be ignored during filename completion. However, if comple-

tion only generates files with suffixes in this list, then these files are completed anyway. ffppaatthh (FFPPAATTHH ) An array (colon separated list) of directories specifying the search path for function definitions. This path is searched

when a function with the -uu attribute is referenced. If an exe-

cutable file is found, then it is read and executed in the cur-

rent environment. hhiissttcchhaarrss

Three characters used by the shell's history and lexical analy-

sis mechanism. The first character signals the start of a his-

tory expansion (default `!!'). The second character signals the start of a quick history substitution (default `^^'). The third

character is the comment character (default `##').

HHIISSTTCCHHAARRSS Same as hhiissttcchhaarrss. (Deprecated.) HHIISSTTFFIILLEE The file to save the history in when an interactive shell exits. If unset, the history is not saved. HHIISSTTSSIIZZEE The maximum number of events stored in the internal history list. If you use the HHIISSTTEEXXPPIIRREEDDUUPPSSFFIIRRSSTT option, setting

this value larger than the SSAAVVEEHHIISSTT size will give you the dif-

ference as a cushion for saving duplicated history events. HHOOMMEE The default argument for the ccdd command. IIFFSS 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 rreeaadd 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. KKEEYYTTIIMMEEOOUUTT The time the shell waits, in hundredths of seconds, for another

key to be pressed when reading bound multi-character sequences.

LLAANNGG This variable determines the locale category for any category not specifically selected via a variable starting with `LLCC'. LLCCAALLLL This variable overrides the value of the `LLAANNGG' variable and the value of any of the other variables starting with `LLCC'. LLCCCCOOLLLLAATTEE

This variable determines the locale category for character col-

lation information within ranges in glob brackets and for sort-

ing. LLCCCCTTYYPPEE

This variable determines the locale category for character han-

dling functions. LLCCMMEESSSSAAGGEESS This variable determines the language in which messages should be written. Note that zsh does not use message catalogs. LLCCNNUUMMEERRIICC 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. LLCCTTIIMMEE This variable determines the locale category for date and time formatting in prompt escape sequences. LLIINNEESS

The number of lines for this terminal session. Used for print-

ing select lists and for the line editor. LLIISSTTMMAAXX 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. LLOOGGCCHHEECCKK The interval in seconds between checks for login/logout activity using the wwaattcchh parameter. MMAAIILL If this parameter is set and mmaaiillppaatthh is not set, the shell looks for mail in the specified file. MMAAIILLCCHHEECCKK The interval in seconds between checks for new mail. mmaaiillppaatthh (MMAAIILLPPAATTHH )

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 `YYoouu hhaavvee nneeww mmaaiill'. If an element is a directory instead of a file the shell will recursively check every file in every subdirectory of the element. mmaannppaatthh (MMAANNPPAATTHH )

An array (colon-separated list) whose value is not used by the

shell. The mmaannppaatthh array can be useful, however, since setting it also sets MMAANNPPAATTHH, and vice versa. mmoodduulleeppaatthh (MMOODDUULLEEPPAATTHH )

An array (colon-separated list) of directories that zzmmooddllooaadd

searches for dynamically loadable modules. This is initialized

to a standard pathname, usually `//uussrr//llooccaall//lliibb//zzsshh//$$ZZSSHHVVEERR-

SSIIOONN'. (The `//uussrr//llooccaall//lliibb' part varies from installation to

installation.) For security reasons, any value set in the envi-

ronment when the shell is started will be ignored. These parameters only exist if the installation supports dynamic module loading. NNUULLLLCCMMDD The command name to assume if a redirection is specified with no command. Defaults to ccaatt. For sshh/kksshh behavior, change this to

::. For ccsshh-like behavior, unset this parameter; the shell will

print an error message if null commands are entered. ppaatthh (PPAATTHH )

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

This string is output whenever the line editor exits. It usu-

ally contains termcap strings to reset the terminal. PPRROOMMPPTT PPRROOMMPPTT22 PPRROOMMPPTT33 PPRROOMMPPTT44 Same as PPSS11, PPSS22, PPSS33 and PPSS44, respectively. pprroommpptt Same as PPSS11. PPSS11 The primary prompt string, printed before a command is read.

the default is `%%mm%%## '. It undergoes a special form of expan-

sion before being displayed; see the section `Prompt Expansion'. PPSS22

The secondary prompt, printed when the shell needs more informa-

tion to complete a command. It is expanded in the same way as

PPSS11. The default is `%%>> ', which displays any shell constructs

or quotation marks which are currently being processed. PPSS33 Selection prompt used within a sseelleecctt loop. It is expanded in

the same way as PPSS11. The default is `??## '.

PPSS44

The execution trace prompt. Default is `++%%NN::%%ii>> ', which dis-

plays the name of the current shell structure and the line num-

ber within it. In sh or ksh emulation, the default is `++ '. ppssvvaarr (PPSSVVAARR )

An array (colon-separated list) whose first nine values can be

used in PPRROOMMPPTT strings. Setting ppssvvaarr also sets PPSSVVAARR, and vice versa. RREEAADDNNUULLLLCCMMDD The command name to assume if a single input redirection is specified with no command. Defaults to mmoorree. RREEPPOORRTTTTIIMMEE

If nonnegative, commands whose combined user and system execu-

tion times (measured in seconds) are greater than this value have timing statistics printed for them. RREEPPLLYY 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 rreeaadd builtin and the sseelleecctt complex command may set RREEPPLLYY, and

filename generation both sets and examines its value when evalu-

ating certain expressions. Some modules also employ RREEPPLLYY for similar purposes. rreeppllyy As RREEPPLLYY, but for array values rather than strings. RRPPRROOMMPPTT RRPPSS11

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 SSIINNGGLLEELLIINNEEZZLLEE option is set. It is expanded in the same way as PPSS11. RRPPRROOMMPPTT22 RRPPSS22

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 SSIINNGGLLEELLIINNEEZZLLEE option is set. It is expanded in the same way as PPSS22. SSAAVVEEHHIISSTT The maximum number of history events to save in the history file. SSPPRROOMMPPTT

The prompt used for spelling correction. The sequence `%%RR'

expands to the string which presumably needs spelling correc-

tion, and `%%rr' expands to the proposed correction. All other

prompt escapes are also allowed. SSTTTTYY If this parameter is set in a command's environment, the shell

runs the ssttttyy command with the value of this parameter as argu-

ments in order to set up the terminal before executing the com-

mand. The modes apply only to the command, and are reset when it

finishes or is suspended. If the command is suspended and con-

tinued later with the ffgg or wwaaiitt builtins it will see the modes

specified by SSTTTTYY, as if it were not suspended. This (inten-

tionally) does not apply if the command is continued via `kkiillll

-CCOONNTT'. SSTTTTYY is ignored if the command is run in the back-

ground, 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 SSTTTTYY should not be used for window size specifi-

cations; these will not be local to the command. TTEERRMM

The type of terminal in use. This is used when looking up term-

cap sequences. An assignment to TTEERRMM causes zsh to re-initial-

ize the terminal, even if the value does not change (e.g.,

`TTEERRMM==$$TTEERRMM'). 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. TTIIMMEEFFMMTT The format of process time reports with the ttiimmee keyword. The

default is `%%EE rreeaall %%UU uusseerr %%SS ssyysstteemm %%PP %%JJ'. Recognizes the

following escape sequences, although not all may be available on all systems, and some that are available may not be useful:

%%%% A `%%'.

%%UU CPU seconds spent in user mode.

%%SS CPU seconds spent in kernel mode.

%%EE Elapsed time in seconds.

%%PP The CPU percentage, computed as (100*%%UU+%%SS)/%%EE.

%%WW Number of times the process was swapped.

%%XX The average amount in (shared) text space used in Kbytes.

%%DD The average amount in (unshared) data/stack space used in

Kbytes.

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

%%MM The maximum memory the process had in use at any time in

Kbytes.

%%FF The number of major page faults (page needed to be

brought from disk).

%%RR The number of minor page faults.

%%II The number of input operations.

%%OO The number of output operations.

%%rr The number of socket messages received.

%%ss The number of socket messages sent.

%%kk The number of signals received.

%%ww Number of voluntary context switches (waits).

%%cc Number of involuntary context switches.

%%JJ The name of this job.

A star may be inserted between the percent sign and flags print-

ing time. This cause the time to be printed in `hh::mm::ss..ttt' format (hours and minutes are only printed if they are not zero). TTMMOOUUTT If this parameter is nonzero, the shell will receive an AALLRRMM signal if a command is not entered within the specified number of seconds after issuing a prompt. If there is a trap on SSIIGGAALLRRMM, it will be executed and a new alarm is scheduled using the value of the TTMMOOUUTT 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 TTMMOOUUTT parameter, zsh terminates. Other-

wise a new alarm is scheduled to TTMMOOUUTT seconds after the last keypress. TTMMPPPPRREEFFIIXX 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 `//ttmmpp//zzsshh'. wwaattcchh (WWAATTCCHH )

An array (colon-separated list) of login/logout events to

report. If it contains the single word `aallll', then all login/logout events are reported. If it contains the single word `nnoottmmee', then all events are reported as with `aallll' except

$USERNAME A ety n hs it a cnit f uenm, n

`@@' followed by a remote hostname, and a `%%' followed by a line

(tty). Any or all of these components may be present in an entry; if a login/logout event matches all of them, it is reported. WWAATTCCHHFFMMTT The format of login/logout reports if the wwaattcchh parameter is

set. Default is `%%nn hhaass %%aa %%ll ffrroomm %%mm'. Recognizes the follow-

ing escape sequences:

%%nn The name of the user that logged in/out.

%%aa The observed action, i.e. "logged on" or "logged off".

%%ll The line (tty) the user is logged in on.

%%MM The full hostname of the remote host.

%%mm The hostname up to the first `..'. If only the IP address

is available or the utmp field contains the name of an

X-windows display, the whole name is printed.

NOTE: The `%%mm' and `%%MM' escapes will work only if there

is a host name field in the utmp on your machine. Other-

wise they are treated as ordinary strings.

%%SS (%%ss)

Start (stop) standout mode.

%%UU (%%uu)

Start (stop) underline mode.

%%BB (%%bb)

Start (stop) boldface mode.

%%tt

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

%%TT The time, in 24-hour format.

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

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

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

%%((x::true-text::false-text))

Specifies a ternary expression. The character following

the x is arbitrary; the same character is used to sepa-

rate the text for the "true" result from that for the

"false" result. Both the separator and the right paren-

thesis may be escaped with a backslash. Ternary expres-

sions may be nested. The test character x may be any one of `ll', `nn', `mm' or `MM', which indicate a `true' result if the corresponding

escape sequence would return a non-empty value; or it may

be `aa', which indicates a `true' result if the watched user has logged in, or `false' if he has logged out. Other characters evaluate to neither true nor false; the entire expression is omitted in this case.

If the result is `true', then the true-text is formatted

according to the rules above and printed, and the

false-text is skipped. If `false', the true-text is

skipped and the false-text is formatted and printed.

Either or both of the branches may be empty, but both separators must be present in any case. WWOORRDDCCHHAARRSS

A list of non-alphanumeric characters considered part of a word

by the line editor. ZZBBEEEEPP If set, this gives a string of characters, which can use all the same codes as the bbiinnddkkeeyy command as described in the zsh/zle

module entry in zshmodules(1), that will be output to the termi-

nal instead of beeping. This may have a visible instead of an audible effect; for example, the string `\\ee[[??55hh\\ee[[??55ll' 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 `\\ee[[??55ll\\ee[[??55hh' instead). This takes precedence over the NNOOBBEEEEPP option. ZZDDOOTTDDIIRR The directory to search for shell startup files (.zshrc, etc),

if not $$HHOOMMEE.

ZSHOPTIONS(1) ZSHOPTIONS(1)

NAME

zshoptions - zsh options

SSPPEECCIIFFYYIINNGG OOPPTTIIOONNSS

Options are primarily referred to by name. These names are case insen-

sitive and underscores are ignored. For example, `aalllleexxppoorrtt' is equiv-

alent to `AAlllleeXXPPoorrtt'. The sense of an option name may be inverted by preceding it with `nnoo', so `sseettoopptt NNooBBeeeepp' is equivalent to `uunnsseettoopptt bbeeeepp'. This inversion

can only be done once, so `nnoonnoobbeeeepp' is not a synonym for `bbeeeepp'. Sim-

ilarly, `ttiiffyy' is not a synonym for `nnoonnoottiiffyy' (the inversion of `nnoottiiffyy'). Some options also have one or more single letter names. There are two sets of single letter options: one used by default, and another used to emulate sshh/kksshh (used when the SSHHOOPPTTIIOONNLLEETTTTEERRSS option is set). The single letter options can be used on the shell command line, or with the sseett, sseettoopptt and uunnsseettoopptt builtins, as normal Unix options preceded

by `-'.

The sense of the single letter options may be inverted by using `++'

instead of `-'. Some of the single letter option names refer to an

option being off, in which case the inversion of that name refers to the option being on. For example, `++nn' is the short name of `eexxeecc',

and `-nn' is the short name of its inversion, `nnooeexxeecc'.

In strings of single letter options supplied to the shell at startup,

trailing whitespace will be ignored; for example the string `-ff '

will be treated just as `-ff', but the string `-ff ii' is an error. This

is because many systems which implement the `##!!' mechanism for calling

scripts do not strip trailing whitespace.

DESCRIPTION OF OPTIONS

In the following list, options set by default in all emulations are

marked ; those set by default only in csh, ksh, sh, or zsh emula-

tions are marked , , , as appropriate. When listing

options (by `sseettoopptt', `uunnsseettoopptt', `sseett -oo' or `sseett ++oo'), those turned

on by default appear in the list prefixed with `nnoo'. Hence (unless KKSSHHOOPPTTIIOONNPPRRIINNTT is set), `sseettoopptt' shows all options whose settings are changed from the default. CChhaannggiinngg DDiirreeccttoorriieess

AAUUTTOOCCDD (-JJ)

If a command is issued that can't be executed as a normal com-

mand, and the command is the name of a directory, perform the ccdd command to that directory.

AAUUTTOOPPUUSSHHDD (-NN)

Make ccdd push the old directory onto the directory stack.

CCDDAABBLLEEVVAARRSS (-TT)

If the argument to a ccdd command (or an implied ccdd with the AAUUTTOOCCDD option set) is not a directory, and does not begin with a slash, try to expand the expression as if it were preceded by a `~~' (see the section `Filename Expansion'). CCHHAASSEEDDOOTTSS When changing to a directory containing a path segment `....'

which would otherwise be treated as canceling the previous seg-

ment in the path (in other words, `ffoooo//....' would be removed from the path, or if `....' is the first part of the path, the last

part of $$PPWWDD would be deleted), instead resolve the path to the

physical directory. This option is overridden by CCHHAASSEELLIINNKKSS. For example, suppose //ffoooo//bbaarr is a link to the directory //aalltt//rroodd. Without this option set, `ccdd //ffoooo//bbaarr//....' changes to //ffoooo; with it set, it changes to //aalltt. The same applies if the current directory is //ffoooo//bbaarr and `ccdd ....' is used. Note that all other symbolic links in the path will also be resolved.

CCHHAASSEELLIINNKKSS (-ww)

Resolve symbolic links to their true values when changing direc-

tory. This also has the effect of CCHHAASSEEDDOOTTSS, i.e. a `....' path segment will be treated as referring to the physical parent, even if the preceding path segment is a symbolic link. PPUUSSHHDDIIGGNNOORREEDDUUPPSS

Don't push multiple copies of the same directory onto the direc-

tory stack. PPUUSSHHDDMMIINNUUSS

Exchanges the meanings of `++' and `-' when used with a number to

specify a directory in the stack.

PPUUSSHHDDSSIILLEENNTT (-EE)

Do not print the directory stack after ppuusshhdd or ppooppdd.

PPUUSSHHDDTTOOHHOOMMEE (-DD)

Have ppuusshhdd with no arguments act like `ppuusshhdd $$HHOOMMEE'.

CCoommpplleettiioonn AALLWWAAYYSSLLAASSTTPPRROOMMPPTT If unset, key functions that list completions try to return to

the last prompt if given a numeric argument. If set these func-

tions try to return to the last prompt if given no numeric argu-

ment. AALLWWAAYYSSTTOOEENNDD If a completion is performed with the cursor within a word, and a full completion is inserted, the cursor is moved to the end of the word. That is, the cursor is moved to the end of the word

if either a single match is inserted or menu completion is per-

formed.

AAUUTTOOLLIISSTT (-99)

Automatically list choices on an ambiguous completion. AAUUTTOOMMEENNUU Automatically use menu completion after the second consecutive request for completion, for example by pressing the tab key repeatedly. This option is overridden by MMEENNUUCCOOMMPPLLEETTEE.

AUTONAMEDIRS

Any parameter that is set to the absolute name of a directory immediately becomes a name for that directory, that will be used

by the `%%~~' and related prompt sequences, and will be available

when completion is performed on a word starting with `~~'. (Oth-

erwise, the parameter must be used in the form `~~param' first.) AAUUTTOOPPAARRAAMMKKEEYYSS If a parameter name was completed and a following character

(normally a space) automatically inserted, and the next charac-

ter typed is one of those that have to come directly after the name (like `}}', `::', etc.), the automatically added character is deleted, so that the character typed comes immediately after the parameter name. Completion in a brace expansion is affected similarly: the added character is a `,,', which will be removed if `}}' is typed next. AAUUTTOOPPAARRAAMMSSLLAASSHH If a parameter is completed whose content is the name of a directory, then add a trailing slash instead of a space. AAUUTTOORREEMMOOVVEESSLLAASSHH When the last character resulting from a completion is a slash and the next character typed is a word delimiter, a slash, or a

character that ends a command (such as a semicolon or an amper-

sand), remove the slash. BBAASSHHAAUUTTOOLLIISSTT On an ambiguous completion, automatically list choices when the completion function is called twice in succession. This takes precedence over AAUUTTOOLLIISSTT. The setting of LLIISSTTAAMMBBIIGGUUOOUUSS is respected. If AAUUTTOOMMEENNUU is set, the menu behaviour will then start with the third press. Note that this will not work with MMEENNUUCCOOMMPPLLEETTEE, since repeated completion calls immediately cycle through the list in that case. CCOOMMPPLLEETTEEAALLIIAASSEESS

Prevents aliases on the command line from being internally sub-

stituted before completion is attempted. The effect is to make the alias a distinct command for completion purposes. CCOOMMPPLLEETTEEIINNWWOORRDD If unset, the cursor is set to the end of the word if completion is started. Otherwise it stays there and completion is done from both ends. GGLLOOBBCCOOMMPPLLEETTEE When the current word has a glob pattern, do not insert all the words resulting from the expansion but generate matches as for completion and cycle through them like MMEENNUUCCOOMMPPLLEETTEE. The matches are generated as if a `**' was added to the end of the word, or inserted at the cursor when CCOOMMPPLLEETTEEIINNWWOORRDD is set. This actually uses pattern matching, not globbing, so it works not only for files but for any completion, such as options, user names, etc. Note that when the pattern matcher is used, matching control

(for example, case-insensitive or anchored matching) cannot be

used. This limitation only applies when the current word con-

tains a pattern; simply turning on the GGLLOOBBCCOOMMPPLLEETTEE option does not have this effect. HHAASSHHLLIISSTTAALLLL Whenever a command completion is attempted, make sure the entire command path is hashed first. This makes the first completion slower. LLIISSTTAAMMBBIIGGUUOOUUSS This option works when AAUUTTOOLLIISSTT or BBAASSHHAAUUTTOOLLIISSTT is also set. If there is an unambiguous prefix to insert on the command line, that is done without a completion list being displayed; in other

words, auto-listing behaviour only takes place when nothing

would be inserted. In the case of BBAASSHHAAUUTTOOLLIISSTT, this means that the list will be delayed to the third call of the function. LLIISSTTBBEEEEPP Beep on an ambiguous completion. More accurately, this forces

the completion widgets to return status 1 on an ambiguous com-

pletion, which causes the shell to beep if the option BBEEEEPP is also set; this may be modified if completion is called from a

user-defined widget.

LLIISSTTPPAACCKKEEDD Try to make the completion list smaller (occupying less lines) by printing the matches in columns with different widths. LLIISSTTRROOWWSSFFIIRRSSTT Lay out the matches in completion lists sorted horizontally, that is, the second match is to the right of the first one, not under it as usual.

LLIISSTTTTYYPPEESS (-XX)

When listing files that are possible completions, show the type of each file with a trailing identifying mark.

MMEENNUUCCOOMMPPLLEETTEE (-YY)

On an ambiguous completion, instead of listing possibilities or

beeping, insert the first match immediately. Then when comple-

tion is requested again, remove the first match and insert the second match, etc. When there are no more matches, go back to

the first one again. rreevveerrssee-mmeennuu-ccoommpplleettee may be used to loop

through the list in the other direction. This option overrides AAUUTTOOMMEENNUU.

RREECCEEXXAACCTT (-SS)

In completion, recognize exact matches even if they are ambigu-

ous. EExxppaannssiioonn aanndd GGlloobbbbiinngg BBAADDPPAATTTTEERRNN (++22) If a pattern for filename generation is badly formed, print an error message. (If this option is unset, the pattern will be left unchanged.) BBAARREEGGLLOOBBQQUUAALL In a glob pattern, treat a trailing set of parentheses as a qualifier list, if it contains no `||', `((' or (if special) `~~' characters. See the section `Filename Generation'. BBRRAACCEECCCCLL Expand expressions in braces which would not otherwise undergo

brace expansion to a lexically ordered list of all the charac-

ters. See the section `Brace Expansion'. CCAASSEEGGLLOOBB Make globbing (filename generation) sensitive to case. Note that other uses of patterns are always sensitive to case. If

the option is unset, the presence of any character which is spe-

cial to filename generation will cause case-insensitive match-

ing. For example, ccvvss((//)) can match the directory CCVVSS owing to the presence of the globbing flag (unless the option BBAARREEGGLLOOBBQQUUAALL is unset). CCSSHHNNUULLLLGGLLOOBB If a pattern for filename generation has no matches, delete the pattern from the argument list; do not report an error unless all the patterns in a command have no matches. Overrides NNOOMMAATTCCHH. EEQQUUAALLSS

Perform == filename expansion. (See the section `Filename Expan-

sion'.) EEXXTTEENNDDEEDDGGLLOOBB

Treat the `##', `~~' and `^^' characters as part of patterns for

filename generation, etc. (An initial unquoted `~~' always pro-

duces named directory expansion.) GGLLOOBB (++FF, ksh: ++ff)

Perform filename generation (globbing). (See the section `File-

name Generation'.) GGLLOOBBAASSSSIIGGNN

If this option is set, filename generation (globbing) is per-

formed on the right hand side of scalar parameter assignments of the form `name==pattern (e.g. `ffoooo==**'). If the result has more than one word the parameter will become an array with those

words as arguments. This option is provided for backwards com-

patibility only: globbing is always performed on the right hand side of array assignments of the form `name==((value))' (e.g. `ffoooo==((**))') and this form is recommended for clarity; with this option set, it is not possible to predict whether the result will be an array or a scalar.

GGLLOOBBDDOOTTSS (-44)

Do not require a leading `..' in a filename to be matched explic-

itly. GGLLOOBBSSUUBBSSTT Treat any characters resulting from parameter expansion as being eligible for file expansion and filename generation, and any characters resulting from command substitution as being eligible for filename generation. Braces (and commas in between) do not become eligible for expansion.

IIGGNNOORREEBBRRAACCEESS (-II)

Do not perform brace expansion. KKSSHHGGLLOOBB In pattern matching, the interpretation of parentheses is

affected by a preceding `@@', `**', `++', `??' or `!!'. See the sec-

tion `Filename Generation'. MMAAGGIICCEEQQUUAALLSSUUBBSSTT

All unquoted arguments of the form `anything==expression' appear-

ing after the command name have filename expansion (that is,

where expression has a leading `~~' or `==') performed on expres-

sion as if it were a parameter assignment. The argument is not otherwise treated specially; it is passed to the command as a single argument, and not used as an actual parameter assignment. For example, in eecchhoo ffoooo==~~//bbaarr::~~//rroodd, both occurrences of ~~ would be replaced. Note that this happens anyway with ttyyppeesseett and similar statements. This option respects the setting of the KKSSHHTTYYPPEESSEETT option. In other words, if both options are in effect, arguments looking like assignments will not undergo wordsplitting.

MMAARRKKDDIIRRSS (-88, ksh: -XX)

Append a trailing `//' to all directory names resulting from filename generation (globbing). NNOOMMAATTCCHH (++33) If a pattern for filename generation has no matches, print an error, instead of leaving it unchanged in the argument list. This also applies to file expansion of an initial `~~' or `=='.

NNUULLLLGGLLOOBB (-GG)

If a pattern for filename generation has no matches, delete the pattern from the argument list instead of reporting an error. Overrides NNOOMMAATTCCHH. NNUUMMEERRIICCGGLLOOBBSSOORRTT

If numeric filenames are matched by a filename generation pat-

tern, sort the filenames numerically rather than lexicographi-

cally.

RRCCEEXXPPAANNDDPPAARRAAMM (-PP)

Array expansions of the form `foo$${{xx}}bar', where the parameter

xx is set to ((a b c)), are substituted with `fooabar foobbar foocbar' instead of the default `fooa b cbar'. SSHHGGLLOOBB

Disables the special meaning of `((', `||', `))' and '<<' for glob-

bing the result of parameter and command substitutions, and in some other places where the shell accepts patterns. This option is set by default if zsh is invoked as sshh or kksshh. UUNNSSEETT (++uu, ksh: ++uu) Treat unset parameters as if they were empty when substituting. Otherwise they are treated as an error. HHiissttoorryy APPENDHISTORY D If this is set, zsh sessions will append their history list to

the history file, rather than overwrite it. Thus, multiple par-

allel zsh sessions will all have their history lists added to the history file, in the order they are killed. BBAANNGGHHIISSTT (++KK)

Perform textual history expansion, ccsshh-style, treating the char-

acter `!!' specially. EXTENDEDHISTORY C Save each command's beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file. The format of this prefixed data is: `::::::'. HHIISSTTAALLLLOOWWCCLLOOBBBBEERR

Add `||' to output redirections in the history. This allows his-

tory references to clobber files even when CCLLOOBBBBEERR is unset. HHIISSTTBBEEEEPP Beep when an attempt is made to access a history entry which isn't there. HHIISSTTEEXXPPIIRREEDDUUPPSSFFIIRRSSTT If the internal history needs to be trimmed to add the current command line, setting this option will cause the oldest history event that has a duplicate to be lost before losing a unique event from the list. You should be sure to set the value of HHIISSTTSSIIZZEE to a larger number than SSAAVVEEHHIISSTT in order to give you some room for the duplicated events, otherwise this option will behave just like HHIISSTTIIGGNNOORREEAALLLLDDUUPPSS once the history fills up with unique events. HHIISSTTFFIINNDDNNOODDUUPPSS When searching for history entries in the line editor, do not display duplicates of a line previously found, even if the duplicates are not contiguous. HHIISSTTIIGGNNOORREEAALLLLDDUUPPSS If a new command line being added to the history list duplicates an older one, the older command is removed from the list (even if it is not the previous event).

HHIISSTTIIGGNNOORREEDDUUPPSS (-hh)

Do not enter command lines into the history list if they are duplicates of the previous event.

HHIISSTTIIGGNNOORREESSPPAACCEE (-gg)

Remove command lines from the history list when the first char-

acter on the line is a space, or when one of the expanded aliases contains a leading space. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line. If you want to make it vanish right away without entering another command, type a space and press return. HHIISSTTNNOOFFUUNNCCTTIIOONNSS Remove function definitions from the history list. Note that

the function lingers in the internal history until the next com-

mand is entered before it vanishes, allowing you to briefly re-

use or edit the definition. HHIISSTTNNOOSSTTOORREE

Remove the hhiissttoorryy (ffcc -ll) command from the history list when

invoked. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line. HHIISSTTRREEDDUUCCEEBBLLAANNKKSS Remove superfluous blanks from each command line being added to the history list. HHIISSTTSSAAVVEENNOODDUUPPSS When writing out the history file, older commands that duplicate newer ones are omitted. HHIISSTTVVEERRIIFFYY Whenever the user enters a line with history expansion, don't execute the line directly; instead, perform history expansion and reload the line into the editing buffer. INCAPPENDHISTORY hs pin wrs ie APPENDHISTORY xet ht e hsoy

lines are added to the $$HHIISSTTFFIILLEE incrementally (as soon as they

are entered), rather than waiting until the shell is killed.

The file is periodically trimmed to the number of lines speci-

fied by $$SSAAVVEEHHIISSTT, but can exceed this value between trimmings.

SHAREHISTORY K This option both imports new commands from the history file, and also causes your typed commands to be appended to the history ie te atr s ie pcfig INCAPPENDHISTORY. h

history lines are also output with timestamps ala EEXXTTEENNDDEEDDHHIISS-

TTOORRYY (which makes it easier to find the spot where we left off

reading the file after it gets re-written).

By default, history movement commands visit the imported lines as well as the local lines, but you can toggle this on and off

with the set-local-history zle binding. It is also possible to

create a zle widget that will make some commands ignore imported commands, and some include them. If you find that you want more control over when commands get motd yu a ws t tr SHAREHISTORY of INCAPPENDHISTORY n ad hn auly mot omns hn

ever you need them using `ffcc -RRII'.

IInniittiiaalliissaattiioonn

AALLLLEEXXPPOORRTT (-aa, ksh: -aa)

All parameters subsequently defined are automatically exported. GGLLOOBBAALLEEXXPPOORRTT (<>)

If this option is set, passing the -xx flag to the builtins

ddeeccllaarree, ffllooaatt, iinntteeggeerr, rreeaaddoonnllyy and ttyyppeesseett (but not llooccaall)

will also set the -gg flag; hence parameters exported to the

environment will not be made local to the enclosing function, unless they were already or the flag ++gg is given explicitly. If the option is unset, exported parameters will be made local in just the same way as any other parameter. This option is set by default for backward compatibility; it is not recommended that its behaviour be relied upon. Note that

the builtin eexxppoorrtt always sets both the -xx and -gg flags, and

hence its effect extends beyond the scope of the enclosing func-

tion; this is the most portable way to achieve this behaviour.

GGLLOOBBAALLRRCCSS (-dd)

If this option is unset, the startup files //eettcc//zzpprrooffiillee, //eettcc//zzsshhrrcc, //eettcc//zzllooggiinn and //eettcc//zzllooggoouutt will not be run. It

can be disabled and re-enabled at any time, including inside

local startup files (..zzsshhrrcc, etc.). RRCCSS (++ff) After //eettcc//zzsshheennvv is sourced on startup, source the ..zzsshheennvv,

//eettcc//zzpprrooffiillee, ..zzpprrooffiillee, //eettcc//zzsshhrrcc, ..zzsshhrrcc, //eettcc//zzllooggiinn, ..zzlloo-

ggiinn, and ..zzllooggoouutt files, as described in the section `Files'. If this option is unset, the //eettcc//zzsshheennvv file is still sourced, but any of the others will not be; it can be set at any time to

prevent the remaining startup files after the currently execut-

ing one from being sourced. IInnppuutt//OOuuttppuutt AALLIIAASSEESS Expand aliases. CCLLOOBBBBEERR (++CC, ksh: ++CC) Allows `>>' redirection to truncate existing files, and `>>>>' to create files. Otherwise `>>!!' or `>>||' must be used to truncate a file, and `>>>>!!' or `>>>>||' to create a file.

CCOORRRREECCTT (-00)

Try to correct the spelling of commands. Note that, when the HHAASSHHLLIISSTTAALLLL option is not set or when some directories in the path are not readable, this may falsely report spelling errors the first time some commands are used.

CCOORRRREECCTTAALLLL (-OO)

Try to correct the spelling of all arguments in a line. DDVVOORRAAKK Use the Dvorak keyboard instead of the standard qwerty keyboard as a basis for examining spelling mistakes for the CCOORRRREECCTT and

CCOORRRREECCTTAALLLL options and the ssppeellll-wwoorrdd editor command.

FFLLOOWWCCOONNTTRROOLL If this option is unset, output flow control via start/stop characters (usually assigned to ^S/^Q) is disabled in the shell's editor.

IIGGNNOORREEEEOOFF (-77)

Do not exit on end-of-file. Require the use of eexxiitt or llooggoouutt

instead. However, ten consecutive EOFs will cause the shell to exit anyway, to avoid the shell hanging if its tty goes away. Also, if this option is set and the Zsh Line Editor is used,

widgets implemented by shell functions can be bound to EOF (nor-

mally Control-D) without printing the normal warning message.

This works only for normal widgets, not for completion widgets.

IINNTTEERRAACCTTIIVVEECCOOMMMMEENNTTSS (-kk)

Allow comments even in interactive shells. HHAASSHHCCMMDDSS Note the location of each command the first time it is executed. Subsequent invocations of the same command will use the saved location, avoiding a path search. If this option is unset, no

path hashing is done at all. However, when CCOORRRREECCTT is set, com-

mands whose names do not appear in the functions or aliases hash tables are hashed in order to avoid reporting them as spelling errors. HHAASSHHDDIIRRSS Whenever a command name is hashed, hash the directory containing it, as well as all directories that occur earlier in the path. Has no effect if neither HHAASSHHCCMMDDSS nor CCOORRRREECCTT is set.

MMAAIILLWWAARRNNIINNGG (-UU)

Print a warning message if a mail file has been accessed since the shell last checked.

PPAATTHHDDIIRRSS (-QQ)

Perform a path search even on command names with slashes in them. Thus if `//uussrr//llooccaall//bbiinn' is in the user's path, and he or she types `XX1111//xxiinniitt', the command `//uussrr//llooccaall//bbiinn//XX1111//xxiinniitt' will be executed (assuming it exists). Commands explicitly beginning with `//', `..//' or `....//' are not subject to the path search. This also applies to the .. builtin. Note that subdirectories of the current directory are always searched for executables specified in this form. This takes place before any search indicated by this option, and regardless of whether `..' or the current directory appear in the command search path. PPRRIINNTTEEIIGGHHTTBBIITT Print eight bit characters literally in completion lists, etc. This option is not necessary if your system correctly returns the printability of eight bit characters (see ctype(3)).

PPRRIINNTTEEXXIITTVVAALLUUEE (-11)

Print the exit value of programs with non-zero exit status.

RRCCQQUUOOTTEESS Allow the character sequence `''''' to signify a single quote within singly quoted strings. Note this does not apply in

quoted strings using the format $$''...'', where a backslashed sin-

gle quote can be used.

RRMMSSTTAARRSSIILLEENNTT (-HH)

Do not query the user before executing `rrmm **' or `rrmm ppaatthh//**'. RRMMSSTTAARRWWAAIITT If querying the user before executing `rrmm **' or `rrmm ppaatthh//**', first wait ten seconds and ignore anything typed in that time. This avoids the problem of reflexively answering `yes' to the query when one didn't really mean it. The wait and query can always be avoided by expanding the `**' in ZLE (with tab). SSHHOORRTTLLOOOOPPSS Allow the short forms of ffoorr, rreeppeeaatt, sseelleecctt, iiff, and ffuunnccttiioonn constructs.

SSUUNNKKEEYYBBOOAARRDDHHAACCKK (-LL)

If a line ends with a backquote, and there are an odd number of backquotes on the line, ignore the trailing backquote. This is useful on some keyboards where the return key is too small, and the backquote key lies annoyingly close to it. JJoobb CCoonnttrrooll AAUUTTOOCCOONNTTIINNUUEE With this option set, stopped jobs that are removed from the job table with the ddiissoowwnn builtin command are automatically sent a CCOONNTT signal to make them running.

AAUUTTOORREESSUUMMEE (-WW)

Treat single word simple commands without redirection as candi-

dates for resumption of an existing job.

BBGGNNIICCEE (-66)

Run all background jobs at a lower priority. This option is set by default. CCHHEECCKKJJOOBBSS

Report the status of background and suspended jobs before exit-

ing a shell with job control; a second attempt to exit the shell will succeed. NNOOCCHHEECCKKJJOOBBSS is best used only in combination with NNOOHHUUPP, else such jobs will be killed automatically.

The check is omitted if the commands run from the previous com-

mand line included a `jjoobbss' command, since it is assumed the user is aware that there are background or suspended jobs. A `jjoobbss' command run from the pprreeccmmdd function is not counted for this purpose. HHUUPP Send the HHUUPP signal to running jobs when the shell exits.

LLOONNGGLLIISSTTJJOOBBSS (-RR)

List jobs in the long format by default.

MMOONNIITTOORR (-mm, ksh: -mm)

Allow job control. Set by default in interactive shells.

NNOOTTIIFFYY (-55, ksh: -bb)

Report the status of background jobs immediately, rather than waiting until just before printing a prompt. PPrroommppttiinngg PPRROOMMPPTTBBAANNGG If set, `!!' is treated specially in prompt expansion. See the section `Prompt Expansion'. PPRROOMMPPTTCCRR (++VV) Print a carriage return just before printing a prompt in the

line editor. This is on by default as multi-line editing is

only possible if the editor knows where the start of the line appears. PPRROOMMPPTTPPEERRCCEENNTT

If set, `%%' is treated specially in prompt expansion. See the

section `Prompt Expansion'. PPRROOMMPPTTSSUUBBSSTT If set, parameter expansion, command substitution and arithmetic expansion are performed in prompts. Substitutions within prompts do not affect the command status. TTRRAANNSSIIEENNTTRRPPRROOMMPPTT Remove any right prompt from display when accepting a command line. This may be useful with terminals with other cut/paste methods. SSccrriippttss aanndd FFuunnccttiioonnss CCBBAASSEESS Output hexadecimal numbers in the standard C format, for example

`00xxFFFF' instead of the usual `1166##FFFF'. If the option OOCCTTAALLZZEERROOEESS

is also set (it is not by default), octal numbers will be

treated similarly and hence appear as `007777' instead of `88##7777'.

This option has no effect on the choice of the output base, nor on the output of bases other than hexadecimal and octal. Note that these formats will be understood on input irrespective of the setting of CCBBAASSEESS.

EERRRREEXXIITT (-ee, ksh: -ee)

If a command has a non-zero exit status, execute the ZZEERRRR trap,

if set, and exit. This is disabled while running initialization scripts. EERRRRRREETTUURRNN

If a command has a non-zero exit status, return immediately from

the enclosing function. The logic is identical to that for EERRRREEXXIITT, except that an implicit rreettuurrnn statement is executed instead of an eexxiitt. This will trigger an exit at the outermost

level of a non-interactive script.

EEVVAALLLLIINNEENNOO If set, line numbers of expressions evaluated using the builtin eevvaall are tracked separately of the enclosing environment. This applies both to the parameter LLIINNEENNOO and the line number output

by the prompt escape %%ii. If the option is set, the prompt

escape %%NN will output the string `((eevvaall))' instead of the script

or function name as an indication. (The two prompt escapes are typically used in the parameter PPSS44 to be output when the option XXTTRRAACCEE is set.) If EEVVAALLLLIINNEENNOO is unset, the line number of the

surrounding script or function is retained during the evalua-

tion. EEXXEECC (++nn, ksh: ++nn) Do execute commands. Without this option, commands are read and checked for syntax errors, but not executed. This option cannot

be turned off in an interactive shell, except when `-nn' is sup-

plied to the shell at startup. FFUUNNCCTTIIOONNAARRGGZZEERROO

When executing a shell function or sourcing a script, set $$00

temporarily to the name of the function/script. LLOOCCAALLOOPPTTIIOONNSS

If this option is set at the point of return from a shell func-

tion, all the options (including this one) which were in force upon entry to the function are restored. Otherwise, only this option and the XXTTRRAACCEE and PPRRIINNTTEEXXIITTVVAALLUUEE options are restored. Hence if this is explicitly unset by a shell function the other options in force at the point of return will remain so. A shell function can also guarantee itself a known shell configuration

with a formulation like `eemmuullaattee -LL zzsshh'; the -LL activates

LLOOCCAALLOOPPTTIIOONNSS. LLOOCCAALLTTRRAAPPSS

If this option is set when a signal trap is set inside a func-

tion, then the previous status of the trap for that signal will be restored when the function exits. Note that this option must be set prior to altering the trap behaviour in a function; unlike LLOOCCAALLOOPPTTIIOONNSS, the value on exit from the function is irrelevant. However, it does not need to be set before any global trap for that to be correctly restored by a function. For example, uunnsseettoopptt llooccaallttrraappss

ttrraapp - IINNTT

ffnn(()) {{ sseettoopptt llooccaallttrraappss;; ttrraapp '''' IINNTT;; sslleeeepp 33;; }} will restore normally handling of SSIIGGIINNTT after the function exits. MMUULLTTIIOOSS Perform implicit tteeees or ccaatts when multiple redirections are attempted (see the section `Redirection'). OOCCTTAALLZZEERROOEESS Interpret any integer constant beginning with a 0 as octal, per

IEEE Std 1003.2-1992 (ISO 9945-2:1993). This is not enabled by

default as it causes problems with parsing of, for example, date and time strings with leading zeroes. TTYYPPEESSEETTSSIILLEENNTT

If this is unset, executing any of the `ttyyppeesseett' family of com-

mands with no options and a list of parameters that have no val-

ues to be assigned but already exist will display the value of the parameter. If the option is set, they will only be shown

when parameters are selected with the `-mm' option. The option

`-pp' is available whether or not the option is set.

VVEERRBBOOSSEE (-vv, ksh: -vv)

Print shell input lines as they are read.

XXTTRRAACCEE (-xx, ksh: -xx)

Print commands and their arguments as they are executed. SShheellll EEmmuullaattiioonn BBSSDDEECCHHOO Make the eecchhoo builtin compatible with the BSD echo(1) command. This disables backslashed escape sequences in echo strings

unless the -ee option is specified.

CSHJUNKIEHISTORY C A history reference without an event specifier will always refer to the previous command. Without this option, such a history

reference refers to the same event as the previous history ref-

erence, defaulting to the previous command. CCSSHHJJUUNNKKIIEELLOOOOPPSS Allow loop bodies to take the form `list; eenndd' instead of `ddoo list; ddoonnee'. CCSSHHJJUUNNKKIIEEQQUUOOTTEESS

Changes the rules for single- and double-quoted text to match

that of ccsshh. These require that embedded newlines be preceded by a backslash; unescaped newlines will cause an error message.

In double-quoted strings, it is made impossible to escape `$$',

```' or `""' (and `\\' itself no longer needs escaping). Command substitutions are only expanded once, and cannot be nested. CCSSHHNNUULLLLCCMMDD Do not use the values of NNUULLLLCCMMDD and RREEAADDNNUULLLLCCMMDD when running redirections with no command. This make such redirections fail (see the section `Redirection'). KKSSHHAARRRRAAYYSS Emulate kksshh array handling as closely as possible. If this option is set, array elements are numbered from zero, an array parameter without subscript refers to the first element instead

of the whole array, and braces are required to delimit a sub-

script (`$${{ppaatthh[[22]]}}' rather than just `$$ppaatthh[[22]]').

KKSSHHAAUUTTOOLLOOAADD

Emulate kksshh function autoloading. This means that when a func-

tion is autoloaded, the corresponding file is merely executed, and must define the function itself. (By default, the function

is defined to the contents of the file. However, the most com-

mon kksshh-style case - of the file containing only a simple defi-

nition of the function - is always handled in the kksshh-compatible

manner.) KKSSHHOOPPTTIIOONNPPRRIINNTT Alters the way options settings are printed: instead of separate lists of set and unset options, all options are shown, marked

`on' if they are in the non-default state, `off' otherwise.

KKSSHHTTYYPPEESSEETT Alters the way arguments to the ttyyppeesseett family of commands, including ddeeccllaarree, eexxppoorrtt, ffllooaatt, iinntteeggeerr, llooccaall and rreeaaddoonnllyy, are processed. Without this option, zsh will perform normal

word splitting after command and parameter expansion in argu-

ments of an assignment; with it, word splitting does not take place in those cases. PPOOSSIIXXBBUUIILLTTIINNSS

When this option is set the ccoommmmaanndd builtin can be used to exe-

cute shell builtin commands. Parameter assignments specified before shell functions and special builtins are kept after the command completes unless the special builtin is prefixed with

the ccoommmmaanndd builtin. Special builtins are .., ::, bbrreeaakk, ccoonn-

ttiinnuuee, ddeeccllaarree, eevvaall, eexxiitt, eexxppoorrtt, iinntteeggeerr, llooccaall, rreeaaddoonnllyy, rreettuurrnn, sseett, sshhiifftt, ssoouurrccee, ttiimmeess, ttrraapp and uunnsseett. SSHHFFIILLEEEEXXPPAANNSSIIOONN Perform filename expansion (e.g., ~ expansion) before parameter expansion, command substitution, arithmetic expansion and brace expansion. If this option is unset, it is performed after brace

xaso, o hns ie ~$USERNAME' n `~{pfalstad,rc} wl

work. SSHHNNUULLLLCCMMDD Do not use the values of NNUULLLLCCMMDD and RREEAADDNNUULLLLCCMMDD when doing redirections, use `::' instead (see the section `Redirection'). SSHHOOPPTTIIOONNLLEETTTTEERRSS If this option is set the shell tries to interpret single letter options (which are used with sseett and sseettoopptt) like kksshh does.

This also affects the value of the - special parameter.

SSHHWWOORRDDSSPPLLIITT (-yy)

Causes field splitting to be performed on unquoted parameter expansions. Note that this option has nothing to do with word splitting. (See the section `Parameter Expansion'.) TTRRAAPPSSAASSYYNNCC While waiting for a program to exit, handle signals and run traps immediately. Otherwise the trap is run after a child process has exited. Note this does not affect the point at which traps are run for any case other than when the shell is waiting for a child process. SShheellll SSttaattee

IINNTTEERRAACCTTIIVVEE (-ii, ksh: -ii)

This is an interactive shell. This option is set upon initiali-

sation if the standard input is a tty and commands are being read from standard input. (See the discussion of SSHHIINNSSTTDDIINN.) This heuristic may be overridden by specifying a state for this option on the command line. The value of this option cannot be changed anywhere other than the command line.

LLOOGGIINN (-ll, ksh: -ll)

This is a login shell. If this option is not explicitly set, the shell is a login shell if the first character of the aarrggvv[[00]]

passed to the shell is a `-'.

PPRRIIVVIILLEEGGEEDD (-pp, ksh: -pp)

Turn on privileged mode. This is enabled automatically on startup if the effective user (group) ID is not equal to the

real user (group) ID. Turning this option off causes the effec-

tive user and group IDs to be set to the real user and group IDs. This option disables sourcing user startup files. If zsh

is invoked as `sshh' or `kksshh' with this option set, //eettcc//ssuuiiddpprroo-

ffiillee is sourced (after //eettcc//pprrooffiillee on interactive shells). Sourcing ~~//..pprrooffiillee is disabled and the contents of the EENNVV

variable is ignored. This option cannot be changed using the -mm

option of sseettoopptt and uunnsseettoopptt, and changing it inside a function always changes it globally regardless of the LLOOCCAALLOOPPTTIIOONNSS option.

RREESSTTRRIICCTTEEDD (-rr)

Enables restricted mode. This option cannot be changed using uunnsseettoopptt, and setting it inside a function always changes it

globally regardless of the LLOOCCAALLOOPPTTIIOONNSS option. See the sec-

tion `Restricted Shell'.

SSHHIINNSSTTDDIINN (-ss, ksh: -ss)

Commands are being read from the standard input. Commands are

read from standard input if no command is specified with -cc and

no file of commands is specified. If SSHHIINNSSTTDDIINN is set explic-

itly on the command line, any argument that would otherwise have been taken as a file to run will instead be treated as a normal positional parameter. Note that setting or unsetting this option on the command line does not necessarily affect the state

the option will have while the shell is running - that is purely

an indicator of whether on not commands are actually being read from standard input. The value of this option cannot be changed anywhere other than the command line.

SSIINNGGLLEECCOOMMMMAANNDD (-tt, ksh: -tt)

If the shell is reading from standard input, it exits after a single command has been executed. This also makes the shell

non-interactive, unless the IINNTTEERRAACCTTIIVVEE option is explicitly set

on the command line. The value of this option cannot be changed anywhere other than the command line. ZZllee BBEEEEPP (++BB) Beep on error in ZLE. EEMMAACCSS If ZLE is loaded, turning on this option has the equivalent

effect of `bbiinnddkkeeyy -ee'. In addition, the VI option is unset.

Turning it off has no effect. The option setting is not guaran-

teed to reflect the current keymap. This option is provided for compatibility; bbiinnddkkeeyy is the recommended interface. OOVVEERRSSTTRRIIKKEE Start up the line editor in overstrike mode.

SSIINNGGLLEELLIINNEEZZLLEE (-MM)

Use single-line command line editing instead of multi-line.

VVII If ZLE is loaded, turning on this option has the equivalent

effect of `bbiinnddkkeeyy -vv'. In addition, the EMACS option is unset.

Turning it off has no effect. The option setting is not guaran-

teed to reflect the current keymap. This option is provided for compatibility; bbiinnddkkeeyy is the recommended interface.

ZZLLEE (-ZZ)

Use the zsh line editor. Set by default in interactive shells connected to a terminal. OOPPTTIIOONN AALLIIAASSEESS Some options have alternative names. These aliases are never used for output, but can be used just like normal option names when specifying options to the shell. BBRRAACCEEEEXXPPAANNDD NOIIGGNNOORREEBBRRAACCEESS (ksh and bash compatibility) DDOOTTGGLLOOBB GGLLOOBBDDOOTTSS (bash compatibility) HHAASSHHAALLLL HHAASSHHCCMMDDSS (bash compatibility) HHIISSTTAAPPPPEENNDD APPENDHISTORY bs cmaiiiy HHIISSTTEEXXPPAANNDD BBAANNGGHHIISSTT (bash compatibility) LLOOGG NOHHIISSTTNNOOFFUUNNCCTTIIOONNSS (ksh compatibility) MMAAIILLWWAARRNN MMAAIILLWWAARRNNIINNGG (bash compatibility) OONNEECCMMDD SSIINNGGLLEECCOOMMMMAANNDD (bash compatibility) PPHHYYSSIICCAALL CCHHAASSEELLIINNKKSS (ksh and bash compatibility) PPRROOMMPPTTVVAARRSS PPRROOMMPPTTSSUUBBSSTT (bash compatibility) SSTTDDIINN SSHHIINNSSTTDDIINN (ksh compatibility) TTRRAACCKKAALLLL HHAASSHHCCMMDDSS (ksh compatibility) SSIINNGGLLEE LLEETTTTEERR OOPPTTIIOONNSS DDeeffaauulltt sseett

-00 CORRECT

-11 PRINTEXITVALUE

-22 NOBADPATTERN

-33 NONOMATCH

-44 GLOBDOTS

-55 NOTIFY

-66 BGNICE

-77 IGNOREEOF

-88 MARKDIRS

-99 AUTOLIST

-BB NOBEEP

-CC NOCLOBBER

-DD PUSHDTOHOME

-EE PUSHDSILENT

-FF NOGLOB

-GG NULLGLOB

-HH RMSTARSILENT

-II IGNOREBRACES

-JJ AUTOCD

-KK NOBANGHIST

-LL SUNKEYBOARDHACK

-MM SINGLELINEZLE

-NN AUTOPUSHD

-OO CORRECTALL

-PP RCEXPANDPARAM

-QQ PATHDIRS

-RR LONGLISTJOBS

-SS RECEXACT

-TT CDABLEVARS

-UU MAILWARNING

-VV NOPROMPTCR

-WW AUTORESUME

-XX LISTTYPES

-YY MENUCOMPLETE

-ZZ ZLE

-aa ALLEXPORT

-ee ERREXIT

-ff NORCS

-gg HISTIGNORESPACE

-hh HISTIGNOREDUPS

-ii INTERACTIVE

-kk INTERACTIVECOMMENTS

-ll LOGIN

-mm MONITOR

-nn NOEXEC

-pp PRIVILEGED

-rr RESTRICTED

-ss SHINSTDIN

-tt SINGLECOMMAND

-uu NOUNSET

-vv VERBOSE

-ww CHASELINKS

-xx XTRACE

-yy SHWORDSPLIT

sshh//kksshh eemmuullaattiioonn sseett

-CC NOCLOBBER

-TT TRAPSASYNC

-XX MARKDIRS

-aa ALLEXPORT

-bb NOTIFY

-ee ERREXIT

-ff NOGLOB

-ii INTERACTIVE

-ll LOGIN

-mm MONITOR

-nn NOEXEC

-pp PRIVILEGED

-rr RESTRICTED

-ss SHINSTDIN

-tt SINGLECOMMAND

-uu NOUNSET

-vv VERBOSE

-xx XTRACE

AAllssoo nnoottee

-AA Used by sseett for setting arrays

-bb Used on the command line to specify end of option processing

-cc Used on the command line to specify a single command

-mm Used by sseettoopptt for pattern-matching option setting

-oo Used in all places to allow use of long option names

-ss Used by sseett to sort positional parameters

ZSHBUILTINS(1) ZSHBUILTINS(1)

NAME

zshbuiltins - zsh built-in commands

SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS

- simple command

See the section `Precommand Modifiers'. .. file [ arg ... ] Read commands from file and execute them in the current shell environment. If file does not contain a slash, or if PPAATTHHDDIIRRSS is set, the

shell looks in the components of $$ppaatthh to find the directory

containing file. Files in the current directory are not read

unless `..' appears somewhere in $$ppaatthh. If a file named

`file..zzwwcc' is found, is newer than file, and is the compiled form (created with the zzccoommppiillee builtin) of file, then commands are read from that file instead of file. If any arguments arg are given, they become the positional parameters; the old positional parameters are restored when the file is done executing. The exit status is the exit status of the last command executed. :: [ arg ... ] This command does nothing, although normal argument expansions is performed which may have effects on shell parameters. A zero exit code is returned.

aalliiaass [ {++||-}}ggmmrrssLL ]] [[ name[[==value]] ...... ]]

For each name with a corresponding value, define an alias with that value. A trailing space in value causes the next word to

be checked for alias expansion. If the -gg flag is present,

define a global alias; global aliases are expanded even if they do not occur in command position.

If the -ss flags is present, define a suffix alias: if the com-

mand word on a command line is in the form `text..name', where

text is any non-empty string, it is replaced by the text `value

text..name'. Note that name is treated as a literal string, not a pattern. A trailing space in value is not special in this case. For example,

aalliiaass -ss ppss==ggvv

will cause the command `**..ppss' to be expanded to `ggvv **..ppss'. As alias expansion is carried out earlier than globbing, the `**..ppss' will then be expanded. Suffix aliases constitute a different name space from other aliases (so in the above example it is still possible to create an alias for the command ppss) and the two sets are never listed together. For each name with no value, print the value of name, if any. With no arguments, print all currently defined aliases other

than suffix aliases. If the -mm flag is given the arguments are

taken as patterns (they should be quoted to preserve them from being interpreted as glob patterns), and the aliases matching these patterns are printed. When printing aliases and one of

the -gg, -rr or -ss flags is present, restrict the printing to

global, regular or suffix aliases, respectively; a regular alias is one which is neither a global nor a suffix alias. Using `++'

instead of `-', or ending the option list with a single `++',

prevents the values of the aliases from being printed.

If the -LL flag is present, then print each alias in a manner

suitable for putting in a startup script. The exit status is nonzero if a name (with no value) is given for which no alias has been defined.

aauuttoollooaadd [ {++|-}UUXXkkttzz ] [ -ww ] [ name ... ]

Equivalent to ffuunnccttiioonnss -uu, with the exception of -XX/++XX and -ww.

The flag -XX may be used only inside a shell function, and may

not be followed by a name. It causes the calling function to be marked for autoloading and then immediately loaded and executed, with the current array of positional parameters as arguments. This replaces the previous definition of the function. If no

function definition is found, an error is printed and the func-

tion remains undefined and marked for autoloading.

The flag ++XX attempts to load each name as an autoloaded func-

tion, but does not execute it. The exit status is zero (suc-

cess) if the function was not previously defined and a defini-

tion for it was found. This does not replace any existing defi-

nition of the function. The exit status is nonzero (failure) if the function was already defined or when no definition was found. In the latter case the function remains undefined and

marked for autoloading. If ksh-style autoloading is enabled,

the function created will contain the contents of the file plus a call to the function itself appended to it, thus giving normal ksh autoloading behaviour on the first call to the function.

With the -ww flag, the names are taken as names of files compiled

with the zzccoommppiillee builtin, and all functions defined in them are marked for autoloading. bbgg [ job ... ] job ... && Put each specified job in the background, or the current job if none is specified. bbiinnddkkeeyy See the section `Zle Builtins' in zshzle(1). bbrreeaakk [ n ] Exit from an enclosing ffoorr, wwhhiillee, uunnttiill, sseelleecctt or rreeppeeaatt loop. If n is specified, then break n levels instead of just one. bbuuiillttiinn name [ args ... ] Executes the builtin name, with the given args. bbyyee Same as eexxiitt. ccaapp See the section `The zsh/cap Module' in zshmodules(1).

ccdd [ -ssLLPP ] [ arg ]

ccdd [ -ssLLPP ] old new

ccdd [ -ssLLPP ] {++|-}n

Change the current directory. In the first form, change the

current directory to arg, or to the value of $$HHOOMMEE if arg is not

specified. If arg is `-', change to the value of $$OOLLDDPPWWDD, the

previous directory. Otherwise, if a directory named arg is not found in the current directory and arg does not begin with a slash, search each component of the shell parameter ccddppaatthh. If no directory is found and the option CCDDAABBLLEEVVAARRSS is set, and a parameter named arg exists whose value begins with a slash, treat its value as the directory. In that case, the parameter is added to the named directory hash table. The second form of ccdd substitutes the string new for the string old in the name of the current directory, and tries to change to this new directory. The third form of ccdd extracts an entry from the directory stack, and changes to that directory. An argument of the form `++n' identifies a stack entry by counting from the left of the list shown by the ddiirrss command, starting with zero. An argument of

the form `-n' counts from the right. If the PPUUSSHHDDMMIINNUUSS option

is set, the meanings of `++' and `-' in this context are swapped.

If the -ss option is specified, ccdd refuses to change the current

directory if the given pathname contains symlinks. If the -PP

option is given or the CCHHAASSEELLIINNKKSS option is set, symbolic links

are resolved to their true values. If the -LL option is given

symbolic links are followed regardless of the state of the CCHHAASSEELLIINNKKSS option. cchhddiirr Same as ccdd. cclloonnee See the section `The zsh/clone Module' in zshmodules(1).

ccoommmmaanndd [ -ppvvVV ] simple command

The simple command argument is taken as an external command instead of a function or builtin and is executed. If the PPOOSSIIXXBBUUIILLTTIINNSS option is set, builtins will also be executed but

certain special properties of them are suppressed. The -pp flag

causes a default path to be searched instead of that in $$ppaatthh.

With the -vv flag, ccoommmmaanndd is similar to wwhheennccee and with -VV, it

is equivalent to wwhheennccee -vv.

See also the section `Precommand Modifiers'. ccoommppaarrgguummeennttss See the section `The zsh/computil Module' in zshmodules(1). ccoommppccaallll See the section `The zsh/compctl Module' in zshmodules(1). ccoommppccttll See the section `The zsh/compctl Module' in zshmodules(1). ccoommppddeessccrriibbee See the section `The zsh/computil Module' in zshmodules(1). ccoommppffiilleess See the section `The zsh/computil Module' in zshmodules(1). ccoommppggrroouuppss See the section `The zsh/computil Module' in zshmodules(1). ccoommppqquuoottee See the section `The zsh/computil Module' in zshmodules(1). ccoommppttaaggss See the section `The zsh/computil Module' in zshmodules(1). ccoommppttrryy See the section `The zsh/computil Module' in zshmodules(1). ccoommppvvaalluueess See the section `The zsh/computil Module' in zshmodules(1). ccoonnttiinnuuee [ n ] Resume the next iteration of the enclosing ffoorr, wwhhiillee, uunnttiill,

sseelleecctt or rreeppeeaatt loop. If n is specified, break out of n-1

loops and resume at the nth enclosing loop. ddeeccllaarree Same as ttyyppeesseett.

ddiirrss [ -cc ] [ arg ... ]

ddiirrss [ -llppvv ]

With no arguments, print the contents of the directory stack. Directories are added to this stack with the ppuusshhdd command, and

removed with the ccdd or ppooppdd commands. If arguments are speci-

fied, load them onto the directory stack, replacing anything that was there, and push the current directory onto the stack.

-cc clear the directory stack.

-ll print directory names in full instead of using of using ~~

expressions.

-pp print directory entries one per line.

-vv number the directories in the stack when printing.

ddiissaabbllee [ -aaffmmrrss ] name ...

Temporarily disable the named hash table elements. The default is to disable builtin commands. This allows you to use an external command with the same name as a builtin command. The

-aa option causes ddiissaabbllee to act on regular or global aliases.

The -ss option causes ddiissaabbllee to act on suffix aliases. The -ff

option causes ddiissaabbllee to act on shell functions. The -rr options

causes ddiissaabbllee to act on reserved words. Without arguments all disabled hash table elements from the corresponding hash table

are printed. With the -mm flag the arguments are taken as pat-

terns (which should be quoted to prevent them from undergoing

filename expansion), and all hash table elements from the corre-

sponding hash table matching these patterns are disabled. Dis-

abled objects can be enabled with the eennaabbllee command. ddiissoowwnn [ job ... ] job ... &&|| job ... &&!! Remove the specified jobs from the job table; the shell will no longer report their status, and will not complain if you try to exit an interactive shell with them running or stopped. If no job is specified, disown the current job. If the jobs are currently stopped and the AAUUTTOOCCOONNTTIINNUUEE option is not set, a warning is printed containing information about how to make them running after they have been disowned. If one of the latter two forms is used, the jobs will automatically be made running, independent of the setting of the AAUUTTOOCCOONNTTIINNUUEE option.

eecchhoo [ -nneeEE ] [ arg ... ]

Write each arg on the standard output, with a space separating

each one. If the -nn flag is not present, print a newline at the

end. eecchhoo recognizes the following escape sequences: \\aa bell character \\bb backspace \\cc suppress final newline \\ee escape \\ff form feed \\nn linefeed (newline) \\rr carriage return \\tt horizontal tab \\vv vertical tab \\\\ backslash \\00NNN character code in octal \\xxNN character code in hexadecimal \\uuNNNN unicode character code in hexadecimal \\UUNNNNNNNN unicode character code in hexadecimal

The -EE flag, or the BBSSDDEECCHHOO option, can be used to disable

these escape sequences. In the latter case, -ee flag can be used

to enable them. eecchhoottcc See the section `The zsh/termcap Module' in zshmodules(1). eecchhoottii See the section `The zsh/terminfo Module' in zshmodules(1).

eemmuullaattee [ -LLRR ] {zzsshh|sshh|kksshh|ccsshh}

Set up zsh options to emulate the specified shell as much as possible. ccsshh will never be fully emulated. If the argument is not one of the shells listed above, zzsshh will be used as a default; more precisely, the tests performed on the argument are the same as those used to determine the emulation at startup

based on the shell name, see the section `Compatibility' in zsh-

misc(1) . If the -RR option is given, all options are reset to

their default value corresponding to the specified emulation mode, except for certain options describing the interactive environment; otherwise, only those options likely to cause portability problems in scripts and functions are altered. If

the -LL option is given, the options LLOOCCAALLOOPPTTIIOONNSS and

LLOOCCAALLTTRRAAPPSS will be set as well, causing the effects of the eemmuu-

llaattee command and any sseettoopptt and ttrraapp commands to be local to the immediately surrounding shell function, if any; normally these options are turned off in all emulation modes except kksshh.

eennaabbllee [ -aaffmmrrss ] name ...

Enable the named hash table elements, presumably disabled ear-

lier with ddiissaabbllee. The default is to enable builtin commands.

The -aa option causes eennaabbllee to act on regular or global aliases.

The -ss option causes eennaabbllee to act on suffix aliases. The -ff

option causes eennaabbllee to act on shell functions. The -rr option

causes eennaabbllee to act on reserved words. Without arguments all enabled hash table elements from the corresponding hash table

are printed. With the -mm flag the arguments are taken as pat-

terns (should be quoted) and all hash table elements from the corresponding hash table matching these patterns are enabled.

Enabled objects can be disabled with the ddiissaabbllee builtin com-

mand. eevvaall [ arg ... ]

Read the arguments as input to the shell and execute the result-

ing command in the current shell process. eexxeecc simple command See the section `Precommand Modifiers'. eexxiitt [ n ] Exit the shell with the exit code specified by n; if none is specified, use the exit code from the last command executed. An EOF condition will also cause the shell to exit, unless the IIGGNNOORREEEEOOFF option is set. eexxppoorrtt [ name[==value] ... ]

The specified names are marked for automatic export to the envi-

ronment of subsequently executed commands. Equivalent to ttyyppee-

sseett -ggxx. If a parameter specified does not already exist, it is

created in the global scope. ffaallssee [ arg ... ] Do nothing and return an exit code of 1.

ffcc [ -ee ename ] [ -nnllrrddDDffEEiimm ] [ old==new ... ] [ first [ last ] ]

ffcc -pp [ -aa ] [ filename [ histsize [ savehistsize ] ] ]

ffcc -PP

ffcc -AARRWWII [ filename ]

Select a range of commands from first to last from the history list. The arguments first and last may be specified as a number or as a string. A negative number is used as an offset to the current history event number. A string specifies the most recent event beginning with the given string. All substitutions old==new, if any, are then performed on the commands.

If the -ll flag is given, the resulting commands are listed on

standard output. If the -mm flag is also given the first argu-

ment is taken as a pattern (should be quoted) and only the his-

tory events matching this pattern will be shown. Otherwise the

editor program ename is invoked on a file containing these his-

tory events. If ename is not given, the value of the parameter

FFCCEEDDIITT is used. If ename is `-', no editor is invoked. When

editing is complete, the edited command is executed.

If first is not specified, it will be set to -1 (the most recent

event), or to -16 if the -ll flag is given. If last is not spec-

ified, it will be set to first, or to -1 if the -ll flag is

given.

The flag -rr reverses the order of the commands and the flag -nn

suppresses command numbers when listing. Also when listing, -dd

prints timestamps for each command, and -ff prints full time-date

stamps. Adding the -EE flag causes the dates to be printed as

`dd..mm..yyyy', instead of the default `mm//dd//yyyy'. Adding the

-ii flag causes the dates to be printed in ISO8601 `yyyy-mm-dd'

format. With the -DD flag, ffcc prints elapsed times.

`ffcc -pp' pushes the current history list onto a stack and

switches to a new history list. If the -aa option is also speci-

fied, this history list will be automatically popped when the

current function scope is exited, which is a much better solu-

tion than creating a trap function to call `ffcc -PP' manually. If

no arguments are specified, the history list is left empty,

$$HHIISSTTFFIILLEE is unset, and $$HHIISSTTSSIIZZEE & $$SSAAVVEEHHIISSTT are set to their

default values. If one argument is given, $$HHIISSTTFFIILLEE is set to

that filename, $$HHIISSTTSSIIZZEE & $$SSAAVVEEHHIISSTT are left unchanged, and the

history file is read in (if it exists) to initialize the new

list. If a second argument is specified, $$HHIISSTTSSIIZZEE & $$SSAAVVEEHHIISSTT

are instead set to the single specified numeric value. Finally,

if a third argument is specified, $$SSAAVVEEHHIISSTT is set to a separate

value from $$HHIISSTTSSIIZZEE. You are free to change these environment

values for the new history list however you desire in order to manipulate the new history list.

`ffcc -PP' pops the history list back to an older list saved by `ffcc

-pp'. The current list is saved to its $$HHIISSTTFFIILLEE before it is

destroyed (assuming that $$HHIISSTTFFIILLEE and $$SSAAVVEEHHIISSTT are set appro-

priately, of course). The values of $$HHIISSTTFFIILLEE, $$HHIISSTTSSIIZZEE, and

$$SSAAVVEEHHIISSTT are restored to the values they had when `ffcc -pp' was

called. Note that this restoration can conflict with making

these variables "local", so your best bet is to avoid local dec-

larations for these variables in functions that use `ffcc -pp'.

The one other guaranteed-safe combination is declaring these

variables to be local at the top of your function and using the

automatic option (-aa) with `ffcc -pp'. Finally, note that it is

legal to manually pop a push marked for automatic popping if you need to do so before the function exits.

`ffcc -RR' reads the history from the given file, `ffcc -WW' writes

the history out to the given file, and `ffcc -AA' appends the his-

tory out to the given file. If no filename is specified, the

$$HHIISSTTFFIILLEE is assumed. If the -II option is added to -RR, only

those events that are not already contained within the internal

history list are added. If the -II option is added to -AA or -WW,

only those events that are new since last incremental append/write to the history file are appended/written. In any

case, the created file will have no more than $$SSAAVVEEHHIISSTT entries.

ffgg [ job ... ] job ... Bring each specified job in turn to the foreground. If no job is specified, resume the current job.

ffllooaatt [ {++|-}EEFFHHgghhllpprrttuuxx ] [ -LLRRZZ [ n ]] [ name[==value] ... ]

Equivalent to ttyyppeesseett -EE, except that options irrelevant to

floating point numbers are not permitted.

ffuunnccttiioonnss [ {++|-}UUXXkkmmttuuzz ] [ name ... ]

Equivalent to ttyyppeesseett -ff.

ggeettccaapp See the section `The zsh/cap Module' in zshmodules(1).

ggeettllnn [ -AAccllnneeEE ] name ...

Read the top value from the buffer stack and put it in the shell

parameter nnaammee. Equivalent to rreeaadd -zzrr.

ggeettooppttss optstring name [ arg ... ] Checks the args for legal options. If the args are omitted, use the positional parameters. A valid option argument begins with

a `++' or a `-'. An argument not beginning with a `++' or a `-',

or the argument `--', ends the options. Note that a single `-'

is not considered a valid option argument. optstring contains the letters that ggeettooppttss recognizes. If a letter is followed by a `::', that option is expected to have an argument. The options can be separated from the argument by blanks. Each time it is invoked, ggeettooppttss places the option letter it finds in the shell parameter name, prepended with a `++' when arg begins with a `++'. The index of the next arg is stored in OOPPTTIINNDD. The option argument, if any, is stored in OOPPTTAARRGG. The first option to be examined may be changed by explicitly assigning to OOPPTTIINNDD. OOPPTTIINNDD has an initial value of 11, and is normally reset to 11 upon exit from a shell function. OOPPTTAARRGG is not reset and retains its value from the most recent call to ggeettooppttss. If either of OOPPTTIINNDD or OOPPTTAARRGG is explicitly unset, it remains unset, and the index or option argument is not stored. The option itself is still stored in name in this case. A leading `::' in optstring causes ggeettooppttss to store the letter of any invalid option in OOPPTTAARRGG, and to set name to `??' for an unknown option and to `::' when a required option is missing. Otherwise, ggeettooppttss sets name to `??' and prints an error message when an option is invalid. The exit status is nonzero when there are no more options.

hhaasshh [ -LLddffmmrrvv ] [ name[==value] ] ...

hhaasshh can be used to directly modify the contents of the command hash table, and the named directory hash table. Normally one

would modify these tables by modifying one's PPAATTHH (for the com-

mand hash table) or by creating appropriate shell parameters (for the named directory hash table). The choice of hash table

to work on is determined by the -dd option; without the option

the command hash table is used, and with the option the named directory hash table is used.

Given no arguments, and neither the -rr or -ff options, the

selected hash table will be listed in full.

The -rr option causes the selected hash table to be emptied. It

will be subsequently rebuilt in the normal fashion. The -ff

option causes the selected hash table to be fully rebuilt imme-

diately. For the command hash table this hashes all the abso-

lute directories in the PPAATTHH, and for the named directory hash table this adds all users' home directories. These two options cannot be used with any arguments.

The -mm option causes the arguments to be taken as patterns

(which should be quoted) and the elements of the hash table matching those patterns are printed. This is the only way to display a limited selection of hash table elements. For each name with a corresponding value, put `name' in the selected hash table, associating it with the pathname `value'. In the command hash table, this means that whenever `name' is used as a command argument, the shell will try to execute the file given by `value'. In the named directory hash table, this means that `value' may be referred to as `~~name'. For each name with no corresponding value, attempt to add name to the hash table, checking what the appropriate vvaalluuee is in the normal manner for that hash table. If an appropriate vvaalluuee can't be found, then the hash table will be unchanged.

The -vv option causes hash table entries to be listed as they are

added by explicit specification. If has no effect if used with

-ff.

If the -LL flag is present, then each hash table entry is printed

in the form of a call to hash. hhiissttoorryy

Same as ffcc -ll.

iinntteeggeerr [ {++|-}HHgghhiillpprrttuuxx ] [ -LLRRZZ [ n ]] [ name[==value] ... ]

Equivalent to ttyyppeesseett -ii, except that options irrelevant to

integers are not permitted.

jjoobbss [ -ddllpprrss ] [ job ... ]

jjoobbss -ZZ string

Lists information about each given job, or all jobs if job is

omitted. The -ll flag lists process IDs, and the -pp flag lists

process groups. If the -rr flag is specified only running jobs

will be listed and if the -ss flag is given only stopped jobs are

shown. If the -dd flag is given, the directory from which the

job was started (which may not be the current directory of the job) will also be shown.

The -ZZ option replaces the shell's argument and environment

space with the given string, truncated if necessary to fit.

This will normally be visible in ppss (ps(1)) listings. This fea-

ture is typically used by daemons, to indicate their state.

kkiillll [ -ss signalname | -nn signalnumber | -sig ] job ...

kkiillll -ll [ sig ... ]

Sends either SSIIGGTTEERRMM or the specified signal to the given jobs or processes. Signals are given by number or by names, with or without the `SSIIGG' prefix. If the signal being sent is not `KKIILLLL' or `CCOONNTT', then the job will be sent a `CCOONNTT' signal if it is stopped. The argument job can be the process ID of a job

not in the job list. In the second form, kkiillll -ll, if sig is not

specified the signal names are listed. Otherwise, for each sig that is a name, the corresponding signal number is listed. For each sig that is a signal number or a number representing the exit status of a process which was terminated or stopped by a signal the name of the signal is printed. On some systems, alternative signal names are allowed for a few signals. Typical examples are SSIIGGCCHHLLDD and SSIIGGCCLLDD or SSIIGGPPOOLLLL and SSIIGGIIOO, assuming they correspond to the same signal number. kkiillll

-ll will only list the preferred form, however kkiillll -ll alt will

show if the alternative form corresponds to a signal number.

For example, under Linux kkiillll -ll IIOO and kkiillll -ll PPOOLLLL both output

29, hence kkiillll -IIOO and kkiillll -PPOOLLLL have the same effect.

lleett arg ... Evaluate each arg as an arithmetic expression. See the section

`Arithmetic Evaluation' for a description of arithmetic expres-

sions. The exit status is 0 if the value of the last expression is nonzero, and 1 otherwise.

lliimmiitt [ -hhss ] [ resource [ limit ] ] ...

Set or display resource limits. Unless the -ss flag is given,

the limit applies only the children of the shell. If -ss is

given without other arguments, the resource limits of the cur-

rent shell is set to the previously set resource limits of the children. If limit is not specified, print the current limit placed on resource, otherwise set the limit to the specified value. If

the -hh flag is given, use hard limits instead of soft limits.

If no resource is given, print all limits.

When looping over multiple resources, the shell will abort imme-

diately if it detects a badly formed argument. However, if it

fails to set a limit for some other reason it will continue try-

ing to set the remaining limits. resource can be one of: aaddddrreessssssppaaccee Maximum amount of address space used. aaiioommeemmoorryylloocckkeedd

Maximum amount of memory locked in RAM for AIO opera-

tions. aaiiooooppeerraattiioonnss Maximum number of AIO operations. ccaacchheeddtthhrreeaaddss Maximum number of cached threads. ccoorreedduummppssiizzee Maximum size of a core dump. ccppuuttiimmee Maximum CPU seconds per process. ddaattaassiizzee Maximum data size (including stack) for each process. ddeessccrriippttoorrss Maximum value for a file descriptor. ffiilleessiizzee Largest single file allowed. mmaaxxpprroocc Maximum number of processes. mmaaxxpptthhrreeaaddss Maximum number of threads per process. mmeemmoorryylloocckkeedd Maximum amount of memory locked in RAM. mmeemmoorryyuussee Maximum resident set size. rreessiiddeenntt Maximum resident set size. ssoocckkbbuuffssiizzee Maximum size of all socket buffers. ssttaacckkssiizzee Maximum stack size for each process. vvmmeemmoorryyssiizzee Maximum amount of virtual memory.

Which of these resource limits are available depends on the sys-

tem. resource can be abbreviated to any unambiguous prefix. It can also be an integer, which corresponds to the integer defined for the resource by the operating system. If argument corresponds to a number which is out of the range of the resources configured into the shell, the shell will try to read or write the limit anyway, and will report an error if this fails. As the shell does not store such resources internally,

an attempt to set the limit will fail unless the -ss option is

present. limit is a number, with an optional scaling factor, as follows: nhh hours nkk kilobytes (default) nmm megabytes or minutes [mm::]ss minutes and seconds

llooccaall [ {++|-}AAEEFFHHUUaahhllpprrttuuxx ] [ -LLRRZZii [ n ]] [ name[==value] ] ...

Same as ttyyppeesseett, except that the options -gg, and -ff are not per-

mitted. In this case the -xx option does not force the use of

-gg, i.e. exported variables will be local to functions.

lloogg List all users currently logged in who are affected by the cur-

rent setting of the wwaattcchh parameter. llooggoouutt [ n ] Same as eexxiitt, except that it only works in a login shell. nnoogglloobb simple command See the section `Precommand Modifiers'.

ppooppdd [ {++|-}n ]

Remove an entry from the directory stack, and perform a ccdd to the new top directory. With no argument, the current top entry is removed. An argument of the form `++n' identifies a stack entry by counting from the left of the list shown by the ddiirrss

command, starting with zero. An argument of the form -nn counts

from the right. If the PPUUSSHHDDMMIINNUUSS option is set, the meanings

of `++' and `-' in this context are swapped.

pprriinntt [ -aabbccDDiillmmnnNNooOOppPPrrsszz ] [ -uu n ] [ -ff format ] [ -CC cols ]

[ -RR [ -eenn ]] [ arg ... ]

With the `-ff' option the arguments are printed as described by

pprriinnttff. With no flags or with the flag `-', the arguments are

printed on the standard output as described by eecchhoo, with the

following differences: the escape sequence `\\MM-x' metafies the

character x (sets the highest bit), `\\CC-x' produces a control

character (`\\CC-@@' and `\\CC-??' give the characters NUL and

delete), and `\\EE' is a synonym for `\\ee'. Finally, if not in an escape sequence, `\\' escapes the following character and is not printed.

-aa Print arguments with the column incrementing first. Only

useful with the -cc and -CC options.

-bb Recognize all the escape sequences defined for the bbiinndd-

kkeeyy command, see zshzle(1).

-cc Print the arguments in columns. Unless -aa is also given,

arguments are printed with the row incrementing first.

-CC cols

Print the arguments in cols columns. Unless -aa is also

given, arguments are printed with the row incrementing first.

-DD Treat the arguments as directory names, replacing pre-

fixes with ~~ expressions, as appropriate.

-ii If given together with -oo or -OO, sorting is performed

case-independently.

-ll Print the arguments separated by newlines instead of spa-

ces.

-mm Take the first argument as a pattern (should be quoted),

and remove it from the argument list together with subse-

quent arguments that do not match this pattern.

-nn Do not add a newline to the output.

-NN Print the arguments separated and terminated by nulls.

-oo Print the arguments sorted in ascending order.

-OO Print the arguments sorted in descending order.

-pp Print the arguments to the input of the coprocess.

-PP Perform prompt expansion (see zshmisc(1)).

-rr Ignore the escape conventions of eecchhoo.

-RR Emulate the BSD eecchhoo command, which does not process

escape sequences unless the -ee flag is given. The -nn

flag suppresses the trailing newline. Only the -ee and -nn

flags are recognized after -RR; all other arguments and

options are printed.

-ss Place the results in the history list instead of on the

standard output.

-uu n Print the arguments to file descriptor n.

-zz Push the arguments onto the editing buffer stack, sepa-

rated by spaces.

If any of `-mm', `-oo' or `-OO' are used in combination with `-ff'

and there are no arguments (after the removal process in the

case of `-mm') then nothing is printed.

pprriinnttff format [ arg ... ]

Print the arguments according to the format specification. For-

matting rules are the same as used in C. The same escape

sequences as for eecchhoo are recognised in the format. All C con-

version specifications ending in one of csdiouxXeEfgGn are han-

dled. In addition to this, `%%bb' can be used instead of `%%ss' to

cause escape sequences in the argument to be recognised and `%%qq'

can be used to quote the argument in such a way that allows it to be reused as shell input. With the numeric format specifiers, if the corresponding argument starts with a quote character, the numeric value of the following character is used as the number to print otherwise the argument is evaluated as an arithmetic expression. See the section `Arithmetic Evaluation' for a

description of arithmetic expressions. With `%%nn', the corre-

sponding argument is taken as an identifier which is created as an integer parameter. Normally, conversion specifications are applied to each argument in order but they can explicitly specify the nth argument is to

be used by replacing `%%' by `%%n$$' and `**' by `**n$$'. It is rec-

ommended that you do not mix references of this explicit style with the normal style and the handling of such mixed styles may be subject to future change. If arguments remain unused after formatting, the format string is reused until all arguments have been consumed. With the pprriinntt

builtin, this can be suppressed by using the -rr option. If more

arguments are required by the format than have been specified,

the behaviour is as if zero or an empty string had been speci-

fied as the argument.

ppuusshhdd [ -ssLLPP ] [ arg ]

ppuusshhdd [ -ssLLPP ] old new

ppuusshhdd [ -ssLLPP ] {++|-}n

Change the current directory, and push the old current directory onto the directory stack. In the first form, change the current directory to arg. If arg is not specified, change to the second directory on the stack (that is, exchange the top two entries),

or change to $$HHOOMMEE if the PPUUSSHHDDTTOOHHOOMMEE option is set or if

there is only one entry on the stack. Otherwise, arg is inter-

preted as it would be by ccdd. The meaning of old and new in the second form is also the same as for ccdd.

The third form of ppuusshhdd changes directory by rotating the direc-

tory list. An argument of the form `++n' identifies a stack entry by counting from the left of the list shown by the ddiirrss

command, starting with zero. An argument of the form `-n'

counts from the right. If the PPUUSSHHDDMMIINNUUSS option is set, the

meanings of `++' and `-' in this context are swapped.

If the option PPUUSSHHDDSSIILLEENNTT is not set, the directory stack will be printed after a ppuusshhdd is performed.

The options -ss, -LL and -PP have the same meanings as for the ccdd

builtin. ppuusshhllnn [ arg ... ]

Equivalent to pprriinntt -nnzz.

ppwwdd [ -rrLLPP ]

Print the absolute pathname of the current working directory.

If the -rr or the -PP flag is specified, or the CCHHAASSEELLIINNKKSS option

is set and the -LL flag is not given, the printed path will not

contain symbolic links.

rr Same as ffcc -ee -.

rreeaadd [ -rrsszzppqqAAccllnneeEE ] [ -tt [ num ] ] [ -kk [ num ] ] [ -dd delim ]

[ -uu n ] [ name[??prompt] ] [ name ... ]

Read one line and break it into fields using the characters in

$$IIFFSS as separators, except as noted below. The first field is

assigned to the first name, the second field to the second name, etc., with leftover fields assigned to the last name. If name is omitted then RREEPPLLYY is used for scalars and rreeppllyy for arrays.

-rr Raw mode: a `\\' at the end of a line does not signify

line continuation and backslashes in the line don't quote the following character and are not removed.

-ss Don't echo back characters if reading from the terminal.

Currently does not work with the -qq option.

-qq Read only one character from the terminal and set name to

`yy' if this character was `yy' or `YY' and to `nn' other-

wise. With this flag set the return value is zero only if the character was `yy' or `YY'. Note that this always

reads from the terminal, even if used with the -pp or -uu

or -zz flags or with redirected input. This option may

also be used within zle widgets.

-kk [ num ]

Read only one (or num) characters. All are assigned to the first name, without word splitting. This flag is

ignored when -qq is present. Input is read from the ter-

minal unless one of -uu or -pp is present. This option may

also be used within zle widgets.

-zz Read one entry from the editor buffer stack and assign it

to the first name, without word splitting. Text is

pushed onto the stack with `pprriinntt -zz' or with ppuusshh-lliinnee

from the line editor (see zshzle(1)). This flag is

ignored when the -kk or -qq flags are present.

-ee

-EE The input read is printed (echoed) to the standard out-

put. If the -ee flag is used, no input is assigned to the

parameters.

-AA The first name is taken as the name of an array and all

words are assigned to it.

-cc

-ll These flags are allowed only if called inside a function

used for completion (specified with the -KK flag to ccoomm-

ppccttll). If the -cc flag is given, the words of the current

command are read. If the -ll flag is given, the whole line

is assigned as a scalar. If both flags are present, -ll

is used and -cc is ignored.

-nn Together with -cc, the number of the word the cursor is on

is read. With -ll, the index of the character the cursor

is on is read. Note that the command name is word number 1, not word 0, and that when the cursor is at the end of the line, its character index is the length of the line plus one.

-uu n Input is read from file descriptor n.

-pp Input is read from the coprocess.

-dd delim

Input is terminated by the first character of delim instead of by newline.

-tt [ num ]

Test if input is available before attempting to read. If num is present, it must begin with a digit and will be evaluated to give a number of seconds, which may be a floating point number; in this case the read times out if input is not available within this time. If num is not present, it is taken to be zero, so that rreeaadd returns immediately if no input is available. If no input is available, return status 1 and do not set any variables. This option is not available when reading from the editor

buffer with -zz, when called from within completion with

-cc or -ll, with -qq which clears the input queue before

reading, or within zle where other mechanisms should be used to test for input.

Note that read does not attempt to alter the input pro-

cessing mode. The default mode is canonical input, in which an entire line is read at a time, so usually `rreeaadd

-tt' will not read anything until an entire line has been

typed. However, when reading from the terminal with -kk

input is processed one key at a time; in this case, only availability of the first character is tested, so that

e.g. `rreeaadd -tt -kk 22' can still block on the second charac-

ter. Use two instances of `rreeaadd -tt -kk' if this is not

what is wanted. If the first argument contains a `??',

the remainder of this word is used as a prompt on stan-

dard error when the shell is interactive.

The value (exit status) of rreeaadd is 1 when an end-of-file is

encountered, or when -cc or -ll is present and the command is not

called from a ccoommppccttll function, or as described for -qq. Other-

wise the value is 0.

The behavior of some combinations of the -kk, -pp, -qq, -uu and -zz

flags is undefined. Presently -qq cancels all the others, -pp

cancels -uu, -kk cancels -zz, and otherwise -zz cancels both -pp and

-uu.

The -cc or -ll flags cancel any and all of -kkppqquuzz.

rreeaaddoonnllyy

Same as ttyyppeesseett -rr.

rreehhaasshh Same as hhaasshh -rr.

rreettuurrnn [ n ] Causes a shell function or .. script to return to the invoking script with the return status specified by n. If n is omitted, the return status is that of the last command executed. If rreettuurrnn was executed from a trap in a TTRRAAPPNAL function, the

effect is different for zero and non-zero return status. With

zero status (or after an implicit return at the end of the

trap), the shell will return to whatever it was previously pro-

cessing; with a non-zero status, the shell will behave as inter-

rupted except that the return status of the trap is retained. Note that the numeric value of the signal which caused the trap is passed as the first argument, so the statement `rreettuurrnn

$$((((112288++$$11))))' will return the same status as if the signal had

not been trapped. sscchheedd See the section `The zsh/sched Module' in zshmodules(1).

sseett [ {++|-}options | {++|-}oo [ optionname ] ] ... [ {++|-}AA [ name ] ] [

arg ... ]

Set the options for the shell and/or set the positional parame-

ters, or declare and set an array. If the -ss option is given,

it causes the specified arguments to be sorted before assigning

them to the positional parameters (or to the array name if -AA is

used). With ++ss sort arguments in descending order. For the meaning of the other flags, see zshoptions(1). Flags may be

specified by name using the -oo option. If no option name is sup-

plied with -oo, the current option states are printed. With ++oo

they are printed in a form that can be used as input to the shell.

If the -AA flag is specified, name is set to an array containing

the given args; if no name is specified, all arrays are printed together with their values. If ++AA is used and name is an array, the given arguments will

replace the initial elements of that array; if no name is speci-

fied, all arrays are printed without their values.

The behaviour of arguments after -AA name or ++AA name depends on

whether the option KKSSHHAARRRRAAYYSS is set. If it is not set, all arguments following name are treated as values for the array, regardless of their form. If the option is set, normal option processing continues at that point; only regular arguments are treated as values for the array. This means that

sseett -AA aarrrraayy -xx -- ffoooo

sets aarrrraayy to `-xx -- ffoooo' if KKSSHHAARRRRAAYYSS is not set, but sets the

array to ffoooo and turns on the option `-xx' if it is set.

If the -AA flag is not present, but there are arguments beyond

the options, the positional parameters are set. If the option

list (if any) is terminated by `--', and there are no further

arguments, the positional parameters will be unset.

If no arguments and no `--' are given, then the names and values

of all parameters are printed on the standard output. If the only argument is `++', the names of all parameters are printed. sseettccaapp See the section `The zsh/cap Module' in zshmodules(1).

sseettoopptt [ {++|-}options | {++|-}oo optionname ] [ name ... ]

Set the options for the shell. All options specified either with flags or by name are set. If no arguments are supplied,

the names of all options currently set are printed. If the -mm

flag is given the arguments are taken as patterns (which should be quoted to protect them from filename expansion), and all options with names matching these patterns are set. sshhiifftt [ n ] [ name ... ]

The positional parameters $${{n+1}} ... are renamed to $$11 ...,

where n is an arithmetic expression that defaults to 1. If any names are given then the arrays with these names are shifted instead of the positional parameters. ssoouurrccee file [ arg ... ] Same as .., except that the current directory is always searched

and is always searched first, before directories in $$ppaatthh.

ssttaatt See the section `The zsh/stat Module' in zshmodules(1).

ssuussppeenndd [ -ff ]

Suspend the execution of the shell (send it a SSIIGGTTSSTTPP) until it

receives a SSIIGGCCOONNTT. Unless the -ff option is given, this will

refuse to suspend a login shell. tteesstt [ arg ... ] [[ [ arg ... ] ]] Like the system version of tteesstt. Added for compatibility; use conditional expressions instead (see the section `Conditional Expressions'). The main differences between the conditional

expression syntax and the tteesstt and [[ builtins are: these com-

mands are not handled syntactically, so for example an empty variable expansion may cause an argument to be omitted; syntax errors cause status 2 to be returned instead of a shell error; and arithmetic operators expect integer arguments rather than arithemetic expressions. ttiimmeess Print the accumulated user and system times for the shell and for processes run from the shell. ttrraapp [ arg [ sig ... ] ] arg is a series of commands (usually quoted to protect it from immediate evaluation by the shell) to be read and executed when the shell receives sig. Each sig can be given as a number or as

the name of a signal. If arg is `-', then all traps sig are

reset to their default values. If arg is the empty string, then this signal is ignored by the shell and by the commands it invokes. If sig is ZZEERRRR then arg will be executed after each command with

a nonzero exit status. If sig is DDEEBBUUGG then arg will be exe-

cuted after each command. If sig is 00 or EEXXIITT and the ttrraapp statement is executed inside the body of a function, then the command arg is executed after the function completes. If sig is 00 or EEXXIITT and the ttrraapp statement is not executed inside the body of a function, then the command arg is executed when the shell terminates. ZZEERRRR, DDEEBBUUGG and EEXXIITT traps are not executed inside other traps. The ttrraapp command with no arguments prints a list of commands associated with each signal.

Note that traps defined with the ttrraapp builtin are slightly dif-

ferent from those defined as `TTRRAAPPNAL () { ... }', as the latter

have their own function environment (line numbers, local vari-

ables, etc.) while the former use the environment of the command in which they were called. For example,

ttrraapp ''pprriinntt $$LLIINNEENNOO'' DDEEBBUUGG

will print the line number of a command executed after it has run, while

TTRRAAPPDDEEBBUUGG(()) {{ pprriinntt $$LLIINNEENNOO;; }}

will always print the number zero. Alternative signal names are allowed as described under kkiillll above. Defining a trap under either name causes any trap under an alternative name to be removed. However, it is recommended that for consistency users stick exclusively to one name or another. ttrruuee [ arg ... ] Do nothing and return an exit code of 0.

ttttyyccttll -ffuu

The -ff option freezes the tty, and -uu unfreezes it. When the

tty is frozen, no changes made to the tty settings by external programs will be honored by the shell, except for changes in the size of the screen; the shell will simply reset the settings to

their previous values as soon as each command exits or is sus-

pended. Thus, ssttttyy and similar programs have no effect when the tty is frozen. Without options it reports whether the terminal is frozen or not.

ttyyppee [ -wwffppaammss ] name ...

Equivalent to wwhheennccee -vv.

ttyyppeesseett [ {++|-}AAEEFFHHUUaaffgghhkkllpprrttuuxxmmzz ] [ -LLRRZZii [ n ]] [ name[==value] ... ]

ttyyppeesseett -T [ {++||-}}UUrruuxx ]] [[ -LLRRZZ [[ n ]]]] SCALAR[[==value]] array [[ sep ]]

Set or display attributes and values for shell parameters. A parameter is created for each name that does not already refer to one. When inside a function, a new parameter is created for every name (even those that already exist), and is unset again

when the function completes. See `Local Parameters' in zsh-

param(1). The same rules apply to special shell parameters, which retain their special attributes when made local. For each name==value assignment, the parameter name is set to value. Note that arrays currently cannot be assigned in ttyyppeesseett expressions, only scalars and integers.

If the shell option TTYYPPEESSEETTSSIILLEENNTT is not set, for each remain-

ing name that refers to a parameter that is set, the name and value of the parameter are printed in the form of an assignment.

Nothing is printed for newly-created parameters, or when any

attribute flags listed below are given along with the name. Using `++' instead of minus to introduce an attribute turns it off.

If the -pp option is given, parameters and values are printed in

the form of a typeset comand and an assignment (which will be

printed separately for arrays and associative arrays), regard-

less of other flags and options. Note that the -hh flag on

parameters is respected; no value will be shown for these param-

eters.

If the -TT option is given, two or three arguments must be

present (an exception is that zero arguments are allowed to show the list of parameters created in this fashion). The first two are the name of a scalar and an array parameter (in that order)

that will be tied together in the manner of $$PPAATTHH and $$ppaatthh.

The optional third argument is a single-character separator

which will be used to join the elements of the array to form the

scalar; if absent, a colon is used, as with $$PPAATTHH. Only the

first character of the separator is significant; any remaining characters are ignored. Only the scalar parameter may be assigned an initial value. Both the scalar and the array may otherwise be manipulated as normal. If one is unset, the other will automatically be unset too. There is no way of untying the variables without unsetting them, or converting the type of one

of them with another ttyyppeesseett command; ++TT does not work, assign-

ing an array to SCALAR is an error, and assigning a scalar to

array sets it to be a single-element array. Note that both

`ttyyppeesseett -xxTT ......' and `eexxppoorrtt -TT ......' work, but only the scalar

will be marked for export. Setting the value using the scalar version causes a split on all separators (which cannot be quoted).

The -gg (global) flag is treated specially: it means that any

resulting parameter will not be restricted to local scope. Note that this does not necessarily mean that the parameter will be global, as the flag will apply to any existing parameter (even if unset) from an enclosing function. This flag does not affect

the parameter after creation, hence it has no effect when list-

ing existing parameters, nor does the flag ++gg have any effect

except in combination with -mm (see below).

If no name is present, the names and values of all parameters

are printed. In this case the attribute flags restrict the dis-

play to only those parameters that have the specified

attributes, and using `++' rather than `-' to introduce the flag

suppresses printing of the values of parameters when there is no parameter name. Also, if the last option is the word `++', then names are printed but values are not.

If the -mm flag is given the name arguments are taken as patterns

(which should be quoted). With no attribute flags, all parame-

ters (or functions with the -ff flag) with matching names are

printed (the shell option TTYYPPEESSEETTSSIILLEENNTT is not used in this

case). Note that -mm is ignored if no patterns are given. If

the ++gg flag is combined with -mm, a new local parameter is cre-

ated for every matching parameter that is not already local.

Otherwise -mm applies all other flags or assignments to the

existing parameters. Except when assignments are made with name==value, using ++mm forces the matching parameters to be printed, even inside a function.

If no attribute flags are given and either no -mm flag is present

or the ++mm form was used, each parameter name printed is preceded

by a list of the attributes of that parameter (aarrrraayy, aassssoocciiaa-

ttiioonn, eexxppoorrtteedd, iinntteeggeerr, rreeaaddoonnllyy). If ++mm is used with attribute flags, and all those flags are introduced with ++, the matching parameter names are printed but their values are not. The following attribute flags may be specified:

-AA The names refer to associative array parameters; see

`Array Parameters' in zshparam(1).

-LL Left justify and remove leading blanks from value. If n

is nonzero, it defines the width of the field. If n is zero, the width is determined by the width of the value

of the first assignment. In the case of numeric parame-

ters, the length of the complete value assigned to the parameter is used to determine the width, not the value that would be output. When the parameter is expanded, it

is filled on the right with blanks or truncated if neces-

sary to fit the field. Note truncation can lead to unex-

pected results with numeric parameters. Leading zeros

are removed if the -ZZ flag is also set.

-RR Similar to -LL, except that right justification is used;

when the parameter is expanded, the field is left filled

with blanks or truncated from the end. May not be com-

bined with the -ZZ flag.

-UU For arrays (but not for associative arrays), keep only

the first occurrence of each duplicated value. This may

also be set for colon-separated special parameters like

PPAATTHH or FFIIGGNNOORREE, etc. This flag has a different meaning

when used with -ff; see below.

-ZZ Specially handled if set along with the -LL flag. Other-

wise, similar to -RR, except that leading zeros are used

for padding instead of blanks if the first non-blank

character is a digit. Numeric parameters are specially handled: they are always eligible for padding with zeroes, and the zeroes are inserted at an appropriate place in the output.

-aa The names refer to array parameters. An array parameter

may be created this way, but it may not be assigned to in the ttyyppeesseett statement. When displaying, both normal and associative arrays are shown.

-ff The names refer to functions rather than parameters. No

assignments can be made, and the only other valid flags

are -tt, -kk, -uu, -UU and -zz. The flag -tt turns on execu-

tion tracing for this function. The -uu and -UU flags

cause the function to be marked for autoloading; -UU also

causes alias expansion to be suppressed when the function is loaded. The ffppaatthh parameter will be searched to find

the function definition when the function is first refer-

enced; see the section `Functions'. The -kk and -zz flags

make the function be loaded using ksh-style or zsh-style

autoloading respectively. If neither is given, the set-

ting of the KSHAUTOLOAD option determines how the func-

tion is loaded.

-hh Hide: only useful for special parameters (those marked

`' in the table in zshparams(1)), and for local param-

eters with the same name as a special parameter, though harmless for others. A special parameter with this attribute will not retain its special effect when made

local. Thus after `ttyyppeesseett -hh PPAATTHH', a function contain-

ing `ttyyppeesseett PPAATTHH' will create an ordinary local parame-

ter without the usual behaviour of PPAATTHH. Alternatively, the local parameter may itself be given this attribute;

hence inside a function `ttyyppeesseett -hh PPAATTHH' creates an

ordinary local parameter and the special PPAATTHH parameter is not altered in any way. It is also possible to create a local parameter using `ttyyppeesseett ++hh special', where the local copy of special will retain its special properties

regardless of having the -hh attribute. Global special

parameters loaded from shell modules (currently those in zzsshh//mmaappffiillee and zzsshh//ppaarraammeetteerr) are automatically given

the -hh attribute to avoid name clashes.

-HH Hide value: specifies that ttyyppeesseett will not display the

value of the parameter when listing parameters; the dis-

play for such parameters is always as if the `++' flag had been given. Use of the parameter is in other respects normal, and the option does not apply if the parameter is

specified by name, or by pattern with the -mm option.

This is on by default for the parameters in the zzsshh//ppaarraammeetteerr and zzsshh//mmaappffiillee modules. Note, however,

that unlike the -hh flag this is also useful for non-spe-

cial parameters.

-ii Use an internal integer representation. If n is nonzero

it defines the output arithmetic base, otherwise it is determined by the first assignment.

-EE Use an internal double-precision floating point represen-

tation. On output the variable will be converted to sci-

entific notation. If n is nonzero it defines the number of significant figures to display; the default is ten.

-FF Use an internal double-precision floating point represen-

tation. On output the variable will be converted to

fixed-point decimal notation. If n is nonzero it defines

the number of digits to display after the decimal point; the default is ten.

-ll Convert the result to lower case whenever the parameter

is expanded. The value is not converted when assigned.

-rr The given names are marked readonly. Note that if name

is a special parameter, the readonly attribute can be turned on, but cannot then be turned off.

-tt Tags the named parameters. Tags have no special meaning

to the shell. This flag has a different meaning when

used with -ff; see above.

-uu Convert the result to upper case whenever the parameter

is expanded. The value is not converted when assigned.

This flag has a different meaning when used with -ff; see

above.

-xx Mark for automatic export to the environment of subse-

quently executed commands. If the option GGLLOOBBAALLEEXXPPOORRTT

is set, this implies the option -gg, unless ++gg is also

explicitly given; in other words the parameter is not

made local to the enclosing function. This is for com-

patibility with previous versions of zsh.

uulliimmiitt [ [ -SSHHaaccddffllmmnnppssttvv | -NN resource [ limit ] ... ]

Set or display resource limits of the shell and the processes started by the shell. The value of limit can be a number in the unit specified below or the value `uunnlliimmiitteedd'. By default, only

soft limits are manipulated. If the -HH flag is given use hard

limits instead of soft limits. If the -SS flag is given together

with the -HH flag set both hard and soft limits. If no options

are used, the file size limit (-ff) is assumed. If limit is

omitted the current value of the specified resources are printed. When more than one resource values are printed the limit name and unit is printed before each value.

When looping over multiple resources, the shell will abort imme-

diately if it detects a badly formed argument. However, if it

fails to set a limit for some other reson it will continue try-

ing to set the remaining limits.

-aa Lists all of the current resource limits.

-cc 512-byte blocks on the size of core dumps.

-dd K-bytes on the size of the data segment.

-ff 512-byte blocks on the size of files written.

-ll K-bytes on the size of locked-in memory.

-mm K-bytes on the size of physical memory.

-nn open file descriptors.

-ss K-bytes on the size of the stack.

-tt CPU seconds to be used.

-uu processes available to the user.

-vv K-bytes on the size of virtual memory. On some systems

this refers to the limit called `address space'.

A resource may also be specified by integer in the form `-NN

resource', where resource corresponds to the integer defined for the resource by the operating system. This may be used to set

the limits for resources known to the shell which do not corre-

spond to option letters. Such limits will be shown by number in

the output of `uulliimmiitt -aa'.

The number may alternatively be out of the range of limits com-

piled into the shell. The shell will try to read or write the limit anyway, and will report an error if this fails.

uummaasskk [ -SS ] [ mask ]

The umask is set to mask. mask can be either an octal number or a symbolic value as described in chmod(1). If mask is omitted,

the current value is printed. The -SS option causes the mask to

be printed as a symbolic value. Otherwise, the mask is printed

as an octal number. Note that in the symbolic form the permis-

sions you specify are those which are to be allowed (not denied) to the users specified. uunnaalliiaass

Same as uunnhhaasshh -aa.

uunnffuunnccttiioonn

Same as uunnhhaasshh -ff.

uunnhhaasshh [ -aaddffmmss ] name ...

Remove the element named name from an internal hash table. The

default is remove elements from the command hash table. The -aa

option causes uunnhhaasshh to remove regular or global aliases. The

-ss option causes uunnhhaasshh to remove suffix aliases. The -ff option

causes uunnhhaasshh to remove shell functions. The -dd options causes

uunnhhaasshh to remove named directories. If the -mm flag is given the

arguments are taken as patterns (should be quoted) and all ele-

ments of the corresponding hash table with matching names will be removed.

uunnlliimmiitt [ -hhss ] resource ...

The resource limit for each resource is set to the hard limit.

If the -hh flag is given and the shell has appropriate privi-

leges, the hard resource limit for each resource is removed.

The resources of the shell process are only changed if the -ss

flag is given.

uunnsseett [ -ffmmvv ] name ...

Each named parameter is unset. Local parameters remain local even if unset; they appear unset within scope, but the previous value will still reappear when the scope ends. Individual elements of associative array parameters may be unset by using subscript syntax on name, which should be quoted (or

the entire command prefixed with nnoogglloobb) to protect the sub-

script from filename generation.

If the -mm flag is specified the arguments are taken as patterns

(should be quoted) and all parameters with matching names are unset. Note that this cannot be used when unsetting associative array elements, as the subscript will be treated as part of the pattern.

The -vv flag specifies that name refers to parameters. This is

the default behaviour.

uunnsseett -ff is equivalent to uunnffuunnccttiioonn.

uunnsseettoopptt [ {++|-}options | {++|-}oo optionname ] [ name ... ]

Unset the options for the shell. All options specified either with flags or by name are unset. If no arguments are supplied,

the names of all options currently unset are printed. If the -mm

flag is given the arguments are taken as patterns (which should

be quoted to preserve them from being interpreted as glob pat-

terns), and all options with names matching these patterns are unset. vvaarreedd See the section `Zle Builtins' in zshzle(1). wwaaiitt [ job ... ] Wait for the specified jobs or processes. If job is not given then all currently active child processes are waited for. Each job can be either a job specification or the process ID of a job in the job table. The exit status from this command is that of the job waited for.

wwhheennccee [ -vvccwwffppaammss ] name ...

For each name, indicate how it would be interpreted if used as a command name.

-vv Produce a more verbose report.

-cc Print the results in a ccsshh-like format. This takes

precedence over -vv.

-ww For each name, print `name:: word' where word is one of

aalliiaass, bbuuiillttiinn, ccoommmmaanndd, ffuunnccttiioonn, hhaasshheedd, rreesseerrvveedd or nnoonnee, according as name corresponds to an alias, a

built-in command, an external command, a shell function,

a command defined with the hhaasshh builtin, a reserved word,

or is not recognised. This takes precedence over -vv and

-cc.

-ff Causes the contents of a shell function to be displayed,

which would otherwise not happen unless the -cc flag were

used.

-pp Do a path search for name even if it is an alias,

reserved word, shell function or builtin.

-aa Do a search for all occurrences of name throughout the

command path. Normally only the first occurrence is printed.

-mm The arguments are taken as patterns (should be quoted),

and the information is displayed for each command match-

ing one of these patterns.

-ss If a pathname contains symlinks, print the symlink-free

pathname as well.

wwhheerree [ -wwppmmss ] name ...

Equivalent to wwhheennccee -ccaa.

wwhhiicchh [ -wwppaammss ] name ...

Equivalent to wwhheennccee -cc.

zzccoommppiillee [ -UU ] [ -zz | -kk ] [ -RR | -MM ] file [ name ... ]

zzccoommppiillee -ccaa [ -mm ] [ -RR | -MM ] file [ name ... ]

zzccoommppiillee -tt file [ name ... ]

This builtin command can be used to compile functions or scripts, storing the compiled form in a file, and to examine files containing the compiled form. This allows faster autoloading of functions and execution of scripts by avoiding parsing of the text when the files are read.

The first form (without the -cc, -aa or -tt options) creates a com-

piled file. If only the file argument is given, the output file has the name `file..zzwwcc' and will be placed in the same directory as the file. The shell will load the compiled file instead of the normal function file when the function is autoloaded; see

the section `Autoloading Functions' in zshfunc(1) for a descrip-

tion of how autoloaded functions are searched. The extension ..zzwwcc stands for `zsh word code'. If there is at least one name argument, all the named files are compiled into the output file given as the first argument. If file does not end in ..zzwwcc, this extension is automatically appended. Files containing multiple compiled functions are called `digest' files, and are intended to be used as elements of the FFPPAATTHH/ffppaatthh special array.

The second form, with the -cc or -aa options, writes the compiled

definitions for all the named functions into file. For -cc, the

names must be functions currently defined in the shell, not those marked for autoloading. Undefined functions that are

marked for autoloading may be written by using the -aa option, in

which case the ffppaatthh is searched and the contents of the defini-

tion files for those functions, if found, are compiled into

file. If both -cc and -aa are given, names of both defined func-

tions and functions marked for autoloading may be given. In

either case, the functions in files written with the -cc or -aa

option will be autoloaded as if the KKSSHHAAUUTTOOLLOOAADD option were unset.

The reason for handling loaded and not-yet-loaded functions with

different options is that some definition files for autoloading define multiple functions, including the function with the same name as the file, and, at the end, call that function. In such

cases the output of `zzccoommppiillee -cc' does not include the addi-

tional functions defined in the file, and any other initializa-

tion code in the file is lost. Using `zzccoommppiillee -aa' captures all

this extra information.

If the -mm option is combined with -cc or -aa, the names are used

as patterns and all functions whose names match one of these patterns will be written. If no name is given, the definitions of all functions currently defined or marked as autoloaded will be written.

The third form, with the -tt option, examines an existing com-

piled file. Without further arguments, the names of the origi-

nal files compiled into it are listed. The first line of output shows the version of the shell which compiled the file and how the file will be used (i.e. by reading it directly or by mapping it into memory). With arguments, nothing is output and the return value is set to zero if definitions for all names were

found in the compiled file, and non-zero if the definition for

at least one name was not found. Other options:

-UU Aliases are not expanded when compiling the named files.

-RR When the compiled file is read, its contents are copied

into the shell's memory, rather than memory-mapped (see

-MM). This happens automatically on systems that do not

support memory mapping. When compiling scripts instead of autoloadable functions, it is often desirable to use this option; otherwise the whole file, including the code to define functions which

have already been defined, will remain mapped, conse-

quently wasting memory.

-MM The compiled file is mapped into the shell's memory when

read. This is done in such a way that multiple instances of the shell running on the same host will share this

mapped file. If neither -RR nor -MM is given, the zzccoommppiillee

builtin decides what to do based on the size of the com-

piled file.

-kk

-zz These options are used when the compiled file contains

functions which are to be autoloaded. If -zz is given, the

function will be autoloaded as if the KKSSHHAAUUTTOOLLOOAADD option is not set, even if it is set at the time the compiled

file is read, while if the -kk is given, the function will

be loaded as if KKSSHHAAUUTTOOLLOOAADD is set. These options also

take precedence over any -kk or -zz options specified to

the aauuttoollooaadd builtin. If neither of these options is given, the function will be loaded as determined by the

setting of the KKSSHHAAUUTTOOLLOOAADD option at the time the com-

piled file is read. These options may also appear as many times as necessary between the listed names to specify the loading style of

all following functions, up to the next -kk or -zz.

The created file always contains two versions of the com-

piled format, one for big-endian machines and one for

small-endian machines. The upshot of this is that the

compiled file is machine independent and if it is read or mapped, only one half of the file is actually used (and mapped). zzffoorrmmaatt See the section `The zsh/zutil Module' in zshmodules(1). zzffttpp See the section `The zsh/zftp Module' in zshmodules(1). zzllee See the section `Zle Builtins' in zshzle(1).

zzmmooddllooaadd [ -ddLL ] [ ... ]

zzmmooddllooaadd -ee [ -AA ] [ ... ]

zzmmooddllooaadd [ -aa [ -bbccppff [ -II ] ] ] [ -iiLL ] ...

zzmmooddllooaadd -uu [ -aabbccddppff [ -II ] ] [ -iiLL ] ...

zzmmooddllooaadd -AA [ -LL ] [ modalias[==module] ... ]

zzmmooddllooaadd -RR modalias ...

Performs operations relating to zsh's loadable modules. Loading of modules while the shell is running (`dynamical loading') is not available on all operating systems, or on all installations on a particular operating system, although the zzmmooddllooaadd command itself is always available and can be used to manipulate modules built into versions of the shell executable without dynamical loading.

Without arguments the names of all currently loaded binary mod-

ules are printed. The -LL option causes this list to be in the

form of a series of zzmmooddllooaadd commands. Forms with arguments are:

zzmmooddllooaadd [ -ii ] name ...

zzmmooddllooaadd -uu [ -ii ] name ...

In the simplest case, zzmmooddllooaadd loads a binary module. The module must be in a file with a name consisting of the specified name followed by a standard suffix, usually `..ssoo' (`..ssll' on HPUX). If the module to be loaded is

already loaded and the -ii option is given, the duplicate

module is ignored. Otherwise zzmmooddllooaadd prints an error message.

The named module is searched for in the same way a com-

mand is, using $$mmoodduulleeppaatthh instead of $$ppaatthh. However,

the path search is performed even when the module name contains a `//', which it usually does. There is no way to prevent the path search.

With -uu, zzmmooddllooaadd unloads modules. The same name must be

given that was given when the module was loaded, but it

is not necessary for the module to exist in the filesys-

tem. The -ii option suppresses the error if the module is

already unloaded (or was never loaded).

Each module has a boot and a cleanup function. The mod-

ule will not be loaded if its boot function fails. Simi-

larly a module can only be unloaded if its cleanup func-

tion runs successfully.

zzmmooddllooaadd -dd [ -LL ] [ name ]

zzmmooddllooaadd -dd name dep ...

zzmmooddllooaadd -uudd name [ dep ... ]

The -dd option can be used to specify module dependencies.

The modules named in the second and subsequent arguments

will be loaded before the module named in the first argu-

ment.

With -dd and one argument, all dependencies for that mod-

ule are listed. With -dd and no arguments, all module

dependencies are listed. This listing is by default in a

Makefile-like format. The -LL option changes this format

to a list of zzmmooddllooaadd -dd commands.

If -dd and -uu are both used, dependencies are removed. If

only one argument is given, all dependencies for that module are removed.

zzmmooddllooaadd -aabb [ -LL ]

zzmmooddllooaadd -aabb [ -ii ] name [ builtin ... ]

zzmmooddllooaadd -uubb [ -ii ] builtin ...

The -aabb option defines autoloaded builtins. It defines

the specified builtins. When any of those builtins is called, the module specified in the first argument is loaded. If only the name is given, one builtin is

defined, with the same name as the module. -ii suppresses

the error if the builtin is already defined or autoloaded, regardless of which module it came from.

With -aabb and no arguments, all autoloaded builtins are

listed, with the module name (if different) shown in

parentheses after the builtin name. The -LL option

changes this format to a list of zzmmooddllooaadd -aa commands.

If -bb is used together with the -uu option, it removes

builtins previously defined with -aabb. This is only pos-

sible if the builtin is not yet loaded. -ii suppresses

the error if the builtin is already removed (or never existed).

zzmmooddllooaadd -aacc [ -IILL ]

zzmmooddllooaadd -aacc [ -iiII ] name [ cond ... ]

zzmmooddllooaadd -uucc [ -iiII ] cond ...

The -aacc option is used to define autoloaded condition

codes. The cond strings give the names of the conditions

defined by the module. The optional -II option is used to

define infix condition names. Without this option prefix condition names are defined. If given no condition names, all defined names are listed

(as a series of zzmmooddllooaadd commands if the -LL option is

given).

The -uucc option removes definitions for autoloaded condi-

tions.

zzmmooddllooaadd -aapp [ -LL ]

zzmmooddllooaadd -aapp [ -ii ] name [ parameter ... ]

zzmmooddllooaadd -uupp [ -ii ] parameter ...

The -pp option is like the -bb and -cc options, but makes

zzmmooddllooaadd work on autoloaded parameters instead.

zzmmooddllooaadd -aaff [ -LL ]

zzmmooddllooaadd -aaff [ -ii ] name [ function ... ]

zzmmooddllooaadd -uuff [ -ii ] function ...

The -ff option is like the -bb, -pp, and -cc options, but

makes zzmmooddllooaadd work on autoloaded math functions instead.

zzmmooddllooaadd -aa [ -LL ]

zzmmooddllooaadd -aa [ -ii ] name [ builtin ... ]

zzmmooddllooaadd -uuaa [ -ii ] builtin ...

Equivalent to -aabb and -uubb.

zzmmooddllooaadd -ee [ -AA ] [ string ... ]

The -ee option without arguments lists all loaded modules;

if the -AA option is also given, module aliases corre-

sponding to loaded modules are also shown. With argu-

ments only the return status is set to zero if all strings given as arguments are names of loaded modules and to one if at least on string is not the name of a

loaded module. This can be used to test for the avail-

ability of things implemented by modules. In this case,

any aliases are automatically resolved and the -AA flag is

not used.

zzmmooddllooaadd -AA [ -LL ] [ modalias[==module] ... ]

For each argument, if both modalias and module are given, define modalias to be an alias for the module module. If the module modalias is ever subsequently requested, either via a call to zzmmooddllooaadd or implicitly, the shell will attempt to load module instead. If module is not given, show the definition of modalias. If no arguments

are given, list all defined module aliases. When list-

ing, if the -LL flag was also given, list the definition

as a zzmmooddllooaadd command to recreate the alias.

The existence of aliases for modules is completely inde-

pendent of whether the name resolved is actually loaded

as a module: while the alias exists, loading and unload-

ing the module under any alias has exactly the same effect as using the resolved name, and does not affect the connection between the alias and the resolved name

which can be removed either by zzmmooddllooaadd -RR or by redefin-

ing the alias. Chains of aliases (i.e. where the first resolved name is itself an alias) are valid so long as these are not circular. As the aliases take the same format as module names, they may include path separators: in this case, there is no requirement for any part of the path named to exist as the alias will be resolved first. For example, `aannyy//oolldd//aalliiaass' is always a valid alias. Dependencies added to aliased modules are actually added to the resolved module; these remain if the alias is removed. It is valid to create an alias whose name is one of the standard shell modules and which resolves to a different module. However, if a module has dependencies, it will not be possible to use the module name as an alias as the module will already be marked as a loadable module in its own right. Apart from the above, aliases can be used in the zzmmooddllooaadd command anywhere module names are required. However, aliases will not be shown in lists of loaded modules with a bare `zzmmooddllooaadd'.

zzmmooddllooaadd -RR modalias ...

For each modalias argument that was previously defined as

a module alias via zzmmooddllooaadd -AA, delete the alias. If any

was not defined, an error is caused and the remainder of the line is ignored. Note that zzsshh makes no distinction between modules that were linked into the shell and modules that are loaded dynamically.

In both cases this builtin command has to be used to make avail-

able the builtins and other things defined by modules (unless the module is autoloaded on these definitions). This is true even for systems that don't support dynamic loading of modules. zzppaarrsseeooppttss See the section `The zsh/zutil Module' in zshmodules(1). zzpprrooff See the section `The zsh/zprof Module' in zshmodules(1). zzppttyy See the section `The zsh/zpty Module' in zshmodules(1). zzrreeggeexxppaarrssee See the section `The zsh/zutil Module' in zshmodules(1). zzssoocckkeett See the section `The zsh/net/socket Module' in zshmodules(1). zzssttyyllee See the section `The zsh/zutil Module' in zshmodules(1). zzttccpp See the section `The zsh/net/tcp Module' in zshmodules(1). ZSHZLE(1) ZSHZLE(1)

NAME

zshzle - zsh command line editor

DESCRIPTION

If the ZZLLEE option is set (which it is by default in interactive shells) and the shell input is attached to the terminal, the user is able to edit command lines. There are two display modes. The first, multiline mode, is the

default. It only works if the TTEERRMM parameter is set to a valid termi-

nal type that can move the cursor up. The second, single line mode, is used if TTEERRMM is invalid or incapable of moving the cursor up, or if the SSIINNGGLLEELLIINNEEZZLLEE option is set. This mode is similar to kksshh, and uses no termcap sequences. If TTEERRMM is "emacs", the ZZLLEE option will be unset by default.

The parameters BBAAUUDD, CCOOLLUUMMNNSS, and LLIINNEESS are also used by the line edi-

tor. See Parameters Used By The Shell in zshparam(1). KKEEYYMMAAPPSS A keymap in ZLE contains a set of bindings between key sequences and ZLE commands. The empty key sequence cannot be bound. There can be any number of keymaps at any time, and each keymap has one or more names. If all of a keymap's names are deleted, it disappears. bbiinnddkkeeyy can be used to manipulate keymap names. Initially, there are four keymaps: eemmaaccss EMACS emulation

vviiiinnss vi emulation - insert mode

vviiccmmdd vi emulation - command mode

..ssaaffee fallback keymap The `..ssaaffee' keymap is special. It can never be altered, and the name can never be removed. However, it can be linked to other names, which can be removed. In the future other special keymaps may be added; users should avoid using names beginning with `..' for their own keymaps. In addition to these four names, either `eemmaaccss' or `vviiiinnss' is also linked to the name `mmaaiinn'. If one of the VVIISSUUAALL or EEDDIITTOORR environment variables contain the string `vvii' when the shell starts up then it will

be `vviiiinnss', otherwise it will be `eemmaaccss'. bbiinnddkkeeyy's -ee and -vv options

provide a convenient way to override this default choice. When the editor starts up, it will select the `mmaaiinn' keymap. If that keymap doesn't exist, it will use `..ssaaffee' instead.

In the `..ssaaffee' keymap, each single key is bound to sseellff-iinnsseerrtt, except

for ^J (line feed) and ^M (return) which are bound to aacccceepptt-lliinnee.

This is deliberately not pleasant to use; if you are using it, it means you deleted the main keymap, and you should put it back. RReeaaddiinngg CCoommmmaannddss When ZLE is reading a command from the terminal, it may read a sequence that is bound to some command and is also a prefix of a longer bound

string. In this case ZLE will wait a certain time to see if more char-

acters are typed, and if not (or they don't match any longer string) it will execute the binding. This timeout is defined by the KKEEYYTTIIMMEEOOUUTT parameter; its default is 0.4 sec. There is no timeout if the prefix string is not itself bound to a command. As well as ZLE commands, key sequences can be bound to other strings,

by using `bbiinnddkkeeyy -ss'. When such a sequence is read, the replacement

string is pushed back as input, and the command reading process starts

again using these fake keystrokes. This input can itself invoke fur-

ther replacement strings, but in order to detect loops the process will be stopped if there are twenty such replacements without a real command being read. ZZLLEE BBUUIILLTTIINNSS The ZLE module contains three related builtin commands. The bbiinnddkkeeyy command manipulates keymaps and key bindings; the vvaarreedd command invokes ZLE on the value of a shell parameter; and the zzllee command manipulates editing widgets and allows command line access to ZLE commands from within shell functions.

bbiinnddkkeeyy [ options ] -ll

bbiinnddkkeeyy [ options ] -dd

bbiinnddkkeeyy [ options ] -DD keymap ...

bbiinnddkkeeyy [ options ] -AA old-keymap new-keymap

bbiinnddkkeeyy [ options ] -NN new-keymap [ old-keymap ]

bbiinnddkkeeyy [ options ] -mm

bbiinnddkkeeyy [ options ] -rr in-string ...

bbiinnddkkeeyy [ options ] -ss in-string out-string ...

bbiinnddkkeeyy [ options ] in-string command ...

bbiinnddkkeeyy [ options ] [ in-string ]

bbiinnddkkeeyy's options can be divided into three categories: keymap

selection, operation selection, and others. The keymap selec-

tion options are:

-ee Selects keymap `eemmaaccss', and also links it to `mmaaiinn'.

-vv Selects keymap `vviiiinnss', and also links it to `mmaaiinn'.

-aa Selects keymap `vviiccmmdd'.

-MM keymap

The keymap specifies a keymap name. If a keymap selection is required and none of the options above are used, the `mmaaiinn' keymap is used. Some operations do not permit a keymap to be selected, namely:

-ll List all existing keymap names. If the -LL option is also

used, list in the form of bbiinnddkkeeyy commands to create the keymaps.

-dd Delete all existing keymaps and reset to the default

state.

-DD keymap ...

Delete the named keymaps.

-AA old-keymap new-keymap

Make the new-keymap name an alias for old-keymap, so that

both names refer to the same keymap. The names have equal standing; if either is deleted, the other remains.

If there is already a keymap with the new-keymap name, it

is deleted.

-NN new-keymap [ old-keymap ]

Create a new keymap, named new-keymap. If a keymap

already has that name, it is deleted. If an old-keymap

name is given, the new keymap is initialized to be a duplicate of it, otherwise the new keymap will be empty. To use a newly created keymap, it should be linked to mmaaiinn. Hence the sequence of commands to create and use a new keymap `mmyymmaapp' initialized from the eemmaaccss keymap (which remains unchanged) is:

bbiinnddkkeeyy -NN mmyymmaapp eemmaaccss

bbiinnddkkeeyy -AA mmyymmaapp mmaaiinn

Note that while `bbiinnddkkeeyy -AA newmap mmaaiinn' will work when newmap

is eemmaaccss or vviiiinnss, it will not work for vviiccmmdd, as switching from vi insert to command mode becomes impossible. The following operations act on the `mmaaiinn' keymap if no keymap selection option was given:

-mm Add the built-in set of meta-key bindings to the selected

keymap. Only keys that are unbound or bound to

sseellff-iinnsseerrtt are affected.

-rr in-string ...

Unbind the specified in-strings in the selected keymap.

This is exactly equivalent to binding the strings to

uunnddeeffiinneedd-kkeeyy.

When -RR is also used, interpret the in-strings as ranges.

When -pp is also used, the in-strings specify prefixes.

Any binding that has the given in-string as a prefix, not

including the binding for the in-string itself, if any,

will be removed. For example,

bbiinnddkkeeyy -rrppMM vviiiinnss ''^^[[''

will remove all bindings in the vi-insert keymap begin-

ning with an escape character (probably cursor keys), but

leave the binding for the escape character itself (proba-

bly vvii-ccmmdd-mmooddee). This is incompatible with the option

-RR.

-ss in-string out-string ...

Bind each in-string to each out-string. When in-string

is typed, out-string will be pushed back and treated as

input to the line editor. When -RR is also used, inter-

pret the in-strings as ranges.

in-string command ...

Bind each in-string to each command. When -RR is used,

interpret the in-strings as ranges.

[ in-string ]

List key bindings. If an in-string is specified, the

binding of that string in the selected keymap is dis-

played. Otherwise, all key bindings in the selected

keymap are displayed. (As a special case, if the -ee or

-vv option is used alone, the keymap is not displayed -

the implicit linking of keymaps is the only thing that happens.)

When the option -pp is used, the in-string must be

present. The listing shows all bindings which have the

given key sequence as a prefix, not including any bind-

ings for the key sequence itself.

When the -LL option is used, the list is in the form of

bbiinnddkkeeyy commands to create the key bindings.

When the -RR option is used as noted above, a valid range consists of

two characters, with an optional `-' between them. All characters

between the two specified, inclusive, are bound as specified.

For either in-string or out-string, the following escape sequences are

recognised: \\aa bell character \\bb backspace \\ee, \\EE escape \\ff form feed \\nn linefeed (newline) \\rr carriage return \\tt horizontal tab \\vv vertical tab \\NNN character code in octal \\xxNN character code in hexadecimal

\\MM[-]X character with meta bit set

\\CC[-]X control character

^^X control character In all other cases, `\\' escapes the following character. Delete is written as `^^??'. Note that `\\MM^^??' and `^^\\MM??' are not the same, and

that (unlike emacs), the bindings `\\MM-X' and `\\eeX' are entirely dis-

tinct, although they are initialized to the same bindings by `bbiinnddkkeeyy

-mm'.

vvaarreedd [ -AAaacchhee ] [ -pp prompt ] [ -rr rprompt ]

[ -M main-keymap ] [ -m vicmd-keymap ] name

The value of the parameter name is loaded into the edit buffer, and the line editor is invoked. When the editor exits, name is

set to the string value returned by the editor. When the -cc

flag is given, the parameter is created if it doesn't already

exist. The -aa flag may be given with -cc to create an array

parameter, or the -AA flag to create an associative array. If

the type of an existing parameter does not match the type to be created, the parameter is unset and recreated. If an array or array slice is being edited, separator characters

as defined in $$IIFFSS will be shown quoted with a backslash, as

will backslashes themselves. Conversely, when the edited text

is split into an array, a backslash quotes an immediately fol-

lowing separator character or backslash; no other special han-

dling of backslashes, or any handling of quotes, is performed. Individual elements of existing array or associative array parameters may be edited by using subscript syntax on name. New

elements are created automatically, even without -cc.

If the -pp flag is given, the following string will be taken as

the prompt to display at the left. If the -rr flag is given, the

following string gives the prompt to display at the right. If

the -hh flag is specified, the history can be accessed from ZLE.

If the -ee flag is given, typing ^^DD (Control-D) on an empty line

causes vvaarreedd to exit immediately with a non-zero return value.

The -MM option gives a keymap to link to the mmaaiinn keymap during

editing, and the -mm option gives a keymap to link to the vviiccmmdd

keymap during editing. For vi-style editing, this allows a pair

of keymaps to override vviiiinnss and vviiccmmdd. For emacs-style edit-

ing, only -MM is normally needed but the -mm option may still be

used. On exit, the previous keymaps will be restored. zzllee

zzllee -ll [ -LL | -aa ] [ string ... ]

zzllee -DD widget ...

zzllee -AA old-widget new-widget

zzllee -NN widget [ function ]

zzllee -CC widget completion-widget function

zzllee -RR [ -cc ] [ display-string ] [ string ... ]

zzllee -MM string

zzllee -UU string

zzllee -KK keymap

zzllee -FF [ -LL ] [ fd [ handler ] ]

zzllee -II

zzllee widget [[ -nn num ]] [[ -NN ]] args ...

The zzllee builtin performs a number of different actions concern-

ing ZLE. With no options and no arguments, only the return status will be set. It is zero if ZLE is currently active and widgets could be

invoked using this builtin command and non-zero otherwise. Note

that even if non-zero status is returned, zle may still be

active as part of the completion system; this does not allow direct calls to ZLE widgets. Otherwise, which operation it performs depends on its options:

-ll [ -LL | -aa ]

List all existing user-defined widgets. If the -LL option

is used, list in the form of zzllee commands to create the widgets.

When combined with the -aa option, all widget names are

listed, including the builtin ones. In this case the -LL

option is ignored. If at least one string is given, nothing will be printed but the return status will be zero if all strings are

names of existing widgets (or of user-defined widgets if

the -aa flag is not given) and non-zero if at least one

string is not a name of an defined widget.

-DD widget ...

Delete the named widgets.

-AA old-widget new-widget

Make the new-widget name an alias for old-widget, so that

both names refer to the same widget. The names have equal standing; if either is deleted, the other remains.

If there is already a widget with the new-widget name, it

is deleted.

-NN widget [ function ]

Create a user-defined widget. If there is already a wid-

get with the specified name, it is overwritten. When the

new widget is invoked from within the editor, the speci-

fied shell function is called. If no function name is specified, it defaults to the same name as the widget.

For further information, see the section Widgets in zsh-

zle(1).

-CC widget completion-widget function

Create a user-defined completion widget named widget. The

completion widget will behave like the built-in comple-

tion-widget whose name is given as completion-widget. To

generate the completions, the shell function function

will be called. For further information, see zshcomp-

wid(1).

-RR [ -cc ] [ display-string ] [ string ... ]

Redisplay the command line; this is to be called from

within a user-defined widget to allow changes to become

visible. If a display-string is given and not empty,

this is shown in the status line (immediately below the line being edited). If the optional strings are given they are listed below the prompt in the same way as completion lists are

printed. If no strings are given but the -cc option is

used such a list is cleared. Note that this option is only useful for widgets that do not exit immediately after using it because the strings displayed will be erased immediately after return from the widget. This command can safely be called outside user defined widgets; if zle is active, the display will be refreshed, while if zle is not active, the command has no effect. In this case there will usually be no other arguments. The status is zero if zle was active, else one.

-MM string

As with the -RR option, the string will be displayed below

the command line; unlike the -RR option, the string will

not be put into the status line but will instead be printed normally below the prompt. This means that the string will still be displayed after the widget returns (until it is overwritten by subsequent commands).

-UU string

This pushes the characters in the string onto the input

stack of ZLE. After the widget currently executed fin-

ishes ZLE will behave as if the characters in the string were typed by the user. As ZLE uses a stack, if this option is used repeatedly the last string pushed onto the stack will be processed first. However, the characters in each string will be processed in the order in which they appear in the string.

-KK keymap

Selects the keymap named keymap. An error message will be displayed if there is no such keymap.

This keymap selection affects the interpretation of fol-

lowing keystrokes within this invocation of ZLE. Any following invocation (e.g., the next command line) will start as usual with the `mmaaiinn' keymap selected.

-FF [ -LL ] [ fd [ handler ] ]

Only available if your system supports one of the `poll' or `select' system calls; most modern systems do. Installs handler (the name of a shell function) to handle input from file descriptor fd. When zle is attempting to read data, it will examine both the terminal and the list of handled fd's. If data becomes available on a handled fd, zle will call handler with the fd which is ready for reading as the only argument. If the handler produces

output to the terminal, it should call `zzllee -II' before

doing so (see below). The handler should not attempt to read from the terminal. Note that zle makes no attempt to check whether this fd is actually readable when installing the handler. The user must make their own arrangements for handling the file descriptor when zle is not active. Any number of handlers for any number of readable file descriptors may be installed. Installing a handler for

an fd which is already handled causes the existing han-

dler to be replaced. If no handler is given, but an fd is present, any handler

for that fd is removed. If there is none, an error mes-

sage is printed and status 1 is returned.

If no arguments are given, or the -LL option is supplied,

a list of handlers is printed in a form which can be stored for later execution. An fd (but not a handler) may optionally be given with

the -LL option; in this case, the function will list the

handler if any, else silently return status 1.

Note that this feature should be used with care. Activ-

ity on one of the fd's which is not properly handled can cause the terminal to become unusable.

Here is a simple example of using this feature. A con-

nection to a remote TCP port is created using the ztcp command; see the description of the zzsshh//nneett//ttccpp module in zshmodules(1). Then a handler is installed which simply prints out any data which arrives on this connection. Note that `select' will indicate that the file descriptor

needs handling if the remote side has closed the connec-

tion; we handle that by testing for a failed read. iiff zzttccpp ppwwssppcc 22881111;; tthheenn

ttccppffdd==$$RREEPPLLYY

hhaannddlleerr(()) {{

zzllee -II

llooccaall lliinnee

iiff !! rreeaadd -rr lliinnee <<&&$$11;; tthheenn

## sseelleecctt mmaarrkkss tthhiiss ffdd iiff wwee rreeaacchh EEOOFF,,

## ssoo hhaannddllee tthhiiss ssppeecciiaallllyy..

pprriinntt ""[[RReeaadd oonn ffdd $$11 ffaaiilleedd,, rreemmoovviinngg..]]"" >>&&22

zzllee -FF $$11

rreettuurrnn 11 ffii

pprriinntt -rr - $$lliinnee

}}

zzllee -FF $$ttccppffdd hhaannddlleerr

ffii

-II Unusually, this option is most useful outside ordinary

widget functions, though it may be used within if normal output to the terminal is required. It invalidates the current zle display in preparation for output; typically this will be from a trap function. It has no effect if zle is not active. When a trap exits, the shell checks

to see if the display needs restoring, hence the follow-

ing will print output in such a way as not to disturb the line being edited: TTRRAAPPUUSSRR11(()) {{

## IInnvvaalliiddaattee zzllee ddiissppllaayy

[[[[ -oo zzllee ]]]] &&&& zzllee -II

## SShhooww oouuttppuutt

pprriinntt HHeelllloo }} In general, the trap function may need to test whether zle is active before using this method (as shown in the example), since the zzsshh//zzllee module may not even be loaded; if it is not, the command can be skipped.

It is possible to call `zzllee -II' several times before con-

trol is returned to the editor; the display will only be invalidated the first time to minimise disruption. Note that there are normally better ways of manipulating the display from within zle widgets; see, for example,

`zzllee -RR' above.

The returned status is zero if zle was invalidated, even

though this may have been by a previous call to `zzllee -II'

or by a system notification. To test if a zle widget may be called at this point, execute zzllee with no arguments and examine the return status.

widget [[ -nn num ]] [[ -NN ]] args ...

Invoke the specified widget. This can only be done when ZLE is active; normally this will be within a

user-defined widget.

With the options -nn and -NN, the current numerical argu-

ment will be saved and then restored after the call to

wwiiddggeett; `-nn num' sets the numerical argument temporarily

to num, while `-NN' sets it to the default, i.e. as if

there were none. Any further arguments will be passed to the widget. If

it is a shell function, these are passed down as posi-

tional parameters; for builtin widgets it is up to the widget in question what it does with them. Currently

arguments are only handled by the incremental-search com-

mands, the hhiissttoorryy-sseeaarrcchh-ffoorrwwaarrdd and -bbaacckkwwaarrdd and the

corresponding functions prefixed by vvii-, and by uunniivveerr-

ssaall-aarrgguummeenntt. No error is flagged if the command does

not use the arguments, or only uses some of them. The return status reflects the success or failure of the operation carried out by the widget, or if it is a

user-defined widget the return status of the shell func-

tion.

A non-zero return status causes the shell to beep when

the widget exits, unless the BBEEEEPP options was unset or the widget was called via the zzllee command. Thus if a user defined widget requires an immediate beep, it should call the bbeeeepp widget directly. WWIIDDGGEETTSS All actions in the editor are performed by `widgets'. A widget's job is simply to perform some small action. The ZLE commands that key sequences in keymaps are bound to are in fact widgets. Widgets can be

user-defined or built in.

The standard widgets built in to ZLE are listed in Standard Widgets

below. Other built-in widgets can be defined by other modules (see

zshmodules(1)). Each built-in widget has two names: its normal canoni-

cal name, and the same name preceded by a `..'. The `..' name is spe-

cial: it can't be rebound to a different widget. This makes the widget available even when its usual name has been redefined.

User-defined widgets are defined using `zzllee -NN', and implemented as

shell functions. When the widget is executed, the corresponding shell function is executed, and can perform editing (or other) actions. It

is recommended that user-defined widgets should not have names starting

with `..'.

UUSSEERR-DDEEFFIINNEEDD WWIIDDGGEETTSS

User-defined widgets, being implemented as shell functions, can execute

any normal shell command. They can also run other widgets (whether

built-in or user-defined) using the zzllee builtin command. The standard

input of the function is closed to prevent external commands from unin-

tentionally blocking ZLE by reading from the terminal, but rreeaadd -kk or

rreeaadd -qq can be used to read characters. Finally, they can examine and

edit the ZLE buffer being edited by reading and setting the special parameters described below. These special parameters are always available in widget functions, but are not in any way special outside ZLE. If they have some normal value outside ZLE, that value is temporarily inaccessible, but will return when the widget function exits. These special parameters in fact have local scope, like parameters created in a function using llooccaall. Inside completion widgets and traps called while ZLE is active, these

parameters are available read-only.

BBUUFFFFEERR (scalar) The entire contents of the edit buffer. If it is written to, the cursor remains at the same offset, unless that would put it outside the buffer. BBUUFFFFEERRLLIINNEESS (integer) The number of screen lines needed for the edit buffer currently displayed on screen (i.e. without any changes to the preceding

parameters done after the last redisplay); read-only.

CCOONNTTEEXXTT (scalar)

The context in which zle was called to read a line; read-only.

One of the values: start The start of a command line (at prompt PPSS11). cont A continuation to a command line (at prompt PPSS22). select In a sseelleecctt loop. vared Editing a variable in vvaarreedd. CCUURRSSOORR (integer) The offset of the cursor, within the edit buffer. This is in

the range 0 to $$##BBUUFFFFEERR, and is by definition equal to

$$##LLBBUUFFFFEERR. Attempts to move the cursor outside the buffer will

result in the cursor being moved to the appropriate end of the buffer. CCUUTTBBUUFFFFEERR (scalar)

The last item to be cut using one of the `kkiillll-' commands; the

string which the next yank would insert in the line. HHIISSTTNNOO (integer) The current history number. Setting this has the same effect as moving up or down in the history to the corresponding history line. An attempt to set it is ignored if the line is not stored in the history. Note this is not the same as the parameter HHIISSTTCCMMDD, which always gives the number of the history line being added to the main shell's history. HHIISSTTNNOO refers to the line being retrieved within zle. KKEEYYMMAAPP (scalar)

The name of the currently selected keymap; read-only.

KKEEYYSS (scalar) The keys typed to invoke this widget, as a literal string;

read-only.

kkiillllrriinngg (array) The array of previously killed items, with the most recently killed first. This gives the items that would be retrieved by a

yyaannkk-ppoopp in the same order.

The default size for the kill ring is eight, however the length may be changed by normal array operations. Any empty string in

the kill ring is ignored by the yyaannkk-ppoopp command, hence the size

of the array effectively sets the maximum length of the kill

ring, while the number of non-zero strings gives the current

length, both as seen by the user at the command line. LLAASSTTSSEEAARRCCHH (scalar) The last search string used by an interactive search ;

read-only.

LLAASSTTWWIIDDGGEETT (scalar)

The name of the last widget that was executed; read-only.

LLBBUUFFFFEERR (scalar)

The part of the buffer that lies to the left of the cursor posi-

tion. If it is assigned to, only that part of the buffer is

replaced, and the cursor remains between the new $$LLBBUUFFFFEERR and

the old $$RRBBUUFFFFEERR.

MMAARRKK (integer) Like CCUURRSSOORR, but for the mark. NNUUMMEERRIICC (integer) The numeric argument. If no numeric argument was given, this parameter is unset. When this is set inside a widget function, builtin widgets called with the zzllee builtin command will use the value assigned. If it is unset inside a widget function, builtin widgets called behave as if no numeric argument was given. PPEENNDDIINNGG (integer) The number of bytes pending for input, i.e. the number of bytes which have already been typed and can immediately be read. On systems where the shell is not able to get this information,

this parameter will always have a value of zero. Read-only.

PPRREEBBUUFFFFEERR (scalar)

In a multi-line input at the secondary prompt, this read-only

parameter contains the contents of the lines before the one the cursor is currently in. PPRREEDDIISSPPLLAAYY (scalar) Text to be displayed before the start of the editable text buffer. This does not have to be a complete line; to display a complete line, a newline must be appended explicitly. The

text is reset on each new invocation (but not recursive invoca-

tion) of zle. PPOOSSTTDDIISSPPLLAAYY (scalar) Text to be displayed after the end of the editable text buffer. This does not have to be a complete line; to display a complete line, a newline must be prepended explicitly. The text is reset on each new invocation (but not recursive invocation) of zle. RRBBUUFFFFEERR (scalar) The part of the buffer that lies to the right of the cursor position. If it is assigned to, only that part of the buffer is

replaced, and the cursor remains between the old $$LLBBUUFFFFEERR and

the new $$RRBBUUFFFFEERR.

WWIIDDGGEETT (scalar)

The name of the widget currently being executed; read-only.

WWIIDDGGEETTFFUUNNCC (scalar) The name of the shell function that implements a widget defined

with either zzllee -NN or zzllee -CC. In the former case, this is the

second argument to the zzllee -NN command that defined the widget,

or the first argument if there was no second argument. In the

latter case this is the the third argument to the zzllee -CC command

that defined the widget. Read-only.

WWIIDDGGEETTSSTTYYLLEE (scalar)

Describes the implementation behind the completion widget cur-

rently being executed; the second argument that followed zzllee -CC

when the widget was defined. This is the name of a builtin com-

pletion widget. For widgets defined with zzllee -NN this is set to

the empty string. Read-only.

SSppeecciiaall WWiiddggeett

There is one user-defined widget which is special to the shell. If it

does not exist, no special action is taken. The environment provided is identical to that for any other editing widget.

zzllee-lliinnee-iinniitt

Executed every time the line editor is started to read a new line of input. The following example puts the line editor into vi command mode when it starts up.

zzllee-lliinnee-iinniitt(()) {{ zzllee -KK vviiccmmdd;; }}

zzllee -NN zzllee-lliinnee-iinniitt

(The command inside the function sets the keymap directly; it is

equivalent to zzllee vvii-ccmmdd-mmooddee.)

SSTTAANNDDAARRDD WWIIDDGGEETTSS The following is a list of all the standard widgets, and their default bindings in emacs mode, vi command mode and vi insert mode (the `eemmaaccss', `vviiccmmdd' and `vviiiinnss' keymaps, respectively). Note that cursor keys are bound to movement keys in all three keymaps; the shell assumes that the cursor keys send the key sequences reported

by the terminal-handling library (termcap or terminfo). The key

sequences shown in the list are those based on the VT100, common on many modern terminals, but in fact these are not necessarily bound. In the case of the vviiiinnss keymap, the initial escape character of the

sequences serves also to return to the vviiccmmdd keymap: whether this hap-

pens is determined by the KKEEYYTTIIMMEEOOUUTT parameter, see zshparam(1). MMoovveemmeenntt

vvii-bbaacckkwwaarrdd-bbllaannkk-wwoorrdd (unbound) (B) (unbound)

Move backward one word, where a word is defined as a series of

non-blank characters.

bbaacckkwwaarrdd-cchhaarr (^B ESC-[D) (unbound) (unbound)

Move backward one character.

vvii-bbaacckkwwaarrdd-cchhaarr (unbound) (^H h ^?) (ESC-[D)

Move backward one character, without changing lines.

bbaacckkwwaarrdd-wwoorrdd (ESC-B ESC-b) (unbound) (unbound)

Move to the beginning of the previous word.

eemmaaccss-bbaacckkwwaarrdd-wwoorrdd

Move to the beginning of the previous word.

vvii-bbaacckkwwaarrdd-wwoorrdd (unbound) (b) (unbound)

Move to the beginning of the previous word, vi-style.

bbeeggiinnnniinngg-ooff-lliinnee (^A) (unbound) (unbound)

Move to the beginning of the line. If already at the beginning of the line, move to the beginning of the previous line, if any.

vvii-bbeeggiinnnniinngg-ooff-lliinnee

Move to the beginning of the line, without changing lines.

eenndd-ooff-lliinnee (^E) (unbound) (unbound)

Move to the end of the line. If already at the end of the line, move to the end of the next line, if any.

vvii-eenndd-ooff-lliinnee (unbound) ($) (unbound)

Move to the end of the line. If an argument is given to this

command, the cursor will be moved to the end of the line (argu-

ment - 1) lines down.

vvii-ffoorrwwaarrdd-bbllaannkk-wwoorrdd (unbound) (W) (unbound)

Move forward one word, where a word is defined as a series of

non-blank characters.

vvii-ffoorrwwaarrdd-bbllaannkk-wwoorrdd-eenndd (unbound) (E) (unbound)

Move to the end of the current word, or, if at the end of the current word, to the end of the next word, where a word is

defined as a series of non-blank characters.

ffoorrwwaarrdd-cchhaarr (^F ESC-[C) (unbound) (unbound)

Move forward one character.

vvii-ffoorrwwaarrdd-cchhaarr (unbound) (space l) (ESC-[C)

Move forward one character.

vvii-ffiinndd-nneexxtt-cchhaarr (^X^F) (f) (unbound)

Read a character from the keyboard, and move to the next occur-

rence of it in the line.

vvii-ffiinndd-nneexxtt-cchhaarr-sskkiipp (unbound) (t) (unbound)

Read a character from the keyboard, and move to the position just before the next occurrence of it in the line.

vvii-ffiinndd-pprreevv-cchhaarr (unbound) (F) (unbound)

Read a character from the keyboard, and move to the previous occurrence of it in the line.

vvii-ffiinndd-pprreevv-cchhaarr-sskkiipp (unbound) (T) (unbound)

Read a character from the keyboard, and move to the position just after the previous occurrence of it in the line.

vvii-ffiirrsstt-nnoonn-bbllaannkk (unbound) (^) (unbound)

Move to the first non-blank character in the line.

vvii-ffoorrwwaarrdd-wwoorrdd (unbound) (w) (unbound)

Move forward one word, vi-style.

ffoorrwwaarrdd-wwoorrdd (ESC-F ESC-f) (unbound) (unbound)

Move to the beginning of the next word. The editor's idea of a word is specified with the WWOORRDDCCHHAARRSS parameter.

eemmaaccss-ffoorrwwaarrdd-wwoorrdd

Move to the end of the next word.

vvii-ffoorrwwaarrdd-wwoorrdd-eenndd (unbound) (e) (unbound)

Move to the end of the next word.

vvii-ggoottoo-ccoolluummnn (ESC-|) (|) (unbound)

Move to the column specified by the numeric argument.

vvii-ggoottoo-mmaarrkk (unbound) (`) (unbound)

Move to the specified mark.

vvii-ggoottoo-mmaarrkk-lliinnee (unbound) (') (unbound)

Move to beginning of the line containing the specified mark.

vvii-rreeppeeaatt-ffiinndd (unbound) (;) (unbound)

Repeat the last vvii-ffiinndd command.

vvii-rreevv-rreeppeeaatt-ffiinndd (unbound) (,) (unbound)

Repeat the last vvii-ffiinndd command in the opposite direction.

HHiissttoorryy CCoonnttrrooll

bbeeggiinnnniinngg-ooff-bbuuffffeerr-oorr-hhiissttoorryy (ESC-<) (unbound) (unbound)

Move to the beginning of the buffer, or if already there, move to the first event in the history list.

bbeeggiinnnniinngg-ooff-lliinnee-hhiisstt

Move to the beginning of the line. If already at the beginning of the buffer, move to the previous history line.

bbeeggiinnnniinngg-ooff-hhiissttoorryy

Move to the first event in the history list.

ddoowwnn-lliinnee-oorr-hhiissttoorryy (^N ESC-[B) (j) (ESC-[B)

Move down a line in the buffer, or if already at the bottom line, move to the next event in the history list.

vvii-ddoowwnn-lliinnee-oorr-hhiissttoorryy (unbound) (+) (unbound)

Move down a line in the buffer, or if already at the bottom line, move to the next event in the history list. Then move to

the first non-blank character on the line.

ddoowwnn-lliinnee-oorr-sseeaarrcchh

Move down a line in the buffer, or if already at the bottom line, search forward in the history for a line beginning with the first word in the buffer. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

ddoowwnn-hhiissttoorryy (unbound) (^N) (unbound)

Move to the next event in the history list.

hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-bbaacckkwwaarrdd

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

eenndd-ooff-bbuuffffeerr-oorr-hhiissttoorryy (ESC->) (unbound) (unbound)

Move to the end of the buffer, or if already there, move to the last event in the history list.

eenndd-ooff-lliinnee-hhiisstt

Move to the end of the line. If already at the end of the buffer, move to the next history line.

eenndd-ooff-hhiissttoorryy

Move to the last event in the history list.

vvii-ffeettcchh-hhiissttoorryy (unbound) (G) (unbound)

Fetch the history line specified by the numeric argument. This defaults to the current history line (i.e. the one that isn't history yet).

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd (^R ^Xr) (unbound) (unbound)

Search backward incrementally for a specified string. The

search is case-insensitive if the search string does not have

uppercase letters and no numeric argument was given. The string may begin with `^^' to anchor the search to the beginning of the line. A restricted set of editing functions is available in the

mini-buffer. An interrupt signal, as defined by the stty set-

ting, will stop the search and go back to the original line. An undefined key will have the same effect. The supported functions

are: bbaacckkwwaarrdd-ddeelleettee-cchhaarr, vvii-bbaacckkwwaarrdd-ddeelleettee-cchhaarr,

cclleeaarr-ssccrreeeenn, rreeddiissppllaayy, qquuootteedd-iinnsseerrtt, vvii-qquuootteedd-iinnsseerrtt,

aacccceepptt-aanndd-hhoolldd, aacccceepptt-aanndd-iinnffeerr-nneexxtt-hhiissttoorryy, aacccceepptt-lliinnee and

aacccceepptt-lliinnee-aanndd-ddoowwnn-hhiissttoorryy.

mmaaggiicc-ssppaaccee just inserts a space. vvii-ccmmdd-mmooddee toggles between

the `mmaaiinn' and `vviiccmmdd' keymaps; the `mmaaiinn' keymap (insert mode)

will be selected initially. hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd

will get the next occurrence of the contents of the mini-buffer.

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-ffoorrwwaarrdd inverts the sense of the

search. vvii-rreeppeeaatt-sseeaarrcchh and vvii-rreevv-rreeppeeaatt-sseeaarrcchh are similarly

supported. The direction of the search is indicated in the

mini-buffer.

Any multi-character string that is not bound to one of the above

functions will beep and interrupt the search, leaving the last found line in the buffer. Any single character that is not bound

to one of the above functions, or sseellff-iinnsseerrtt or

sseellff-iinnsseerrtt-uunnmmeettaa, will have the same effect but the function

will be executed. When called from a widget function by the zzllee command, the incremental search commands can take a string argument. This will be treated as a string of keys, as for arguments to the bbiinnddkkeeyy command, and used as initial input for the command. Any characters in the string which are unused by the incremental search will be silently ignored. For example,

zzllee hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd ffoorrcceeppss

will search backwards for ffoorrcceeppss, leaving the minibuffer con-

taining the string `ffoorrcceeppss'.

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-ffoorrwwaarrdd (^S ^Xs) (unbound) (unbound)

Search forward incrementally for a specified string. The search

is case-insensitive if the search string does not have uppercase

letters and no numeric argument was given. The string may begin with `^^' to anchor the search to the beginning of the line. The

functions available in the mini-buffer are the same as for hhiiss-

ttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd.

hhiissttoorryy-sseeaarrcchh-bbaacckkwwaarrdd (ESC-P ESC-p) (unbound) (unbound)

Search backward in the history for a line beginning with the first word in the buffer. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

vvii-hhiissttoorryy-sseeaarrcchh-bbaacckkwwaarrdd (unbound) (/) (unbound)

Search backward in the history for a specified string. The string may begin with `^^' to anchor the search to the beginning of the line. A restricted set of editing functions is available in the

mini-buffer. An interrupt signal, as defined by the stty set-

ting, will stop the search. The functions available in the

mini-buffer are: aacccceepptt-lliinnee, bbaacckkwwaarrdd-ddeelleettee-cchhaarr, vvii-bbaacckk-

wwaarrdd-ddeelleettee-cchhaarr, bbaacckkwwaarrdd-kkiillll-wwoorrdd, vvii-bbaacckkwwaarrdd-kkiillll-wwoorrdd,

cclleeaarr-ssccrreeeenn, rreeddiissppllaayy, qquuootteedd-iinnsseerrtt and vvii-qquuootteedd-iinnsseerrtt.

vvii-ccmmdd-mmooddee is treated the same as accept-line, and mmaaggiicc-ssppaaccee

is treated as a space. Any other character that is not bound to

self-insert or self-insert-unmeta will beep and be ignored. If

the function is called from vi command mode, the bindings of the current insert mode will be used. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

hhiissttoorryy-sseeaarrcchh-ffoorrwwaarrdd (ESC-N ESC-n) (unbound) (unbound)

Search forward in the history for a line beginning with the first word in the buffer. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

vvii-hhiissttoorryy-sseeaarrcchh-ffoorrwwaarrdd (unbound) (?) (unbound)

Search forward in the history for a specified string. The string may begin with `^^' to anchor the search to the beginning

of the line. The functions available in the mini-buffer are the

same as for vvii-hhiissttoorryy-sseeaarrcchh-bbaacckkwwaarrdd. Argument handling is

also the same as for that command.

iinnffeerr-nneexxtt-hhiissttoorryy (^X^N) (unbound) (unbound)

Search in the history list for a line matching the current one and fetch the event following it.

iinnsseerrtt-llaasstt-wwoorrdd (ESC- ESC-.) (unbound) (unbound)

Insert the last word from the previous history event at the cur-

sor position. If a positive numeric argument is given, insert that word from the end of the previous history event. If the argument is zero or negative insert that word from the left

(zero inserts the previous command word). Repeating this com-

mand replaces the word just inserted with the last word from the history event prior to the one just used; numeric arguments can be used in the same way to pick a word from that event.

When called from a shell function invoked from a user-defined

widget, the command can take one to three arguments. The first argument specifies a history offset which applies to successive

calls to this widget: if is -1, the default behaviour is used,

while if it is 1, successive calls will move forwards through

the history. The value 0 can be used to indicate that the his-

tory line examined by the previous execution of the command will be reexamined. Note that negative numbers should be preceded

with a `--' argument to avoid confusing them with options.

If two arguments are given, the second specifies the word on the command line in normal array index notation (as a more natural alternative to the prefix argument). Hence 1 is the first word,

and -1 (the default) is the last word.

If a third argument is given, its value is ignored, but it is

used to signify that the history offset is relative to the cur-

rent history line, rather than the one remembered after the pre-

vious invocations of iinnsseerrtt-llaasstt-wwoorrdd.

For example, the default behaviour of the command corresponds to

zzllee iinnsseerrtt-llaasstt-wwoorrdd -- -11 -11

while the command

zzllee iinnsseerrtt-llaasstt-wwoorrdd -- -11 11 -

always copies the first word of the line in the history immedi-

ately before the line being edited. This has the side effect that later invocations of the widget will be relative to that line.

vvii-rreeppeeaatt-sseeaarrcchh (unbound) (n) (unbound)

Repeat the last vi history search.

vvii-rreevv-rreeppeeaatt-sseeaarrcchh (unbound) (N) (unbound)

Repeat the last vi history search, but in reverse.

uupp-lliinnee-oorr-hhiissttoorryy (^P ESC-[A) (k) (ESC-[A)

Move up a line in the buffer, or if already at the top line, move to the previous event in the history list.

vvii-uupp-lliinnee-oorr-hhiissttoorryy (unbound) (-) (unbound)

Move up a line in the buffer, or if already at the top line, move to the previous event in the history list. Then move to

the first non-blank character on the line.

uupp-lliinnee-oorr-sseeaarrcchh

Move up a line in the buffer, or if already at the top line, search backward in the history for a line beginning with the first word in the buffer. If called from a function by the zzllee command with arguments, the first argument is taken as the string for which to search, rather than the first word in the buffer.

uupp-hhiissttoorryy (unbound) (^P) (unbound)

Move to the previous event in the history list.

hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-ffoorrwwaarrdd

Search forward in the history for a line beginning with the cur-

rent line up to the cursor. This leaves the cursor in its orig-

inal position. MMooddiiffyyiinngg TTeexxtt

vvii-aadddd-eeooll (unbound) (A) (unbound)

Move to the end of the line and enter insert mode.

vvii-aadddd-nneexxtt (unbound) (a) (unbound)

Enter insert mode after the current cursor position, without changing lines.

bbaacckkwwaarrdd-ddeelleettee-cchhaarr (^H ^?) (unbound) (unbound)

Delete the character behind the cursor.

vvii-bbaacckkwwaarrdd-ddeelleettee-cchhaarr (unbound) (X) (^H)

Delete the character behind the cursor, without changing lines. If in insert mode, this won't delete past the point where insert mode was last entered.

bbaacckkwwaarrdd-ddeelleettee-wwoorrdd

Delete the word behind the cursor.

bbaacckkwwaarrdd-kkiillll-lliinnee

Kill from the beginning of the line to the cursor position.

bbaacckkwwaarrdd-kkiillll-wwoorrdd (^W ESC-^H ESC-^?) (unbound) (unbound)

Kill the word behind the cursor.

vvii-bbaacckkwwaarrdd-kkiillll-wwoorrdd (unbound) (unbound) (^W)

Kill the word behind the cursor, without going past the point where insert mode was last entered.

ccaappiittaalliizzee-wwoorrdd (ESC-C ESC-c) (unbound) (unbound)

Capitalize the current word and move past it.

vvii-cchhaannggee (unbound) (c) (unbound)

Read a movement command from the keyboard, and kill from the cursor position to the endpoint of the movement. Then enter

insert mode. If the command is vvii-cchhaannggee, change the current

line.

vvii-cchhaannggee-eeooll (unbound) (C) (unbound)

Kill to the end of the line and enter insert mode.

vvii-cchhaannggee-wwhhoollee-lliinnee (unbound) (S) (unbound)

Kill the current line and enter insert mode.

ccooppyy-rreeggiioonn-aass-kkiillll (ESC-W ESC-w) (unbound) (unbound)

Copy the area from the cursor to the mark to the kill buffer.

ccooppyy-pprreevv-wwoorrdd (ESC-^) (unbound) (unbound)

Duplicate the word to the left of the cursor.

ccooppyy-pprreevv-sshheellll-wwoorrdd

Like ccooppyy-pprreevv-wwoorrdd, but the word is found by using shell pars-

ing, whereas ccooppyy-pprreevv-wwoorrdd looks for blanks. This makes a dif-

ference when the word is quoted and contains spaces.

vvii-ddeelleettee (unbound) (d) (unbound)

Read a movement command from the keyboard, and kill from the cursor position to the endpoint of the movement. If the command

is vvii-ddeelleettee, kill the current line.

ddeelleettee-cchhaarr

Delete the character under the cursor.

vvii-ddeelleettee-cchhaarr (unbound) (x) (unbound)

Delete the character under the cursor, without going past the end of the line.

ddeelleettee-wwoorrdd

Delete the current word.

ddoowwnn-ccaassee-wwoorrdd (ESC-L ESC-l) (unbound) (unbound)

Convert the current word to all lowercase and move past it.

kkiillll-wwoorrdd (ESC-D ESC-d) (unbound) (unbound)

Kill the current word.

ggoossmmaaccss-ttrraannssppoossee-cchhaarrss

Exchange the two characters behind the cursor.

vvii-iinnddeenntt (unbound) (>) (unbound)

Indent a number of lines.

vvii-iinnsseerrtt (unbound) (i) (unbound)

Enter insert mode.

vvii-iinnsseerrtt-bbooll (unbound) (I) (unbound)

Move to the first non-blank character on the line and enter

insert mode.

vvii-jjooiinn (^X^J) (J) (unbound)

Join the current line with the next one.

kkiillll-lliinnee (^K) (unbound) (unbound)

Kill from the cursor to the end of the line. If already on the end of the line, kill the newline character.

vvii-kkiillll-lliinnee (unbound) (unbound) (^U)

Kill from the cursor back to wherever insert mode was last entered.

vvii-kkiillll-eeooll (unbound) (D) (unbound)

Kill from the cursor to the end of the line.

kkiillll-rreeggiioonn

Kill from the cursor to the mark.

kkiillll-bbuuffffeerr (^X^K) (unbound) (unbound)

Kill the entire buffer.

kkiillll-wwhhoollee-lliinnee (^U) (unbound) (unbound)

Kill the current line.

vvii-mmaattcchh-bbrraacckkeett (^X^B) (%) (unbound)

Move to the bracket character (one of {{}}, (()) or [[]]) that matches the one under the cursor. If the cursor is not on a bracket character, move forward without going past the end of the line to find one, and then go to the matching bracket.

vvii-ooppeenn-lliinnee-aabboovvee (unbound) (O) (unbound)

Open a line above the cursor and enter insert mode.

vvii-ooppeenn-lliinnee-bbeellooww (unbound) (o) (unbound)

Open a line below the cursor and enter insert mode.

vvii-ooppeerr-sswwaapp-ccaassee

Read a movement command from the keyboard, and swap the case of all characters from the cursor position to the endpoint of the

movement. If the movement command is vvii-ooppeerr-sswwaapp-ccaassee, swap

the case of all characters on the current line.

oovveerrwwrriittee-mmooddee (^X^O) (unbound) (unbound)

Toggle between overwrite mode and insert mode.

vvii-ppuutt-bbeeffoorree (unbound) (P) (unbound)

Insert the contents of the kill buffer before the cursor. If the kill buffer contains a sequence of lines (as opposed to characters), paste it above the current line.

vvii-ppuutt-aafftteerr (unbound) (p) (unbound)

Insert the contents of the kill buffer after the cursor. If the

kill buffer contains a sequence of lines (as opposed to charac-

ters), paste it below the current line.

qquuootteedd-iinnsseerrtt (^V) (unbound) (unbound)

Insert the next character typed into the buffer literally. An interrupt character will not be inserted.

vvii-qquuootteedd-iinnsseerrtt (unbound) (unbound) (^Q ^V)

Display a `^^' at the cursor position, and insert the next char-

acter typed into the buffer literally. An interrupt character will not be inserted.

qquuoottee-lliinnee (ESC-') (unbound) (unbound)

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

qquuoottee-rreeggiioonn (ESC-") (unbound) (unbound)

Quote the region from the cursor to the mark.

vvii-rreeppllaaccee (unbound) (R) (unbound)

Enter overwrite mode.

vvii-rreeppeeaatt-cchhaannggee (unbound) (.) (unbound)

Repeat the last vi mode text modification. If a count was used with the modification, it is remembered. If a count is given to

this command, it overrides the remembered count, and is remem-

bered for future uses of this command. The cut buffer specifi-

cation is similarly remembered.

vvii-rreeppllaaccee-cchhaarrss (unbound) (r) (unbound)

Replace the character under the cursor with a character read from the keyboard.

sseellff-iinnsseerrtt (printable characters) (unbound) (printable characters and

some control characters) Insert a character into the buffer at the cursor position.

sseellff-iinnsseerrtt-uunnmmeettaa (ESC-^I ESC-^J ESC-^M) (unbound) (unbound)

Insert a character into the buffer after stripping the meta bit and converting ^M to ^J.

vvii-ssuubbssttiittuuttee (unbound) (s) (unbound)

Substitute the next character(s).

vvii-sswwaapp-ccaassee (unbound) (~) (unbound)

Swap the case of the character under the cursor and move past it.

ttrraannssppoossee-cchhaarrss (^T) (unbound) (unbound)

Exchange the two characters to the left of the cursor if at end of line, else exchange the character under the cursor with the character to the left.

ttrraannssppoossee-wwoorrddss (ESC-T ESC-t) (unbound) (unbound)

Exchange the current word with the one before it.

vvii-uunniinnddeenntt (unbound) (<) (unbound)

Unindent a number of lines.

uupp-ccaassee-wwoorrdd (ESC-U ESC-u) (unbound) (unbound)

Convert the current word to all caps and move past it. yyaannkk (^Y) (unbound) (unbound) Insert the contents of the kill buffer at the cursor position.

yyaannkk-ppoopp (ESC-y) (unbound) (unbound)

Remove the text just yanked, rotate the kill-ring, and yank the

new top. Only works following yyaannkk or yyaannkk-ppoopp.

vvii-yyaannkk (unbound) (y) (unbound)

Read a movement command from the keyboard, and copy the region from the cursor position to the endpoint of the movement into

the kill buffer. If the command is vvii-yyaannkk, copy the current

line.

vvii-yyaannkk-wwhhoollee-lliinnee (unbound) (Y) (unbound)

Copy the current line into the kill buffer.

vvii-yyaannkk-eeooll

Copy the region from the cursor position to the end of the line into the kill buffer. Arguably, this is what Y should do in vi, but it isn't what it actually does. AArrgguummeennttss

ddiiggiitt-aarrgguummeenntt (ESC-0..ESC-9) (1-9) (unbound)

Start a new numeric argument, or add to the current one. See

also vvii-ddiiggiitt-oorr-bbeeggiinnnniinngg-ooff-lliinnee. This only works if bound to

a key sequence ending in a decimal digit. Inside a widget function, a call to this function treats the last key of the key sequence which called the widget as the digit.

nneegg-aarrgguummeenntt (ESC-) (unbound) (unbound)

Changes the sign of the following argument.

uunniivveerrssaall-aarrgguummeenntt

Multiply the argument of the next command by 4. Alternatively,

if this command is followed by an integer (positive or nega-

tive), use that as the argument for the next command. Thus dig-

its cannot be repeated using this command. For example, if this

command occurs twice, followed immediately by ffoorrwwaarrdd-cchhaarr, move

forward sixteen spaces; if instead it is followed by -22, then

ffoorrwwaarrdd-cchhaarr, move backward two spaces.

Inside a widget function, if passed an argument, i.e. `zzllee uunnii-

vveerrssaall-aarrgguummeenntt num', the numerical argument will be set to num;

this is equivalent to `NNUUMMEERRIICC==num'. CCoommpplleettiioonn

aacccceepptt-aanndd-mmeennuu-ccoommpplleettee

In a menu completion, insert the current completion into the buffer, and advance to the next possible completion.

ccoommpplleettee-wwoorrdd

Attempt completion on the current word.

ddeelleettee-cchhaarr-oorr-lliisstt (^D) (unbound) (unbound)

Delete the character under the cursor. If the cursor is at the end of the line, list possible completions for the current word.

eexxppaanndd-ccmmdd-ppaatthh

Expand the current command to its full pathname.

eexxppaanndd-oorr-ccoommpplleettee (TAB) (unbound) (TAB)

Attempt shell expansion on the current word. If that fails, attempt completion.

eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx

Attempt shell expansion on the current word up to cursor.

eexxppaanndd-hhiissttoorryy (ESC-space ESC-!) (unbound) (unbound)

Perform history expansion on the edit buffer.

eexxppaanndd-wwoorrdd (^X*) (unbound) (unbound)

Attempt shell expansion on the current word.

lliisstt-cchhooiicceess (ESC-^D) (^D =) (^D)

List possible completions for the current word.

lliisstt-eexxppaanndd (^Xg ^XG) (^G) (^G)

List the expansion of the current word.

mmaaggiicc-ssppaaccee

Perform history expansion and insert a space into the buffer. This is intended to be bound to space.

mmeennuu-ccoommpplleettee

Like ccoommpplleettee-wwoorrdd, except that menu completion is used. See

the MMEENNUUCCOOMMPPLLEETTEE option.

mmeennuu-eexxppaanndd-oorr-ccoommpplleettee

Like eexxppaanndd-oorr-ccoommpplleettee, except that menu completion is used.

rreevveerrssee-mmeennuu-ccoommpplleettee

Perform menu completion, like mmeennuu-ccoommpplleettee, except that if a

menu completion is already in progress, move to the previous completion rather than the next.

eenndd-ooff-lliisstt

When a previous completion displayed a list below the prompt, this widget can be used to move the prompt below the list. MMiisscceellllaanneeoouuss

aacccceepptt-aanndd-hhoolldd (ESC-A ESC-a) (unbound) (unbound)

Push the contents of the buffer on the buffer stack and execute it.

aacccceepptt-aanndd-iinnffeerr-nneexxtt-hhiissttoorryy

Execute the contents of the buffer. Then search the history

list for a line matching the current one and push the event fol-

lowing onto the buffer stack.

aacccceepptt-lliinnee (^J ^M) (^J ^M) (^J ^M)

Finish editing the buffer. Normally this causes the buffer to be executed as a shell command.

aacccceepptt-lliinnee-aanndd-ddoowwnn-hhiissttoorryy (^O) (unbound) (unbound)

Execute the current line, and push the next history event on the the buffer stack. bbeeeepp Beep, unless the BBEEEEPP option is unset.

vvii-ccmmdd-mmooddee (^X^V) (unbound) (^[)

Enter command mode; that is, select the `vviiccmmdd' keymap. Yes, this is bound by default in emacs mode.

vvii-ccaappss-lloocckk-ppaanniicc

Hang until any lowercase key is pressed. This is for vi users without the mental capacity to keep track of their caps lock key (like the author).

cclleeaarr-ssccrreeeenn (^L ESC-^L) (^L) (^L)

Clear the screen and redraw the prompt.

ddeessccrriibbee-kkeeyy-bbrriieeffllyy

Reads a key sequence, then prints the function bound to that sequence.

eexxcchhaannggee-ppooiinntt-aanndd-mmaarrkk (^X^X) (unbound) (unbound)

Exchange the cursor position with the position of the mark.

eexxeeccuuttee-nnaammeedd-ccmmdd (ESC-x) (unbound) (unbound)

Read the name of an editor command and execute it. A restricted

set of editing functions is available in the mini-buffer. An

interrupt signal, as defined by the stty setting, will abort the

function. The allowed functions are: bbaacckkwwaarrdd-ddeelleettee-cchhaarr,

vvii-bbaacckkwwaarrdd-ddeelleettee-cchhaarr, cclleeaarr-ssccrreeeenn, rreeddiissppllaayy, qquuootteedd-iinnsseerrtt,

vvii-qquuootteedd-iinnsseerrtt, bbaacckkwwaarrdd-kkiillll-wwoorrdd, vvii-bbaacckkwwaarrdd-kkiillll-wwoorrdd,

kkiillll-wwhhoollee-lliinnee, vvii-kkiillll-lliinnee, bbaacckkwwaarrdd-kkiillll-lliinnee, lliisstt-cchhooiicceess,

ddeelleettee-cchhaarr-oorr-lliisstt, ccoommpplleettee-wwoorrdd, aacccceepptt-lliinnee, eexxppaanndd-oorr-ccoomm-

pplleettee and eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx.

kkiillll-rreeggiioonn kills the last word, and vi-cmd-mode is treated the

same as accept-line. The space and tab characters, if not bound

to one of these functions, will complete the name and then list the possibilities if the AAUUTTOOLLIISSTT option is set. Any other

character that is not bound to sseellff-iinnsseerrtt or sseellff-iinnsseerrtt-uunnmmeettaa

will beep and be ignored. The bindings of the current insert mode will be used.

eexxeeccuuttee-llaasstt-nnaammeedd-ccmmdd (ESC-z) (unbound) (unbound)

Redo the last function executed with eexxeeccuuttee-nnaammeedd-ccmmdd.

ggeett-lliinnee (ESC-G ESC-g) (unbound) (unbound)

Pop the top line off the buffer stack and insert it at the cur-

sor position.

ppoouunndd-iinnsseerrtt (unbound) (#) (unbound)

If there is no # character at the beginning of the buffer, add

one to the beginning of each line. If there is one, remove a #

from each line that has one. In either case, accept the current line. The IINNTTEERRAACCTTIIVVEECCOOMMMMEENNTTSS option must be set for this to have any usefulness.

vvii-ppoouunndd-iinnsseerrtt

If there is no # character at the beginning of the current line,

add one. If there is one, remove it. The IINNTTEERRAACCTTIIVVEECCOOMMMMEENNTTSS option must be set for this to have any usefulness.

ppuusshh-iinnppuutt

Push the entire current multiline construct onto the buffer

stack and return to the top-level (PPSS11) prompt. If the current

parser construct is only a single line, this is exactly like

ppuusshh-lliinnee. Next time the editor starts up or is popped with

ggeett-lliinnee, the construct will be popped off the top of the buffer

stack and loaded into the editing buffer.

ppuusshh-lliinnee (^Q ESC-Q ESC-q) (unbound) (unbound)

Push the current buffer onto the buffer stack and clear the buffer. Next time the editor starts up, the buffer will be

popped off the top of the buffer stack and loaded into the edit-

ing buffer.

ppuusshh-lliinnee-oorr-eeddiitt

At the top-level (PPSS11) prompt, equivalent to ppuusshh-lliinnee. At a

secondary (PPSS22) prompt, move the entire current multiline con-

struct into the editor buffer. The latter is equivalent to

ppuusshh-iinnppuutt followed by ggeett-lliinnee.

rreeccuurrssiivvee-eeddiitt

Only useful from a user-defined widget. At this point in the

function, the editor regains control until one of the standard widgets which would normally cause zle to exit (typically an

aacccceepptt-lliinnee caused by hitting the return key) is executed.

Instead, control returns to the user-defined widget. The status

returned is non-zero if the return was caused by an error, but

the function still continues executing and hence may tidy up.

This makes it safe for the user-defined widget to alter the com-

mand line or key bindings temporarily.

The following widget, ccaappss-lloocckk, serves as an example.

sseellff-iinnsseerrtt-uuccaassee(()) {{

LLBBUUFFFFEERR++==$${{((UU))KKEEYYSS[[-11]]}}

}} integer stat

zle -N self-insert self-insert-ucase

zle -A caps-lock save-caps-lock

zle -A accept-line caps-lock

zle recursive-edit

stat=$?

zle -A .self-insert self-insert

zle -A save-caps-lock caps-lock

zle -D save-caps-lock

(( stat )) && zle send-break

return $stat

This causes typed letters to be inserted capitalised until

either aacccceepptt-lliinnee (i.e. typically the return key) is typed or

the ccaappss-lloocckk widget is invoked again; the later is handled by

saving the old definition of ccaappss-lloocckk as ssaavvee-ccaappss-lloocckk and

then rebinding it to invoke aacccceepptt-lliinnee. Note that an error

from the recursive edit is detected as a non-zero return status

and propagated by using the sseenndd-bbrreeaakk widget.

rreeddiissppllaayy (unbound) (^R) (^R) Redisplays the edit buffer.

rreesseett-pprroommpptt (unbound) (unbound) (unbound)

Force the prompts on both the left and right of the screen to be

re-expanded, then redisplay the edit buffer. This reflects

changes both to the prompt variables themselves and changes in the expansion of the values (for example, changes in time or directory, or changes to the value of variables referred to by the prompt). Otherwise, the prompt is only expanded each time zle starts, and when the display as been interrupted by output from another part

of the shell (such as a job notification) which causes the com-

mand line to be reprinted.

sseenndd-bbrreeaakk (^G ESC-^G) (unbound) (unbound)

Abort the current editor function, e.g. eexxeeccuuttee-nnaammeedd-ccoommmmaanndd,

or the editor itself, e.g. if you are in vvaarreedd. Otherwise abort the parsing of the current line.

rruunn-hheellpp (ESC-H ESC-h) (unbound) (unbound)

Push the buffer onto the buffer stack, and execute the command

`rruunn-hheellpp cmd', where cmd is the current command. rruunn-hheellpp is

normally aliased to mmaann.

vvii-sseett-bbuuffffeerr (unbound) (") (unbound)

Specify a buffer to be used in the following command. There are 35 buffers that can be specified: the 26 `named' buffers ""aa to ""zz and the nine `queued' buffers ""11 to ""99. The named buffers can also be specified as ""AA to ""ZZ. When a buffer is specified for a cut command, the text being cut replaces the previous contents of the specified buffer. If a named buffer is specified using a capital, the newly cut text is appended to the buffer instead of overwriting it. If no buffer is specified for a cut command, ""11 is used, and the

contents of ""11 to ""88 are each shifted along one buffer; the con-

tents of ""99 is lost.

vvii-sseett-mmaarrkk (unbound) (m) (unbound)

Set the specified mark at the cursor position.

sseett-mmaarrkk-ccoommmmaanndd (^@) (unbound) (unbound)

Set the mark at the cursor position.

ssppeellll-wwoorrdd (ESC-$ ESC-S ESC-s) (unbound) (unbound)

Attempt spelling correction on the current word.

uunnddeeffiinneedd-kkeeyy

This command is executed when a key sequence that is not bound to any command is typed. By default it beeps. uunnddoo (^ ^Xu ^X^U) (unbound) (unbound) Incrementally undo the last text modification. rreeddoo Incrementally redo undone text modifications.

vvii-uunnddoo-cchhaannggee (unbound) (u) (unbound)

Undo the last text modification. If repeated, redo the modifi-

cation.

wwhhaatt-ccuurrssoorr-ppoossiittiioonn (^X=) (unbound) (unbound)

Print the character under the cursor, its code as an octal, dec-

imal and hexadecimal number, the current cursor position within the buffer and the column of the cursor in the current line.

wwhheerree-iiss

Read the name of an editor command and and print the listing of key sequences that invoke the specified command.

wwhhiicchh-ccoommmmaanndd (ESC-?) (unbound) (unbound)

Push the buffer onto the buffer stack, and execute the command

`wwhhiicchh-ccoommmmaanndd cmd'. where cmd is the current command.

wwhhiicchh-ccoommmmaanndd is normally aliased to whence.

vvii-ddiiggiitt-oorr-bbeeggiinnnniinngg-ooff-lliinnee (unbound) (0) (unbound)

If the last command executed was a digit as part of an argument,

continue the argument. Otherwise, execute vi-beginning-of-line.

ZSHCOMPWID(1) ZSHCOMPWID(1)

NAME

zshcompwid - zsh completion widgets

DESCRIPTION

The shell's programmable completion mechanism can be manipulated in two

ways; here the low-level features supporting the newer, function-based

mechanism are defined. A complete set of shell functions based on

these features is described in zshcompsys(1), and users with no inter-

est in adding to that system (or, potentially, writing their own --

see dictionary entry for `hubris') should skip this section. The older

system based on the ccoommppccttll builtin command is described in zshcom-

pctl(1).

Completion widgets are defined by the -CC option to the zzllee builtin com-

mand provided by the zzsshh//zzllee module (see zshzle(1)). For example,

zzllee -CC ccoommpplleettee eexxppaanndd-oorr-ccoommpplleettee ccoommpplleetteerr

defines a widget named `ccoommpplleettee'. The second argument is the name of

any of the builtin widgets that handle completions: ccoommpplleettee-wwoorrdd,

eexxppaanndd-oorr-ccoommpplleettee, eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx, mmeennuu-ccoommpplleettee,

mmeennuu-eexxppaanndd-oorr-ccoommpplleettee, rreevveerrssee-mmeennuu-ccoommpplleettee, lliisstt-cchhooiicceess, or

ddeelleettee-cchhaarr-oorr-lliisstt. Note that this will still work even if the widget

in question has been re-bound.

When this newly defined widget is bound to a key using the bbiinnddkkeeyy builtin command defined in the zzsshh//zzllee module (see zshzle(1)), typing that key will call the shell function `ccoommpplleetteerr'. This function is responsible for generating the possible matches using the builtins described below. As with other ZLE widgets, the function is called with its standard input closed. Once the function returns, the completion code takes over control again

and treats the matches in the same manner as the specified builtin wid-

get, in this case eexxppaanndd-oorr-ccoommpplleettee.

SSPPEECCIIAALL PPAARRAAMMEETTEERRSS Inside completion widgets, and any functions called from them, some parameters have special meaning; outside these functions they are not special to the shell in any way. These parameters are used to pass information between the completion code and the completion widget. Some

of the builtin commands and the condition codes use or change the cur-

rent values of these parameters. Any existing values will be hidden during execution of completion widgets; except for ccoommppssttaattee, the parameters are reset on each function exit (including nested function calls from within the completion widget) to the values they had when the function was entered. CCUURRRREENNTT This is the number of the current word, i.e. the word the cursor is currently on in the wwoorrddss array. Note that this value is only correct if the kksshhaarrrraayyss option is not set. IIPPRREEFFIIXX Initially this will be set to the empty string. This parameter functions like PPRREEFFIIXX; it contains a string which precedes the one in PPRREEFFIIXX and is not considered part of the list of matches. Typically, a string is transferred from the beginning of PPRREEFFIIXX to the end of IIPPRREEFFIIXX, for example:

IIPPRREEFFIIXX==$${{PPRREEFFIIXX%%%%\\==**}}==

PPRREEFFIIXX==$${{PPRREEFFIIXX##**==}}

causes the part of the prefix up to and including the first equal sign not to be treated as part of a matched string. This can be done automatically by the ccoommppsseett builtin, see below. IISSUUFFFFIIXX As IIPPRREEFFIIXX, but for a suffix that should not be considered part of the matches; note that the IISSUUFFFFIIXX string follows the SSUUFFFFIIXX string. PPRREEFFIIXX Initially this will be set to the part of the current word from the beginning of the word up to the position of the cursor; it may be altered to give a common prefix for all matches. QQIIPPRREEFFIIXX

This parameter is read-only and contains the quoted string up to

the word being completed. E.g. when completing `""ffoooo', this

parameter contains the double quote. If the -qq option of ccoommppsseett

is used (see below), and the original string was `""ffoooo bbaarr' with the cursor on the `bbaarr', this parameter contains `""ffoooo '. QQIISSUUFFFFIIXX Like QQIIPPRREEFFIIXX, but containing the suffix. SSUUFFFFIIXX Initially this will be set to the part of the current word from

the cursor position to the end; it may be altered to give a com-

mon suffix for all matches. It is most useful when the option

CCOOMMPPLLEETTEEIINNWWOORRDD is set, as otherwise the whole word on the com-

mand line is treated as a prefix. ccoommppssttaattee This is an associative array with various keys and values that

the completion code uses to exchange information with the com-

pletion widget. The keys are: aallllqquuootteess

The -qq option of the ccoommppsseett builtin command (see below)

allows a quoted string to be broken into separate words; if the cursor is on one of those words, that word will be

completed, possibly invoking `ccoommppsseett -qq' recursively.

With this key it is possible to test the types of quoted strings which are currently broken into parts in this

fashion. Its value contains one character for each quot-

ing level. The characters are a single quote or a double quote for strings quoted with these characters and a

backslash for strings not starting with a quote charac-

ter. The first character in the value always corresponds to the innermost quoting level. ccoonntteexxtt This will be set by the completion code to the overall context in which completion is attempted. Possible values are: aarrrraayyvvaalluuee when completing inside the value of an array parameter assignment; in this case the wwoorrddss array contains the words inside the parentheses. bbrraacceeppaarraammeetteerr when completing the name of a parameter in a

parameter expansion beginning with $${{.

aassssiiggnnppaarraammeetteerr when completing the name of a parameter in a parameter assignment. ccoommmmaanndd when completing for a normal command (either in

command position or for an argument of the com-

mand). ccoonnddiittiioonn when completing inside a `[[[[...]]]]' conditional expression; in this case the wwoorrddss array contains only the words inside the conditional expression. mmaatthh when completing in a mathematical environment such as a `((((...))))' construct. ppaarraammeetteerr when completing the name of a parameter in a

parameter expansion beginning with $$ but not $${{.

rreeddiirreecctt when completing after a redirection operator. ssuubbssccrriipptt when completing inside a parameter subscript.

vvaalluuee when completing the value of a parameter assign-

ment. eexxaacctt Controls the behaviour when the RREECCEEXXAACCTT option is set. It will be set to aacccceepptt if an exact match would be accepted, and will be unset otherwise. If it was set when at least one match equal to the string on the line was generated, the match is accepted. eexxaaccttssttrriinngg The string of an exact match if one was found, otherwise unset. iiggnnoorreedd The number of words that were ignored because they

matched one of the patterns given with the -FF option to

the ccoommppaadddd builtin command. iinnsseerrtt This controls the manner in which a match is inserted into the command line. On entry to the widget function, if it is unset the command line is not to be changed; if set to uunnaammbbiigguuoouuss, any prefix common to all matches is

to be inserted; if set to aauuttoommeennuu-uunnaammbbiigguuoouuss, the com-

mon prefix is to be inserted and the next invocation of the completion code may start menu completion (due to the AAUUTTOOMMEENNUU option being set); if set to mmeennuu or aauuttoommeennuu menu completion will be started for the matches currently generated (in the latter case this will happen because the AAUUTTOOMMEENNUU is set). The value may also contain the string `ttaabb' when the completion code would normally not really do completion, but only insert the TAB character. On exit it may be set to any of the values above (where setting it to the empty string is the same as unsetting it), or to a number, in which case the match whose number

is given will be inserted into the command line. Nega-

tive numbers count backward from the last match (with

`-11' selecting the last match) and out-of-range values

are wrapped around, so that a value of zero selects the last match and a value one more than the maximum selects the first. Unless the value of this key ends in a space,

the match is inserted as in a menu completion, i.e. with-

out automatically appending a space. Both mmeennuu and aauuttoommeennuu may also specify the the number of the match to insert, given after a colon. For example, `mmeennuu::22' says to start menu completion, beginning with the second match. Note that a value containing the substring `ttaabb' makes the matches generated be ignored and only the TAB be inserted. Finally, it may also be set to aallll, which makes all matches generated be inserted into the line. iinnsseerrttppoossiittiioonnss When the completion system inserts an unambiguous string

into the line, there may be multiple places where charac-

ters are missing or where the character inserted differs from at least one match. The value of this key contains a colon separated list of all these positions, as indexes into the command line. llaassttpprroommpptt

If this is set to a non-empty string for every match

added, the completion code will move the cursor back to the previous prompt after the list of completions has been displayed. Initially this is set or unset according to the AALLWWAAYYSSLLAASSTTPPRROOMMPPTT option. lliisstt This controls whether or how the list of matches will be displayed. If it is unset or empty they will never be listed; if its value begins with lliisstt, they will always be listed; if it begins with aauuttoolliisstt or aammbbiigguuoouuss, they will be listed when the AAUUTTOOLLIISSTT or LLIISSTTAAMMBBIIGGUUOOUUSS options respectively would normally cause them to be. If the substring ffoorrccee appears in the value, this makes

the list be shown even if there is only one match. Nor-

mally, the list would be shown only if there are at least two matches. The value contains the substring ppaacckkeedd if the LLIISSTTPPAACCKKEEDD option is set. If this substring is given for all matches added to a group, this group will show the LLIISSTTPPAACCKKEEDD behavior. The same is done for the LLIISSTTRROOWWSSFFIIRRSSTT option with the substring rroowwss. Finally, if the value contains the string eexxppllaannaattiioonnss, only the explanation strings, if any, will be listed and if it contains mmeessssaaggeess, only the messages (added with

the -xx option of ccoommppaadddd) will be listed. If it contains

both eexxppllaannaattiioonnss and mmeessssaaggeess both kinds of explanation strings will be listed. It will be set appropriately on entry to a completion widget and may be changed there. lliissttlliinneess This gives the number of lines that are needed to display the full list of completions. Note that to calculate the

total number of lines to display you need to add the num-

ber of lines needed for the command line to this value, this is available as the value of the BBUUFFFFEERRLLIINNEESS special parameter. lliissttmmaaxx

Initially this is set to the value of the LLIISSTTMMAAXX parame-

ter. It may be set to any other value; when the widget exits this value will be used in the same way as the value of LLIISSTTMMAAXX. nnmmaattcchheess

The number of matches generated and accepted by the com-

pletion code so far. oollddiinnsseerrtt On entry to the widget this will be set to the number of the match of an old list of completions that is currently inserted into the command line. If no match has been inserted, this is unset. As with oollddlliisstt, the value of this key will only be used if it is the string kkeeeepp. If it was set to this value by the widget and there was an old match inserted into the command line, this match will be kept and if the value of the iinnsseerrtt key specifies that another match should be inserted, this will be inserted after the old one. oollddlliisstt

This is set to yyeess if there is still a valid list of com-

pletions from a previous completion at the time the wid-

get is invoked. This will usually be the case if and only if the previous editing operation was a completion widget or one of the builtin completion functions. If there is a valid list and it is also currently shown on the screen, the value of this key is sshhoowwnn. After the widget has exited the value of this key is only used if it was set to kkeeeepp. In this case the completion code will continue to use this old list. If the widget generated new matches, they will not be used. ppaarraammeetteerr The name of the parameter when completing in a subscript or in the value of a parameter assignment. ppaatttteerrnniinnsseerrtt Normally this is set to mmeennuu, which specifies that menu completion will be used whenever a set of matches was generated using pattern matching. If it is set to any

other non-empty string by the user and menu completion is

not selected by other option settings, the code will instead insert any common prefix for the generated matches as with normal completion. ppaatttteerrnnmmaattcchh Locally controls the behaviour given by the GGLLOOBBCCOOMMPPLLEETTEE option. Initially it is set to `**' if and only if the option is set. The completion widget may set it to this value, to an empty string (which has the same effect as

unsetting it), or to any other non-empty string. If it

is non-empty, unquoted metacharacters on the command line

will be treated as patterns; if it is `**', then addition-

ally a wildcard `**' is assumed at the cursor position; if

it is empty or unset, metacharacters will be treated lit-

erally. Note that the matcher specifications given to the ccoommppaadddd builtin command are not used if this is set to a

non-empty string.

qquuoottee When completing inside quotes, this contains the quota-

tion character (i.e. either a single quote, a double quote, or a backtick). Otherwise it is unset. qquuoottiinngg When completing inside single quotes, this is set to the string ssiinnggllee; inside double quotes, the string ddoouubbllee; inside backticks, the string bbaacckkttiicckk. Otherwise it is unset. rreeddiirreecctt The redirection operator when completing in a redirection position, i.e. one of <<, >>, etc. rreessttoorree This is set to aauuttoo before a function is entered, which forces the special parameters mentioned above (wwoorrddss, CCUURRRREENNTT, PPRREEFFIIXX, IIPPRREEFFIIXX, SSUUFFFFIIXX, and IISSUUFFFFIIXX) to be restored to their previous values when the function exits. If a function unsets it or sets it to any other string, they will not be restored. ttooeenndd Specifies the occasions on which the cursor is moved to the end of a string when a match is inserted. On entry

to a widget function, it may be ssiinnggllee if this will hap-

pen when a single unambiguous match was inserted or mmaattcchh

if it will happen any time a match is inserted (for exam-

ple, by menu completion; this is likely to be the effect of the AALLWWAAYYSSTTOOEENNDD option). On exit, it may be set to ssiinnggllee as above. It may also be set to aallwwaayyss, or to the empty string or unset; in those cases the cursor will be moved to the end of the string always or never respectively. Any other string is treated as mmaattcchh. uunnaammbbiigguuoouuss

This key is read-only and will always be set to the com-

mon (unambiguous) prefix the completion code has gener-

ated for all matches added so far. uunnaammbbiigguuoouussccuurrssoorr This gives the position the cursor would be placed at if the common prefix in the uunnaammbbiigguuoouuss key were inserted, relative to the value of that key. The cursor would be placed before the character whose index is given by this key. uunnaammbbiigguuoouussppoossiittiioonnss

This contains all positions where characters in the unam-

biguous string are missing or where the character inserted differs from at least one of the matches. The positions are given as indexes into the string given by the value of the uunnaammbbiigguuoouuss key. vvaarreedd If completion is called while editing a line using the vvaarreedd builtin, the value of this key is set to the name of the parameter given as an argument to vvaarreedd. This key is only set while a vvaarreedd command is active.

wwoorrddss This array contains the words present on the command line cur-

rently being edited. BBUUIILLTTIINN CCOOMMMMAANNDDSS

ccoommppaadddd [ -aakkqqQQffeennUUll1122CC ] [ -FF array ]

[ -PP prefix ] [ -SS suffix ]

[ -pp hidden-prefix ] [ -ss hidden-suffix ]

[ -ii ignored-prefix ] [ -II ignored-suffix ]

[ -WW file-prefix ] [ -dd array ]

[ -JJ name ] [ -VV name ] [ -XX explanation ] [ -xx message ]

[ -rr remove-chars ] [ -RR remove-func ]

[ -DD array ] [ -OO array ] [ -AA array ]

[ -EE number ]

[ -MM match-spec ] [ -- ] [ words ... ]

This builtin command can be used to add matches directly and control all the information the completion code stores with each possible match. The return value is zero if at least one match

was added and non-zero if no matches were added.

The completion code breaks the string to complete into seven fields in the order: The first field is an ignored prefix taken from the command line, the contents of the IIPPRREEFFIIXX parameter plus the string

given with the -ii option. With the -UU option, only the string

from the -ii option is used. The field is an optional pre-

fix string given with the -PP option. The field is a

string that is considered part of the match but that should not

be shown when listing completions, given with the -pp option; for

example, functions that do filename generation might specify a common path prefix this way. is the part of the match that should appear in the list of completions, i.e. one of the words given at the end of the ccoommppaadddd command line. The suffixes , and correspond to the prefixes ,

and and are given by the options -ss, -SS and -II,

respectively. The supported flags are:

-PP prefix

This gives a string to be inserted before the given words. The string given is not considered as part of the match and any shell metacharacters in it will not be quoted when the string is inserted.

-SS suffix

Like -PP, but gives a string to be inserted after the

match.

-pp hidden-prefix

This gives a string that should be inserted into the com-

mand line before the match but that should not appear in

the list of matches. Unless the -UU option is given, this

string must be matched as part of the string on the com-

mand line.

-ss hidden-suffix

Like `-pp', but gives a string to insert after the match.

-ii ignored-prefix

This gives a string to insert into the command line just

before any string given with the `-PP' option. Without

`-PP' the string is inserted before the string given with

`-pp' or directly before the match.

-II ignored-suffix

Like -ii, but gives an ignored suffix.

-aa With this flag the words are taken as names of arrays and

the possible matches are their values. If only some ele-

ments of the arrays are needed, the words may also con-

tain subscripts, as in `ffoooo[[22,,-11]]'.

-kk With this flag the words are taken as names of associa-

tive arrays and the possible matches are their keys. As

for -aa, the words may also contain subscripts, as in

`ffoooo[[((RR))**bbaarr**]]'.

-dd array

This adds per-match display strings. The array should

contain one element per word given. The completion code will then display the first element instead of the first word, and so on. The array may be given as the name of an

array parameter or directly as a space-separated list of

words in parentheses.

If there are fewer display strings than words, the left-

over words will be displayed unchanged and if there are more display strings than words, the leftover display strings will be silently ignored.

-ll This option only has an effect if used together with the

-dd option. If it is given, the display strings are listed

one per line, not arrayed in columns.

-JJ name

Gives the name of the group of matches the words should be stored in.

-VV name

Like -JJ but naming a unsorted group. These are in a dif-

ferent name space than groups created with the -JJ flag.

-11 If given together with the -VV option, makes only consecu-

tive duplicates in the group be removed. If combined with

the -JJ option, this has no visible effect. Note that

groups with and without this flag are in different name spaces.

-22 If given together with the -JJ or -VV option, makes all

duplicates be kept. Again, groups with and without this flag are in different name spaces.

-XX explanation

The explanation string will be printed with the list of matches, above the group currently selected.

-xx message

Like -XX, but the message will be printed even if there

are no matches in the group.

-qq The suffix given with -SS will be automatically removed if

the next character typed is a blank or does not insert anything, or if the suffix consists of only one character and the next character typed is the same character.

-rr remove-chars

This is a more versatile form of the -qq option. The suf-

fix given with -SS or the slash automatically added after

completing directories will be automatically removed if the next character typed inserts one of the characters

given in the remove-chars. This string is parsed as a

characters class and understands the backslash sequences

used by the pprriinntt command. For example, `-rr ""aa-zz\\tt""'

removes the suffix if the next character typed inserts a

lowercase character or a TAB, and `-rr ""^^00-99""' removes the

suffix if the next character typed inserts anything but a digit. One extra backslash sequence is understood in this

string: `\\-' stands for all characters that insert noth-

ing. Thus `-SS ""=="" -qq' is the same as `-SS ""=="" -rr ""==

\\tt\\nn\\-""'.

This option may also be used without the -SS option; then

any automatically added space will be removed when one of the characters in the list is typed.

-RR remove-func

This is another form of the -rr option. When a suffix has

been inserted and the completion accepted, the function

remove-func will be called after the next character

typed. It is passed the length of the suffix as an argu-

ment and can use the special parameters available in

ordinary (non-completion) zle widgets (see zshzle(1)) to

analyse and modify the command line.

-ff If this flag is given, all of the matches built from

words are marked as being the names of files. They are not required to be actual filenames, but if they are, and the option LLIISSTTTTYYPPEESS is set, the characters describing the types of the files in the completion lists will be shown. This also forces a slash to be added when the name of a directory is completed.

-ee This flag can be used to tell the completion code that

the matches added are parameter names for a parameter expansion. This will make the AAUUTTOOPPAARRAAMMSSLLAASSHH and AAUUTTOOPPAARRAAMMKKEEYYSS options be used for the matches.

-WW file-prefix

This string is a pathname that will be prepended to each of the matches formed by the given words together with

any prefix specified by the -pp option to form a complete

filename for testing. Hence it is only useful if com-

bined with the -ff flag, as the tests will not otherwise

be performed.

-FF array

Specifies an array containing patterns. Words matching one of these patterns are ignored, i.e. not considered to be possible matches. The array may be the name of an array parameter or a list of literal patterns enclosed in parentheses and quoted,

as in `-FF ""((**??..oo **??..hh))""'. If the name of an array is

given, the elements of the array are taken as the pat-

terns.

-QQ This flag instructs the completion code not to quote any

metacharacters in the words when inserting them into the command line.

-MM match-spec

This gives local match specifications as described below in the section `Matching Control'. This option may be

given more than once. In this case all match-specs given

are concatenated with spaces between them to form the specification string to use. Note that they will only be

used if the -UU option is not given.

-nn Specifies that the words added are to be used as possible

matches, but are not to appear in the completion listing.

-UU If this flag is given, all words given will be accepted

and no matching will be done by the completion code. Nor-

mally this is used in functions that do the matching themselves.

-OO array

If this option is given, the words are not added to the set of possible completions. Instead, matching is done as usual and all of the words given as arguments that match the string on the command line will be stored in the array parameter whose name is given as array.

-AA array

As the -OO option, except that instead of those of the

words which match being stored in array, the strings gen-

erated internally by the completion code are stored. For

example, with a matching specification of `-MM ""LL::||nnoo==""',

the string `nnooff' on the command line and the string `ffoooo' as one of the words, this option stores the string

`nnooffoooo' in the array, whereas the -OO option stores the

`ffoooo' originally given.

-DD array

As with -OO, the words are not added to the set of possi-

ble completions. Instead, the completion code tests whether each word in turn matches what is on the line. If the n'th word does not match, the n'th element of the array is removed. Elements for which the corresponding word is matched are retained.

-CC This option adds a special match which expands to all

other matches when inserted into the line, even those that are added after this option is used. Together with

the -dd option it is possible to specify a string that

should be displayed in the list for this special match.

If no string is given, it will be shown as a string con-

taining the strings that would be inserted for the other matches, truncated to the width of the screen.

-EE This option adds number empty matches after the words

have been added. An empty match takes up space in com-

pletion listings but will never be inserted in the line

and can't be selected with menu completion or menu selec-

tion. This makes empty matches only useful to format completion lists and to make explanatory string be shown in completion lists (since empty matches can be given

display strings with the -dd option). And because all but

one empty string would otherwise be removed, this option

implies the -VV and -22 options (even if an explicit -JJ

option is given).

-

-- This flag ends the list of flags and options. All argu-

ments after it will be taken as the words to use as matches even if they begin with hyphens.

Except for the -MM flag, if any of these flags is given more than

once, the first one (and its argument) will be used.

ccoommppsseett -pp number

ccoommppsseett -PP [ number ] pattern

ccoommppsseett -ss number

ccoommppsseett -SS [ number ] pattern

ccoommppsseett -nn begin [ end ]

ccoommppsseett -NN beg-pat [ end-pat ]

ccoommppsseett -qq

This command simplifies modification of the special parameters, while its return value allows tests on them to be carried out. The options are:

-pp number

If the contents of the PPRREEFFIIXX parameter is longer than number characters, the first number characters are removed from it and appended to the contents of the IIPPRREEFFIIXX parameter.

-PP [ number ] pattern

If the value of the PPRREEFFIIXX parameter begins with anything that matches the pattern, the matched portion is removed from PPRREEFFIIXX and appended to IIPPRREEFFIIXX. Without the optional number, the longest match is taken, but if number is given, anything up to the number'th match is moved. If the number is negative, the number'th longest match is moved. For example, if PPRREEFFIIXX contains

the string `aa==bb==cc', then ccoommppsseett -PP ''**\\=='' will move the

string `aa==bb==' into the IIPPRREEFFIIXX parameter, but ccoommppsseett -PP

11 ''**\\=='' will move only the string `aa=='.

-ss number

As -pp, but transfer the last number characters from the

value of SSUUFFFFIIXX to the front of the value of IISSUUFFFFIIXX.

-SS [ number ] pattern

As -PP, but match the last portion of SSUUFFFFIIXX and transfer

the matched portion to the front of the value of IISSUUFFFFIIXX.

-nn begin [ end ]

If the current word position as specified by the parame-

ter CCUURRRREENNTT is greater than or equal to begin, anything up to the begin'th word is removed from the wwoorrddss array and the value of the parameter CCUURRRREENNTT is decremented by begin. If the optional end is given, the modification is done only if the current word position is also less than or equal to end. In this case, the words from position end onwards are also removed from the wwoorrddss array. Both begin and end may be negative to count backwards from the last element of the wwoorrddss array.

-NN beg-pat [ end-pat ]

If one of the elements of the wwoorrddss array before the one at the index given by the value of the parameter CCUURRRREENNTT

matches the pattern beg-pat, all elements up to and

including the matching one are removed from the wwoorrddss array and the value of CCUURRRREENNTT is changed to point to the same word in the changed array.

If the optional pattern end-pat is also given, and there

is an element in the wwoorrddss array matching this pattern, the parameters are modified only if the index of this

word is higher than the one given by the CCUURRRREENNTT parame-

ter (so that the matching word has to be after the cur-

sor). In this case, the words starting with the one

matching eenndd-ppaatt are also removed from the wwoorrddss array.

If wwoorrddss contains no word matching end-pat, the testing

and modification is performed as if it were not given.

-qq The word currently being completed is split on spaces

into separate words, respecting the usual shell quoting conventions. The resulting words are stored in the wwoorrddss

array, and CCUURRRREENNTT, PPRREEFFIIXX, SSUUFFFFIIXX, QQIIPPRREEFFIIXX, and QQIISSUUFF-

FFIIXX are modified to reflect the word part that is com-

pleted.

In all the above cases the return value is zero if the test suc-

ceeded and the parameters were modified and non-zero otherwise.

This allows one to use this builtin in tests such as:

iiff ccoommppsseett -PP ''**\\=='';; tthheenn ......

This forces anything up to and including the last equal sign to be ignored by the completion code.

ccoommppccaallll [ -TTDD ]

This allows the use of completions defined with the ccoommppccttll builtin from within completion widgets. The list of matches

will be generated as if one of the non-widget completion func-

tion (ccoommpplleettee-wwoorrdd, etc.) had been called, except that only

ccoommppccttlls given for specific commands are used. To force the code

to try completions defined with the -TT option of ccoommppccttll and/or

the default completion (whether defined by ccoommppccttll -DD or the

builtin default) in the appropriate places, the -TT and/or -DD

flags can be passed to ccoommppccaallll.

The return value can be used to test if a matching ccoommppccttll defi-

nition was found. It is non-zero if a ccoommppccttll was found and zero

otherwise. Note that this builtin is defined by the zzsshh//ccoommppccttll module. CCOONNDDIITTIIOONN CCOODDEESS The following additional condition codes for use within the [[[[ ...... ]]]]

construct are available in completion widgets. These work on the spe-

cial parameters. All of these tests can also be performed by the ccoommppsseett builtin, but in the case of the condition codes the contents of the special parameters are not modified.

-pprreeffiixx [ number ] pattern

true if the test for the -PP option of ccoommppsseett would succeed.

-ssuuffffiixx [ number ] pattern

true if the test for the -SS option of ccoommppsseett would succeed.

-aafftteerr beg-pat

true if the test of the -NN option with only the beg-pat given

would succeed.

-bbeettwweeeenn beg-pat end-pat

true if the test for the -NN option with both patterns would suc-

ceed. MMAATTCCHHIINNGG CCOONNTTRROOLL

It is possible by use of the -MM option of the ccoommppaadddd builtin command

to specify how the characters in the string to be completed (referred to here as the command line) map onto the characters in the list of matches produced by the completion code (referred to here as the trial completions). Note that this is not used if the command line contains a glob pattern and the GGLLOOBBCCOOMMPPLLEETTEE option is set or the ppaatttteerrnnmmaattcchh

of the ccoommppssttaattee special association is set to a non-empty string.

The match-spec given as the argument to the -MM option (see `Builtin

Commands' above) consists of one or more matching descriptions sepa-

rated by whitespace. Each description consists of a letter followed by a colon and then the patterns describing which character sequences on the line match which character sequences in the trial completion. Any sequence of characters not handled in this fashion must match exactly, as usual.

The forms of match-spec understood are as follows. In each case, the

form with an uppercase initial character retains the string already typed on the command line as the final result of completion, while with a lowercase initial character the string on the command line is changed into the corresponding part of the trial completion. mm::lpat==tpat MM::lpat==tpat

Here, lpat is a pattern that matches on the command line, corre-

sponding to tpat which matches in the trial completion. ll::lanchor||lpat==tpat LL::lanchor||lpat==tpat ll::lanchor||||ranchor==tpat LL::lanchor||||ranchor==tpat bb::lpat==tpat BB::lpat==tpat

These letters are for patterns that are anchored by another pat-

tern on the left side. Matching for lpat and tpat is as for mm and MM, but the pattern lpat matched on the command line must be preceded by the pattern lanchor. The lanchor can be blank to

anchor the match to the start of the command line string; other-

wise the anchor can occur anywhere, but must match in both the command line and trial completion strings. If no lpat is given but a ranchor is, this matches the gap

between substrings matched by lanchor and ranchor. Unlike lan-

chor, the ranchor only needs to match the trial completion string. The bb and BB forms are similar to ll and LL with an empty anchor, but need to match only the beginning of the trial completion or the word on the command line, respectively. rr::lpat||ranchor==tpat RR::lpat||ranchor==tpat rr::lanchor||||ranchor==tpat RR::lanchor||||ranchor==tpat ee::lpat==tpat EE::lpat==tpat As ll, LL, bb and BB, with the difference that the command line and trial completion patterns are anchored on the right side. Here an empty ranchor and the ee and EE forms force the match to the end of the trial completion or command line string. Each lpat, tpat or anchor is either an empty string or consists of a sequence of literal characters (which may be quoted with a backslash), question marks, character classes, and correspondence classes; ordinary shell patterns are not used. Literal characters match only themselves, question marks match any character, and character classes are formed as for globbing and match any character in the given set. Correspondence classes are defined like character classes, but with two differences: they are delimited by a pair of braces, and negated classes are not allowed, so the characters !! and ^^ have no special meaning directly after the opening brace. They indicate that a range

of characters on the line match a range of characters in the trial com-

pletion, but (unlike ordinary character classes) paired according to the corresponding position in the sequence. For example, to make any lowercase letter on the line match the corresponding uppercase letter

in the trial completion, you can use `mm::{{aa-zz}}=={{AA-ZZ}}'. More than one

pair of classes can occur, in which case the first class before the == corresponds to the first after it, and so on. If one side has more such classes than the other side, the superfluous classes behave like normal character classes. In anchor patterns correspondence classes also behave like normal character classes. The pattern tpat may also be one or two stars, `**' or `****'. This means that the pattern on the command line can match any number of characters in the trial completion. In this case the pattern must be anchored (on either side); in the case of a single star, the anchor then determines

how much of the trial completion is to be included -- only the charac-

ters up to the next appearance of the anchor will be matched. With two stars, substrings matched by the anchor can be matched, too. Examples: The keys of the ooppttiioonnss association defined by the ppaarraammeetteerr module are

the option names in all-lowercase form, without underscores, and with-

out the optional nnoo at the beginning even though the builtins sseettoopptt

and uunnsseettoopptt understand option names with uppercase letters, under-

scores, and the optional nnoo. The following alters the matching rules so that the prefix nnoo and any underscore are ignored when trying to match the trial completions generated and uppercase letters on the line match the corresponding lowercase letters in the words:

ccoommppaadddd -MM ''LL::||[[nnNN]][[ooOO]]== MM::== MM::{{AA-ZZ}}=={{aa-zz}}'' - \\

$${{((kk))ooppttiioonnss}}

The first part says that the pattern `[[nnNN]][[ooOO]]' at the beginning (the empty anchor before the pipe symbol) of the string on the line matches the empty string in the list of words generated by completion, so it

will be ignored if present. The second part does the same for an under-

score anywhere in the command line string, and the third part uses cor-

respondence classes so that any uppercase letter on the line matches

the corresponding lowercase letter in the word. The use of the upper-

case forms of the specification characters (LL and MM) guarantees that

what has already been typed on the command line (in particular the pre-

fix nnoo) will not be deleted. Note that the use of LL in the first part means that it matches only when at the beginning of both the command line string and the trial completion. I.e., the string `NNOOff' would not be completed to `NNOOffoooo', nor would `NNOONNOOff' be completed to `NNOONNOOffoooo' because of the

leading underscore or the second `NNOO' on the line which makes the pat-

tern fail even though they are otherwise ignored. To fix this, one would use `BB::[[nnNN]][[ooOO]]==' instead of the first part. As described above, this matches at the beginning of the trial completion, independent of other characters or substrings at the beginning of the command line

word which are ignored by the same or other match-specs.

The second example makes completion case insensitive. This is just the

same as in the option example, except here we wish to retain the char-

acters in the list of completions:

ccoommppaadddd -MM ''mm::{{aa-zz}}=={{AA-ZZ}}'' ......

This makes lowercase letters match their uppercase counterparts. To make uppercase letters match the lowercase forms as well:

ccoommppaadddd -MM ''mm::{{aa-zzAA-ZZ}}=={{AA-ZZaa-zz}}'' ......

A nice example for the use of ** patterns is partial word completion. Sometimes you would like to make strings like `cc..ss..uu' complete to

strings like `ccoommpp..ssoouurrccee..uunniixx', i.e. the word on the command line con-

sists of multiple parts, separated by a dot in this example, where each

part should be completed separately -- note, however, that the case

where each part of the word, i.e. `ccoommpp', `ssoouurrccee' and `uunniixx' in this

example, is to be completed from separate sets of matches is a differ-

ent problem to be solved by the implementation of the completion wid-

get. The example can be handled by:

ccoommppaadddd -MM ''rr::||..==** rr::||==**'' \\

- ccoommpp..ssoouurrcceess..uunniixx ccoommpp..ssoouurrcceess..mmiisscc ......

The first specification says that lpat is the empty string, while anchor is a dot; tpat is **, so this can match anything except for the `..' from the anchor in the trial completion word. So in `cc..ss..uu', the matcher sees `cc', followed by the empty string, followed by the anchor `..', and likewise for the second dot, and replaces the empty strings before the anchors, giving `cc[oommpp]..ss[oouurrcceess]..uu[nniixx]', where the last part of the completion is just as normal. With the pattern shown above, the string `cc..uu' could not be completed to `ccoommpp..ssoouurrcceess..uunniixx' because the single star means that no dot (matched by the anchor) can be skipped. By using two stars as in `rr::||..==****', however, `cc..uu' could be completed to `ccoommpp..ssoouurrcceess..uunniixx'. This also shows that in some cases, especially if the anchor is a real pattern, like a character class, the form with two stars may result in more matches than one would like. The second specification is needed to make this work when the cursor is

in the middle of the string on the command line and the option CCOOMM-

PPLLEETTEEIINNWWOORRDD is set. In this case the completion code would normally try to match trial completions that end with the string as typed so far, i.e. it will only insert new characters at the cursor position rather then at the end. However in our example we would like the code to recognise matches which contain extra characters after the string on the line (the `nniixx' in the example). Hence we say that the empty string at the end of the string on the line matches any characters at the end of the trial completion. More generally, the specification

ccoommppaadddd -MM ''rr::||[[..,,-]]==** rr::||==**'' ......

allows one to complete words with abbreviations before any of the char-

acters in the square brackets. For example, to complete vveerryyvveerryylloonngg-

ffiillee..cc rather than vveerryyvveerryylloonngghheeaaddeerr..hh with the above in effect, you can just type vveerryy..cc before attempting completion. The specifications with both a left and a right anchor are useful to complete partial words whose parts are not separated by some special character. For example, in some places strings have to be completed that are formed `LLiikkeeTThhiiss' (i.e. the separate parts are determined by a leading uppercase letter) or maybe one has to complete strings with trailing numbers. Here one could use the simple form with only one anchor as in:

ccoommppaadddd -MM ''rr::||[[AA-ZZ00-99]]==** rr::||==**'' LLiikkeeTTHHIISS FFooooHHoooo 55ffoooo112233 55bbaarr223344

But with this, the string `HH' would neither complete to `FFooooHHoooo' nor to `LLiikkeeTTHHIISS' because in each case there is an uppercase letter before the `HH' and that is matched by the anchor. Likewise, a `22' would not be completed. In both cases this could be changed by using

`rr::||[[AA-ZZ00-99]]==****', but then `HH' completes to both `LLiikkeeTTHHIISS' and

`FFooooHHoooo' and a `22' matches the other strings because characters can be inserted before every uppercase letter and digit. To avoid this one would use:

ccoommppaadddd -MM ''rr::[[^^AA-ZZ00-99]]||||[[AA-ZZ00-99]]==**** rr::||==**'' \\

LLiikkeeTTHHIISS FFooooHHoooo ffoooo112233 bbaarr223344 By using these two anchors, a `HH' matches only uppercase `HH's that are

immediately preceded by something matching the left anchor `[[^^AA-ZZ00-99]]'.

The effect is, of course, that `HH' matches only the string `FFooooHHoooo', a `22' matches only `bbaarr223344' and so on. When using the completion system (see zshcompsys(1)), users can define match specifications that are to be used for specific contexts by using

the mmaattcchheerr and mmaattcchheerr-lliisstt styles. The values for the latter will be

used everywhere. CCOOMMPPLLEETTIIOONN WWIIDDGGEETT EEXXAAMMPPLLEE The first step is to define the widget:

zzllee -CC ccoommpplleettee ccoommpplleettee-wwoorrdd ccoommpplleettee-ffiilleess

Then the widget can be bound to a key using the bbiinnddkkeeyy builtin com-

mand: bbiinnddkkeeyy ''^^XX\\tt'' ccoommpplleettee

After that the shell function ccoommpplleettee-ffiilleess will be invoked after typ-

ing control-X and TAB. The function should then generate the matches,

e.g.:

ccoommpplleettee-ffiilleess (()) {{ ccoommppaadddd - ** }}

This function will complete files in the current directory matching the current word. ZSHCOMPSYS(1) ZSHCOMPSYS(1)

NAME

zshcompsys - zsh completion system

DESCRIPTION

This describes the shell code for the new completion system. It con-

sists of various shell functions; those beginning `ccoommpp' are to be called directly, while those beginning `' are called by the completion

code. The shell functions of the second set, which implement comple-

tion behaviour and may be bound to keystrokes, are referred to as `wid-

gets'. IINNIITTIIAALLIIZZAATTIIOONN If the system was installed completely, it should be enough to call the shell function ccoommppiinniitt from your initialization file; see the next section. However, the function ccoommppiinnssttaallll can be run by a user to configure various aspects of the completion system. Usually, ccoommppiinnssttaallll will insert code into ..zzsshhrrcc, although if that is not writable it will save it in another file and tell you that file's location. Note that it is up to you to make sure that the lines added to ..zzsshhrrcc are actually run; you may, for example, need to move them to an earlier place in the file if ..zzsshhrrcc usually returns early. So long as you keep them all together (including the comment lines at the start and finish), you can rerun ccoommppiinnssttaallll and it will correctly locate and

modify these lines. Note, however, that any code you add to this sec-

tion by hand is likely to be lost if you rerun ccoommppiinnssttaallll, although lines using the command `zzssttyyllee' should be gracefully handled. The new code will take effect next time you start the shell, or run

..zzsshhrrcc by hand; there is also an option to make them take effect imme-

diately. However, if ccoommppiinnssttaallll has removed definitions, you will need to restart the shell to see the changes.

To run ccoommppiinnssttaallll you will need to make sure it is in a directory men-

tioned in your ffppaatthh parameter, which should already be the case if zsh was properly configured as long as your startup files do not remove the appropriate directories from ffppaatthh. Then it must be autoloaded

(`aauuttoollooaadd -UU ccoommppiinnssttaallll' is recommended). You can abort the instal-

lation any time you are being prompted for information, and your ..zzsshhrrcc will not be altered at all; changes only take place right at the end, where you are specifically asked for confirmation. UUssee ooff ccoommppiinniitt This section describes the use of ccoommppiinniitt to initialize completion for the current session when called directly; if you have run ccoommppiinnssttaallll it will be called automatically from your ..zzsshhrrcc.

To initialize the system, the function ccoommppiinniitt should be in a direc-

tory mentioned in the ffppaatthh parameter, and should be autoloaded

(`aauuttoollooaadd -UU ccoommppiinniitt' is recommended), and then run simply as

`ccoommppiinniitt'. This will define a few utility functions, arrange for all

the necessary shell functions to be autoloaded, and will then re-define

all widgets that do completion to use the new system. If you use the

mmeennuu-sseelleecctt widget, which is part of the zzsshh//ccoommpplliisstt module, you

should make sure that that module is loaded before the call to ccoommppiinniitt

so that that widget is also re-defined. If completion styles (see

below) are set up to perform expansion as well as completion by

default, and the TAB key is bound to eexxppaanndd-oorr-ccoommpplleettee, ccoommppiinniitt will

rebind it to ccoommpplleettee-wwoorrdd; this is necessary to use the correct form

of expansion. Should you need to use the original completion commands, you can still bind keys to the old widgets by putting a `..' in front of the widget

name, e.g. `..eexxppaanndd-oorr-ccoommpplleettee'.

To speed up the running of ccoommppiinniitt, it can be made to produce a dumped configuration that will be read in on future invocations; this is the

default, but can be turned off by calling ccoommppiinniitt with the option -DD.

The dumped file is ..zzccoommppdduummpp in the same directory as the startup

files (i.e. $$ZZDDOOTTDDIIRR or $$HHOOMMEE); alternatively, an explicit file name

can be given by `ccoommppiinniitt -dd dumpfile'. The next invocation of

ccoommppiinniitt will read the dumped file instead of performing a full ini-

tialization. If the number of completion files changes, ccoommppiinniitt will recognise this and produce a new dump file. However, if the name of a function or the

arguments in the first line of a ##ccoommppddeeff function (as described below)

change, it is easiest to delete the dump file by hand so that ccoommppiinniitt

will re-create it the next time it is run. The check performed to see

if there are new functions can be omitted by giving the option -CC. In

this case the dump file will only be created if there isn't one already. The dumping is actually done by another function, ccoommppdduummpp, but you will only need to run this yourself if you change the configuration (e.g. using ccoommppddeeff) and then want to dump the new one. The name of the old dumped file will be remembered for this purpose. If the parameter ccoommppddiirr is set, ccoommppiinniitt uses it as a directory where completion functions can be found; this is only necessary if they are not already in the function search path. For security reasons ccoommppiinniitt also checks if the completion system would use files not owned by root or by the current user, or files in

directories that are world- or group-writable or that are not owned by

root or by the current user. If such files or directories are found, ccoommppiinniitt will ask if the completion system should really be used. To avoid these tests and make all files found be used without asking, use

the option -uu, and to make ccoommppiinniitt silently ignore all insecure files

and directories use the option -ii. This security check is skipped

entirely when the -CC option is given.

The security check can be retried at any time by running the function ccoommppaauuddiitt. This is the same check used by ccoommppiinniitt, but when it is executed directly any changes to ffppaatthh are made local to the function so they do not persist. The directories to be checked may be passed as arguments; if none are given, ccoommppaauuddiitt uses ffppaatthh and ccoommppddiirr to find

completion system directories, adding missing ones to ffppaatthh as neces-

sary. To force a check of exactly the directories currently named in ffppaatthh, set ccoommppddiirr to an empty string before calling ccoommppaauuddiitt or ccoommppiinniitt. AAuuttoollooaaddeedd ffiilleess The convention for autoloaded functions used in completion is that they

start with an underscore; as already mentioned, the ffppaatthh//FFPPAATTHH parame-

ter must contain the directory in which they are stored. If zzsshh was

properly installed on your system, then ffppaatthh//FFPPAATTHH automatically con-

tains the required directories for the standard functions. For incomplete installations, if ccoommppiinniitt does not find enough files beginning with an underscore (fewer than twenty) in the search path, it will try to find more by adding the directory ccoommppddiirr to the search

path. If that directory has a subdirectory named BBaassee, all subdirecto-

ries will be added to the path. Furthermore, if the subdirectory BBaassee has a subdirectory named CCoorree, ccoommppiinniitt will add all subdirectories of the subdirectories is to the path: this allows the functions to be in the same format as in the zzsshh source distribution. When ccoommppiinniitt is run, it searches all such files accessible via ffppaatthh//FFPPAATTHH and reads the first line of each of them. This line should contain one of the tags described below. Files whose first line does not start with one of these tags are not considered to be part of the completion system and will not be treated specially. The tags are:

##ccoommppddeeff names... [ -[[ppPP]] patterns... [ -NN names... ] ]

The file will be made autoloadable and the function defined in it will be called when completing names, each of which is either the name of a command whose arguments are to be completed or one

of a number of special contexts in the form -context- described

below.

Each name may also be of the form `cmd==service'. When complet-

ing the command cmd, the function typically behaves as if the command (or special context) service was being completed

instead. This provides a way of altering the behaviour of func-

tions that can perform many different completions. It is imple-

mented by setting the parameter $$sseerrvviiccee when calling the func-

tion; the function may choose to interpret this how it wishes, and simpler functions will probably ignore it.

If the ##ccoommppddeeff line contains one of the options -pp or -PP, the

words following are taken to be patterns. The function will be called when completion is attempted for a command or context

that matches one of the patterns. The options -pp and -PP are

used to specify patterns to be tried before or after other com-

pletions respectively. Hence -PP may be used to specify default

actions.

The option -NN is used after a list following -pp or -PP; it speci-

fies that remaining words no longer define patterns. It is pos-

sible to toggle between the three options as many times as nec-

essary.

##ccoommppddeeff -kk style key-sequences...

This option creates a widget behaving like the builtin widget

style and binds it to the given key-sequences, if any. The

style must be one of the builtin widgets that perform comple-

tion, namely ccoommpplleettee-wwoorrdd, ddeelleettee-cchhaarr-oorr-lliisstt, eexxppaanndd-oorr-ccoomm-

pplleettee, eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx, lliisstt-cchhooiicceess, mmeennuu-ccoommpplleettee,

mmeennuu-eexxppaanndd-oorr-ccoommpplleettee, or rreevveerrssee-mmeennuu-ccoommpplleettee. If the

zzsshh//ccoommpplliisstt module is loaded (see zshmodules(1)) the widget

mmeennuu-sseelleecctt is also available.

When one of the key-sequences is typed, the function in the file

will be invoked to generate the matches. Note that a key will

not be re-bound if if it already was (that is, was bound to

something other than uunnddeeffiinneedd-kkeeyy). The widget created has the

same name as the file and can be bound to any other keys using bbiinnddkkeeyy as usual.

##ccoommppddeeff -KK widget-name style key-sequences ...

This is similar to -kk except that only one key-sequences argu-

ment may be given for each widget-name style pair. However, the

entire set of three arguments may be repeated with a different

set of arguments. Note in particular that the widget-name must

be distinct in each set. If it does not begin with `' this

will be added. The widget-name should not clash with the name

of any existing widget: names based on the name of the function are most useful. For example,

##ccoommppddeeff -KK ffooooccoommpplleettee ccoommpplleettee-wwoorrdd ""^^XX^^CC"" \\

ffoooolliisstt lliisstt-cchhooiicceess ""^^XX^^DD""

(all on one line) defines a widget ffooooccoommpplleettee for completion, bound to `^^XX^^CC', and a widget ffoooolliisstt for listing, bound to `^^XX^^DD'.

##aauuttoollooaadd [ options ]

Functions with the ##aauuttoollooaadd tag are marked for autoloading but

are not otherwise treated specially. Typically they are to be called from within one of the completion functions. Any options supplied will be passed to the aauuttoollooaadd builtin; a typical use is ++XX to force the function to be loaded immediately. Note that

the -UU and -zz flags are always added implicitly.

The ## is part of the tag name and no white space is allowed after it.

The ##ccoommppddeeff tags use the ccoommppddeeff function described below; the main

difference is that the name of the function is supplied implicitly. The special contexts for which completion functions can be defined are:

-aarrrraayy-vvaalluuee-

The right hand side of an array-assignment (`ffoooo==((......))')

-bbrraaccee-ppaarraammeetteerr-

The name of a parameter expansion within braces (`$${{......}}')

-aassssiiggnn-ppaarraammeetteerr-

The name of a parameter in an assignment, i.e. on the left hand side of an `=='

-ccoommmmaanndd-

A word in command position

-ccoonnddiittiioonn-

A word inside a condition (`[[[[......]]]]')

-ddeeffaauulltt-

Any word for which no other completion is defined

-eeqquuaall-

A word beginning with an equals sign

-ffiirrsstt-

This is tried before any other completion function. The func-

tion called may set the ccoommppsskkiipp parameter to one of various

values: aallll: no further completion is attempted; a string con-

taining the substring ppaatttteerrnnss: no pattern completion functions will be called; a string containing ddeeffaauulltt: the function for

the `-ddeeffaauulltt-' context will not be called, but functions

defined for commands will

-mmaatthh- Inside mathematical contexts, such as `((((...))))'

-ppaarraammeetteerr-

The name of a parameter expansion (`$$......')

-rreeddiirreecctt-

The word after a redirection operator.

-ssuubbssccrriipptt-

The contents of a parameter subscript.

-ttiillddee-

After an initial tilde (`~~'), but before the first slash in the word.

-vvaalluuee-

On the right hand side of an assignment. Default implementations are supplied for each of these contexts. In

most cases the context -context- is implemented by a corresponding

function context, for example the context `-ttiillddee-' and the function

`ttiillddee').

The contexts -rreeddiirreecctt- and -vvaalluuee- allow extra context-specific infor-

mation. (Internally, this is handled by the functions for each context

calling the function ddiissppaattcchh.) The extra information is added sepa-

rated by commas.

For the -rreeddiirreecctt- context, the extra information is in the form `-rree-

ddiirreecctt-,,op,,command', where op is the redirection operator and command

is the name of the command on the line. If there is no command on the line yet, the command field will be empty.

For the -vvaalluuee- context, the form is `-vvaalluuee-,,name,,command', where name

is the name of the parameter. In the case of elements of an associa-

tive array, for example `aassssoocc==((kkeeyy <>', name is expanded to

`name-key'. In certain special contexts, such as completing after

`mmaakkee CCFFLLAAGGSS==', the command part gives the name of the command, here mmaakkee; otherwise it is empty.

It is not necessary to define fully specific completions as the func-

tions provided will try to generate completions by progressively

replacing the elements with `-ddeeffaauulltt-'. For example, when completing

after `ffoooo==<>', vvaalluuee will try the names `-vvaalluuee-,,ffoooo,,' (note the

empty command part), `-vvaalluuee-,,ffoooo,,-ddeeffaauulltt-'

and`-vvaalluuee-,,-ddeeffaauulltt-,,-ddeeffaauulltt-', in that order, until it finds a func-

tion to handle the context. As an example:

ccoommppddeeff ''ffiilleess -gg ""**..lloogg""'' ''-rreeddiirreecctt-,,22>>,,-ddeeffaauulltt-''

completes files matching `**..lloogg' after `22>> <>' for any command with no more specific handler defined. Also:

ccoommppddeeff ffoooo -vvaalluuee-,,-ddeeffaauulltt-,,-ddeeffaauulltt-

specifies that ffoooo provides completions for the values of parameters

for which no special function has been defined. This is usually han-

dled by the function vvaalluuee itself. The same lookup rules are used when looking up styles (as described below); for example

zzssttyyllee ''::ccoommpplleettiioonn::**::**::-rreeddiirreecctt-,,22>>,,**::**'' ffiillee-ppaatttteerrnnss ''**..lloogg''

is another way to make completion after `22>> <>' complete files matching `**..lloogg'. FFuunnccttiioonnss The following function is defined by ccoommppiinniitt and may be called directly.

ccoommppddeeff [ -aann ] function names... [ -[[ppPP]] patterns... [ -NN names... ] ]

ccoommppddeeff -dd names...

ccoommppddeeff -kk [ -aann ] function style key-sequences...

ccoommppddeeff -KK [ -aann ] function name style key-sequences ...

The first form defines the function to call for completion in

the given contexts as described for the ##ccoommppddeeff tag above.

Alternatively, all the arguments may have the form `cmd==ser-

vice'. Here service should already have been defined by

`cmd1==service' lines in ##ccoommppddeeff files, as described above. The

argument for cmd will be completed in the same way as service. The function argument may alternatively be a string containing any shell code. The string will be executed using the eevvaall builtin command to generate completions. This provides a way of

avoiding having to define a new completion function. For exam-

ple, to complete files ending in `..hh' as arguments to the com-

mand ffoooo:

ccoommppddeeff ''ffiilleess -gg ""**..hh""'' ffoooo

The option -nn prevents any completions already defined for the

command or context from being overwritten.

The option -dd deletes any completion defined for the command or

contexts listed.

The names may also contain -pp, -PP and -NN options as described

for the ##ccoommppddeeff tag. The effect on the argument list is iden-

tical, switching between definitions of patterns tried ini-

tially, patterns tried finally, and normal commands and con-

texts.

The parameter $$ccoommppsskkiipp may be set by any function defined for

a pattern context. If it is set to a value containing the sub-

string `ppaatttteerrnnss' none of the pattern-functions will be called;

if it is set to a value containing the substring `aallll', no other function will be called.

The form with -kk defines a widget with the same name as the

function that will be called for each of the key-sequences; this

is like the ##ccoommppddeeff -kk tag. The function should generate the

completions needed and will otherwise behave like the builtin widget whose name is given as the style argument. The widgets

usable for this are: ccoommpplleettee-wwoorrdd, ddeelleettee-cchhaarr-oorr-lliisstt,

eexxppaanndd-oorr-ccoommpplleettee, eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx, lliisstt-cchhooiicceess,

mmeennuu-ccoommpplleettee, mmeennuu-eexxppaanndd-oorr-ccoommpplleettee, and rreevveerrssee-mmeennuu-ccoomm-

pplleettee, as well as mmeennuu-sseelleecctt if the zzsshh//ccoommpplliisstt module is

loaded. The option -nn prevents the key being bound if it is

already to bound to something other than uunnddeeffiinneedd-kkeeyy.

The form with -KK is similar and defines multiple widgets based

on the same function, each of which requires the set of three

arguments name, style and key-sequences, where the latter two

are as for -kk and the first must be a unique widget name begin-

ning with an underscore.

Wherever applicable, the -aa option makes the function autoload-

able, equivalent to aauuttoollooaadd -UU function.

The function ccoommppddeeff can be used to associate existing completion func-

tions with new commands. For example, ccoommppddeeff ppiiddss ffoooo uses the function ppiiddss to complete process IDs for the command ffoooo. Note also the ggnnuuggeenneerriicc function described below, which can be used

to complete options for commands that understand the `--hheellpp' option.

CCOOMMPPLLEETTIIOONN SSYYSSTTEEMM CCOONNFFIIGGUURRAATTIIOONN This section gives a short overview of how the completion system works, and then more detail on how users can configure how and when matches are generated. OOvveerrvviieeww

When completion is attempted somewhere on the command line the comple-

tion system first works out the context. This takes account of a num-

ber of things including the command word (such as `ggrreepp' or `zzsshh') and

options to which the current word may be an argument (such as the `-oo'

option to zzsshh which takes a shell option as an argument).

This context information is condensed into a string consisting of mul-

tiple fields separated by colons, referred to simply as `the context' in the remainder of the documentation. This is used to look up styles,

context-sensitive options that can be used to configure the completion

system. The context used for lookup may vary during the same call to the completion system. The context string always consists of the following fields, separated by colons and with a leading colon before the first: +o The literal string ccoommpplleettiioonn, saying that this style is used by the completion system. This distinguishes the context from those used by, for example, zle widgets and ZFTP functions. +o The function, if completion is called from a named widget rather than through the normal completion system. Typically this is

blank, but it is set by special widgets such as pprreeddiicctt-oonn and

the various functions in the WWiiddggeett directory of the distribu-

tion to the name of that function, often in an abbreviated form. +o The completer currently active, the name of the function without the leading underscore. A `completer' is in overall control of how completion is to be performed; `ccoommpplleettee' is the simplest,

but other completers exist to perform related tasks such as cor-

rection, or to modify the behaviour of a later completer. See the section `Control Functions' below for more information.

+o The command or a special -context-, just at it appears following

the ##ccoommppddeeff tag or the ccoommppddeeff function. Completion functions

for commands that have sub-commands usually modify this field to

contain the name of the command followed by a minus sign and the

sub-command. For example, the completion function for the ccvvss

command sets this field to ccvvss-aadddd when completing arguments to

the aadddd subcommand.

+o The argument; this indicates which command line or option argu-

ment we are completing. For command arguments this generally

takes the form aarrgguummeenntt-n, where n is the number of the argu-

ment, and for arguments to options the form ooppttiioonn-opt-n where n

is the number of the argument to option opt. However, this is only the case if the command line is parsed with standard

UNIX-style options and arguments, so many completions do not set

this. +o The tag. Tags are used to discriminate between the types of matches a completion function can generate in a certain context and are described further below. As an example, the context name

::ccoommpplleettiioonn::::ccoommpplleettee::ddvviippss::ooppttiioonn-oo-11::ffiilleess

says that normal completion was attempted as the first argument to the

option -oo of the command ddvviippss:

ddvviippss -oo ......

and the completion function will generate filenames. Each type of completion the system can perform in a given context is described by a `tag', a short descriptive string such as ffiilleess in the example above. Any completion function may use any tag name it likes, but a list of the more common ones is given below. Usually completion will be tried by all possible tags in an order given by the completion function. However, this can be altered by using the

ttaagg-oorrddeerr style. Completion is then restricted to the list of given

tags in the given order. The ccoommpplleetteehheellpp bindable command shows all the contexts and tags available for completion at a particular point. This provides an easy

way of finding information for ttaagg-oorrddeerr and other styles. It is

described in the section `Bindable Commands' below.

Styles determine such things as how the matches are generated, simi-

larly to shell options but with much more control. They can have any number of strings as their value. They are defined with the zzssttyyllee builtin command (see zshmodules(1)). When looking up styles the completion system uses full context names, including the tag. Looking up the value of a style therefore consists of two things: the context, which may be matched as a pattern, and the name of the style itself, which must be given exactly. For example, many completion functions can generate matches in a simple and a verbose form and use the vveerrbboossee style to decide which form should be used. To make all such functions use the verbose form, put zzssttyyllee ''::ccoommpplleettiioonn::**'' vveerrbboossee yyeess in a startup file (probably ..zzsshhrrcc). This gives the vveerrbboossee style the value yyeess in every context inside the completion system, unless that context has a more specific definition. It is best to avoid giving the

context as `**' in case the style has some meaning outside the comple-

tion system. Many such general purpose styles can be configured simply by using the ccoommppiinnssttaallll function.

A more specific example of the use of the vveerrbboossee style is by the com-

pletion for the kkiillll builtin. If the style is set, the builtin lists full job texts and process command lines; otherwise it shows the bare job numbers and PIDs. To turn the style off for this use only: zzssttyyllee ''::ccoommpplleettiioonn::**::**::kkiillll::**'' vveerrbboossee nnoo For even more control, the style can use one of the tags `jjoobbss' or `pprroocceesssseess'. To turn off verbose display only for jobs: zzssttyyllee ''::ccoommpplleettiioonn::**::**::kkiillll::**::jjoobbss'' vveerrbboossee nnoo

The -ee option to zzssttyyllee even allows completion function code to appear

as the argument to a style; this requires some understanding of the

internals of completion functions (see see zshcompwid(1))). For exam-

ple:

zzssttyyllee -ee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ''

iiff [[[[ $$wwoorrddss[[11]] == ccvvss ]]]];; tthheenn

rreeppllyy==((ccoommpplleettee)) eellssee rreeppllyy==((ccoommpplleettee aapppprrooxxiimmaattee)) ffii'' uses the value `ccoommpplleettee' for the ccoommpplleetteerr style in most contexts,

but the value `ccoommpplleettee aapppprrooxxiimmaattee' when the first word on the com-

mand line is `ccvvss'. This is probably more conveniently done by speci-

fying the style for two different contexts. This form can be slow and should be avoided for commonly examined styles such as mmeennuu and

lliisstt-rroowwss-ffiirrsstt.

Note that the order in which styles are defined does not matter; the style mechanism uses the most specific possible match for a particular

style to determine the set of values. More precisely, strings are pre-

ferred over patterns (for example, `::ccoommpplleettiioonn::::ccoommpplleettee::ffoooo' is more

specific than `::ccoommpplleettiioonn::::ccoommpplleettee::**''), and longer patterns are pre-

ferred over shorter patterns.

Style names like those of tags are arbitrary and depend on the comple-

tion function. However, the following two sections list some of the most common tags and styles. SSttaannddaarrdd TTaaggss Some of the following are only used when looking up particular styles and do not refer to a type of match. aaccccoouunnttss

used to look up the uusseerrss-hhoossttss style

aallll-eexxppaannssiioonnss

used by the eexxppaanndd completer when adding the single string con-

taining all possible expansions

aallll-ffiilleess

for the names of all files (as distinct from a particular sub-

set, see the gglloobbbbeedd-ffiilleess tag).

aarrgguummeennttss for arguments to a command aarrrraayyss for names of array parameters

aassssoocciiaattiioonn-kkeeyyss

for keys of associative arrays; used when completing inside a subscript to a parameter of this type bbooookkmmaarrkkss when completing bookmarks (e.g. for URLs and the zzffttpp function suite) bbuuiillttiinnss for names of builtin commands cchhaarraacctteerrss for single characters in arguments of commands such as ssttttyy. Also used when completing character classes after an opening bracket ccoolloorrmmaappiiddss for X colormap ids ccoolloorrss for color names ccoommmmaannddss for names of external commands. Also used by complex commands such as ccvvss when completing names subcommands. ccoonntteexxttss for contexts in arguments to the zzssttyyllee builtin command ccoorrrreeccttiioonnss used by the aapppprrooxxiimmaattee and ccoorrrreecctt completers for possible corrections ccuurrssoorrss for cursor names used by X programs ddeeffaauulltt used in some contexts to provide a way of supplying a default when more specific tags are also valid. Note that this tag is used when only the function field of the context name is set ddeessccrriippttiioonnss used when looking up the value of the ffoorrmmaatt style to generate descriptions for types of matches ddeevviicceess for names of device special files ddiirreeccttoorriieess for names of directories

ddiirreeccttoorryy-ssttaacckk

for entries in the directory stack ddiissppllaayyss for X display names ddoommaaiinnss for network domains eexxppaannssiioonnss used by the eexxppaanndd completer for individual words (as opposed to the complete set of expansions) resulting from the expansion of a word on the command line eexxtteennssiioonnss for X server extensions

ffiillee-ddeessccrriippttoorrss

for numbers of open file descriptors

ffiilleess the generic file-matching tag used by functions completing file-

names ffoonnttss for X font names ffssttyyppeess for file system types (e.g. for the mmoouunntt command) ffuunnccttiioonnss

names of functions -- normally shell functions, although cer-

tain commands may understand other kinds of function

gglloobbbbeedd-ffiilleess

for filenames when the name has been generated by pattern match-

ing ggrroouuppss for names of user groups

hhiissttoorryy-wwoorrddss

for words from the history hhoossttss for hostnames iinnddeexxeess for array indexes jjoobbss for jobs (as listed by the `jjoobbss' builtin) iinntteerrffaacceess for network interfaces kkeeyymmaappss for names of zsh keymaps kkeeyyssyymmss for names of X keysyms lliibbrraarriieess for names of system libraries lliimmiittss for system limits

llooccaall-ddiirreeccttoorriieess

for names of directories that are subdirectories of the current working directory when completing arguments of ccdd and related

builtin commands (compare ppaatthh-ddiirreeccttoorriieess)

mmaannuuaallss for names of manual pages mmaaiillbbooxxeess

for e-mail folders

mmaappss for map names (e.g. NIS maps) mmeessssaaggeess used to look up the ffoorrmmaatt style for messages mmooddiiffiieerrss for names of X modifiers mmoodduulleess for modules (e.g. zzsshh modules)

mmyy-aaccccoouunnttss

used to look up the uusseerrss-hhoossttss style

nnaammeedd-ddiirreeccttoorriieess

for named directories (you wouldn't have guessed that, would you?) nnaammeess for all kinds of names nneewwssggrroouuppss for USENET groups nniicckknnaammeess for nicknames of NIS maps ooppttiioonnss for command options oorriiggiinnaall used by the aapppprrooxxiimmaattee, ccoorrrreecctt and eexxppaanndd completers when offering the original string as a match

ootthheerr-aaccccoouunnttss

used to look up the uusseerrss-hhoossttss style

ppaacckkaaggeess for packages (e.g. rrppmm or installed DDeebbiiaann packages) ppaarraammeetteerrss for names of parameters

ppaatthh-ddiirreeccttoorriieess

for names of directories found by searching the ccddppaatthh array when completing arguments of ccdd and related builtin commands

(compare llooccaall-ddiirreeccttoorriieess)

ppaatthhss used to look up the values of the eexxppaanndd, aammbbiigguuoouuss and ssppee-

cciiaall-ddiirrss styles

ppooddss for perl pods (documentation files) ppoorrttss for communication ports pprreeffiixxeess for prefixes (like those of a URL) pprriinntteerrss for print queue names pprroocceesssseess for process identifiers

pprroocceesssseess-nnaammeess

used to look up the ccoommmmaanndd style when generating the names of processes for kkiillllaallll sseeqquueenncceess for sequences (e.g. mmhh sequences) sseessssiioonnss for sessions in the zzffttpp function suite ssiiggnnaallss for signal names ssttrriinnggss for strings (e.g. the replacement strings for the ccdd builtin command) ssttyylleess for styles used by the zstyle builtin command ssuuffffiixxeess for filename extensions ttaaggss for tags (e.g. rrppmm tags) ttaarrggeettss for makefile targets

ttiimmee-zzoonneess

for time zones (e.g. when setting the TTZZ parameter) ttyyppeess for types of whatever (e.g. address types for the xxhhoosstt command) uurrllss used to look up the uurrllss and llooccaall styles when completing URLs uusseerrss for usernames vvaalluueess for one of a set of values in certain lists vvaarriiaanntt

used by ppiicckkvvaarriiaanntt to look up the command to run when deter-

mining what program is installed for a particular command name. vviissuuaallss for X visuals wwaarrnniinnggss used to look up the ffoorrmmaatt style for warnings wwiiddggeettss for zsh widget names wwiinnddoowwss for IDs of X windows

zzsshh-ooppttiioonnss

for shell options SSttaannddaarrdd SSttyylleess

Note that the values of several of these styles represent boolean val-

ues. Any of the strings `ttrruuee', `oonn', `yyeess', and `11' can be used for the value `true' and any of the strings `ffaallssee', `ooffff', `nnoo', and `00' for the value `false'. The behavior for any other value is undefined except where explicitly mentioned. The default value may be either true or false if the style is not set.

Some of these styles are tested first for every possible tag corre-

sponding to a type of match, and if no style was found, for the ddeeffaauulltt

tag. The most notable styles of this type are mmeennuu, lliisstt-ccoolloorrss and

styles controlling completion listing such as lliisstt-ppaacckkeedd and

llaasstt-pprroommpptt). When tested for the ddeeffaauulltt tag, only the function field

of the context will be set so that a style using the default tag will normally be defined along the lines of: zzssttyyllee ''::ccoommpplleettiioonn::**::ddeeffaauulltt'' mmeennuu ......

aacccceepptt-eexxaacctt

This is tested for the default tag in addition to the tags valid for the current context. If it is set to `true' and any of the trial matches is the same as the string on the command line,

this match will immediately be accepted (even if it would other-

wise be considered ambiguous). When completing pathnames (where the tag used is `ppaatthhss') this style accepts any number of patterns as the value in addition to the boolean values. Pathnames matching one of these patterns will be accepted immediately even if the command line contains some more partially typed pathname components and these match no file under the directory accepted. This style is also used by the eexxppaanndd completer to decide if words beginning with a tilde or parameter expansion should be expanded. For example, if there are parameters ffoooo and ffoooobbaarr,

the string `$$ffoooo' will only be expanded if aacccceepptt-eexxaacctt is set

to `true'; otherwise the completion system will be allowed to

complete $$ffoooo to $$ffoooobbaarr. If the style is set to `continue',

expand will add the expansion as a match and the completion system will also be allowed to continue.

aadddd-ssppaaccee

This style is used by the eexxppaanndd completer. If it is true (the default), a space will be inserted after all words resulting from the expansion, or a slash in the case of directory names. If the value is `ffiillee', the completer will only add a space to names of existing files. Either a boolean true or the value `ffiillee' may be combined with `ssuubbsstt', in which case the completer will not add a space to words generated from the expansion of a

substitution of the form `$$((......))' or `$${{......}}'.

The pprreeffiixx completer uses this style as a simple boolean value to decide if a space should be inserted before the suffix. aammbbiigguuoouuss

This applies when completing non-final components of filename

paths, in other words those with a trailing slash. If it is set, the cursor is left after the first ambiguous component, even if menu completion is in use. The style is always tested with the ppaatthhss tag.

aassssiiggnn-lliisstt

When completing after an equals sign that is being treated as an assignment, the completion system normally completes only one filename. In some cases the value may be a list of filenames separated by colons, as with PPAATTHH and similar parameters. This style can be set to a list of patterns matching the names of such parameters. The default is to complete lists when the word on the line already contains a colon.

aauuttoo-ddeessccrriippttiioonn

If set, this style's value will be used as the description for options that are not described by the completion functions, but

that have exactly one argument. The sequence `%%dd' in the value

will be replaced by the description for this argument. Depend-

ing on personal preferences, it may be useful to set this style

to something like `ssppeecciiffyy:: %%dd'. Note that this may not work

for some commands.

aavvooiidd-ccoommpplleetteerr

This is used by the aallllmmaattcchheess completer to decide if the string consisting of all matches should be added to the list

currently being generated. Its value is a list of names of com-

pleters. If any of these is the name of the completer that gen-

erated the matches in this completion, the string will not be added. The default value for this style is `eexxppaanndd oollddlliisstt ccoorrrreecctt aapppprrooxxiimmaattee', i.e. it contains the completers for which a string with all matches will almost never be wanted.

ccaacchhee-ppaatthh

This style defines the path where any cache files containing

dumped completion data are stored. It defaults to `$$ZZDDOOTT-

DDIIRR//..zzccoommppccaacchhee', or `$$HHOOMMEE//..zzccoommppccaacchhee' if $$ZZDDOOTTDDIIRR is not

defined. The completion cache will not be used unless the

uussee-ccaacchhee style is set.

ccaacchhee-ppoolliiccyy

This style defines the function that will be used to determine whether a cache needs rebuilding. See the section on the ccaacchheeiinnvvaalliidd function below.

ccaallll-ccoommmmaanndd

This style is used in the function for commands such as mmaakkee and

aanntt where calling the command directly to generate matches suf-

fers problems such as being slow or, as in the case of mmaakkee can potentially causes actions in the makefile to be executed. If it is set to `true' the command is called to generate matches. The default value of this style is `false'. ccoommmmaanndd

In many places, completion functions need to call external com-

mands to generate the list of completions. This style can be used to override the command that is called in some such cases.

The elements of the value are joined with spaces to form a com-

mand line to execute. The value can also start with a hyphen, in which case the usual command will be added to the end; this is most useful for putting `bbuuiillttiinn' or `ccoommmmaanndd' in front to make sure the appropriate version of a command is called, for example to avoid calling a shell function with the same name as an external command. As an example, the completion function for process IDs uses this style with the pprroocceesssseess tag to generate the IDs to complete and the list of processes to display (if the vveerrbboossee style is `true'). The list produced by the command should look like the output of the ppss command. The first line is not displayed, but is searched for the string `PPIIDD' (or `ppiidd') to find the position of the process IDs in the following lines. If the line does not contain `PPIIDD', the first numbers in each of the other lines are taken as the process IDs to complete. Note that the completion function generally has to call the specified command for each attempt to generate the completion list. Hence care should be taken to specify only commands that take a short time to run, and in particular to avoid any that may never terminate.

ccoommmmaanndd-ppaatthh

This is a list of directories to search for commands to com-

plete. The default for this style is the value of the special parameter ppaatthh. ccoommmmaannddss

This is used by the function completing sub-commands for the

system initialisation scripts (residing in //eettcc//iinniitt..dd or some-

where not too far away from that). Its values give the default commands to complete for those commands for which the completion function isn't able to find them out automatically. The default for this style are the two strings `ssttaarrtt' and `ssttoopp'. ccoommpplleettee This is used by the eexxppaannddaalliiaass function when invoked as a

bindable command. If it set to `true' and the word on the com-

mand line is not the name of an alias, matching alias names will be completed. ccoommpplleetteerr The strings given as the value of this style provide the names

of the completer functions to use. The available completer func-

tions are described in the section `Control Functions' below. Each string may be either the name of a completer function or a

string of the form `function::name'. In the first case the com-

pleter field of the context will contain the name of the com-

pleter without the leading underscore and with all other under-

scores replaced by hyphens. In the second case the function is the name of the completer to call, but the context will contain

the user-defined name in the completer field of the context. If

the name starts with a hyphen, the string for the context will be build from the name of the completer function as in the first case with the name appended to it. For example:

zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ccoommpplleettee ccoommpplleettee::-ffoooo

Here, completion will call the ccoommpplleettee completer twice, once

using `ccoommpplleettee' and once using `ccoommpplleettee-ffoooo' in the completer

field of the context. Normally, using the same completer more than once only makes sense when used with the `functions::name' form, because otherwise the context name will be the same in all calls to the completer; possible exceptions to this rule are the iiggnnoorreedd and pprreeffiixx completers. The default value for this style is `ccoommpplleettee iiggnnoorreedd': only

completion will be done, first using the iiggnnoorreedd-ppaatttteerrnnss style

and the $$ffiiggnnoorree array and then without ignoring matches.

ccoonnddiittiioonn This style is used by the lliisstt completer function to decide if insertion of matches should be delayed unconditionally. The default is `true'. ddiissaabblleedd

If this is set to `true', the eexxppaannddaalliiaass completer and bind-

able command will try to expand disabled aliases, too. The default is `ffaallssee'.

ddiissaabbllee-ssttaatt

This is used with an empty tag by the ccvvss function to decide whether the zzsshh//ssttaatt module should be used to generate names of modified files in the appropriate places (this is its only use). If the style is set, completion will use the llss command. ddoommaaiinnss A list of names of network domains for completion. If this is not set, domain names will be taken from the file //eettcc//rreessoollvv..ccoonnff.

eexxppaanndd This style is used when completing strings consisting of multi-

ple parts, such as path names. If one of its values is the string `pprreeffiixx', the partially typed word from the line will be expanded as far as possible even if trailing parts cannot be completed. If one of its values is the string `ssuuffffiixx', matching names for components after the first ambiguous one will also be added. This means that the resulting string is the longest unambiguous string possible. However, menu completion can be used to cycle through all matches. ffaakkee This style may be set for any completion context. It specifies

additional strings that will always be completed in that con-

text. The form of each string is `value::description'; the colon and description may be omitted, but any literal colons in value must be quoted with a backslash. Any description provided is shown alongside the value in completion listings. It is important to use a sufficiently restrictive context when

specifying fake strings. Note that the styles ffaakkee-ffiilleess and

ffaakkee-ppaarraammeetteerrss provide additional features when completing

files or parameters.

ffaakkee-ffiilleess

This style is used when completing files and looked up without a tag. Its values are of the form `dir::names...'. This will add the names (strings separated by spaces) as possible matches when completing in the directory dir, even if no such files really exist. This can be useful on systems that support special filesystems

whose top-level pathnames can not be listed or generated with

glob patterns. It can also be used for directories for which one does not have read permission.

ffaakkee-ppaarraammeetteerrss

This is used by the completion function for parameter names. Its values are names of parameters that might not yet be set but should be completed nonetheless. Each name may also be followed by a colon and a string specifying the type of the parameter (like `ssccaallaarr', `aarrrraayy' or `iinntteeggeerr'). If the type is given, the name will only be completed if parameters of that type are required in the particular context. Names for which no type is specified will always be completed.

ffiillee-ppaatttteerrnnss

This is used by the standard function for completing filenames, ffiilleess. If the style is unset up to three tags are offered,

`gglloobbbbeedd-ffiilleess',`ddiirreeccttoorriieess' and `aallll-ffiilleess', depending on the

types of files expected by the caller of ffiilleess. The first two

(`gglloobbbbeedd-ffiilleess' and `ddiirreeccttoorriieess') are normally offered

together to make it easier to complete files in sub-directories.

The ffiillee-ppaatttteerrnnss style provides alternatives to the default

tags, which are not used. Its value consists of elements of the form `pattern::tag'; each string may contain any number of such specifications separated by spaces.

The pattern is a pattern that is to be used to generate file-

names. Any occurrence of the sequence `%%pp' is replaced by any

pattern(s) passed by the function calling ffiilleess. Colons in the

pattern must be preceded by a backslash to make them distin-

guishable from the colon before the tag. If more than one pat-

tern is needed, the patterns can be given inside braces, sepa-

rated by commas. The tags of all strings in the value will be offered by ffiilleess and used when looking up other styles. Any tags in the same word will be offered at the same time and before later words. If no `::tag' is given the `ffiilleess' tag will be used. The tag may also be followed by an optional second colon and a

description, which will be used for the `%%dd' in the value of the

ffoorrmmaatt style (if that is set) instead of the default description supplied by the completion function. If the description given

here contains itself a `%%dd', that is replaced with the descrip-

tion supplied by the completion function. For example, to make the rrmm command first complete only names of object files and then the names of all files if there is no matching object file:

zzssttyyllee ''::ccoommpplleettiioonn::**::**::rrmm::**'' ffiillee-ppaatttteerrnnss \\

''**..oo::oobbjjeecctt-ffiilleess'' ''%%pp::aallll-ffiilleess''

To alter the default behaviour of file completion -- offer

files matching a pattern and directories on the first attempt,

then all files -- to offer only matching files on the first

attempt, then directories, and finally all files:

zzssttyyllee ''::ccoommpplleettiioonn::**'' ffiillee-ppaatttteerrnnss \\

''%%pp::gglloobbbbeedd-ffiilleess'' ''**((-//))::ddiirreeccttoorriieess'' ''**::aallll-ffiilleess''

This works even where there is no special pattern: ffiilleess matches all files using the pattern `**' at the first step and stops when it sees this pattern. Note also it will never try a pattern more than once for a single completion attempt. During the execution of completion functions, the EEXXTTEENNDDEEDDGGLLOOBB

option is in effect, so the characters `##', `~~' and `^^' have

special meanings in the patterns.

ffiillee-ssoorrtt

The standard filename completion function uses this style with-

out a tag to determine in which order the names should be listed; menu completion will cycle through them in the same order. The possible values are: `ssiizzee' to sort by the size of the file; `lliinnkkss' to sort by the number of links to the file;

`mmooddiiffiiccaattiioonn' (or `ttiimmee' or `ddaattee') to sort by the last modifi-

cation time; `aacccceessss' to sort by the last access time; and `iinnooddee' (or `cchhaannggee') to sort by the last inode change time. If the style is set to any other value, or is unset, files will be sorted alphabetically by name. If the value contains the string `rreevveerrssee', sorting is done in the opposite order.

ffiilltteerr This is used by the LDAP plugin for e-mail address completion to

specify the attributes to match against when filtering entries. So for example, if the style is set to `ssnn', matching is done against surnames. Standard LDAP filtering is used so normal completion matching is bypassed. If this style is not set, the LDAP plugin is skipped. You may also need to set the ccoommmmaanndd style to specify how to connect to your LDAP server.

ffoorrccee-lliisstt

This forces a list of completions to be shown at any point where listing is done, even in cases where the list would usually be suppressed. For example, normally the list is only shown if there are at least two different matches. By setting this style to `aallwwaayyss', the list will always be shown, even if there is only a single match that will immediately be accepted. The style may also be set to a number. In this case the list will be shown if there are at least that many matches, even if they would all insert the same string. This style is tested for the default tag as well as for each tag valid for the current completion. Hence the listing can be forced only for certain types of match. ffoorrmmaatt If this is set for the ddeessccrriippttiioonnss tag, its value is used as a string to display above matches in completion lists. The

sequence `%%dd' in this string will be replaced with a short

description of what these matches are. This string may also contain the sequences to specify output attributes, such as

`%%BB', `%%SS' and `%%{{...%%}}'.

The style is tested with each tag valid for the current comple-

tion before it is tested for the ddeessccrriippttiioonnss tag. Hence dif-

ferent format strings can be defined for different types of match. Note also that some completer functions define additional

`%%'-sequences. These are described for the completer functions

that make use of them.

Some completion functions display messages that may be cus-

tomised by setting this style for the mmeessssaaggeess tag. Here, the

`%%dd' is replaced with a message given by the completion func-

tion. Finally, the format string is looked up with the wwaarrnniinnggss tag, for use when no matches could be generated at all. In this case

the `%%dd' is replaced with the descriptions for the matches that

were expected separated by spaces. The sequence `%%DD' is

replaced with the same descriptions separated by newlines.

It is possible to use printf-style field width specifiers with

`%%dd' and similar escape sequences. This is handled by the zzffoorr-

mmaatt builtin command from the zzsshh//zzuuttiill module, see zshmod-

ules(1). gglloobb This is used by the eexxppaanndd completer. If it is set to `true' (the default), globbing will be attempted on the words resulting from a previous substitution (see the ssuubbssttiittuuttee style) or else the original string from the line.

gglloobbaall If this is set to `true' (the default), the eexxppaannddaalliiaass com-

pleter and bindable command will try to expand global aliases.

ggrroouupp-nnaammee

The completion system can group different types of matches, which appear in separate lists. This style can be used to give

the names of groups for particular tags. For example, in com-

mand position the completion system generates names of builtin and external commands, names of aliases, shell functions and parameters and reserved words as possible completions. To have the external commands and shell functions listed separately:

zzssttyyllee ''::ccoommpplleettiioonn::**::**::-ccoommmmaanndd-::**::ccoommmmaannddss'' ggrroouupp-nnaammee ccoommmmaannddss

zzssttyyllee ''::ccoommpplleettiioonn::**::**::-ccoommmmaanndd-::**::ffuunnccttiioonnss'' ggrroouupp-nnaammee ffuunnccttiioonnss

As a consequence, any match with the same tag will be displayed in the same group. If the name given is the empty string the name of the tag for the matches will be used as the name of the group. So, to have all different types of matches displayed separately, one can just set:

zzssttyyllee ''::ccoommpplleettiioonn::**'' ggrroouupp-nnaammee ''''

All matches for which no group name is defined will be put in a

group named -ddeeffaauulltt-.

ggrroouupp-oorrddeerr

This style is additional to the ggrroouupp-nnaammee style to specify the

order for display of the groups defined by that style (compare

ttaagg-oorrddeerr, which determines which completions appear at all).

The groups named are shown in the given order; any other groups are shown in the order defined by the completion function. For example, to have names of builtin commands, shell functions and external commands appear in that order when completing in command position:

zzssttyyllee ''::ccoommpplleettiioonn::**::**::-ccoommmmaanndd-::**'' ggrroouupp-oorrddeerr \\

bbuuiillttiinnss ffuunnccttiioonnss ccoommmmaannddss ggrroouuppss A list of names of UNIX groups. If this is not set, group names are taken from the YP database or the file `//eettcc//ggrroouupp'. hhiiddddeenn If this is set to true, matches for the given context will not be listed, although any description for the matches set with the ffoorrmmaatt style will be shown. If it is set to `aallll', not even the description will be displayed. Note that the matches will still be completed; they are just not

shown in the list. To avoid having matches considered as possi-

ble completions at all, the ttaagg-oorrddeerr style can be modified as

described below. hhoossttss A list of names of hosts that should be completed. If this is not set, hostnames are taken from the file `//eettcc//hhoossttss'.

hhoossttss-ppoorrttss

This style is used by commands that need or accept hostnames and network ports. The strings in the value should be of the form `host::port'. Valid ports are determined by the presence of hostnames; multiple ports for the same host may appear.

iiggnnoorree-lliinnee

This is tested for each tag valid for the current completion. If it is set to `ttrruuee', none of the words that are already on the line will be considered as possible completions. If it is

set to `ccuurrrreenntt', the word the cursor is on will not be consid-

ered as a possible completion. The value `ccuurrrreenntt-sshhoowwnn' is

similar but only applies if the list of completions is currently shown on the screen. Finally, if the style is set to `ootthheerr',

no word apart from the current one will be considered as a pos-

sible completion.

The values `ccuurrrreenntt' and `ccuurrrreenntt-sshhoowwnn' are a bit like the

opposite of the aacccceepptt-eexxaacctt style: only strings with missing

characters will be completed. Note that you almost certainly don't want to set this to `true' or `ootthheerr' for a general context such as `::ccoommpplleettiioonn::**'. This is because it would disallow completion of, for example, options multiple times even if the command in question accepts the option more than once.

iiggnnoorree-ppaarreennttss

The style is tested without a tag by the function completing pathnames in order to determine whether to ignore the names of directories already mentioned in the current word, or the name of the current working directory. The value must include one or both of the following strings: ppaarreenntt The name of any directory whose path is already contained in the word on the line is ignored. For example, when completing after ffoooo//....//, the directory ffoooo will not be considered a valid completion. ppwwdd The name of the current working directory will not be completed; hence, for example, completion after ....// will not use the name of the current directory. In addition, the value may include one or both of: .... Ignore the specified directories only when the word on the line contains the substring `....//'. ddiirreeccttoorryy Ignore the specified directories only when names of directories are completed, not when completing names of files. Excluded values act in a similar fashion to values of the

iiggnnoorreedd-ppaatttteerrnnss style, so they can be restored to consideration

by the iiggnnoorreedd completer.

iiggnnoorreedd-ppaatttteerrnnss

A list of patterns; any trial completion matching one of the

patterns will be excluded from consideration. The iiggnnoorreedd com-

pleter can appear in the list of completers to restore the ignored matches. This is a more configurable version of the

shell parameter $$ffiiggnnoorree.

Note that the EEXXTTEENNDDEEDDGGLLOOBB option is set during the execution

of completion functions, so the characters `##', `~~' and `^^' have

special meanings in the patterns. iinnsseerrtt This style is used by the aallllmmaattcchheess completer to decide whether to insert the list of all matches unconditionally instead of adding the list as another match.

iinnsseerrtt-iiddss

When completing process IDs, for example as arguments to the kkiillll and wwaaiitt builtins the name of a command may be converted to the appropriate process ID. A problem arises when the process name typed is not unique. By default (or if this style is set explicitly to `mmeennuu') the name will be converted immediately to a set of possible IDs, and menu completion will be started to cycle through them. If the value of the style is `ssiinnggllee', the shell will wait until

the user has typed enough to make the command unique before con-

verting the name to an ID; attempts at completion will be unsuc-

cessful until that point. If the value is any other string, menu completion will be started when the string typed by the user is longer than the common prefix to the corresponding IDs.

iinnsseerrtt-ttaabb

If this is set to `true', the completion system will insert a TAB character (assuming that was used to start completion)

instead of performing completion when there is no non-blank

character to the left of the cursor. If it is set to `false', completion will be done even there.

The value may also contain the substrings `ppeennddiinngg' or `ppeenndd-

iinngg==val'. In this case, the typed character will be inserted instead of staring completion when there is unprocessed input pending. If a val is given, completion will not be done if there are at least that many characters of unprocessed input. This is often useful when pasting characters into a terminal.

Note however, that it relies on the $$PPEENNDDIINNGG special parameter

from the zzsshh//zzllee module being set properly which is not guaran-

teed on all platforms. The default value of this style is `true' except for completion within vvaarreedd builtin command where it is `false'.

iinnsseerrtt-uunnaammbbiigguuoouuss

This is used by the mmaattcchh and aapppprrooxxiimmaattee completers. These completers are often used with menu completion since the word

typed may bear little resemblance to the final completion. How-

ever, if this style is `true', the completer will start menu completion only if it could find no unambiguous initial string at least as long as the original string typed by the user. In the case of the aapppprrooxxiimmaattee completer, the completer field

in the context will already have been set to one of ccoorrrreecctt-num

or aapppprrooxxiimmaattee-num, where num is the number of errors that were

accepted. In the case of the mmaattcchh completer, the style may also be set to the string `ppaatttteerrnn'. Then the pattern on the line is left unchanged if it does not match unambiguously.

kkeeeepp-pprreeffiixx

This style is used by the eexxppaanndd completer. If it is `true', the completer will try to keep a prefix containing a tilde or parameter expansion. Hence, for example, the string `~~//ff**' would be expanded to `~~//ffoooo' instead of `//hhoommee//uusseerr//ffoooo'. If the style is set to `cchhaannggeedd' (the default), the prefix will only be left unchanged if there were other changes between the expanded words and the original word from the command line. Any other value forces the prefix to be expanded unconditionally. The behaviour of expand when this style is true is to cause eexxppaanndd to give up when a single expansion with the restored

prefix is the same as the original; hence any remaining com-

pleters may be called.

llaasstt-pprroommpptt

This is a more flexible form of the AALLWWAAYYSSLLAASSTTPPRROOMMPPTT option.

If it is true, the completion system will try to return the cur-

sor to the previous command line after displaying a completion

list. It is tested for all tags valid for the current comple-

tion, then the ddeeffaauulltt tag. The cursor will be moved back to the previous line if this style is `true' for all types of match. Note that unlike the AALLWWAAYYSSLLAASSTTPPRROOMMPPTT option this is independent of the numeric prefix argument.

lliisstt This style is used by the hhiissttoorryyccoommpplleetteewwoorrdd bindable com-

mand. If it is set to `true' it has no effect. If it is set to `false' matches will not be listed. This overrides the setting of the options controlling listing behaviour, in particular

AAUUTTOOLLIISSTT. The context always starts with `::ccoommpplleettiioonn::hhiiss-

ttoorryy-wwoorrddss'.

lliisstt-ccoolloorrss

If the zzsshh//ccoommpplliisstt module is loaded, this style can be used to set color specifications. This mechanism replaces the use of

the ZZLLSSCCOOLLOORRSS and ZZLLSSCCOOLLOOUURRSS parameters described in the sec-

tion `The zsh/complist Module' in zshmodules(1), but the syntax is the same. If this style is set for the ddeeffaauulltt tag, the strings in the

value are taken as specifications that are to be used every-

where. If it is set for other tags, the specifications are used only for matches of the type described by the tag. For this to

work best, the ggrroouupp-nnaammee style must be set to an empty string.

In addition to setting styles for specific tags, it is also pos-

sible to use group names specified explicitly by the ggrroouupp-nnaammee

tag together with the `((ggrroouupp))' syntax allowed by the ZZLLSSCCOOLLOORRSS and ZZLLSSCCOOLLOOUURRSS parameters and simply using the ddeeffaauulltt tag. It is possible to use any color specifications already set up for the GNU version of the llss command:

zzssttyyllee ''::ccoommpplleettiioonn::**::ddeeffaauulltt'' lliisstt-ccoolloorrss $${{((ss..::..))LLSSCCOOLLOORRSS}}

The default colors are the same as for the GNU llss command and can be obtained by setting the style to an empty string (i.e. '''').

lliisstt-ggrroouuppeedd

If this style is `true' (the default), the completion system will try to make certain completion listings more compact by grouping matches. For example, options for commands that have the same description (shown when the vveerrbboossee style is set to `true') will appear as a single entry. However, menu selection can be used to cycle through all the matches.

lliisstt-ppaacckkeedd

This is tested for each tag valid in the current context as well as the ddeeffaauulltt tag. If it is set to `true', the corresponding matches appear in listings as if the LLIISSTTPPAACCKKEEDD option were set. If it is set to `false', they are listed normally.

lliisstt-pprroommpptt

If this style is set for the ddeeffaauulltt tag, completion lists that don't fit on the screen can be scrolled (see the description of the zzsshh//ccoommpplliisstt module in zshmodules(1)). The value, if not the empty string, will be displayed after every screenful and the shell will prompt for a key press; if the style is set to the empty string, a default prompt will be used.

The value may contain the escape sequences: `%%ll' or `%%LL', which

will be replaced by the number of the last line displayed and

the total number of lines; `%%mm' or `%%MM', the number of the last

match shown and the total number of matches; and `%%pp' and `%%PP',

`TToopp' when at the beginning of the list, `BBoottttoomm' when at the end and the position shown as a percentage of the total length otherwise. In each case the form with the uppercase letter will be replaced by a string of fixed width, padded to the right with spaces, while the lowercase form will be replaced by a variable width string. As in other prompt strings, the escape

sequences `%%SS', `%%ss', `%%BB', `%%bb', `%%UU', `%%uu' for entering and

leaving the display modes standout, bold and underline are also

available, as is the form `%%{{...%%}}' for enclosing escape

sequences which display with zero width.

lliisstt-rroowwss-ffiirrsstt

This style is tested in the same way as the lliisstt-ppaacckkeedd style

and determines whether matches are to be listed in a rows-first

fashion as if the LLIISSTTRROOWWSSFFIIRRSSTT option were set.

lliisstt-ssuuffffiixxeess

This style is used by the function that completes filenames. If it is true, and completion is attempted on a string containing

multiple partially typed pathname components, all ambiguous com-

ponents will be shown. Otherwise, completion stops at the first ambiguous component.

lliisstt-sseeppaarraattoorr

The value of this style is used in completion listing to sepa-

rate the string to complete from a description when possible

(e.g. when completing options). It defaults to `--' (two

hyphens). llooccaall This is for use with functions that complete URLs for which the

corresponding files are available directly from the filing sys-

tem. Its value should consist of three strings: a hostname, the path to the default web pages for the server, and the directory name used by a user placing web pages within their home area. For example: zzssttyyllee ''::ccoommpplleettiioonn::**'' llooccaall ttooaasstt \\ //vvaarr//hhttttpp//ppuubblliicc//ttooaasstt ppuubblliicchhttmmll Completion after `hhttttpp::////ttooaasstt//ssttuuffff//' will look for files in the directory //vvaarr//hhttttpp//ppuubblliicc//ttooaasstt//ssttuuffff, while completion

after `hhttttpp::////ttooaasstt//~~yyoouussiirr//' will look for files in the direc-

tory ~~yyoouussiirr//ppuubblliicchhttmmll.

mmaaiill-ddiirreeccttoorryy

If set, zsh will assume that mailbox files can be found in the directory specified. It defaults to `~~//MMaaiill'.

mmaattcchh-oorriiggiinnaall

This is used by the mmaattcchh completer. If it is set to oonnllyy, mmaattcchh will try to generate matches without inserting a `**' at

the cursor position. If set to any other non-empty value, it

will first try to generate matches without inserting the `**' and if that yields no matches, it will try again with the `**' inserted. If it is unset or set to the empty string, matching will only be performed with the `**' inserted. mmaattcchheerr

This style is tested separately for each tag valid in the cur-

rent context. Its value is added to any match specifications

given by the mmaattcchheerr-lliisstt style. It should be in the form

described in the section `Matching Control' in zshcompwid(1).

mmaattcchheerr-lliisstt

This style can be set to a list of match specifications that are to be applied everywhere. Match specifications are described in the section `Matching Control' in zshcompwid(1). The completion system will try them one after another for each completer selected. For example, to try first simple completion and, if

that generates no matches, case-insensitive completion:

zzssttyyllee ''::ccoommpplleettiioonn::**'' mmaattcchheerr-lliisstt '''' ''mm::{{aa-zzAA-ZZ}}=={{AA-ZZaa-zz}}''

By default each specification replaces the previous one; how-

ever, if a specification is prefixed with ++, it is added to the

existing list. Hence it is possible to create increasingly gen-

eral specifications without repetition:

zzssttyyllee ''::ccoommpplleettiioonn::**'' mmaattcchheerr-lliisstt '''' ''++mm{{aa-ZZ}}=={{AA-ZZ}}'' ''++mm{{AA-ZZ}}=={{aa-zz}}''

It is possible to create match specifications valid for particu-

lar completers by using the third field of the context. For example, to use the completers ccoommpplleettee and pprreeffiixx but only

allow case-insensitive completion with ccoommpplleettee:

zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ccoommpplleettee pprreeffiixx

zzssttyyllee ''::ccoommpplleettiioonn::**::ccoommpplleettee::**'' mmaattcchheerr-lliisstt \\

'''' ''mm::{{aa-zzAA-ZZ}}=={{AA-ZZaa-zz}}''

User-defined names, as explained for the ccoommpplleetteerr style, are

available. This makes it possible to try the same completer more than once with different match specifications each time.

For example, to try normal completion without a match specifica-

tion, then normal completion with case-insensitive matching,

then correction, and finally partial-word completion:

zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ccoommpplleettee ccoorrrreecctt ccoommpplleettee::ffoooo

zzssttyyllee ''::ccoommpplleettiioonn::**::ccoommpplleettee::**'' mmaattcchheerr-lliisstt \\

'''' ''mm::{{aa-zzAA-ZZ}}=={{AA-ZZaa-zz}}''

zzssttyyllee ''::ccoommpplleettiioonn::**::ffoooo::**'' mmaattcchheerr-lliisstt \\

''mm::{{aa-zzAA-ZZ}}=={{AA-ZZaa-zz}} rr::||[[-..//]]==** rr::||==**''

If the style is unset in any context no match specification is applied. Note also that some completers such as ccoorrrreecctt and aapppprrooxxiimmaattee do not use the match specifications at all, though these completers will only ever called once even if the

mmaattcchheerr-lliisstt contains more than one element.

Where multiple specifications are useful, note that the entire

completion is done for each element of mmaattcchheerr-lliisstt, which can

quickly reduce the shell's performance. As a rough rule of thumb, one to three strings will give acceptable performance.

On the other hand, putting multiple space-separated values into

the same string does not have an appreciable impact on perfor-

mance.

mmaaxx-eerrrroorrss

This is used by the aapppprrooxxiimmaattee and ccoorrrreecctt completer func-

tions to determine the maximum number of errors to allow. The completer will try to generate completions by first allowing one error, then two errors, and so on, until either a match or matches were found or the maximum number of errors given by this style has been reached. If the value for this style contains the string `nnuummeerriicc', the completer function will take any numeric argument as the maximum number of errors allowed. For example, with

zzssttyyllee ''::ccoommpplleettiioonn::**::aapppprrooxxiimmaattee::::::'' mmaaxx-eerrrroorrss 22 nnuummeerriicc

two errors are allowed if no numeric argument is given, but with

a numeric argument of six (as in `EESSCC-66 TTAABB'), up to six errors

are accepted. Hence with a value of `00 nnuummeerriicc', no correcting completion will be attempted unless a numeric argument is given.

If the value contains the string `nnoott-nnuummeerriicc', the completer

will not try to generate corrected completions when given a numeric argument, so in this case the number given should be

greater than zero. For example, `22 nnoott-nnuummeerriicc' specifies that

correcting completion with two errors will usually be performed, but if a numeric argument is given, correcting completion will not be performed. The default value for this style is `22 nnuummeerriicc'.

mmaaxx-mmaattcchheess-wwiiddtthh

This style is used to determine the trade off between the width of the display used for matches and the width used for their descriptions when the vveerrbboossee style is in effect. The value gives the number of display columns to reserve for the matches. The default is half the width of the screen. This has the most impact when several matches have the same description and so will be grouped together. Increasing the style will allow more matches to be grouped together; decreasing it will allow more of the description to be visible. mmeennuu If this is true in the context of any of the tags defined for the current completion menu completion will be used. The value for a specific tag will take precedence over that for the `ddeeffaauulltt' tag. If none of the values found in this way is true but at least one is set to `aauuttoo', the shell behaves as if the AAUUTTOOMMEENNUU option is set. If one of the values is explicitly set to false, menu completion will be explicitly turned off, overriding the MMEENNUUCCOOMMPPLLEETTEE option and other settings. In the form `yyeess==num', where `yyeess' may be any of the true values (`yyeess', `ttrruuee', `oonn' and `11'), menu completion will be turned on if there are at least num matches. In the form `yyeess==lloonngg', menu completion will be turned on if the list does not fit on the screen. This does not activate menu completion if the widget normally only lists completions, but menu completion can be

activated in that case with the value `yyeess==lloonngg-lliisstt' (Typi-

cally, the value `sseelleecctt==lloonngg-lliisstt' described later is more use-

ful as it provides control over scrolling.) Similarly, with any of the `false' values (as in `nnoo==1100'), menu completion will not be used if there are num or more matches.

The value of this widget also controls menu selection, as imple-

mented by the zzsshh//ccoommpplliisstt module. The following values may appear either alongside or instead of the values above. If the value contains the string `sseelleecctt', menu selection will be started unconditionally. In the form `sseelleecctt==num', menu selection will only be started if there are at least num matches. If the values for more than one tag provide a number, the smallest number is taken. Menu selection can be turned off explicitly by defining a value

containing the string`nnoo-sseelleecctt'.

It is also possible to start menu selection only if the list of matches does not fit on the screen by using the value

`sseelleecctt==lloonngg'. To start menu selection even if the current wid-

get only performs listing, use the value `sseelleecctt==lloonngg-lliisstt'.

To turn on menu completion or menu selection when a there are a certain number of matches or the list of matches does not fit on the screen, both of `yyeess==' and `sseelleecctt==' may be given twice,

once with a number and once with `lloonngg' or `lloonngg-lliisstt'.

Finally, it is possible to activate two special modes of menu

selection. The word `iinntteerraaccttiivvee' in the value causes interac-

tive mode to be entered immediately when menu selection is

started; see the description of the zzsshh//ccoommpplliisstt module in zsh-

modules(1).RE for a description of interactive mode. Including the string `sseeaarrcchh' does the same for incremental search mode. To select backward incremental search, include the string

`sseeaarrcchh-bbaacckkwwaarrdd'. )

mmuuttttrrcc If set, gives the location of the mutt configuration file. It defaults to `~~//..mmuuttttrrcc'. nnuummbbeerrss This is used with the jjoobbss tag. If it is `true', the shell will complete job numbers instead of the shortest unambiguous prefix of the job command text. If the value is a number, job numbers will only be used if that many words from the job descriptions are required to resolve ambiguities. For example, if the value is `11', strings will only be used if all jobs differ in the first word on their command lines.

oolldd-lliisstt

This is used by the oollddlliisstt completer. If it is set to `aallwwaayyss', then standard widgets which perform listing will retain the current list of matches, however they were generated; this can be turned off explicitly with the value `nneevveerr', giving the behaviour without the oollddlliisstt completer. If the style is unset, or any other value, then the existing list of completions is displayed if it is not already; otherwise, the standard completion list is generated; this is the default behaviour of oollddlliisstt. However, if there is an old list and this style contains the name of the completer function that generated the list, then the old list will be used even

if it was generated by a widget which does not do list-

ing.

For example, suppose you type ^^XXcc to use the ccoorr-

rreeccttwwoorrdd widget, which generates a list of corrections for the word under the cursor. Usually, typing ^^DD would generate a standard list of completions for the word on the command line, and show that. With oollddlliisstt, it will instead show the list of corrections already generated. As another example consider the mmaattcchh completer: with

the iinnsseerrtt-uunnaammbbiigguuoouuss style set to `true' it inserts

only a common prefix string, if there is any. However, this may remove parts of the original pattern, so that further completion could produce more matches than on the

first attempt. By using the oollddlliisstt completer and set-

ting this style to mmaattcchh, the list of matches generated on the first attempt will be used again.

oolldd-mmaattcchheess

This is used by the aallllmmaattcchheess completer to decide if an old list of matches should be used if one exists. This is selected by one of the `true' values or by the string `oonnllyy'. If the value is `oonnllyy', aallllmmaattcchheess will only use an old list and won't have any effect on the list of matches currently being generated. If this style is set it is generally unwise to call the aallllmmaattcchheess completer unconditionally. One possible use is for either this style or the ccoommpplleetteerr style to be

defined with the -ee option to zzssttyyllee to make the style

conditional.

oolldd-mmeennuu

This is used by the oollddlliisstt completer. It controls how menu completion behaves when a completion has already been inserted and the user types a standard completion key such as TTAABB. The default behaviour of oollddlliisstt is that menu completion always continues with the existing list of completions. If this style is set to `false', however, a new completion is started if the old list was generated by a different completion command; this is the behaviour without the oollddlliisstt completer. For example, suppose you type ^^XXcc to generate a list of corrections, and menu completion is started in one of the usual ways. Usually, or with this style set to ffaallssee, typing TTAABB at this point would start trying to complete the line as it now appears. With oollddlliisstt, it instead continues to cycle through the list of corrections. oorriiggiinnaall This is used by the aapppprrooxxiimmaattee and ccoorrrreecctt completers to decide if the original string should be added as a possible completion. Normally, this is done only if there are at least two possible corrections, but if this style is set to `true', it is always added. Note that the style will be examined with the completer field in

the context name set to ccoorrrreecctt-num or aapppprrooxxiimmaattee-num,

where num is the number of errors that were accepted. ppaacckkaaggeesseett This style is used when completing arguments of the Debian `ddppkkgg' program. It contains an override for the default package set for a given context. For example,

zzssttyyllee ''::ccoommpplleettiioonn::**::ccoommpplleettee::ddppkkgg::ooppttiioonn--ssttaattuuss-11::**'' \\

ppaacckkaaggeesseett aavvaaiill causes available packages, rather than only installed

packages, to be completed for `dpkg -status'.

ppaatthh The function that completes color names uses this style with the ccoolloorrss tag. The value should be the pathname of a file containing color names in the format of an X11 rrggbb..ttxxtt file. If the style is not set but this file is found in one of various standard locations it will be used as the default.

ppiinnee-ddiirreeccttoorryy

If set, specifies the directory containing PINE mailbox files. It defaults to `~~//mmaaiill'.

ppoorrttss A list of Internet service names (network ports) to com-

plete. If this is not set, service names are taken from the file `//eettcc//sseerrvviicceess'.

pprreeffiixx-hhiiddddeenn

This is used for certain completions which share a common prefix, for example command options beginning with dashes. If it is `true', the prefix will not be shown in the list of matches. The default value for this style is `false'.

pprreeffiixx-nneeeeddeedd

This, too, is used for matches with a common prefix. If it is set to `true' this common prefix must be typed by the user to generate the matches. In the case of command

options, this means that the initial `-', `++', or `--'

must be typed explicitly before option names will be com-

pleted. The default value for this style is `true'.

pprreesseerrvvee-pprreeffiixx

This style is used when completing path names. Its value should be a pattern matching an initial prefix of the word to complete that should be left unchanged under all circumstances. For example, on some Unices an initial `////' (double slash) has a special meaning; setting this style to the string `////' will preserve it. As another example, setting this style to `??:://' under Cygwin would allow completion after `aa:://......' and so on.

rraannggee This is used by the hhiissttoorryy completer and the hhiiss-

ttoorryyccoommpplleetteewwoorrdd bindable command to decide which words should be completed. If it is a singe number, only the last N words from the history will be completed. If it is a range of the form `max::slice', the last slice words will be completed; then if that yields no matches, the slice words before those will be tried and so on. This process stops either when at least one match was been found, or max words have been tried. The default is to complete all words from the history at once. rreegguullaarr This style is used by the eexxppaannddaalliiaass completer and

bindable command. If set to `ttrruuee' (the default), regu-

lar aliases will be expanded but only in command posi-

tion. If it is set to `ffaallssee', regular aliases will never be expanded. If it is set to `aallwwaayyss', regular aliases will be expanded even if not in command position.

rreemmoottee-aacccceessss

If set to ffaallssee, certain commands will be prevented from

making Internet connections to retrieve remote informa-

tion. This includes the completion for the CCVVSS command. It is not always possible to know if connections are in

fact to a remote site, so some may be prevented unneces-

sarily.

rreemmoovvee-aallll-dduuppss

The hhiissttoorryyccoommpplleetteewwoorrdd bindable command and the hhiiss-

ttoorryy completer use this to decide if all duplicate matches should be removed, rather than just consecutive duplicates.

sseelleecctt-pprroommpptt

If this is set for the ddeeffaauulltt tag, its value will be displayed during menu selection (see the mmeennuu style above) when the completion list does not fit on the screen as a whole. The same escapes as for the

lliisstt-pprroommpptt style are understood, except that the numbers

refer to the match or line the mark is on. A default prompt is used when the value is the empty string.

sseelleecctt-ssccrroollll

This style is tested for the ddeeffaauulltt tag and determines how a completion list is scrolled during a menu selection (see the mmeennuu style above) when the completion list does not fit on the screen as a whole. If the value is `00'

(zero), the list is scrolled by half-screenfuls; if it is

a positive integer, the list is scrolled by the given number of lines; if it is a negative number, the list is scrolled by a screenful minus the absolute value of the

given number of lines. The default is to scroll by sin-

gle lines.

sseeppaarraattee-sseeccttiioonnss

This style is used with the mmaannuuaallss tag when completing

names of manual pages. If it is `true', entries for dif-

ferent sections are added separately using tag names of the form `mmaannuuaall..X', where X is the section number. When

the ggrroouupp-nnaammee style is also in effect, pages from dif-

ferent sections will appear separately. This style is also used similarly with the wwoorrddss style when completing

words for the dict command. It allows words from differ-

ent dictionary databases to be added separately. The default for this style is `false'.

sshhooww-ccoommpplleetteerr

Tested whenever a new completer is tried. If it is true, the completion system outputs a progress message in the listing area showing what completer is being tried. The

message will be overwritten by any output when comple-

tions are found and is removed after completion is fin-

ished.

ssiinnggllee-iiggnnoorreedd

This is used by the iiggnnoorreedd completer when there is only one match. If its value is `sshhooww', the single match will be displayed but not inserted. If the value is `mmeennuu', then the single match and the original string are both added as matches and menu completion is started, making it easy to select either of them. ssoorrtt Many completion widgets call ddeessccrriippttiioonn at some point which decides whether the matches are added sorted or unsorted (often indirectly via wwaanntteedd or rreeqquueesstteedd). This style can be set explicitly to one of the usual true or false values as an override. If it is not set for the context, the standard behaviour of the calling widget is used. The style is tested first against the full context including the tag, and if that fails to produce a value against the context without the tag. If the calling widget explicitly requests unsorted matches, this is usually honoured. However, the default

(unsorted) behaviour of completion for the command his-

tory may be overridden by setting the style to ttrruuee. In the eexxppaanndd completer, if it is set to `true', the expansions generated will always be sorted. If it is set to `mmeennuu', then the expansions are only sorted when they

are offered as single strings but not in the string con-

taining all possible expansions.

ssppeecciiaall-ddiirrss

Normally, the completion code will not produce the direc-

tory names `..' and `....' as possible completions. If this style is set to `true', it will add both `..' and `....' as possible completions; if it is set to `....', only `....' will be added.

The following example sets ssppeecciiaall-ddiirrss to `....' when the

current prefix is empty, is a single `..', or consists only of a path beginning with `....//'. Otherwise the value is `false'.

zzssttyyllee -ee ''::ccoommpplleettiioonn::**'' ssppeecciiaall-ddiirrss \\

''[[[[ $$PPRREEFFIIXX == ((....//))##((||..||....)) ]]]] &&&& rreeppllyy==((....))''

ssqquueeeezzee-ssllaasshheess

If set to `true', sequences of slashes in filename paths (for example in `ffoooo////bbaarr') will be treated as a single

slash. This is the usual behaviour of UNIX paths. How-

ever, by default the file completion function behaves as if there were a `**' between the slashes. ssttoopp If set to `true', the hhiissttoorryyccoommpplleetteewwoorrdd bindable command will stop once when reaching the beginning or end of the history. Invoking hhiissttoorryyccoommpplleetteewwoorrdd will then wrap around to the opposite end of the history. If

this style is set to `false' (the default), hhiissttoorryyccoomm-

pplleetteewwoorrdd will loop immediately as in a menu completion.

ssttrriipp-ccoommmmeennttss

If set to `true', this style causes non-essential comment

text to be removed from completion matches. Currently it

is only used when completing e-mail addresses where it

removes any display name from the addresses, cutting them down to plain user@host form.

ssuubbsstt-gglloobbss-oonnllyy

This is used by the eexxppaanndd completer. If it is set to `true', the expansion will only be used if it resulted from globbing; hence, if expansions resulted from the use of the ssuubbssttiittuuttee style described below, but these were not further changed by globbing, the expansions will be rejected. The default for this style is `false'. ssuubbssttiittuuttee This boolean style controls whether the eexxppaanndd completer will first try to expand all substitutions in the string

(such as `$$((......))' and `$${{......}}').

The default is `true'. ssuuffffiixx This is used by the eexxppaanndd completer if the word starts with a tilde or contains a parameter expansion. If it is set to `true', the word will only be expanded if it doesn't have a suffix, i.e. if it is something like

`~~ffoooo' or `$$ffoooo' rather than `~~ffoooo//' or `$$ffoooo//bbaarr',

unless that suffix itself contains characters eligible for expansion. The default for this style is `true'.

ttaagg-oorrddeerr

This provides a mechanism for sorting how the tags avail-

able in a particular context will be used.

The values for the style are sets of space-separated

lists of tags. The tags in each value will be tried at the same time; if no match is found, the next value is

used. (See the ffiillee-ppaatttteerrnnss style for an exception to

this behavior.) For example:

zzssttyyllee ''::ccoommpplleettiioonn::**::ccoommpplleettee::-ccoommmmaanndd-::**'' ttaagg-oorrddeerr \\

''ccoommmmaannddss ffuunnccttiioonnss'' specifies that completion in command position first offers external commands and shell functions. Remaining tags will be tried if no completions are found. In addition to tag names, each string in the value may take one of the following forms:

- If any value consists of only a hyphen, then only

the tags specified in the other values are gener-

ated. Normally all tags not explicitly selected

are tried last if the specified tags fail to gen-

erate any matches. This means that a single value

consisting only of a single hyphen turns off com-

pletion. !! tags...

A string starting with an exclamation mark speci-

fies names of tags that are not to be used. The effect is the same as if all other possible tags for the context had been listed. tag::label ... Here, tag is one of the standard tags and label is

an arbitrary name. Matches are generated as nor-

mal but the name label is used in contexts instead of tag. This is not useful in words starting with !!. If the label starts with a hyphen, the tag is prepended to the label to form the name used for lookup. This can be used to make the completion system try a certain tag more than once, supplying different style settings for each attempt; see below for an example. tag::label::description

As before, but ddeessccrriippttiioonn will replace the `%%dd'

in the value of the ffoorrmmaatt style instead of the default description supplied by the completion function. Spaces in the description must be

quoted with a backslash. A `%%dd' appearing in

description is replaced with the description given by the completion function. In any of the forms above the tag may be a pattern or several patterns in the form `{{pat1,,pat2...}}'. In this case all matching tags will be used except for any given explicitly in the same string. One use of these features is to try one tag more than once, setting other styles differently on each attempt, but still to use all the other tags without having to repeat them all. For example, to make completion of

function names in command position ignore all the comple-

tion functions starting with an underscore the first time completion is tried:

zzssttyyllee ''::ccoommpplleettiioonn::**::**::-ccoommmmaanndd-::**'' ttaagg-oorrddeerr \\

''ffuunnccttiioonnss::-nnoonn-ccoommpp **'' ffuunnccttiioonnss

zzssttyyllee ''::ccoommpplleettiioonn::**::ffuunnccttiioonnss-nnoonn-ccoommpp'' iiggnnoorreedd-ppaatttteerrnnss ''**''

On the first attempt, all tags will be offered but the

ffuunnccttiioonnss tag will be replaced by ffuunnccttiioonnss-nnoonn-ccoommpp.

The iiggnnoorreedd-ppaatttteerrnnss style is set for this tag to exclude

functions starting with an underscore. If there are no

matches, the second value of the ttaagg-oorrddeerr style is used

which completes functions using the default tag, this time presumably including all function names. The matches for one tag can be split into different groups. For example:

zzssttyyllee ''::ccoommpplleettiioonn::**'' ttaagg-oorrddeerr \\

''ooppttiioonnss::-lloonngg::lloonngg\\ ooppttiioonnss

ooppttiioonnss::-sshhoorrtt::sshhoorrtt\\ ooppttiioonnss

ooppttiioonnss::-ssiinnggllee-lleetttteerr::ssiinnggllee\\ lleetttteerr\\ ooppttiioonnss''

zstyle ':completion:*:options-long' ignored-patterns '[-+](|-|[^-]*)'

zstyle ':completion:*:options-short' ignored-patterns '-*' '[-+]?'

zstyle ':completion:*:options-single-letter' ignored-patterns '???*'

With the ggrroouupp-nnaammeess style set, options beginning with

`--', options beginning with a single `-' or `++' but con-

taining multiple characters, and single-letter options

will be displayed in separate groups with different descriptions.

Another use of patterns is to try multiple match specifi-

cations one after another. The mmaattcchheerr-lliisstt style offers

something similar, but it is tested very early in the

completion system and hence can't be set for single com-

mands nor for more specific contexts. Here is how to try normal completion without any match specification and, if

that generates no matches, try again with case-insensi-

tive matching, restricting the effect to arguments of the command ffoooo:

zzssttyyllee ''::ccoommpplleettiioonn::**::**::ffoooo::**'' ttaagg-oorrddeerr ''**'' ''**::-ccaassee''

zzssttyyllee ''::ccoommpplleettiioonn::**-ccaassee'' mmaattcchheerr ''mm::{{aa-zz}}=={{AA-ZZ}}''

First, all the tags offered when completing after ffoooo are tried using the normal tag name. If that generates no

matches, the second value of ttaagg-oorrddeerr is used, which

tries all tags again except that this time each has -ccaassee

appended to its name for lookup of styles. Hence this time the value for the mmaattcchheerr style from the second call to zzssttyyllee in the example is used to make completion

case-insensitive.

It is possible to use the -ee option of the zzssttyyllee builtin

command to specify conditions for the use of particular tags. For example:

zzssttyyllee -ee ''**::-ccoommmmaanndd-::**'' ttaagg-oorrddeerr ''

iiff [[[[ -nn $$PPRREEFFIIXX$$SSUUFFFFIIXX ]]]];; tthheenn

rreeppllyy==(( )) eellssee

rreeppllyy==(( - ))

ffii'' Completion in command position will be attempted only if the string typed so far is not empty. This is tested using the PPRREEFFIIXX special parameter; see zshcompwid for a

description of parameters which are special inside com-

pletion widgets. Setting rreeppllyy to an empty array pro-

vides the default behaviour of trying all tags at once; setting it to an array containing only a hyphen disables the use of all tags and hence of all completions.

If no ttaagg-oorrddeerr style has been defined for a context, the

strings `((||**-))aarrgguummeenntt-** ((||**-))ooppttiioonn-** vvaalluueess' and

`ooppttiioonnss' plus all tags offered by the completion func-

tion will be used to provide a sensible default behavior that causes arguments (whether normal command arguments or arguments of options) to be completed before option names for most commands. uurrllss This is used together with the the uurrllss tag by functions completing URLs. If the value consists of more than one string, or if the only string does not name a file or directory, the strings are used as the URLs to complete. If the value contains only one string which is the name of a normal file the URLs are taken from that file (where the URLs may be separated by white space or newlines).

Finally, if the only string in the value names a direc-

tory, the directory hierarchy rooted at this directory gives the completions. The top level directory should be the file access method, such as `hhttttpp', `ffttpp', `bbooookkmmaarrkk' and so on. In many cases the next level of directories will be a filename. The directory hierarchy can descend as deep as necessary. For example, zzssttyyllee ''::ccoommpplleettiioonn::**'' uurrllss ~~//..uurrllss

mmkkddiirr -pp ~~//..uurrllss//ffttpp//ffttpp..zzsshh..oorrgg//ppuubb//ddeevveellooppmmeenntt

allows completion of all the components of the URL ffttpp::////ffttpp..zzsshh..oorrgg//ppuubb//ddeevveellooppmmeenntt after suitable commands such as `nneettssccaappee' or `llyynnxx'. Note, however, that access methods and files are completed separately, so if the

hhoossttss style is set hosts can be completed without refer-

ence to the uurrllss style. See the description in the function uurrllss itself for more

information (e.g. `mmoorree $$^^ffppaatthh//uurrllss((NN))').

uussee-ccaacchhee

If this is set, the completion caching layer is activated for any completions which use it (via the ssttoorreeccaacchhee, rreettrriieevveeccaacchhee, and ccaacchheeiinnvvaalliidd functions). The directory containing the cache files can be changed with

the ccaacchhee-ppaatthh style.

uussee-ccoommppccttll

If this style is set to a string not equal to ffaallssee, 00, nnoo, and ooffff, the completion system may use any completion specifications defined with the ccoommppccttll builtin command.

If the style is unset, this is done only if the zzsshh//ccoomm-

ppccttll module is loaded. The string may also contain the

substring `ffiirrsstt' to use completions defined with `ccoomm-

ppccttll -TT', and the substring `ddeeffaauulltt' to use the comple-

tion defined with `ccoommppccttll -DD'.

Note that this is only intended to smooth the transition

from ccoommppccttll to the new completion system and may disap-

pear in the future. Note also that the definitions from ccoommppccttll will only be used if there is no specific completion function for the command in question. For example, if there is a function ffoooo to complete arguments to the command ffoooo, ccoommppccttll

will never be invoked for ffoooo. However, the ccoommppccttll ver-

sion will be tried if ffoooo only uses default completion.

uussee-ppeerrll

Various parts of the function system use awk to extract words from files or command output as this universally available. However, many versions of awk have arbitrary limits on the size of input. If this style is set, perl will be used instead. This is almost always preferable if perl is available on your system. Currently this is only used in completions for `make',

but it may be extended depending on authorial frustra-

tion. uusseerrss This may be set to a list of usernames to be completed. If it is not set or the string on the line doesn't match any of the strings in this list, all usernames will be completed.

uusseerrss-hhoossttss

The values of this style should be of the form `user@@host' or `user::host'. It is used for commands that

need pairs of user- and hostnames. These commands will

complete usernames from this style (only), and will restrict subsequent hostname completion to hosts paired with that user in one of the values of the style. It is possible to group values for sets of commands which allow a remote login, such as rrllooggiinn and sssshh, by using

the mmyy-aaccccoouunnttss tag. Similarly, values for sets of com-

mands which usually refer to the accounts of other peo-

ple, such as ttaallkk and ffiinnggeerr, can be grouped by using the

ootthheerr-aaccccoouunnttss tag. More ambivalent commands may use the

aaccccoouunnttss tag.

uusseerrss-hhoossttss-ppoorrttss

Like uusseerrss-hhoossttss but used for commands like tteellnneett and

containing strings of the form `user@@host::port'. vveerrbboossee If set, as it is by default, the completion listing is

more verbose. In particular many commands show descrip-

tions for options if this style is `true'. wwoorrdd This is used by the lliisstt completer, which prevents the insertion of completions until a second completion attempt when the line has not changed. The normal way of finding out if the line has changed is to compare its entire contents between the two occasions. If this style is true, the comparison is instead performed only on the current word. Hence if completion is performed on another word with the same contents, completion will not be delayed. CCOONNTTRROOLL FFUUNNCCTTIIOONNSS

The initialization script ccoommppiinniitt redefines all the widgets which per-

form completion to call the supplied widget function mmaaiinnccoommpplleettee.

This function acts as a wrapper calling the so-called `completer' func-

tions that generate matches. If mmaaiinnccoommpplleettee is called with argu-

ments, these are taken as the names of completer functions to be called in the order given. If no arguments are given, the set of functions to

try is taken from the ccoommpplleetteerr style. For example, to use normal com-

pletion and correction if that doesn't generate any matches: zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ccoommpplleettee ccoorrrreecctt after calling ccoommppiinniitt. The default value for this style is `ccoommpplleettee iiggnnoorreedd', i.e. normally only ordinary completion is tried, first with

the effect of the iiggnnoorreedd-ppaatttteerrnnss style and then without it. The

mmaaiinnccoommpplleettee function uses the return value of the completer func-

tions to decide if other completers should be called. If the return value is zero, no other completers are tried and the mmaaiinnccoommpplleettee function returns.

If the first argument to mmaaiinnccoommpplleettee is a single hyphen, the argu-

ments will not be taken as names of completers. Instead, the second argument gives a name to use in the completer field of the context and

the other arguments give a command name and arguments to call to gener-

ate the matches. The following completer functions are contained in the distribution, although users may write their own. Note that in contexts the leading underscore is stripped, for example basic completion is performed in the context `::ccoommpplleettiioonn::::ccoommpplleettee::...'. aallllmmaattcchheess This completer can be used to add a string consisting of all other matches. As it influences later completers it must appear as the first completer in the list. The list of all matches is

affected by the aavvooiidd-ccoommpplleetteerr and oolldd-mmaattcchheess styles described

above. It may be useful to use the ggeenneerriicc function described below to bind aallllmmaattcchheess to its own keystroke, for example:

zzllee -CC aallll-mmaattcchheess ccoommpplleettee-wwoorrdd ggeenneerriicc

bbiinnddkkeeyy ''^^XXaa'' aallll-mmaattcchheess

zzssttyyllee ''::ccoommpplleettiioonn::aallll-mmaattcchheess::**'' oolldd-mmaattcchheess oonnllyy

zzssttyyllee ''::ccoommpplleettiioonn::aallll-mmaattcchheess::::::::'' ccoommpplleetteerr aallllmmaattcchheess

aapppprrooxxiimmaattee This is similar to the basic ccoommpplleettee completer but allows the completions to undergo corrections. The maximum number of

errors can be specified by the mmaaxx-eerrrroorrss style; see the

description of approximate matching in zshexpn(1) for how errors are counted. Normally this completer will only be tried after the normal ccoommpplleettee completer: zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ccoommpplleettee aapppprrooxxiimmaattee

This will give correcting completion if and only if normal com-

pletion yields no possible completions. When corrected comple-

tions are found, the completer will normally start menu comple-

tion allowing you to cycle through these strings.

This completer uses the tags ccoorrrreeccttiioonnss and oorriiggiinnaall when gen-

erating the possible corrections and the original string. The ffoorrmmaatt style for the former may contain the additional sequences

`%%ee' and `%%oo' which will be replaced by the number of errors

accepted to generate the corrections and the original string, respectively. The completer progressively increases the number of errors

allowed up to the limit by the mmaaxx-eerrrroorrss style, hence if a com-

pletion is found with one error, no completions with two errors will be shown, and so on. It modifies the completer name in the context to indicate the number of errors being tried: on the

first try the completer field contains `aapppprrooxxiimmaattee-11', on the

second try `aapppprrooxxiimmaattee-22', and so on.

When aapppprrooxxiimmaattee is called from another function, the number of

errors to accept may be passed with the -aa option. The argument

is in the same format as the mmaaxx-eerrrroorrss style, all in one

string. Note that this completer (and the ccoorrrreecctt completer mentioned below) can be quite expensive to call, especially when a large number of errors are allowed. One way to avoid this is to set

up the ccoommpplleetteerr style using the -ee option to zstyle so that

some completers are only used when completion is attempted a second time on the same string, e.g.:

zzssttyyllee -ee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ''

iiff [[[[ $$llaassttttrryy !!== ""$$HHIISSTTNNOO$$BBUUFFFFEERR$$CCUURRSSOORR"" ]]]];; tthheenn

llaassttttrryy==""$$HHIISSTTNNOO$$BBUUFFFFEERR$$CCUURRSSOORR""

rreeppllyy==((ccoommpplleettee mmaattcchh pprreeffiixx)) eellssee rreeppllyy==((iiggnnoorreedd ccoorrrreecctt aapppprrooxxiimmaattee)) ffii'' This uses the HHIISSTTNNOO parameter and the BBUUFFFFEERR and CCUURRSSOORR special parameters that are available inside zle and completion widgets to find out if the command line hasn't changed since the last time completion was tried. Only then are the iiggnnoorreedd, ccoorrrreecctt and aapppprrooxxiimmaattee completers called. ccoommpplleettee

This completer generates all possible completions in a con-

text-sensitive manner, i.e. using the settings defined with the

ccoommppddeeff function explained above and the current settings of all special parameters. This gives the normal completion behaviour. To complete arguments of commands, ccoommpplleettee uses the utility function nnoorrmmaall, which is in turn responsible for finding the particular function; it is described below. Various contexts of

the form -context- are handled specifically. These are all men-

tioned above as possible arguments to the ##ccoommppddeeff tag.

Before trying to find a function for a specific context, ccoomm-

pplleettee checks if the parameter `ccoommppccoonntteexxtt' is set. Setting `ccoommppccoonntteexxtt' allows the usual completion dispatching to be overridden which is useful in places such as a function that uses vvaarreedd for input. If it is set to an array, the elements are taken to be the possible matches which will be completed using the tag `vvaalluueess' and the description `vvaalluuee'. If it is set to an associative array, the keys are used as the possible completions

and the values (if non-empty) are used as descriptions for the

matches. If `ccoommppccoonntteexxtt' is set to a string containing colons, it should be of the form `tag::descr::action'. In this case the tag and descr give the tag and description to use and the action indicates what should be completed in one of the forms accepted by the aarrgguummeennttss utility function described below. Finally, if `ccoommppccoonntteexxtt' is set to a string without colons, the

value is taken as the name of the context to use and the func-

tion defined for that context will be called. For this purpose,

there is a special context named -ccoommmmaanndd-lliinnee- that completes

whole command lines (commands and their arguments). This is not used by the completion system itself but is nonetheless handled when explicitly called. ccoorrrreecctt Generate corrections, but not completions, for the current word; this is similar to aapppprrooxxiimmaattee but will not allow any number of extra characters at the cursor as that completer does. The

effect is similar to spell-checking. It is based on aapppprrooxxii-

mmaattee, but the completer field in the context name is ccoorrrreecctt. For example, with: zzssttyyllee ''::ccoommpplleettiioonn::::::::::'' ccoommpplleetteerr ccoommpplleettee ccoorrrreecctt aapppprrooxxiimmaattee

zzssttyyllee ''::ccoommpplleettiioonn::**::ccoorrrreecctt::::::'' mmaaxx-eerrrroorrss 22 nnoott-nnuummeerriicc

zzssttyyllee ''::ccoommpplleettiioonn::**::aapppprrooxxiimmaattee::::::'' mmaaxx-eerrrroorrss 33 nnuummeerriicc

correction will accept up to two errors. If a numeric argument

is given, correction will not be performed, but correcting com-

pletion will be, and will accept as many errors as given by the numeric argument. Without a numeric argument, first correction and then correcting completion will be tried, with the first one accepting two errors and the second one accepting three errors. When ccoorrrreecctt is called as a function, the number of errors to

accept may be given following the -aa option. The argument is in

the same form a values to the aacccceepptt style, all in one string. This completer function is intended to be used without the aapppprrooxxiimmaattee completer or, as in the example, just before it. Using it after the aapppprrooxxiimmaattee completer is useless since

aapppprrooxxiimmaattee will at least generate the corrected strings gener-

ated by the ccoorrrreecctt completer - and probably more.

eexxppaanndd This completer function does not really perform completion, but instead checks if the word on the command line is eligible for expansion and, if it is, gives detailed control over how this expansion is done. For this to happen, the completion system

needs to be invoked with ccoommpplleettee-wwoorrdd, not eexxppaanndd-oorr-ccoommpplleettee

(the default binding for TTAABB), as otherwise the string will be expanded by the shell's internal mechanism before the completion system is started. Note also this completer should be called before the ccoommpplleettee completer function.

The tags used when generating expansions are aallll-eexxppaannssiioonnss for

the string containing all possible expansions, eexxppaannssiioonnss when adding the possible expansions as single matches and oorriiggiinnaall when adding the original string from the line. The order in which these strings are generated, if at all, can be controlled

by the ggrroouupp-oorrddeerr and ttaagg-oorrddeerr styles, as usual.

The format string for aallll-eexxppaannssiioonnss and for eexxppaannssiioonnss may con-

tain the sequence `%%oo' which will be replaced by the original

string from the line.

The kind of expansion to be tried is controlled by the ssuubbssttii-

ttuuttee, gglloobb and ssuubbsstt-gglloobbss-oonnllyy styles.

It is also possible to call eexxppaanndd as a function, in which case

the different modes may be selected with options: -ss for ssuubbssttii-

ttuuttee, -gg for gglloobb and -oo for ssuubbsstt-gglloobbss-oonnllyy.

eexxppaannddaalliiaass If the word the cursor is on is an alias, it is expanded and no other completers are called. The types of aliases which are to be expanded can be controlled with the styles rreegguullaarr, gglloobbaall and ddiissaabblleedd.

This function is also a bindable command, see the section `Bind-

able Commands' below. hhiissttoorryy

Complete words from the shell's command history. This com-

pleter can be controlled by the rreemmoovvee-aallll-dduuppss, and ssoorrtt styles

as for the hhiissttoorryyccoommpplleetteewwoorrdd bindable command, see the sec-

tion `Bindable Commands' below and the section `Completion Sys-

tem Configuration' above. iiggnnoorreedd

The iiggnnoorreedd-ppaatttteerrnnss style can be set to a list of patterns

which are compared against possible completions; matching ones

are removed. With this completer those matches can be rein-

stated, as if no iiggnnoorreedd-ppaatttteerrnnss style were set. The completer

actually generates its own list of matches; which completers are

invoked is determined in the same way as for the pprreeffiixx com-

pleter. The ssiinnggllee-iiggnnoorreedd style is also available as described

above. lliisstt This completer allows the insertion of matches to be delayed until completion is attempted a second time without the word on the line being changed. On the first attempt, only the list of matches will be shown. It is affected by the styles ccoonnddiittiioonn and wwoorrdd, see the section `Completion System Configuration' above.

mmaattcchh This completer is intended to be used after the ccoommpplleettee com-

pleter. It behaves similarly but the string on the command line may be a pattern to match against trial completions. This gives the effect of the GGLLOOBBCCOOMMPPLLEETTEE option. Normally completion will be performed by taking the pattern from the line, inserting a `**' at the cursor position and comparing the resulting pattern with the possible completions generated.

This can be modified with the mmaattcchh-oorriiggiinnaall style described

above. The generated matches will be offered in a menu completion

unless the iinnsseerrtt-uunnaammbbiigguuoouuss style is set to `true'; see the

description above for other options for this style. Note that matcher specifications defined globally or used by the

completion functions (the styles mmaattcchheerr-lliisstt and mmaattcchheerr) will

not be used. mmeennuu This completer was written as simple example function to show how menu completion can be enabled in shell code. However, it has the notable effect of disabling menu selection which can be useful with ggeenneerriicc based widgets. It should be used as the first completer in the list. Note that this is independent of the setting of the MMEENNUUCCOOMMPPLLEETTEE option and does not work with

the other menu completion widgets such as rreevveerrssee-mmeennuu-ccoommpplleettee,

or aacccceepptt-aanndd-mmeennuu-ccoommpplleettee.

oollddlliisstt This completer controls how the standard completion widgets behave when there is an existing list of completions which may

have been generated by a special completion (i.e. a sepa-

rately-bound completion command). It allows the ordinary com-

pletion keys to continue to use the list of completions thus

generated, instead of producing a new list of ordinary contex-

tual completions. It should appear in the list of completers before any of the widgets which generate matches. It uses two

styles: oolldd-lliisstt and oolldd-mmeennuu, see the section `Completion Sys-

tem Configuration' above. pprreeffiixx This completer can be used to try completion with the suffix

(everything after the cursor) ignored. In other words, the suf-

fix will not be considered to be part of the word to complete.

The effect is similar to the eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx command.

The ccoommpplleetteerr style is used to decide which other completers are to be called to generate matches. If this style is unset, the

list of completers set for the current context is used -

except, of course, the pprreeffiixx completer itself. Furthermore,

if this completer appears more than once in the list of com-

pleters only those completers not already tried by the last invocation of pprreeffiixx will be called. For example, consider this global ccoommpplleetteerr style: zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr \\ ccoommpplleettee pprreeffiixx ccoorrrreecctt pprreeffiixx::ffoooo Here, the pprreeffiixx completer tries normal completion but ignoring the suffix. If that doesn't generate any matches, and neither does the call to the ccoorrrreecctt completer after it, pprreeffiixx will be called a second time and, now only trying correction with the suffix ignored. On the second invocation the completer part of the context appears as `ffoooo'. To use pprreeffiixx as the last resort and try only normal completion when it is invoked: zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr ccoommpplleettee ...... pprreeffiixx zzssttyyllee ''::ccoommpplleettiioonn::::pprreeffiixx::**'' ccoommpplleetteerr ccoommpplleettee

The aadddd-ssppaaccee style is also respected. If it is set to `true'

then pprreeffiixx will insert a space between the matches generated (if any) and the suffix. Note that this completer is only useful if the CCOOMMPPLLEETTEEIINNWWOORRDD option is set; otherwise, the cursor will be moved to the end of the current word before the completion code is called and hence there will be no suffix. bbaasshhccoommppiinniitt This function provides compatibility with bash's programmable

completion system. When run it will define the functions, ccoommpp-

ggeenn and ccoommpplleettee which correspond to the bash builtins with the

same names. It will then be possible to use completion specifi-

cations and functions written for bash. BBIINNDDAABBLLEE CCOOMMMMAANNDDSS

In addition to the context-dependent completions provided, which are

expected to work in an intuitively obvious way, there are a few widgets implementing special behaviour which can be bound separately to keys. The following is a list of these and their default bindings. bbaasshhccoommpplleettiioonnss

This function is used by two widgets, bbaasshhccoommpplleettee-wwoorrdd and

bbaasshhlliisstt-cchhooiicceess. It exists to provide compatibility with

completion bindings in bash. The last character of the binding

determines what is completed: `!!', command names; `$$', environ-

ment variables; `@@', host names; `//', file names; `~~' user names. In bash, the binding preceded by `\\ee' gives completion, and preceded by `^^XX' lists options. As some of these bindings clash with standard zsh bindings, only `\\ee~~' and `^^XX~~' are bound by default. To add the rest, the following should be added to ..zzsshhrrcc after ccoommppiinniitt has been run:

ffoorr kkeeyy iinn ''!!'' ''$$'' ''@@'' ''//'' ''~~'';; ddoo

bbiinnddkkeeyy ""\\ee$$kkeeyy"" bbaasshhccoommpplleettee-wwoorrdd

bbiinnddkkeeyy ""^^XX$$kkeeyy"" bbaasshhlliisstt-cchhooiicceess

ddoonnee This includes the bindings for `~~' in case they were already bound to something else; the completion code does not override user bindings. ccoorrrreeccttffiilleennaammee ((^^XXCC)) Correct the filename path at the cursor position. Allows up to six errors in the name. Can also be called with an argument to correct a filename path, independently of zle; the correction is printed on standard output. ccoorrrreeccttwwoorrdd (^Xc)

Performs correction of the current argument using the usual con-

textual completions as possible choices. This stores the string

`ccoorrrreecctt-wwoorrdd' in the function field of the context name and

then calls the ccoorrrreecctt completer. eexxppaannddaalliiaass ((^^XXaa))

This function can be used as a completer and as a bindable com-

mand. It expands the word the cursor is on if it is an alias. The types of alias expanded can be controlled with the styles rreegguullaarr, gglloobbaall and ddiissaabblleedd. When used as a bindable command there is one additional feature that can be selected by setting the ccoommpplleettee style to `true'. In this case, if the word is not the name of an alias, eexxppaannddaalliiaass tries to complete the word to a full alias name without expanding it. It leaves the cursor directly after the completed word so that invoking eexxppaannddaalliiaass once more will

expand the now-complete alias name.

eexxppaannddwwoorrdd ((^^XXee))

Performs expansion on the current word: equivalent to the stan-

dard eexxppaanndd-wwoorrdd command, but using the eexxppaanndd completer.

Before calling it, the function field of the context is set to

`eexxppaanndd-wwoorrdd'.

ggeenneerriicc This function is not defined as a widget and not bound by default. However, it can be used to define a widget and will then store the name of the widget in the function field of the

context and call the completion system. This allows custom com-

pletion widgets with their own set of style settings to be defined easily. For example, to define a widget that performs normal completion and starts menu selection:

zzllee -CC ffoooo ccoommpplleettee-wwoorrdd ggeenneerriicc

bbiinnddkkeeyy ''......'' ffoooo zzssttyyllee ''::ccoommpplleettiioonn::ffoooo::**'' mmeennuu yyeess sseelleecctt==11 hhiissttoorryyccoommpplleetteewwoorrdd (\e/) Complete words from the shell's command history. This uses the

lliisstt, rreemmoovvee-aallll-dduuppss, ssoorrtt, and ssttoopp styles.

mmoossttrreecceennttffiillee ((^^XXmm)) Complete the name of the most recently modified file matching the pattern on the command line (which may be blank). If given a numeric argument N, complete the Nth most recently modified file. Note the completion, if any, is always unique. nneexxttttaaggss (^Xn) This command alters the set of matches used to that for the next

tag, or set of tags, either as given by the ttaagg-oorrddeerr style or

as set by default; these matches would otherwise not be avail-

able. Successive invocations of the command cycle through all possible sets of tags. rreeaaddccoommpp ((^^XX^^RR)) Prompt the user for a string, and use that to perform completion on the current word. There are two possibilities for the string. First, it can be a set of words beginning `', for

example `ffiilleess -//', in which case the function with any argu-

ments will be called to generate the completions. Unambiguous

parts of the function name will be completed automatically (nor-

mal completion is not available at this point) until a space is typed. Second, any other string will be passed as a set of arguments to ccoommppaadddd and should hence be an expression specifying what should be completed. A very restricted set of editing commands is available when reading the string: `DDEELL' and `^^HH' delete the last character; `^^UU' deletes the line, and `^^CC' and `^^GG' abort the function, while `RREETT' accepts the completion. Note the string is used verbatim as a command line, so arguments must be quoted in accordance with standard shell rules. Once a string has been read, the next call to rreeaaddccoommpp will use the existing string instead of reading a new one. To force

a new string to be read, call rreeaaddccoommpp with a numeric argu-

ment. ccoommpplleetteeddeebbuugg ((^^XX??))

This widget performs ordinary completion, but captures in a tem-

porary file a trace of the shell commands executed by the com-

pletion system. Each completion attempt gets its own file. A command to view each of these files is pushed onto the editor buffer stack. ccoommpplleetteehheellpp ((^^XXhh)) This widget displays information about the context names, the tags, and the completion functions used when completing at the current cursor position. If given a numeric argument other than

11 (as in `EESSCC-22 ^^XXhh'), then the styles used and the contexts for

which they are used will be shown, too. Note that the information about styles may be incomplete; it

depends on the information available from the completion func-

tions called, which in turn is determined by the user's own styles and other settings. ccoommpplleetteettaagg ((^^XXtt)) This widget completes symbol tags created by the eettaaggss or ccttaaggss

programmes (note there is no connection with the completion sys-

tem's tags) stored in a file TTAAGGSS, in the format used by eettaaggss, or ttaaggss, in the format created by ccttaaggss. It will look back up the path hierarchy for the first occurrence of either file; if both exist, the file TTAAGGSS is preferred. You can specify the

full path to a TTAAGGSS or ttaaggss file by setting the parameter $$TTAAGGSS-

FFIILLEE or $$ttaaggssffiillee respectively. The corresponding completion

tags used are eettaaggss and vvttaaggss, after emacs and vi respectively. UUTTIILLIITTYY FFUUNNCCTTIIOONNSS

Descriptions follow for utility functions that may be useful when writ-

ing completion functions. If functions are installed in subdirecto-

ries, most of these reside in the BBaassee subdirectory. Like the example

functions for commands in the distribution, the utility functions gen-

erating matches all follow the convention of returning zero if they

generated completions and non-zero if no matching completions could be

added. Two more features are offered by the mmaaiinnccoommpplleettee function. The arrays ccoommpppprreeffuunnccss and ccoommppppoossttffuunnccss may contain names of functions that are to be called immediately before or after completion has been

tried. A function will only be called once unless it explicitly rein-

serts itself into the array.

aallllllaabbeellss [ -xx ] [ -1122VVJJ ] tag name descr [ command args ... ]

This is a convenient interface to the nneexxttllaabbeell function below, implementing the loop shown in the nneexxttllaabbeell example. The command and its arguments are called to generate the

matches. The options stored in the parameter name will automat-

ically be inserted into the args passed to the command. Nor-

mally, they are put directly after the command, but if one of the args is a single hyphen, they are inserted directly before that. If the hyphen is the last argument, it will be removed from the argument list before the command is called. This allows aallllllaabbeellss to be used in almost all cases where the matches can be generated by a single call to the ccoommppaadddd builtin command or by a call to one of the utility functions. For example: llooccaall eexxppll ...... iiff rreeqquueesstteedd ffoooo;; tthheenn ......

aallllllaabbeellss ffoooo eexxppll ''......'' ccoommppaadddd ...... - $$mmaattcchheess

ffii

Will complete the strings from the mmaattcchheess parameter, using ccoomm-

ppaadddd with additional options which will take precedence over those generated by aallllllaabbeellss.

aalltteerrnnaattiivvee [ -CC name ] spec ...

This function is useful in simple cases where multiple tags are available. Essentially it implements a loop like the one described for the ttaaggss function below. The tags to use and the action to perform if a tag is requested are described using the specs which are of the form: `tag::descr::action'. The tags are offered using ttaaggss and if the

tag is requested, the action is executed with the given descrip-

tion descr. The actions are those accepted by the aarrgguummeennttss

function (described below), excluding the `->>state' and `==...'

forms. For example, the action may be a simple function call: aalltteerrnnaattiivvee \\ ''uusseerrss::uusseerr::uusseerrss'' \\ ''hhoossttss::hhoosstt::hhoossttss'' offers usernames and hostnames as possible matches, generated by the uusseerrss and hhoossttss functions respectively. Like aarrgguummeennttss, this functions uses aallllllaabbeellss to execute the

actions, which will loop over all sets of tags. Special han-

dling is only required if there is an additional valid tag, for example inside a function called from aalltteerrnnaattiivvee.

Like ttaaggss this function supports the -CC option to give a dif-

ferent name for the argument context field.

aarrgguummeennttss [ -sswwWWAACCRRSS ] [ -OO name ] [ -MM matchspec ] [ :: ] spec ...

This function can be used to give a complete specification for completion for a command whose arguments follow standard UNIX option and argument conventions. The following forms specify individual sets of options and arguments; to avoid ambiguity, these may be separated from the options to aarrgguummeennttss itself by a single colon. n::message::action n::::message::action This describes the n'th normal argument. The message will be printed above the matches generated and the action indicates what can be completed in this position (see below). If there are two colons before the message the argument is optional. If the message contains only white space, nothing will be printed above the matches unless the action adds an explanation string itself. ::message::action ::::message::action Similar, but describes the next argument, whatever number that happens to be. If all arguments are specified in

this form in the correct order the numbers are unneces-

sary. **::message::action **::::message::action **::::::message::action

This describes how arguments (usually non-option argu-

ments, those not beginning with - or ++) are to be com-

pleted when neither of the first two forms was provided. Any number of arguments can be completed in this fashion. With two colons before the message, the wwoorrddss special array and the CCUURRRREENNTT special parameter are modified to refer only to the normal arguments when the action is

executed or evaluated. With three colons before the mes-

sage they are modified to refer only to the normal argu-

ments covered by this description. optspec optspec:... This describes an option. The colon indicates handling for one or more arguments to the option; if it is not present, the option is assumed to take no arguments.

By default, options are multi-character name, one `-word'

per option. With -ss, options may be single characters,

with more than one option per word, although words start-

ing with two hyphens, such as `--pprreeffiixx', are still con-

sidered complete option names. This is suitable for standard GNU options.

The combination of -ss with -ww allows single-letter

options to be combined in a single word even if one or

more of the options take arguments. For example, if -aa

takes an argument, with no -ss `-aabb' is considered as a

single (unhandled) option; with -ss -aabb is an option with

the argument `bb'; with both -ss and -ww, -aabb may be the

option -aa and the option(-b) with arguments still to

come.

The option -WW takes this a stage further: it is possible

to complete single-letter options even after an argument

that occurs in the same word. However, it depends on the action performed whether options will really be completed at this point. For more control, use a utility function like gguuaarrdd as part of the action.

The following forms are available for the initial opt-

spec, whether or not the option has arguments. **optspec Here optspec is one of the remaining forms below. This indicates the following optspec may be repeated. Otherwise if the corresponding option is already present on the command line to the left of the cursor it will not be offered again.

-optname

++optname In the simplest form the optspec is just the option name beginning with a minus or a plus sign,

such as `-ffoooo'. The first argument for the option

(if any) must follow as a separate word directly after the option.

Either of `-++optname' and `++-optname' can be used

to specify that -optname and ++optname are both

valid.

In all the remaining forms, the leading `-' may be

replaced by or paired with `++' in this way.

-optname-

The first argument of the option must come directly after the option name in the same word.

For example, `-ffoooo-::...' specifies that the com-

pleted option and argument will look like

`-ffooooarg'.

-optname++

The first argument may appear immediately after

optname in the same word, or may appear as a sepa-

rate word after the option. For example,

`-ffoooo++::...' specifies that the completed option

and argument will look like either `-ffooooarg' or

`-ffoooo arg'.

-optname==

The argument may appear as the next word, or in same word as the option name provided that it is separated from it by an equals sign, for example

`-ffoooo==arg' or `-ffoooo arg'.

-optname==-

The argument to the option must appear after an equals sign in the same word, and may not be given in the next argument. optspec[[explanation]] An explanation string may be appended to any of the preceding forms of optspec by enclosing it in

brackets, as in `-qq[[qquueerryy ooppeerraattiioonn]]'.

The vveerrbboossee style is used to decide whether the explanation strings are displayed with the option in a completion listing. If no bracketed explanation string is given but

the aauuttoo-ddeessccrriippttiioonn style is set and only one

argument is described for this optspec, the value of the style is displayed, with any appearance of

the sequence `%%dd' in it replaced by the message of

the first optarg that follows the optspec; see below. It is possible for options with a literal `+' or `==' to appear,

but that character must be quoted, for example `-\\++'.

Each optarg following an optspec must take one of the following forms: ::message::action ::::message::action An argument to the option; message and action are treated

as for ordinary arguments. In the first form, the argu-

ment is mandatory, and in the second form it is optional.

This group may be repeated for options which take multi-

ple arguments. In other words, ::message1::action1::mes-

sage2::action2 specifies that the option takes two argu-

ments. ::**pattern::message::action ::**pattern::::message::action ::**pattern::::::message::action This describes multiple arguments. Only the last optarg for an option taking multiple arguments may be given in this form. If the pattern is empty (i.e., ::**::), all the remaining words on the line are to be completed as described by the action; otherwise, all the words up to a word matching the pattern are to be completed using the action. Multiple colons are treated as for the `**::...' forms for ordinary arguments: when the message is preceded by two colons, the wwoorrddss special array and the CCUURRRREENNTT special parameter are modified during the execution or evaluation of the action to refer only to the words after the option. When preceded by three colons, they are modified to refer only to the words covered by this description. Any literal colon in an optname, message, or action must be preceded by a backslash, `\\::'. Each of the forms above may be preceded by a list in parentheses of

option names and argument numbers. If the given option is on the com-

mand line, the options and arguments indicated in parentheses will not

be offered. For example, `((-ttwwoo -tthhrreeee 11))-oonnee::......' completes the

option `-oonnee'; if this appears on the command line, the options -ttwwoo

and -tthhrreeee and the first ordinary argument will not be completed after

it. `((-ffoooo))::...' specifies an ordinary argument completion; -ffoooo will

not be completed if that argument is already present.

Other items may appear in the list of excluded options to indicate var-

ious other items that should not be applied when the current specifica-

tion is matched: a single star (**) for the rest arguments (i.e. a spec-

ification of the form `**::......'); a colon (::) for all normal

(non-option-) arguments; and a hyphen (-) for all options. For exam-

ple, if `((**))' appears before an option and the option appears on the command line, the list of remaining arguments (those shown in the above table beginning with `**::') will not be completed. To aid in reuse of specifications, it is possible to precede any of the forms above with `!!'; then the form will no longer be completed, although if the option or argument appears on the command line they will be skipped as normal. The main use for this is when the arguments are given by an array, and aarrgguummeennttss is called repeatedly for more

specific contexts: on the first call `aarrgguummeennttss $$gglloobbaallooppttiioonnss' is

used, and on subsequent calls `aarrgguummeennttss !!$$^^gglloobbaallooppttiioonnss'.

In each of the forms above the action determines how completions should

be generated. Except for the `->>string' form below, the action will be

executed by calling the aallllllaabbeellss function to process all tag labels. No special handling of tags is needed unless a function call introduces a new one. The forms for action are as follows. (single unquoted space)

This is useful where an argument is required but it is not pos-

sible or desirable to generate matches for it. The message will be displayed but no completions listed. Note that even in this case the colon at the end of the message is needed; it may only be omitted when neither a message nor an action is given. ((item1 item2 ...)) One of a list of possible matches, for example: ::ffoooo::((ffoooo bbaarr bbaazz)) ((((item1\\::desc1 ...)))) Similar to the above, but with descriptions for each possible match. Note the backslash before the colon. For example, ::ffoooo::((((aa\\::bbaarr bb\\::bbaazz)))) The matches will be listed together with their descriptions if the ddeessccrriippttiioonn style is set with the vvaalluueess tag in the context.

->>string

In this form, aarrgguummeennttss processes the arguments and options and then returns control to the calling function with parameters set to indicate the state of processing; the calling function then makes its own arrangements for generating completions. For example, functions that implement a state machine can use this type of action.

Where aarrgguummeennttss encounters a `->>string', it will strip all

leading and trailing whitespace from string and set the array ssttaattee to the set of all stringss for which an action is to be performed. By default and in common with all other well behaved completion functions, arguments returns zero if it was able to add matches

and non-zero otherwise. However, if the -RR option is given,

aarrgguummeennttss will instead return a status of 300 to indicate that

$$ssttaattee is to be handled.

In addition to $$ssttaattee, aarrgguummeennttss also sets the global parame-

ters `ccoonntteexxtt', `lliinnee' and `ooppttaarrggss' as described below, and does not reset any changes made to the special parameters such as PPRREEFFIIXX and wwoorrddss. This gives the calling function the choice of resetting these parameters or propagating changes in them.

A function calling aarrgguummeennttss with at least one action contain-

ing a `->>string' therefore must declare appropriate local param-

eters: llooccaall ccoonntteexxtt ssttaattee lliinnee

ttyyppeesseett -AA ooppttaarrggss

to avoid aarrgguummeennttss from altering the global environment.

{{eval-string}}

A string in braces is evaluated as shell code to generate

matches. If the eval-string itself does not begin with an open-

ing parenthesis or brace it is split into separate words before execution. == action If the action starts with `== ' (an equals sign followed by a space), aarrgguummeennttss will insert the contents of the argument field of the current context as the new first element in the

wwoorrddss special array and increment the value of the CCUURRRREENNTT spe-

cial parameter. This has the effect of inserting a dummy word onto the completion command line while not changing the point at which completion is taking place. This is most useful with one of the specifiers that restrict the words on the command line on which the action is to operate (the

two- and three-colon forms above). One particular use is when

an action itself causes aarrgguummeennttss on a restricted range; it is necessary to use this trick to insert an appropriate command name into the range for the second call to aarrgguummeennttss to be able to parse the line. word... word... This covers all forms other than those above. If the action starts with a space, the remaining list of words will be invoked unchanged. Otherwise it will be invoked with some extra strings placed after the first word; these are to be passed down as options to the ccoommppaadddd builtin. They ensure that the state specified by

aarrgguummeennttss, in particular the descriptions of options and argu-

ments, is correctly passed to the completion command. These additional arguments are taken from the array parameter `eexxppll'; this will be set up before executing the action and hence may be referred to inside it, typically in an expansion of the form

`$$eexxppll[[@@]]' which preserves empty elements of the array.

During the performance of the action the array `lliinnee' will be set to the command name and normal arguments from the command line, i.e. the words from the command line excluding all options and their arguments. Options are stored in the associative array `ooppttaarrggss' with option names as keys and their arguments as the values. For options that have more than one argument these are given as one string, separated by

colons. All colons in the original arguments are preceded with back-

slashes. The parameter `ccoonntteexxtt' is set when returning to the calling function

to perform an action of the form `->>string'. It is set to an array of

elements corresponding to the elements of $$ssttaattee. Each element is a

suitable name for the argument field of the context: either a string of

the form `ooppttiioonn-opt-n' for the n'th argument of the option -opt, or a

string of the form `aarrgguummeenntt-n' for the n'th argument. For `rest'

arguments, that is those in the list at the end not handled by posi-

tion, n is the string `rreesstt'. For example, when completing the argu-

ment of the -oo option, the name is `ooppttiioonn-oo-11', while for the second

normal (non-option-) argument it is `aarrgguummeenntt-22'.

Furthermore, during the evaluation of the action the context name in the ccuurrccoonntteexxtt parameter is altered to append the same string that is stored in the ccoonntteexxtt parameter. It is possible to specify multiple sets of options and arguments with the sets separated by single hyphens. The specifications before the first hyphen (if any) are shared by all the remaining sets. The first word in every other set provides a name for the set which may appear in exclusion lists in specifications, either alone or before one of the

possible values described above. In the second case a `-' should

appear between this name and the remainder. For example: aarrgguummeennttss \\

-aa \\

- sseett11 \\

-cc \\

- sseett22 \\

-dd \\

''::aarrgg::((xx22 yy22))''

This defines two sets. When the command line contains the option `-cc',

the `-dd' option and the argument will not be considered possible com-

pletions. When it contains `-dd' or an argument, the option `-cc' will

not be considered. However, after `-aa' both sets will still be consid-

ered valid. If the name given for one of the mutually exclusive sets is of the form `((name))' then only one value from each set will ever be completed; more

formally, all specifications are mutually exclusive to all other speci-

fications in the same set. This is useful for defining multiple sets of options which are mutually exclusive and in which the options are aliases for each other. For example: aarrgguummeennttss \\

-aa -bb \\

- ''((ccoommpprreessss))'' \\

{{-cc,,--ccoommpprreessss}}''[[ccoommpprreessss]]'' \\

- ''((uunnccoommpprreessss))'' \\

{{-dd,,--ddeeccoommpprreessss}}''[[ddeeccoommpprreessss]]''

As the completion code has to parse the command line separately for each set this form of argument is slow and should only be used when necessary. A useful alternative is often an option specification with

rest-arguments (as in `-ffoooo::**::......'); here the option -ffoooo swallows up

all remaining arguments as described by the optarg definitions.

The options -SS and -AA are available to simplify the specifications for

commands with standard option parsing. With -SS, no option will be com-

pleted after a `--' appearing on its own on the line; this argument

will otherwise be ignored; hence in the line

ffoooobbaarr -aa -- -bb

the `-aa' is considered an option but the `-bb' is considered an argu-

ment, while the `--' is considered to be neither.

With -AA, no options will be completed after the first non-option argu-

ment on the line. The -AA must be followed by a pattern matching all

strings which are not to be taken as arguments. For example, to make aarrgguummeennttss stop completing options after the first normal argument, but ignoring all strings starting with a hyphen even if they are not

described by one of the optspecs, the form is `-AA ""-**""'.

The option `-OO name' specifies the name of an array whose elements will

be passed as arguments to functions called to execute actions. For

example, this can be used to pass the same set of options for the ccoomm-

ppaadddd builtin to all actions.

The option `-MM spec' sets a match specification to use to completion

option names and values. It must appear before the first argument

specification. The default is `rr::||[[-]]==** rr::||==**': this allows partial

word completion after `' and `-', for example `-f-b' can be completed

to `-ffoooo-bbaarr'.

The option -CC tells aarrgguummeennttss to modify the ccuurrccoonntteexxtt parameter for

an action of the form `->>state'. This is the standard parameter used

to keep track of the current context. Here it (and not the ccoonntteexxtt array) should be made local to the calling function to avoid passing back the modified value and should be initialised to the current value at the start of the function:

llooccaall ccuurrccoonntteexxtt==""$$ccuurrccoonntteexxtt""

This is useful where it is not possible for multiple states to be valid together.

The option `--' allows aarrgguummeennttss to work out the names of long options

that support the `--hheellpp' option which is standard in many GNU com-

mands. The command word is called with the argument `--hheellpp' and the

output examined for option names. Clearly, it can be dangerous to pass this to commands which may not support this option as the behaviour of the command is unspecified.

In addition to options, `aarrgguummeennttss --' will try to deduce the types of

arguments available for options when the form `--opt=val' is valid. It

is also possible to provide hints by examining the help text of the command and adding specifiers of the form `pattern::message::action'; note that normal aarrgguummeennttss specifiers are not used. The pattern is

matched against the help text for an option, and if it matches the mes-

sage and action are used as for other argument specifiers. For exam-

ple:

aarrgguummeennttss -- ''**\\**::ttooggggllee::((yyeess nnoo))'' \\

''**==FFIILLEE**::ffiillee::ffiilleess'' \\

''**==DDIIRR**::ddiirreeccttoorryy::ffiilleess -//'' \\

''**==PPAATTHH**::ddiirreeccttoorryy::ffiilleess -//''

Here, `yyeess' and `nnoo' will be completed as the argument of options whose description ends in a star; file names will be completed for options that contain the substring `==FFIILLEE' in the description; and directories will be completed for options whose description contains `==DDIIRR' or `==PPAATTHH'. The last three are in fact the default and so need not be given explicitly, although it is possible to override the use of these patterns. A typical help text which uses this feature is:

-CC,, --ddiirreeccttoorryy==DDIIRR cchhaannggee ttoo ddiirreeccttoorryy DDIIRR

so that the above specifications will cause directories to be completed

after `--ddiirreeccttoorryy', though not after `-CC'.

Note also that aarrgguummeennttss tries to find out automatically if the argu-

ment for an option is optional. This can be specified explicitly by doubling the colon before the message.

If the pattern ends in `((-))', this will removed from the pattern and

the action will be used only directly after the `==', not in the next word. This is the behaviour of a normal specification defined with the

form `==-'.

The `aarrgguummeennttss --' can be followed by the option `-ii patterns' to give

patterns for options which are not to be completed. The patterns can be given as the name of an array parameter or as a literal list in parentheses. For example,

aarrgguummeennttss -- -ii \\

""((--((eenn||ddiiss))aabbllee-FFEEAATTUURREE**))""

will cause completion to ignore the options `--eennaabbllee-FFEEAATTUURREE' and

`--ddiissaabbllee-FFEEAATTUURREE' (this example is useful with GNU ccoonnffiigguurree).

The `aarrgguummeennttss --' form can also be followed by the option `-ss pair'

to describe option aliases. Each pair consists of a pattern and a

replacement. For example, some ccoonnffiigguurree-scripts describe options only

as `--eennaabbllee-ffoooo', but also accept `--ddiissaabbllee-ffoooo'. To allow comple-

tion of the second form:

aarrgguummeennttss -- -ss ""((##--eennaabbllee- --ddiissaabbllee-))""

Here is a more general example of the use of aarrgguummeennttss:

aarrgguummeennttss ''-ll++::lleefftt bboorrddeerr::'' \\

''-ffoorrmmaatt::ppaappeerr ssiizzee::((lleetttteerr AA44))'' \\

''**-ccooppyy::oouuttppuutt ffiillee::ffiilleess::::rreessoolluuttiioonn::((330000 660000))'' \\

''::ppoossttssccrriipptt ffiillee::ffiilleess -gg \\**..\\((ppss\\||eeppss\\))'' \\

''**::ppaaggee nnuummbbeerr::''

This describes three options: `-ll', `-ffoorrmmaatt', and `-ccooppyy'. The first

takes one argument described as `left border' for which no completion will be offered because of the empty action. Its argument may come

directly after the `-ll' or it may be given as the next word on the

line.

The `-ffoorrmmaatt' option takes one argument in the next word, described as

`paper size' for which only the strings `lleetttteerr' and `AA44' will be com-

pleted.

The `-ccooppyy' option may appear more than once on the command line and

takes two arguments. The first is mandatory and will be completed as a filename. The second is optional (because of the second colon before the description `resolution') and will be completed from the strings `330000' and `660000'. The last two descriptions say what should be completed as arguments. The first describes the first argument as a `postscript file' and makes files ending in `ppss' or `eeppss' be completed. The last description gives all other arguments the description `page numbers' but does not offer completions. ccaacchheeiinnvvaalliidd cacheidentifier

This function returns status zero if the completions cache cor-

responding to the given cache identifier needs rebuilding. It

determines this by looking up the ccaacchhee-ppoolliiccyy style for the

current context. This should provide a function name which is run with the full path to the relevant cache file as the only argument. Example: eexxaammpplleeccaacchhiinnggppoolliiccyy (()) {{

## rreebbuuiilldd iiff ccaacchhee iiss mmoorree tthhaann aa wweeeekk oolldd

oollddpp==(( ""$$11""((NNmmww++11)) ))

(((( $$##oollddpp ))))

}} ccaallllffuunnccttiioonn return name [ args ... ] If a function name exists, it is called with the arguments args. The return argument gives the name of a parameter in which the return status from the function name; if return is empty or a single hyphen it is ignored.

The return value of ccaallllffuunnccttiioonn itself is zero if the func-

tion name exists and was called and non-zero otherwise.

ccaallllpprrooggrraamm tag string ... This function provides a mechanism for the user to override the use of an external command. It looks up the ccoommmmaanndd style with the supplied tag. If the style is set, its value is used as the command to execute. The strings from the call to ccaallllpprrooggrraamm, or from the style if set, are concatenated with spaces between them and the resulting string is evaluated. The return value is the return value of the command called.

ccoommbbiinnaattiioonn [ -ss pattern ] tag style spec ... field opts ...

This function is used to complete combinations of values, for example pairs of hostnames and usernames. The style argument gives the style which defines the pairs; it is looked up in a context with the tag specified. The style name consists of field names separated by hyphens, for

example `uusseerrss-hhoossttss-ppoorrttss'. For each field for a value is

already known, a spec of the form `field==pattern' is given. For example, if the command line so far specifies a user `ppwwss', the argument `uusseerrss==ppwwss' should appear. The next argument with no equals sign is taken as the name of the field for which completions should be generated (presumably not one of the fields for which the value is known). The matches generated will be taken from the value of the style. These should contain the possible values for the combinations in the appropriate order (users, hosts, ports in the example above). The different fields the values for the different fields are separated by colons. This can be altered with the

option -ss to ccoommbbiinnaattiioonn which specifies a pattern. Typically

this is a character class, as for example `-ss ""[[::@@]]""' in the

case of the uusseerrss-hhoossttss style. Each `field==pattern' specifi-

cation restricts the completions which apply to elements of the style with appropriately matching fields. If no style with the given name is defined for the given tag, or if none of the strings in style's value match, but a function name of the required field preceded by an underscore is defined,

that function will be called to generate the matches. For exam-

ple, if there is no `uusseerrss-hhoossttss-ppoorrttss' or no matching hostname

when a host is required, the function `hhoossttss' will automati-

cally be called. If the same name is used for more than one field, in both the `field==pattern' and the argument that gives the name of the field to be completed, the number of the field (starting with one) may be given after the fieldname, separated from it by a colon.

All arguments after the required field name are passed to ccoomm-

ppaadddd when generating matches from the style value, or to the functions for the fields if they are called.

ddeessccrriibbee [ -ooOO | -tt tag ] descr name1 [ name2 ] opts ... -- ...

This function associates completions with descriptions. Multi-

ple groups separated by -- can be supplied, potentially with

different completion options opts. The descr is taken as a string to display above the matches if

the ffoorrmmaatt style for the ddeessccrriippttiioonnss tag is set. This is fol-

lowed by one or two names of arrays followed by options to pass to ccoommppaadddd. The first array contains the possible completions with their descriptions in the form `completion::description'. If a second array is given, it should have the same number of elements as the first; in this case the corresponding elements are added as possible completions instead of the completion strings from the first array. The completion list will retain

the descriptions from the first array. Finally, a set of com-

pletion options can appear.

If the option `-oo' appears before the first argument, the

matches added will be treated as names of command options (N.B.

not shell options), typically following a `-', `--' or `++' on

the command line. In this case ddeessccrriibbee uses the pprreeffiixx-hhiidd-

ddeenn, pprreeffiixx-nneeeeddeedd and vveerrbboossee styles to find out if the strings

should be added as completions and if the descriptions should be

shown. Without the `-oo' option, only the vveerrbboossee style is used

to decide how descriptions are shown. If `-OO' is used instead

of `-OO', command options are completed as above but ddeessccrriibbee

will not handle the pprreeffiixx-nneeeeddeedd style.

With the -tt option a tag can be specified. The default is `vvaall-

uueess' or, if the -oo option is given, `ooppttiioonnss'.

If selected by the lliisstt-ggrroouuppeedd style, strings with the same

description will appear together in the list. ddeessccrriibbee uses the aallllllaabbeellss function to generate the matches, so it does not need to appear inside a loop over tag labels.

ddeessccrriippttiioonn [ -xx ] [ -1122VVJJ ] tag name descr [ spec ... ]

This function is not to be confused with the previous one; it is used as a helper function for creating options to ccoommppaadddd. It is buried inside many of the higher level completion functions and so often does not need to be called directly. The styles listed below are tested in the current context using the given tag. The resulting options for ccoommppaadddd are put into the array named name (this is traditionally `eexxppll', but this

convention is not enforced). The description for the corre-

sponding set of matches is passed to the function in descr.

The styles tested are: ffoorrmmaatt, hhiiddddeenn, mmaattcchheerr, iiggnnoorreedd-ppaatttteerrnnss

and ggrroouupp-nnaammee. The ffoorrmmaatt style is first tested for the given

tag and then for the ddeessccrriippttiioonnss tag if no value was found, while the remainder are only tested for the tag given as the first argument. The function also calls sseettuupp which tests some more styles.

The string returned by the ffoorrmmaatt style (if any) will be modi-

fied so that the sequence `%%dd' is replaced by the descr given as

the third argument without any leading or trailing white space. If, after removing the white space, the descr is the empty string, the format style will not be used and the options put into the name array will not contain an explanation string to be displayed above the matches. If ddeessccrriippttiioonn is called with more than three arguments, the additional specs should be of the form `char::str'. These supply

escape sequence replacements for the ffoorrmmaatt style: every appear-

ance of `%%char' will be replaced by string.

If the -xx option is given, the description will be passed to

ccoommppaadddd using the -xx option instead of the default -XX. This

means that the description will be displayed even if there are no corresponding matches. The options placed in the array name take account of the

ggrroouupp-nnaammee style, so matches are placed in a separate group

where necessary. The group normally has its elements sorted (by

passing the option -JJ to ccoommppaadddd), but if an option starting

with `-VV', `-JJ', `-11', or `-22' is passed to ddeessccrriippttiioonn, that

option will be included in the array. Hence it is possible for

the completion group to be unsorted by giving the option `-VV',

`-11VV', or `-22VV'.

In most cases, the function will be used like this: llooccaall eexxppll ddeessccrriippttiioonn ffiilleess eexxppll ffiillee

ccoommppaadddd ""$$eexxppll[[@@]]"" - ""$$ffiilleess[[@@]]""

Note the use of the parameter eexxppll, the hyphen, and the list of

matches. Almost all calls to ccoommppaadddd within the completion sys-

tem use a similar format; this ensures that user-specified

styles are correctly passed down to the builtins which implement the internals of completion. ddiissppaattcchh context string ...

This sets the current context to context and looks for comple-

tion functions to handle this context by hunting through the list of command names or special contexts (as described above for ccoommppddeeff) given as string .... The first completion function to be defined for one of the contexts in the list is used to

generate matches. Typically, the last string is -ddeeffaauulltt- to

cause the function for default completion to be used as a fall-

back.

The function sets the parameter $$sseerrvviiccee to the string being

tried, and sets the context/command field (the fourth) of the

$$ccuurrccoonntteexxtt parameter to the context given as the first argu-

ment. ffiilleess The function ffiilleess calls ppaatthhffiilleess with all the arguments it

was passed except for -gg and -//. The use of these two options

depends on the setting of the ffiillee-ppaatttteerrnnss style.

This function accepts the full set of options allowed by ppaatthhffiilleess, described below. ggnnuuggeenneerriicc This function is a simple wrapper around the aarrgguummeennttss function described above. It can be used to determine automatically the long options understood by commands that produce a list when

passed the option `--hheellpp'. It is intended to be used as a

top-level completion function in its own right. For example, to

enable option completion for the commands ffoooo and bbaarr, use ccoommppddeeff ggnnuuggeenneerriicc ffoooo bbaarr after the call to ccoommppiinniitt. The completion system as supplied is conservative in its use of this function, since it is important to be sure the command

understands the option `-'-hheellpp'.

gguuaarrdd [ options ] pattern descr

This function is intended to be used in the action for the spec-

ifications passed to aarrgguummeennttss and similar functions. It

returns immediately with a non-zero return value if the string

to be completed does not match the pattern. If the pattern matches, the descr is displayed; the function then returns zero

if the word to complete is not empty, non-zero otherwise.

The pattern may be preceded by any of the options understood by

ccoommppaadddd that are passed down from ddeessccrriippttiioonn, namely -MM, -JJ,

-VV, -11, -22, -nn, -FF and -XX. All of these options will be

ignored. This fits in conveniently with the argument-passing

conventions of actions for aarrgguummeennttss.

As an example, consider a command taking the options -nn and

-nnoonnee, where -nn must be followed by a numeric value in the same

word. By using:

aarrgguummeennttss ''-nn-:: ::gguuaarrdd ""[[00-99]]##"" ""nnuummeerriicc vvaalluuee""'' ''-nnoonnee''

aarrgguummeennttss can be made to both display the message `nnuummeerriicc

vvaalluuee' and complete options after `-nn<>'. If the `-nn' is

already followed by one or more digits (the pattern passed to

gguuaarrdd) only the message will be displayed; if the `-nn' is fol-

lowed by another character, only options are completed.

mmeessssaaggee [ -rr1122 ] [ -VVJJ group ] descr

mmeessssaaggee -ee [ tag ] descr

The descr is used in the same way as the third argument to the ddeessccrriippttiioonn function, except that the resulting string will always be shown whether or not matches were generated. This is

useful for displaying a help message in places where no comple-

tions can be generated. The ffoorrmmaatt style is examined with the mmeessssaaggeess tag to find a message; the usual tag, ddeessccrriippttiioonnss, is used only if the style is not set with the former.

If the -rr option is given, no style is used; the descr is taken

literally as the string to display. This is most useful when

the descr comes from a pre-processed argument list which already

contains an expanded description.

The -1122VVJJ options and the group are passed to ccoommppaadddd and hence

determine the group the message string is added to. The second form gives a description for completions with the tag tag to be shown even if there are no matches for that tag. The tag can be omitted and if so the tag is taken from the parameter

$$ccuurrttaagg; this is maintained by the completion system and so is

usually correct. mmuullttiippaarrttss sep array The argument sep is a separator character. The array may be either the name of an array parameter or a literal array in the form `((ffoooo bbaarr))', a parenthesised list of words separated by whitespace. The possible completions are the strings from the array. However, each chunk delimited by sep will be completed separately. For example, the ttaarr function uses `mmuullttiippaarrttss // patharray' to complete partial file paths from the given array of complete file paths.

The -ii option causes mmuullttiippaarrttss to insert a unique match even

if that requires multiple separators to be inserted. This is not usually the expected behaviour with filenames, but certain other types of completion, for example those with a fixed set of possibilities, may be more suited to this form.

Like other utility functions, this function accepts the `-VV',

`-JJ', `-11', `-22', `-nn', `-ff', `-XX', `-MM', `-PP', `-SS', `-rr',

`-RR', and `-qq' options and passes them to the ccoommppaadddd builtin.

nneexxttllaabbeell [ -xx ] [ -1122VVJJ ] tag name descr [ options ... ]

This function is used to implement the loop over different tag

labels for a particular tag as described above for the ttaagg-oorrddeerr

style. On each call it checks to see if there are any more tag

labels; if there is it returns status zero, otherwise non-zero.

As this function requires a current tag to be set, it must always follow a call to ttaaggss or rreeqquueesstteedd.

The -xx1122VVJJ options and the first three arguments are passed to

the ddeessccrriippttiioonn function. Where appropriate the tag will be replaced by a tag label in this call. Any description given in

the ttaagg-oorrddeerr style is preferred to the descr passed to

nneexxttllaabbeell. The options given after the descr are set in the parameter given

by name, and hence are to be passed to ccoommppaadddd or whatever func-

tion is called to add the matches. Here is a typical use of this function for the tag ffoooo. The call to rreeqquueesstteedd determines if tag ffoooo is required at all; the loop over nneexxttllaabbeell handles any labels defined for the tag in

the ttaagg-oorrddeerr style.

llooccaall eexxppll rreett==11 ...... iiff rreeqquueesstteedd ffoooo;; tthheenn ...... wwhhiillee nneexxttllaabbeell ffoooo eexxppll ''......'';; ddoo

ccoommppaadddd ""$$eexxppll[[@@]]"" ...... &&&& rreett==00

ddoonnee ...... ffii rreettuurrnn rreett nnoorrmmaall

This is the standard function called to handle completion out-

side any special -context-. It is called both to complete the

command word and also the arguments for a command. In the sec-

ond case, nnoorrmmaall looks for a special completion for that com-

mand, and if there is none it uses the completion for the

-ddeeffaauulltt- context.

A second use is to reexamine the command line specified by the

$$wwoorrddss array and the $$CCUURRRREENNTT parameter after those have been

modified. For example, the function pprreeccoommmmaanndd, which com-

pletes after pre-command specifiers such as nnoohhuupp, removes the

first word from the wwoorrddss array, decrements the CCUURRRREENNTT parame-

ter, then calls nnoorrmmaall again. The effect is that `nnoohhuupp cmd ...' is treated in the same way as `cmd ...'. If the command name matches one of the patterns given by one of

the options -pp or -PP to ccoommppddeeff, the corresponding completion

function is called and then the parameter ccoommppsskkiipp is checked. If it is set completion is terminated at that point even if no matches have been found. This is the same effect as in the

-ffiirrsstt- context.

ooppttiioonnss This can be used to complete the names of shell options. It provides a matcher specification that ignores a leading `nnoo',

ignores underscores and allows upper-case letters to match their

lower-case counterparts (for example, `gglloobb', `nnoogglloobb',

`NNOOGGLLOOBB' are all completed). Any arguments are propagated to the ccoommppaadddd builtin. ooppttiioonnsssseett and ooppttiioonnssuunnsseett These functions complete only set or unset options, with the same matching specification used in the ooppttiioonnss function.

Note that you need to uncomment a few lines in the mmaaiinnccoomm-

pplleettee function for these functions to work properly. The lines in question are used to store the option settings in effect before the completion widget locally sets the options it needs. Hence these functions are not generally used by the completion system. ppaarraammeetteerrss This is used to complete the names of shell parameters.

The option `-gg pattern' limits the completion to parameters

whose type matches the pattern. The type of a parameter is that

shown by `pprriinntt $${{((tt))param}}', hence judicious use of `**' in pat-

tern is probably necessary. All other arguments are passed to the ccoommppaadddd builtin. ppaatthhffiilleess

This function is used throughout the completion system to com-

plete filenames. It allows completion of partial paths. For example, the string `//uu//ii//ss//ssiigg' may be completed to `//uussrr//iinncclluuddee//ssyyss//ssiiggnnaall..hh'. The options accepted by both ppaatthhffiilleess and ffiilleess are:

-ff Complete all filenames. This is the default.

-// Specifies that only directories should be completed.

-gg pattern

Specifies that only files matching the pattern should be completed.

-WW paths

Specifies path prefixes that are to be prepended to the string from the command line to generate the filenames but that should not be inserted as completions nor shown in completion listings. Here, paths may be the name of an array parameter, a literal list of paths enclosed in parentheses or an absolute pathname.

-FF ignored-files

This behaves as for the corresponding option to the ccoomm-

ppaadddd builtin. It gives direct control over which file-

names should be ignored. If the option is not present,

the iiggnnoorreedd-ppaatttteerrnnss style is used.

Both ppaatthhffiilleess and ffiilleess also accept the following options

which are passed to ccoommppaadddd: `-JJ', `-VV', `-11', `-22', `-nn', `-XX',

`-MM', `-PP', `-SS', `-qq', `-rr', and `-RR'.

Finally, the ppaatthhffiilleess function uses the styles eexxppaanndd,

aammbbiigguuoouuss, ssppeecciiaall-ddiirrss, lliisstt-ssuuffffiixxeess and ffiillee-ssoorrtt described

above.

ppiicckkvvaarriiaanntt [[ -cc command ]] [[ -rr name ]] label==pattern ...... label [[ args

...... ]]

This function is used to resolve situations where a single com-

mand name requires more than one type of handling, either because it has more than one variant or because there is a name clash between two different commands. The command to run is taken from the first element of the array

wwoorrddss unless this is overridden by the option -cc. This command

is run and its output is compared with a series of patterns. Arguments to be passed to the command can be specified at the end after all the other arguments. The patterns to try in order

are given by the arguments label==pattern; if the output of `com-

mand args ......' contains pattern, then llaabbeell is selected as the label for the command variant. If none of the patterns match, the final command label is selected and status 1 is returned.

If the `-rr name' is given, the label picked is stored in the

parameter named name. The results are also cached in the cmdvariant associative array indexed by the name of the command run. rreeggeexxaarrgguummeennttss name spec ... This function generates a completion function name which matches the specifications spec ......, a set of regular expressions as described below. After running rreeggeexxaarrgguummeennttss, the function name should be called at the appropriate point. The pattern to be matched is given by the contents of the wwoorrddss array up to the current cursor position joined together with null characters; no quotation is applied. The arguments are grouped as sets of alternatives separated by `||', which are tried one after the other until one matches. Each alternative consists of a one or more specifications which are tried left to right, with each pattern matched being stripped in turn from the command line being tested, until all of the group succeeds or until one fails; in the latter case, the next alternative is tried. This structure can be repeated to arbitrary depth by using parentheses; matching proceeds from inside to outside. A special procedure is applied if no test succeeds but the

remaining command line string contains no null character (imply-

ing the remaining word is the one for which completions are to be generated). The completion target is restricted to the remaining word and any actions for the corresponding patterns

are executed. In this case, nothing is stripped from the com-

mand line string. The order of evaluation of the actions can be

determined by the ttaagg-oorrddeerr style; the various formats supported

by aalltteerrnnaattiivvee can be used in action. The descr is used for setting up the array parameter eexxppll. Specification arguments take one of following forms, in which

metacharacters such as `((', `))', `##' and `||' should be quoted.

//pattern// [%%lookahead%%] [-guard] [::tag::descr::action]

This is a single primitive component. The function tests

whether the combined pattern `((##bb))((((##BB))pattern))looka-

head**' matches the command line string. If so, `guard'

is evaluated and its return status is examined to deter-

mine if the test has succeeded. The pattern string `[[]]' is guaranteed never to match. The lookahead is not stripped from the command line before the next pattern is examined.

//pattern//++ [%%lookahead%%] [-guard] [::tag::descr::action]

This is similar to `//pattern// ...' but the left part of the command line string (i.e. the part already matched by

previous patterns) is also considered part of the comple-

tion target.

//pattern//- [%%lookahead%%] [-guard] [::tag::descr::action]

This is similar to `//pattern// ...' but the actions of the current and previously matched patterns are ignored even if the following `pattern' matches the empty string. (( spec ))

Parentheses may be used to groups specs; note each paren-

thesis is a single argument to rreeggeexxaarrgguummeennttss.

spec ## This allows any number of repetitions of spec.

spec spec The two specs are to be matched one after the other as described above. spec || spec Either of the two specs can be matched.

rreeqquueesstteedd [ -xx ] [ -1122VVJJ ] tag [ name descr [ command args ... ] ]

This function is called to decide whether a tag already regis-

tered by a call to ttaaggss (see below) has been requested by the user and hence completion should be performed for it. It

returns status zero if the tag is requested and non-zero other-

wise. The function is typically used as part of a loop over different tags as follows: ttaaggss ffoooo bbaarr bbaazz wwhhiillee ttaaggss;; ddoo iiff rreeqquueesstteedd ffoooo;; tthheenn

...... ## ppeerrffoorrmm ccoommpplleettiioonn ffoorr ffoooo

ffii

...... ## tteesstt tthhee ttaaggss bbaarr aanndd bbaazz iinn tthhee ssaammee wwaayy

...... ## eexxiitt lloooopp iiff mmaattcchheess wweerree ggeenneerraatteedd

ddoonnee Note that the test for whether matches were generated is not performed until the end of the ttaaggss loop. This is so that the

user can set the ttaagg-oorrddeerr style to specify a set of tags to be

completed at the same time. If name and descr are given, rreeqquueesstteedd calls the ddeessccrriippttiioonn function with these arguments together with the options passed to rreeqquueesstteedd. If command is given, the aallllllaabbeellss function will be called immediately with the same arguments. In simple cases this makes it possible to perform the test for the tag and the matching in one go. For example: llooccaall eexxppll rreett==11 ttaaggss ffoooo bbaarr bbaazz wwhhiillee ttaaggss;; ddoo rreeqquueesstteedd ffoooo eexxppll ''ddeessccrriippttiioonn'' \\ ccoommppaadddd ffoooobbaarr ffoooobbaazz &&&& rreett==00 ...... (((( rreett )))) |||| bbrreeaakk ddoonnee If the command is not ccoommppaadddd, it must nevertheless be prepared to handle the same options. rreettrriieevveeccaacchhee cacheidentifier This function retrieves completion information from the file given by cacheidentifier, stored in a directory specified by

the ccaacchhee-ppaatthh style which defaults to ~~//..zzccoommppccaacchhee. The

return value is zero if retrieval was successful. It will only

attempt retrieval if the uussee-ccaacchhee style is set, so you can call

this function without worrying about whether the user wanted to use the caching layer. See ssttoorreeccaacchhee below for more details. sseeppppaarrttss This function is passed alternating arrays and separators as arguments. The arrays specify completions for parts of strings to be separated by the separators. The arrays may be the names of array parameters or a quoted list of words in parentheses. For example, with the array `hhoossttss==((ffttpp nneewwss))' the call `sseeppppaarrttss ''((ffoooo bbaarr))'' @@ hhoossttss' will complete the string `ff' to `ffoooo' and the string `bb@@nn' to `bbaarr@@nneewwss'.

This function accepts the ccoommppaadddd options `-VV', `-JJ', `-11',

`-22', `-nn', `-XX', `-MM', `-PP', `-SS', `-rr', `-RR', and `-qq' and

passes them on to the ccoommppaadddd builtin used to add the matches. sseettuupp tag [ group ]

This function sets up the special parameters used by the comple-

tion system appropriately for the tag given as the first argu-

ment. It uses the styles lliisstt-ccoolloorrss, lliisstt-ppaacckkeedd,

lliisstt-rroowwss-ffiirrsstt, llaasstt-pprroommpptt, aacccceepptt-eexxaacctt, mmeennuu and ffoorrccee-lliisstt.

The optional group supplies the name of the group in which the matches will be placed. If it is not given, the tag is used as the group name. This function is called automatically from ddeessccrriippttiioonn and hence is not normally called explicitly. ssttoorreeccaacchhee cacheidentifier params ... This function, together with rreettrriieevveeccaacchhee and ccaacchheeiinnvvaalliidd, implements a caching layer which can be used in any completion function. Data obtained by costly operations are stored in

parameters; this function then dumps the values of those parame-

ters to a file. The data can then be retrieved quickly from that file via rreettrriieevveeccaacchhee, even in different instances of the shell. The cacheidentifier specifies the file which the data should be dumped to. The file is stored in a directory specified by the

ccaacchhee-ppaatthh style which defaults to ~~//..zzccoommppccaacchhee. The remaining

params arguments are the parameters to dump to the file.

The return value is zero if storage was successful. The func-

tion will only attempt storage if the uussee-ccaacchhee style is set, so

you can call this function without worrying about whether the user wanted to use the caching layer. The completion function may avoid calling rreettrriieevveeccaacchhee when it already has the completion data available as parameters. However, in that case it should call ccaacchheeiinnvvaalliidd to check whether the data in the parameters and in the cache are still valid. See the perlmodules completion function for a simple example of the usage of the caching layer.

ttaaggss [ [ -CC name ] tags ... ]

If called with arguments, these are taken to be the names of tags valid for completions in the current context. These tags

are stored internally and sorted by using the ttaagg-oorrddeerr style.

Next, ttaaggss is called repeatedly without arguments from the same

completion function. This successively selects the first, sec-

ond, etc. set of tags requested by the user. The return value

is zero if at least one of the tags is requested and non-zero

otherwise. To test if a particular tag is to be tried, the rreeqquueesstteedd function should be called (see above).

If `-CC name' is given, name is temporarily stored in the argu-

ment field (the fifth) of the context in the ccuurrccoonntteexxtt parame-

ter during the call to ttaaggss; the field is restored on exit. This allows ttaaggss to use a more specific context without having to change and reset the ccuurrccoonntteexxtt parameter (which has the same effect).

vvaalluueess [ -OO name ] [ -ss sep ] [ -SS sep ] [ -wwCC ] desc spec ...

This is used to complete arbitrary keywords (values) and their arguments, or lists of such combinations.

If the first argument is the option `-OO name', it will be used

in the same way as by the aarrgguummeennttss function. In other words, the elements of the name array will be passed to ccoommppaadddd when executing an action.

If the first argument (or the first argument after `-OO name') is

`-ss', the next argument is used as the character that separates

multiple values. This character is automatically added after

each value in an auto-removable fashion (see below); all values

completed by `vvaalluueess -ss' appear in the same word on the command

line, unlike completion using aarrgguummeennttss. If this option is not present, only a single value will be completed per word. Normally, vvaalluueess will only use the current word to determine which values are already present on the command line and hence

are not to be completed again. If the -ww option is given, other

arguments are examined as well.

The first non-option argument is used as a string to print as a

description before listing the values.

All other arguments describe the possible values and their argu-

ments in the same format used for the description of options by the aarrgguummeennttss function (see above). The only differences are that no minus or plus sign is required at the beginning, values can have only one argument, and the forms of action beginning with an equal sign are not supported. The character separating a value from its argument can be set

using the option -SS (like -ss, followed by the character to use

as the separator in the next argument). By default the equals sign will be used as the separator between values and arguments. Example:

vvaalluueess -ss ,, ''ddeessccrriippttiioonn'' \\

''**ffoooo[[bbaarr]]'' \\ ''((ttwwoo))**oonnee[[nnuummbbeerr]]::ffiirrsstt ccoouunntt::'' \\ ''ttwwoo[[aannootthheerr nnuummbbeerr]]::::sseeccoonndd ccoouunntt::((11 22 33))'' This describes three possible values: `ffoooo', `oonnee', and `ttwwoo'. The first is described as `bbaarr', takes no argument and may appear more than once. The second is described as `nnuummbbeerr', may appear more than once, and takes one mandatory argument described as `ffiirrsstt ccoouunntt'; no action is specified, so it will not be completed. The `((ttwwoo))' at the beginning says that if the value `oonnee' is on the line, the value `ttwwoo' will no longer be considered a possible completion. Finally, the last value (`ttwwoo') is described as `aannootthheerr nnuummbbeerr' and takes an optional argument described as `sseeccoonndd ccoouunntt' for which the completions (to appear after an `==') are `11', `22', and `33'. The vvaalluueess

function will complete lists of these values separated by com-

mas. Like aarrgguummeennttss, this function temporarily adds another context

name component to the arguments element (the fifth) of the cur-

rent context while executing the action. Here this name is just the name of the value for which the argument is completed. The style vveerrbboossee is used to decide if the descriptions for the values (but not those for the arguments) should be printed. The associative array vvaallaarrggss is used to report values and

their arguments; this works similarly to the ooppttaarrggss associa-

tive array used by aarrgguummeennttss. Hence the function calling vvaall-

uueess should declare the local parameters ssttaattee, lliinnee, ccoonntteexxtt and vvaallaarrggss: llooccaall ccoonntteexxtt ssttaattee lliinnee

ttyyppeesseett -AA vvaallaarrggss

when using an action of the form `->>string'. With this function

the ccoonntteexxtt parameter will be set to the name of the value whose argument is to be completed. Note also that vvaalluueess normally adds the character used as the

separator between values as an auto-removable suffix (similar to

a `//' after a directory). However, this is not possible for a

`->>string' action as the matches for the argument are generated

by the calling function. To get the usual behaviour, the the calling function can add the separator x as a suffix by passing

the options `-qqSS x' either directly or indirectly to ccoommppaadddd.

The option -CC is treated in the same way as it is by aarrgguummeennttss.

In that case the parameter ccuurrccoonntteexxtt should be made local instead of ccoonntteexxtt (as described above).

wwaanntteedd [ -xx ] [ -CC name ] [ -1122VVJJ ] tag name descr command args ...

In many contexts, completion can only generate one particular set of matches, usually corresponding to a single tag. However, it is still necessary to decide whether the user requires matches of this type. This function is useful in such a case. The arguments to wwaanntteedd are the same as those to rreeqquueesstteedd, i.e. arguments to be passed to ddeessccrriippttiioonn. However, in this case the command is not optional; all the processing of tags,

including the loop over both tags and tag labels and the genera-

tion of matches, is carried out automatically by wwaanntteedd.

Hence to offer only one tag and immediately add the correspond-

ing matches with the given description: wwaanntteedd ttaagg eexxppll ''ddeessccrriippttiioonn'' \\ ccoommppaadddd mmaattcchheess...... Note that, as for rreeqquueesstteedd, the command must be able to accept options to be passed down to ccoommppaadddd.

Like ttaaggss this function supports the -CC option to give a dif-

ferent name for the argument context field. The -xx option has

the same meaning as for ddeessccrriippttiioonn. CCOOMMPPLLEETTIIOONN DDIIRREECCTTOORRIIEESS

In the source distribution, the files are contained in various subdi-

rectories of the CCoommpplleettiioonn directory. They may have been installed in

the same structure, or into one single function directory. The follow-

ing is a description of the files found in the original directory structure. If you wish to alter an installed file, you will need to copy it to some directory which appears earlier in your ffppaatthh than the standard directory where it appears. BBaassee The core functions and special completion widgets automatically bound to keys. You will certainly need most of these, though

will probably not need to alter them. Many of these are docu-

mented above. ZZsshh Functions for completing arguments of shell builtin commands and utility functions for this. Some of these are also used by functions from the UUnniixx directory. UUnniixx Functions for completing arguments of external commands and suites of commands. They may need modifying for your system,

although in many cases some attempt is made to decide which ver-

sion of a command is present. For example, completion for the mmoouunntt command tries to determine the system it is running on, while completion for many other utilities try to decide whether the GNU version of the command is in use, and hence whether the

--hheellpp option is supported.

XX, AAIIXX, BBSSDD, ... Completion and utility function for commands available only on some systems. These are not arranged hierarchically, so, for example, both the LLiinnuuxx and DDeebbiiaann directories, as well as the XX directory, may be useful on your system. ZSHCOMPCTL(1) ZSHCOMPCTL(1)

NAME

zshcompctl - zsh programmable completion

DESCRIPTION

This version of zsh has two ways of performing completion of words on the command line. New users of the shell may prefer to use the newer and more powerful system based on shell functions; this is described in zshcompsys(1), and the basic shell mechanisms which support it are

described in zshcompwid(1). This manual entry describes the older ccoomm-

ppccttll command.

ccoommppccttll [ -CCDDTT ] options [ command ... ]

ccoommppccttll [ -CCDDTT ] options [ -xx pattern options - ... -- ] [ ++ options [

-xx ... -- ] ... [++] ] [ command ... ]

ccoommppccttll -MM match-specs ...

ccoommppccttll -LL [ -CCDDTTMM ] [ command ... ]

ccoommppccttll ++ command ... Control the editor's completion behavior according to the supplied set

of options. Various editing commands, notably eexxppaanndd-oorr-ccoommpplleettee-wwoorrdd,

usually bound to tab, will attempt to complete a word typed by the

user, while others, notably ddeelleettee-cchhaarr-oorr-lliisstt, usually bound to ^D in

EMACS editing mode, list the possibilities; ccoommppccttll controls what those possibilities are. They may for example be filenames (the most common case, and hence the default), shell variables, or words from a

user-specified list.

CCOOMMMMAANNDD FFLLAAGGSS

Completion of the arguments of a command may be different for each com-

mand or may use the default. The behavior when completing the command word itself may also be separately specified. These correspond to the

following flags and arguments, all of which (except for -LL) may be com-

bined with any combination of the options described subsequently in the section `Option Flags': command ... controls completion for the named commands, which must be listed

last on the command line. If completion is attempted for a com-

mand with a pathname containing slashes and no completion defi-

nition is found, the search is retried with the last pathname component. If the command starts with a ==, completion is tried with the pathname of the command. Any of the command strings may be patterns of the form normally

used for filename generation. These should be be quoted to pro-

tect them from immediate expansion; for example the command

string ''ffoooo**'' arranges for completion of the words of any com-

mand beginning with ffoooo. When completion is attempted, all pat-

tern completions are tried in the reverse order of their defini-

tion until one matches. By default, completion then proceeds as normal, i.e. the shell will try to generate more matches for the specific command on the command line; this can be overridden by

including -ttnn in the flags for the pattern completion.

Note that aliases are expanded before the command name is deter-

mined unless the CCOOMMPPLLEETTEEAALLIIAASSEESS option is set. Commands may

not be combined with the -CC, -DD or -TT flags.

-CC controls completion when the command word itself is being com-

pleted. If no ccoommppccttll -CC command has been issued, the names of

any executable command (whether in the path or specific to the shell, such as aliases or functions) are completed.

-DD controls default completion behavior for the arguments of com-

mands not assigned any special behavior. If no ccoommppccttll -DD com-

mand has been issued, filenames are completed.

-TT supplies completion flags to be used before any other processing

is done, even before processing for ccoommppccttlls defined for spe-

cific commands. This is especially useful when combined with

extended completion (the -xx flag, see the section `Extended Com-

pletion' below). Using this flag you can define default behav-

ior which will apply to all commands without exception, or you can alter the standard behavior for all commands. For example,

if your access to the user database is too slow and/or it con-

tains too many users (so that completion after `~~' is too slow to be usable), you can use

ccoommppccttll -TT -xx ''ss[[~~]] CC[[00,,[[^^//]]##]]'' -kk ffrriieennddss -SS// -ttnn

to complete the strings in the array ffrriieennddss after a `~~'. The

CC[[......]] argument is necessary so that this form of ~-completion

is not tried after the directory name is finished.

-LL lists the existing completion behavior in a manner suitable for

putting into a start-up script; the existing behavior is not

changed. Any combination of the above forms, or the -MM flag

(which must follow the -LL flag), may be specified, otherwise all

defined completions are listed. Any other flags supplied are ignored. no argument If no argument is given, ccoommppccttll lists all defined completions in an abbreviated form; with a list of options, all completions with those flags set (not counting extended completion) are listed. If the ++ flag is alone and followed immediately by the command list, the completion behavior for all the commands in the list is reset to the default. In other words, completion will subsequently use the

options specified by the -DD flag.

The form with -MM as the first and only option defines global matching

specifications (see zshcompwid). The match specifications given will be used for every completion attempt (only when using ccoommppccttll, not with the new completion system) and are tried in the order in which they are defined until one generates at least one match. E.g.:

ccoommppccttll -MM '''' ''mm::{{aa-zzAA-ZZ}}=={{AA-ZZaa-zz}}''

This will first try completion without any global match specifications (the empty string) and, if that generates no matches, will try case insensitive completion. OOPPTTIIOONN FFLLAAGGSS

[ -ffccFFBBddeeaaRRGGoovvNNAAIIOOPPZZEEnnbbjjrrzzuu//1122 ]

[ -kk array ] [ -gg globstring ] [ -ss subststring ]

[ -KK function ]

[ -QQ ] [ -PP prefix ] [ -SS suffix ]

[ -WW file-prefix ] [ -HH num pattern ]

[ -qq ] [ -XX explanation ] [ -YY explanation ]

[ -yy func-or-var ] [ -ll cmd ] [ -hh cmd ] [ -UU ]

[ -tt continue ] [ -JJ name ] [ -VV name ]

[ -MM match-spec ]

The remaining options specify the type of command arguments to look for during completion. Any combination of these flags may be specified; the result is a sorted list of all the possibilities. The options are as follows. SSiimmppllee FFllaaggss These produce completion lists made up by the shell itself:

-ff Filenames and filesystem paths.

-// Just filesystem paths.

-cc Command names, including aliases, shell functions, builtins and

reserved words.

-FF Function names.

-BB Names of builtin commands.

-mm Names of external commands.

-ww Reserved words.

-aa Alias names.

-RR Names of regular (non-global) aliases.

-GG Names of global aliases.

-dd This can be combined with -FF, -BB, -ww, -aa, -RR and -GG to get names

of disabled functions, builtins, reserved words or aliases.

-ee This option (to show enabled commands) is in effect by default,

but may be combined with -dd; -ddee in combination with -FF, -BB, -ww,

-aa, -RR and -GG will complete names of functions, builtins,

reserved words or aliases whether or not they are disabled.

-oo Names of shell options (see zshoptions(1)).

-vv Names of any variable defined in the shell.

-NN Names of scalar (non-array) parameters.

-AA Array names.

-II Names of integer variables.

-OO Names of read-only variables.

-pp Names of parameters used by the shell (including special parame-

ters).

-ZZ Names of shell special parameters.

-EE Names of environment variables.

-nn Named directories.

-bb Key binding names.

-jj Job names: the first word of the job leader's command line.

This is useful with the kkiillll builtin.

-rr Names of running jobs.

-zz Names of suspended jobs.

-uu User names.

FFllaaggss wwiitthh AArrgguummeennttss

These have user supplied arguments to determine how the list of comple-

tions is to be made up:

-kk array

Names taken from the elements of $$array (note that the `$$' does

not appear on the command line). Alternatively, the argument

array itself may be a set of space- or comma-separated values in

parentheses, in which any delimiter may be escaped with a back-

slash; in this case the argument should be quoted. For example,

ccoommppccttll -kk ""((ccppuuttiimmee ffiilleessiizzee ddaattaassiizzee ssttaacckkssiizzee

ccoorreedduummppssiizzee rreessiiddeenntt ddeessccrriippttoorrss))"" lliimmiitt

-gg globstring

The globstring is expanded using filename globbing; it should be quoted to protect it from immediate expansion. The resulting filenames are taken as the possible completions. Use `**((//))' instead of `**//' for directories. The ffiiggnnoorree special parameter is not applied to the resulting files. More than one pattern may be given separated by blanks. (Note that brace expansion is not part of globbing. Use the syntax `((eeiitthheerr||oorr))' to match alternatives.)

-ss subststring

The subststring is split into words and these words are than expanded using all shell expansion mechanisms (see zshexpn(1)).

The resulting words are taken as possible completions. The ffiigg-

nnoorree special parameter is not applied to the resulting files.

Note that -gg is faster for filenames.

-KK function

Call the given function to get the completions. Unless the name starts with an underscore, the function is passed two arguments: the prefix and the suffix of the word on which completion is to be attempted, in other words those characters before the cursor position, and those from the cursor position onwards. The whole

command line can be accessed with the -cc and -ll flags of the

rreeaadd builtin. The function should set the variable rreeppllyy to an array containing the completions (one completion per element); note that rreeppllyy should not be made local to the function. From

such a function the command line can be accessed with the -cc and

-ll flags to the rreeaadd builtin. For example,

ffuunnccttiioonn wwhhoossoonn {{ rreeppllyy==((``uusseerrss``));; }}

ccoommppccttll -KK wwhhoossoonn ttaallkk

completes only logged-on users after `ttaallkk'. Note that `wwhhoossoonn'

must return an array, so `rreeppllyy==``uusseerrss``' would be incorrect.

-HH num pattern

The possible completions are taken from the last num history lines. Only words matching pattern are taken. If num is zero or negative the whole history is searched and if pattern is the empty string all words are taken (as with `**'). A typical use is

ccoommppccttll -DD -ff ++ -HH 00 ''''

which forces completion to look back in the history list for a word if no filename matches. CCoonnttrrooll FFllaaggss

These do not directly specify types of name to be completed, but manip-

ulate the options that do:

-QQ This instructs the shell not to quote any metacharacters in the

possible completions. Normally the results of a completion are inserted into the command line with any metacharacters quoted so

that they are interpreted as normal characters. This is appro-

priate for filenames and ordinary strings. However, for special

effects, such as inserting a backquoted expression from a com-

pletion array (-kk) so that the expression will not be evaluated

until the complete line is executed, this option must be used.

-PP prefix

The prefix is inserted just before the completed string; any

initial part already typed will be completed and the whole pre-

fix ignored for completion purposes. For example,

ccoommppccttll -jj -PP ""%%"" kkiillll

inserts a `%' after the kill command and then completes job

names.

-SS suffix

When a completion is found the suffix is inserted after the com-

pleted string. In the case of menu completion the suffix is inserted immediately, but it is still possible to cycle through the list of completions by repeatedly hitting the same key.

-WW file-prefix

With directory file-prefix: for command, file, directory and

globbing completion (options -cc, -ff, -//, -gg), the file prefix is

implicitly added in front of the completion. For example,

ccoommppccttll -// -WW ~~//MMaaiill mmaaiillddiirrss

completes any subdirectories to any depth beneath the directory ~~//MMaaiill, although that prefix does not appear on the command

line. The file-prefix may also be of the form accepted by the

-kk flag, i.e. the name of an array or a literal list in paren-

thesis. In this case all the directories in the list will be searched for possible completions.

-qq If used with a suffix as specified by the -SS option, this causes

the suffix to be removed if the next character typed is a blank or does not insert anything or if the suffix consists of only

one character and the next character typed is the same charac-

ter; this the same rule used for the AAUUTTOORREEMMOOVVEESSLLAASSHH option. The option is most useful for list separators (comma, colon, etc.).

-ll cmd This option restricts the range of command line words that are

considered to be arguments. If combined with one of the extended completion patterns `pp[[...]]', `rr[[...]]', or `RR[[...]]' (see the section `Extended Completion' below) the range is restricted to the range of arguments specified in the brackets.

Completion is then performed as if these had been given as argu-

ments to the cmd supplied with the option. If the cmd string is

empty the first word in the range is instead taken as the com-

mand name, and command name completion performed on the first word in the range. For example,

ccoommppccttll -xx ''rr[[-eexxeecc,,;;]]'' -ll '''' -- ffiinndd

completes arguments between `-eexxeecc' and the following `;;' (or

the end of the command line if there is no such string) as if they were a separate command line.

-hh cmd Normally zsh completes quoted strings as a whole. With this

option, completion can be done separately on different parts of

such strings. It works like the -ll option but makes the comple-

tion code work on the parts of the current word that are sepa-

rated by spaces. These parts are completed as if they were argu-

ments to the given cmd. If cmd is the empty string, the first

part is completed as a command name, as with -ll.

-UU Use the whole list of possible completions, whether or not they

actually match the word on the command line. The word typed so far will be deleted. This is most useful with a function (given

by the -KK option) which can examine the word components passed

to it (or via the rreeaadd builtin's -cc and -ll flags) and use its

own criteria to decide what matches. If there is no completion,

the original word is retained. Since the produced possible com-

pletions seldom have interesting common prefixes and suffixes, menu completion is started immediately if AAUUTTOOMMEENNUU is set and this flag is used.

-yy func-or-var

The list provided by func-or-var is displayed instead of the

list of completions whenever a listing is required; the actual completions to be inserted are not affected. It can be provided

in two ways. Firstly, if func-or-var begins with a $$ it defines

a variable, or if it begins with a left parenthesis a literal array, which contains the list. A variable may have been set by

a call to a function using the -KK option. Otherwise it contains

the name of a function which will be executed to create the list. The function will be passed as an argument list all matching completions, including prefixes and suffixes expanded in full, and should set the array rreeppllyy to the result. In both cases, the display list will only be retrieved after a complete list of matches has been created. Note that the returned list does not have to correspond, even in length, to the original set of matches, and may be passed as a scalar instead of an array. No special formatting of characters is performed on the output in this case; in particular, newlines are printed literally and if they appear output in columns is suppressed.

-XX explanation

Print explanation when trying completion on the current set of

options. A `%%nn' in this string is replaced by the number of

matches that were added for this explanation string. The expla-

nation only appears if completion was tried and there was no unique match, or when listing completions. Explanation strings will be listed together with the matches of the group specified

together with the -XX option (using the -JJ or -VV option). If the

same explanation string is given to multiple -XX options, the

string appears only once (for each group) and the number of

matches shown for the `%%nn' is the total number of all matches

for each of these uses. In any case, the explanation string will only be shown if there was at least one match added for the explanation string.

The sequences %%BB, %%bb, %%SS, %%ss, %%UU, and %%uu specify output

attributes (bold, standout, and underline) and %%{{......%%}} can be

used to include literal escape sequences as in prompts.

-YY explanation

Identical to -XX, except that the explanation first undergoes

expansion following the usual rules for strings in double quotes. The expansion will be carried out after any functions

are called for the -KK or -yy options, allowing them to set vari-

ables.

-tt continue

The continue-string contains a character that specifies which

set of completion flags should be used next. It is useful:

(i) With -TT, or when trying a list of pattern completions, when

ccoommppccttll would usually continue with ordinary processing after

finding matches; this can be suppressed with `-ttnn'.

(ii) With a list of alternatives separated by ++, when ccoommppccttll would normally stop when one of the alternatives generates

matches. It can be forced to consider the next set of comple-

tions by adding `-tt++' to the flags of the alternative before the

`++'. (iii) In an extended completion list (see below), when ccoommppccttll would normally continue until a set of conditions succeeded,

then use only the immediately following flags. With `-tt-', ccoomm-

ppccttll will continue trying extended completions after the next

`-'; with `-ttxx' it will attempt completion with the default

flags, in other words those before the `-xx'.

-JJ name

This gives the name of the group the matches should be placed

in. Groups are listed and sorted separately; likewise, menu com-

pletion will offer the matches in the groups in the order in which the groups were defined. If no group name is explicitly given, the matches are stored in a group named default. The first time a group name is encountered, a group with that name is created. After that all matches with the same group name are stored in that group.

This can be useful with non-exclusive alternative completions.

For example, in

ccoommppccttll -ff -JJ ffiilleess -tt++ ++ -vv -JJ vvaarriiaabblleess ffoooo

both files and variables are possible completions, as the -tt++

forces both sets of alternatives before and after the ++ to be

considered at once. Because of the -JJ options, however, all

files are listed before all variables.

-VV name

Like -JJ, but matches within the group will not be sorted in

listings nor in menu completion. These unsorted groups are in a different name space from the sorted ones, so groups defined as

-JJ ffiilleess and -VV ffiilleess are distinct.

-11 If given together with the -VV option, makes only consecutive

duplicates in the group be removed. Note that groups with and without this flag are in different name spaces.

-22 If given together with the -JJ or -VV option, makes all duplicates

be kept. Again, groups with and without this flag are in differ-

ent name spaces.

-MM match-spec

This defines additional matching control specifications that should be used only when testing words for the list of flags

this flag appears in. The format of the match-spec string is

described in zshcompwid. AALLTTEERRNNAATTIIVVEE CCOOMMPPLLEETTIIOONN

ccoommppccttll [ -CCDDTT ] options ++ options [ ++ ... ] [ ++ ] command ...

The form with `++' specifies alternative options. Completion is tried

with the options before the first `++'. If this produces no matches com-

pletion is tried with the flags after the `++' and so on. If there are no flags after the last `++' and a match has not been found up to that

point, default completion is tried. If the list of flags contains a -tt

with a ++ character, the next list of flags is used even if the current list produced matches. EEXXTTEENNDDEEDD CCOOMMPPLLEETTIIOONN

ccoommppccttll [ -CCDDTT ] options -xx pattern options - ... --

[ command ... ]

ccoommppccttll [ -CCDDTT ] options [ -xx pattern options - ... -- ]

[ ++ options [ -xx ... -- ] ... [++] ] [ command ... ]

The form with `-xx' specifies extended completion for the commands

given; as shown, it may be combined with alternative completion using

`++'. Each pattern is examined in turn; when a match is found, the cor-

responding options, as described in the section `Option Flags' above, are used to generate possible completions. If no pattern matches, the

options given before the -xx are used.

Note that each pattern should be supplied as a single argument and should be quoted to prevent expansion of metacharacters by the shell.

A pattern is built of sub-patterns separated by commas; it matches if

at least one of these sub-patterns matches (they are `or'ed). These

sub-patterns are in turn composed of other sub-patterns separated by

white spaces which match if all of the sub-patterns match (they are

`and'ed). An element of the sub-patterns is of the form `c[[...]][[...]]',

where the pairs of brackets may be repeated as often as necessary, and matches if any of the sets of brackets match (an `or'). The example below makes this clearer. The elements may be any of the following: ss[[string]]... Matches if the current word on the command line starts with one of the strings given in brackets. The string is not removed and is not part of the completion. SS[[string]]... Like ss[[string]] except that the string is part of the completion. pp[[from,,to]]... Matches if the number of the current word is between one of the from and to pairs inclusive. The comma and to are optional; to

defaults to the same value as from. The numbers may be nega-

tive: -n refers to the n'th last word on the line.

cc[[offset,,string]]... Matches if the string matches the word offset by offset from the current word position. Usually offset will be negative. CC[[offset,,pattern]]... Like cc but using pattern matching instead. ww[[index,,string]]...

Matches if the word in position index is equal to the corre-

sponding string. Note that the word count is made after any alias expansion. WW[[index,,pattern]]... Like ww but using pattern matching instead. nn[[index,,string]]... Matches if the current word contains string. Anything up to and

including the indexth occurrence of this string will not be con-

sidered part of the completion, but the rest will. index may be negative to count from the end: in most cases, index will be 1

or -1. For example,

ccoommppccttll -ss ''``uusseerrss``'' -xx ''nn[[11,,@@]]'' -kk hhoossttss -- ttaallkk

will usually complete usernames, but if you insert an @@ after

the name, names from the array hosts (assumed to contain host-

names, though you must make the array yourself) will be com-

pleted. Other commands such as rrccpp can be handled similarly. NN[[index,,string]]... Like nn except that the string will be taken as a character class. Anything up to and including the indexth occurrence of any of the characters in string will not be considered part of the completion. mm[[min,,max]]... Matches if the total number of words lies between min and max inclusive. rr[[str1,,str2]]... Matches if the cursor is after a word with prefix str1. If there is also a word with prefix str2 on the command line after the one matched by str1 it matches only if the cursor is before this word. If the comma and str2 are omitted, it matches if the cursor is after a word with prefix str1. RR[[str1,,str2]]... Like rr but using pattern matching instead. qq[[str]]... Matches the word currently being completed is in single quotes and the str begins with the letter `s', or if completion is done

in double quotes and str starts with the letter `d', or if com-

pletion is done in backticks and str starts with a `b'. EEXXAAMMPPLLEE

ccoommppccttll -uu -xx ''ss[[++]] cc[[-11,,-ff]],,ss[[-ff++]]'' \\

-gg ''~~//MMaaiill//**((::tt))'' - ''ss[[-ff]],,cc[[-11,,-ff]]'' -ff -- mmaaiill

This is to be interpreted as follows: If the current command is mmaaiill, then

if ((the current word begins with ++ and the previous word is -ff)

or (the current word begins with -ff++)), then complete the

non-directory part (the `::tt' glob modifier) of files in the directory

~~//MMaaiill; else

if the current word begins with -ff or the previous word was -ff, then

complete any file; else complete user names. ZSHMODULES(1) ZSHMODULES(1)

NAME

zshmodules - zsh loadable modules

DESCRIPTION

Some optional parts of zsh are in modules, separate from the core of the shell. Each of these modules may be linked in to the shell at build time, or can be dynamically linked while the shell is running if the installation supports this feature. The modules that are bundled with the zsh distribution are: zzsshh//ccaapp

Builtins for manipulating POSIX.1e (POSIX.6) capability (privi-

lege) sets. zzsshh//cclloonnee A builtin that can clone a running shell onto another terminal. zzsshh//ccoommppccttll The ccoommppccttll builtin for controlling completion. zzsshh//ccoommpplleettee The basic completion code. zzsshh//ccoommpplliisstt Completion listing extensions. zzsshh//ccoommppuuttiill A module with utility builtins needed for the shell function based completion system. zzsshh//ddaatteettiimmee Some date/time commands and parameters. zzsshh//ddeellttoocchhaarr

A ZLE function duplicating EMACS' zzaapp-ttoo-cchhaarr.

zzsshh//eexxaammppllee An example of how to write a module. zzsshh//ffiilleess Some basic file manipulation commands as builtins. zzsshh//mmaappffiillee Access to external files via a special associative array. zzsshh//mmaatthhffuunncc

Standard scientific functions for use in mathematical evalua-

tions. zzsshh//ppaarraammeetteerr Access to internal hash tables via special associative arrays. zzsshh//ppccrree Interface to the PCRE library. zzsshh//sscchheedd A builtin that provides a timed execution facility within the shell. zzsshh//nneett//ssoocckkeett Manipulation of Unix domain sockets zzsshh//ssttaatt A builtin command interface to the ssttaatt system call. zzsshh//ssyysstteemm

A builtin interface to various low-level system features.

zzsshh//nneett//ttccpp Manipulation of TCP sockets zzsshh//tteerrmmccaapp Interface to the termcap database. zzsshh//tteerrmmiinnffoo Interface to the terminfo database. zzsshh//zzffttpp A builtin FTP client. zzsshh//zzllee The Zsh Line Editor, including the bbiinnddkkeeyy and vvaarreedd builtins. zzsshh//zzlleeppaarraammeetteerr Access to internals of the Zsh Line Editor via parameters. zzsshh//zzpprrooff A module allowing profiling for shell functions. zzsshh//zzppttyy

A builtin for starting a command in a pseudo-terminal.

zzsshh//zzsseelleecctt Block and return when file descriptors are ready. zzsshh//zzuuttiill Some utility builtins, e.g. the one for supporting configuration via styles. TTHHEE ZZSSHH//CCAAPP MMOODDUULLEE

The zzsshh//ccaapp module is used for manipulating POSIX.1e (POSIX.6) capabil-

ity sets. If the operating system does not support this interface, the builtins defined by this module will do nothing. The builtins in this module are: ccaapp [ capabilities ] Change the shell's process capability sets to the specified

capabilities, otherwise display the shell's current capabili-

ties. ggeettccaapp filename ...

This is a built-in implementation of the POSIX standard utility.

It displays the capability sets on each specified filename. sseettccaapp capabilities filename ...

This is a built-in implementation of the POSIX standard utility.

It sets the capability sets on each specified filename to the specified capabilities. TTHHEE ZZSSHH//CCLLOONNEE MMOODDUULLEE The zzsshh//cclloonnee module makes available one builtin command: cclloonnee tty Creates a forked instance of the current shell, attached to the specified tty. In the new shell, the PPIIDD, PPPPIIDD and TTTTYY special

parameters are changed appropriately. $$!! is set to zero in the

new shell, and to the new shell's PID in the original shell.

The return value of the builtin is zero in both shells if suc-

cessful, and non-zero on error.

The target of cclloonnee should be an unused terminal, such as an unused virtual console or a virtual terminal created by

xterm -e sh -c 'trap : INT QUIT TSTP; tty; while :; do sleep

100000000; done' Some words of explanation are warranted about this long xterm

command line: when doing clone on a pseudo-terminal, some other

session ("session" meant as a unix session group, or SID) is already owning the terminal. Hence the cloned zsh cannot acquire

the pseudo-terminal as a controlling tty. That means two things:

the job control signals will go to the sh-started-by-xterm

process group (that's why we disable INT QUIT and TSTP with trap; otherwise the while loop could get suspended or killed) the cloned shell will have job control disabled, and the job

control keys (control-C, control-\ and control-Z) will not

work. This does not apply when cloning to an uunnuusseedd vc. Cloning to an used (and unprepared) terminal will result in two processes reading simultaneously from the same terminal, with input bytes going randomly to either process.

cclloonnee is mostly useful as a shell built-in replacement for

openvt. TTHHEE ZZSSHH//CCOOMMPPCCTTLL MMOODDUULLEE The zzsshh//ccoommppccttll module makes available two builtin commands. ccoommppccttll,

is the old, deprecated way to control completions for ZLE. See zshcom-

pctl(1). The other builtin command, ccoommppccaallll can be used in

user-defined completion widgets, see zshcompwid(1).

TTHHEE ZZSSHH//CCOOMMPPLLEETTEE MMOODDUULLEE The zzsshh//ccoommpplleettee module makes available several builtin commands which

can be used in user-defined completion widgets, see zshcompwid(1).

TTHHEE ZZSSHH//CCOOMMPPLLIISSTT MMOODDUULLEE The zzsshh//ccoommpplliisstt module offers three extensions to completion listings: the ability to highlight matches in such a list, the ability to scroll through long lists and a different style of menu completion. CCoolloorreedd ccoommpplleettiioonn lliissttiinnggss Whenever one of the parameters ZZLLSSCCOOLLOORRSS or ZZLLSSCCOOLLOOUURRSS is set and the zzsshh//ccoommpplliisstt module is loaded or linked into the shell, completion

lists will be colored. Note, however, that ccoommpplliisstt will not automati-

cally be loaded if it is not linked in: on systems with dynamic load-

ing, `zzmmooddllooaadd zzsshh//ccoommpplliisstt' is required. The parameters ZZLLSSCCOOLLOORRSS and ZZLLSSCCOOLLOOUURRSS describe how matches are highlighted. To turn on highlighting an empty value suffices, in which case all the default values given below will be used. The format of the value of these parameters is the same as used by the GNU version of

the llss command: a colon-separated list of specifications of the form

`name=value'. The name may be one of the following strings, most of which specify file types for which the value will be used. The strings and their default values are: nnoo 00 for normal text (i.e. when displaying something other than a matched file) ffii 00 for regular files ddii 3322 for directories llnn 3366 for symbolic links ppii 3311 for named pipes (FIFOs) ssoo 3333 for sockets bbdd 4444;;3377 for block devices ccdd 4444;;3377 for character devices eexx 3355 for executable files mmii none

for a non-existent file (default is the value defined for ffii)

llcc \\ee[[ for the left code (see below) rrcc mm for the right code

ttcc 00 for the character indicating the file type printed after file-

names if the LLIISSTTTTYYPPEESS option is set sspp 00 for the spaces printed after matches to align the next column eecc none for the end code

Apart from these strings, the name may also be an asterisk (`**') fol-

lowed by any string. The value given for such a string will be used for all files whose name ends with the string. The name may also be an

equals sign (`==') followed by a pattern. The value given for this pat-

tern will be used for all matches (not just filenames) whose display string are matched by the pattern. Definitions for both of these take precedence over the values defined for file types and the form with the leading asterisk takes precedence over the form with the leading equal sign. The last form also allows different parts of the displayed strings to

be colored differently. For this, the pattern has to use the `((##bb))'

globbing flag and pairs of parentheses surrounding the parts of the strings that are to be colored differently. In this case the value may consist of more than one color code separated by equal signs. The first code will be used for all parts for which no explicit code is specified and the following codes will be used for the parts matched by

the sub-patterns in parentheses. For example, the specification

`==((##bb))((??))**((??))==00==33==77' will be used for all matches which are at least

two characters long and will use the code `33' for the first character, `77' for the last character and `00' for the rest. All three forms of name may be preceded by a pattern in parentheses. If this is given, the value will be used only for matches in groups whose names are matched by the pattern given in the parentheses. For example, `((gg**))mm**==4433' highlights all matches beginning with `mm' in groups whose names begin with `gg' using the color code `4433'. In case of the `llcc', `rrcc', and `eecc' codes, the group pattern is ignored. Note also that all patterns are tried in the order in which they appear in the parameter value until the first one matches which is then used. When printing a match, the code prints the value of llcc, the value for

the file-type or the last matching specification with a `**', the value

of rrcc, the string to display for the match itself, and then the value of eecc if that is defined or the values of llcc, nnoo, and rrcc if eecc is not defined. The default values are ISO 6429 (ANSI) compliant and can be used on vt100 compatible terminals such as xxtteerrmms. On monochrome terminals the default values will have no visible effect. The ccoolloorrss function from the contribution can be used to get associative arrays containing the

codes for ANSI terminals (see the section `Other Functions' in zshcon-

trib(1)). For example, after loading ccoolloorrss, one could use `$$ccooll-

oorrss[[rreedd]]' to get the code for foreground color red and `$$ccooll-

oorrss[[bbgg-ggrreeeenn]]' for the code for background color green.

If the completion system invoked by compinit is used, these parameters should not be set directly because the system controls them itself.

Instead, the lliisstt-ccoolloorrss style should be used (see the section `Comple-

tion System Configuration' in zshcompsys(1)). SSccrroolllliinngg iinn ccoommpplleettiioonn lliissttiinnggss To enable scrolling through a completion list, the LLIISSTTPPRROOMMPPTT parameter must be set. Its value will be used as the prompt; if it is the empty string, a default prompt will be used. The value may contain escapes

of the form `%%xx'. It supports the escapes `%%BB', `%%bb', `%%SS', `%%ss',

`%%UU', `%%uu' and `%%{{......%%}}' used also in shell prompts as well as three

pairs of additional sequences: a `%%ll' or `%%LL' is replaced by the number

of the last line shown and the total number of lines in the form `num-

ber//total'; a `%%mm' or `%%MM' is replaced with the number of the last

match shown and the total number of matches; and `%%pp' or `%%PP' is

replaced with `TToopp', `BBoottttoomm' or the position of the first line shown in percent of the total number of lines, respectively. In each of these cases the form with the uppercase letter will be replaced with a

string of fixed width, padded to the right with spaces, while the low-

ercase form will not be padded. If the parameter LLIISSTTPPRROOMMPPTT is set, the completion code will not ask if the list should be shown. Instead it immediately starts displaying the list, stopping after the first screenful, showing the prompt at the bottom, waiting for a keypress after temporarily switching to the lliissttssccrroollll keymap. Some of the zle functions have a special meaning while scrolling lists:

sseenndd-bbrreeaakk

stops listing discarding the key pressed

aacccceepptt-lliinnee, ddoowwnn-hhiissttoorryy, ddoowwnn-lliinnee-oorr-hhiissttoorryy

ddoowwnn-lliinnee-oorr-sseeaarrcchh, vvii-ddoowwnn-lliinnee-oorr-hhiissttoorryy

scrolls forward one line

ccoommpplleettee-wwoorrdd, mmeennuu-ccoommpplleettee, eexxppaanndd-oorr-ccoommpplleettee

eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx, mmeennuu-ccoommpplleettee-oorr-eexxppaanndd

scrolls forward one screenful Every other character stops listing and immediately processes the key as usual. Any key that is not bound in the lliissttssccrroollll keymap or that

is bound to uunnddeeffiinneedd-kkeeyy is looked up in the keymap currently

selected. As for the ZZLLSSCCOOLLOORRSS and ZZLLSSCCOOLLOOUURRSS parameters, LLIISSTTPPRROOMMPPTT should not be set directly when using the shell function based completion system.

Instead, the lliisstt-pprroommpptt style should be used.

MMeennuu sseelleeccttiioonn The zzsshh//ccoommpplliisstt module also offers an alternative style of selecting matches from a list, called menu selection, which can be used if the shell is set up to return to the last prompt after showing a completion list (see the AALLWWAAYYSSLLAASSTTPPRROOMMPPTT option in zshoptions(1)). It can be

invoked directly by the widget mmeennuu-sseelleecctt defined by the module.

Alternatively, the parameter MMEENNUUSSEELLEECCTT can be set to an integer, which gives the minimum number of matches that must be present before menu selection is automatically turned on. This second method requires that menu completion be started, either directly from a widget such as

mmeennuu-ccoommpplleettee, or due to one of the options MMEENNUUCCOOMMPPLLEETTEE or AAUUTTOOMMEENNUU

being set. If MMEENNUUSSEELLEECCTT is set, but is 0, 1 or empty, menu selection will always be started during an ambiguous menu completion.

When using the completion system based on shell functions, the MMEENNUUSSEE-

LLEECCTT parameter should not be used (like the ZZLLSSCCOOLLOORRSS and ZZLLSSCCOOLLOOUURRSS parameters described above). Instead, the mmeennuu style should be used with the sseelleecctt==... keyword. After menu selection is started, the matches will be listed. If there are more matches than fit on the screen, only the first screenful is shown. The matches to insert into the command line can be selected from this list. In the list one match is highlighted using the value for mmaa from the ZZLLSSCCOOLLOORRSS or ZZLLSSCCOOLLOOUURRSS parameter. The default value for this is `77' which forces the selected match to be highlighted using

standout mode on a vt100-compatible terminal. If neither ZZLLSSCCOOLLOORRSS

nor ZZLLSSCCOOLLOOUURRSS is set, the same terminal control sequence as for the

`%%SS' escape in prompts is used.

If there are more matches than fit on the screen and the parameter

MMEENNUUPPRROOMMPPTT is set, its value will be shown below the matches. It sup-

ports the same escape sequences as LLIISSTTPPRROOMMPPTT, but the number of the match or line shown will be that of the one where the mark is placed. If its value is the empty string, a default prompt will be used. The MMEENNUUSSCCRROOLLLL parameter can be used to specify how the list is scrolled. If the parameter is unset, this is done line by line, if it is set to `00' (zero), the list will scroll half the number of lines of the screen. If the value is positive, it gives the number of lines to scroll and if it is negative, the list will be scrolled the number of lines of the screen minus the (absolute) value. As for the ZZLLSSCCOOLLOORRSS, ZZLLSSCCOOLLOOUURRSS and LLIISSTTPPRROOMMPPTT parameters, neither MMEENNUUPPRROOMMPPTT nor MMEENNUUSSCCRROOLLLL should be set directly when using the shell

function based completion system. Instead, the sseelleecctt-pprroommpptt and

sseelleecctt-ssccrroollll styles should be used.

The completion code sometimes decides not to show all of the matches in

the list. These hidden matches are either matches for which the com-

pletion function which added them explicitly requested that they not

appear in the list (using the -nn option of the ccoommppaadddd builtin command)

or they are matches which duplicate a string already in the list (because they differ only in things like prefixes or suffixes that are not displayed). In the list used for menu selection, however, even these matches are shown so that it is possible to select them. To highlight such matches the hhii and dduu capabilities in the ZZLLSSCCOOLLOORRSS and ZZLLSSCCOOLLOOUURRSS parameters are supported for hidden matches of the first and second kind, respectively.

Selecting matches is done by moving the mark around using the zle move-

ment functions. When not all matches can be shown on the screen at the same time, the list will scroll up and down when crossing the top or bottom line. The following zle functions have special meaning during menu selection:

aacccceepptt-lliinnee

accepts the current match and leaves menu selection

sseenndd-bbrreeaakk

leaves menu selection and restores the previous contents of the command line

rreeddiissppllaayy, cclleeaarr-ssccrreeeenn

execute their normal function without leaving menu selection

aacccceepptt-aanndd-hhoolldd, aacccceepptt-aanndd-mmeennuu-ccoommpplleettee

accept the currently inserted match and continue selection allowing to select the next match to insert into the line

aacccceepptt-aanndd-iinnffeerr-nneexxtt-hhiissttoorryy

accepts the current match and then tries completion with menu selection again; in the case of files this allows one to select a directory and immediately attempt to complete files in it; if there are no matches, a message is shown and one can use uunnddoo to go back to completion on the previous level, every other key leaves menu selection (including the other zle functions which are otherwise special during menu selection) uunnddoo removes matches inserted during the menu selection by one of the three functions before

ddoowwnn-hhiissttoorryy, ddoowwnn-lliinnee-oorr-hhiissttoorryy

vvii-ddoowwnn-lliinnee-oorr-hhiissttoorryy, ddoowwnn-lliinnee-oorr-sseeaarrcchh

moves the mark one line down

uupp-hhiissttoorryy, uupp-lliinnee-oorr-hhiissttoorryy

vvii-uupp-lliinnee-oorr-hhiissttoorryy, uupp-lliinnee-oorr-sseeaarrcchh

moves the mark one line up

ffoorrwwaarrdd-cchhaarr, vvii-ffoorrwwaarrdd-cchhaarr

moves the mark one column right

bbaacckkwwaarrdd-cchhaarr, vvii-bbaacckkwwaarrdd-cchhaarr

moves the mark one column left

ffoorrwwaarrdd-wwoorrdd, vvii-ffoorrwwaarrdd-wwoorrdd

vvii-ffoorrwwaarrdd-wwoorrdd-eenndd, eemmaaccss-ffoorrwwaarrdd-wwoorrdd

moves the mark one screenful down

bbaacckkwwaarrdd-wwoorrdd, vvii-bbaacckkwwaarrdd-wwoorrdd, eemmaaccss-bbaacckkwwaarrdd-wwoorrdd

moves the mark one screenful up

vvii-ffoorrwwaarrdd-bbllaannkk-wwoorrdd, vvii-ffoorrwwaarrdd-bbllaannkk-wwoorrdd-eenndd

moves the mark to the first line of the next group of matches

vvii-bbaacckkwwaarrdd-bbllaannkk-wwoorrdd

moves the mark to the last line of the previous group of matches

bbeeggiinnnniinngg-ooff-hhiissttoorryy

moves the mark to the first line

eenndd-ooff-hhiissttoorryy

moves the mark to the last line

bbeeggiinnnniinngg-ooff-bbuuffffeerr-oorr-hhiissttoorryy, bbeeggiinnnniinngg-ooff-lliinnee

bbeeggiinnnniinngg-ooff-lliinnee-hhiisstt, vvii-bbeeggiinnnniinngg-ooff-lliinnee

moves the mark to the leftmost column

eenndd-ooff-bbuuffffeerr-oorr-hhiissttoorryy, eenndd-ooff-lliinnee

eenndd-ooff-lliinnee-hhiisstt, vvii-eenndd-ooff-lliinnee

moves the mark to the rightmost column

ccoommpplleettee-wwoorrdd, mmeennuu-ccoommpplleettee, eexxppaanndd-oorr-ccoommpplleettee

eexxppaanndd-oorr-ccoommpplleettee-pprreeffiixx, mmeennuu-eexxppaanndd-oorr-ccoommpplleettee

moves the mark to the next match

rreevveerrssee-mmeennuu-ccoommpplleettee

moves the mark to the previous match

vvii-iinnsseerrtt

this toggles between normal and interactive mode; in interactive

mode the keys bound to sseellff-iinnsseerrtt and sseellff-iinnsseerrtt-uunnmmeettaa insert

into the command line as in normal editing mode but without leaving menu selection; after each character completion is tried again and the list changes to contain only the new matches; the completion widgets make the longest unambiguous string be

inserted in the command line and uunnddoo and bbaacckkwwaarrdd-ddeelleettee-cchhaarr

go back to the previous set of matches

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-ffoorrwwaarrdd,

hhiissttoorryy-iinnccrreemmeennttaall-sseeaarrcchh-bbaacckkwwaarrdd this starts incremental

searches in the list of completions displayed; in this mode,

aacccceepptt-lliinnee only leaves incremental search, going back to the

normal menu selection mode All movement functions wrap around at the edges; any other zle function not listed leaves menu selection and executes that function. It is possible to make widgets in the above list do the same by using the form of the widget with a `..' in front. For example, the widget

`..aacccceepptt-lliinnee' has the effect of leaving menu selection and accepting

the entire command line. During this selection the widget uses the keymap mmeennuusseelleecctt. Any key

that is not defined in this keymap or that is bound to uunnddeeffiinneedd-kkeeyy is

looked up in the keymap currently selected. This is used to ensure that the most important keys used during selection (namely the cursor keys, return, and TAB) have sensible defaults. However, keys in the mmeennuusseelleecctt keymap can be modified directly using the bbiinnddkkeeyy builtin command (see zshmodules(1)). For example, to make the return key leave menu selection without accepting the match currently selected one could call

bbiinnddkkeeyy -MM mmeennuusseelleecctt ''^^MM'' sseenndd-bbrreeaakk

after loading the zzsshh//ccoommpplliisstt module. TTHHEE ZZSSHH//CCOOMMPPUUTTIILL MMOODDUULLEE The zzsshh//ccoommppuuttiill module adds several builtin commands that are used by some of the completion functions in the completion system based on shell functions (see zshcompsys(1) ). Except for ccoommppqquuoottee these builtin commands are very specialised and thus not very interesting when writing your own completion functions. In summary, these builtin commands are: ccoommppaarrgguummeennttss This is used by the aarrgguummeennttss function to do the argument and

command line parsing. Like ccoommppddeessccrriibbee it has an option -ii to

do the parsing and initialize some internal state and various options to access the state information to decide what should be completed. ccoommppddeessccrriibbee This is used by the ddeessccrriibbee function to build the displays for the matches and to get the strings to add as matches with their

options. On the first call one of the options -ii or -II should

be supplied as the first argument. In the first case, display

strings without the descriptions will be generated, in the sec-

ond case, the string used to separate the matches from their descriptions must be given as the second argument and the descriptions (if any) will be shown. All other arguments are like the definition arguments to ddeessccrriibbee itself.

Once ccoommppddeessccrriibbee has been called with either the -ii or the -II

option, it can be repeatedly called with the -gg option and the

names of five arrays as its arguments. This will step through the different sets of matches and store the options in the first array, the strings with descriptions in the second, the matches for these in the third, the strings without descriptions in the fourth, and the matches for them in the fifth array. These are then directly given to ccoommppaadddd to register the matches with the completion code. ccoommppffiilleess Used by the ppaatthhffiilleess function to optimize complex recursive filename generation (globbing). It does three things. With the

-pp and -PP options it builds the glob patterns to use, including

the paths already handled and trying to optimize the patterns with respect to the prefix and suffix from the line and the

match specification currently used. The -ii option does the

directory tests for the iiggnnoorree-ppaarreennttss style and the -rr option

tests if a component for some of the matches are equal to the string on the line and removes all other matches if that is true. ccoommppggrroouuppss Used by the ttaaggss function to implement the internals of the

ggrroouupp-oorrddeerr style. This only takes its arguments as names of

completion groups and creates the groups for it (all six types: sorted and unsorted, both without removing duplicates, with

removing all duplicates and with removing consecutive dupli-

cates).

ccoommppqquuoottee [ -pp ] names ...

There may be reasons to write completion functions that have to

add the matches using the -QQ option to ccoommppaadddd and perform quot-

ing themselves. Instead of interpreting the first character of the aallllqquuootteess key of the ccoommppssttaattee special association and using the qq flag for parameter expansions, one can use this builtin command. The arguments are the names of scalar or array parameters and the values of these parameters are quoted as

needed for the innermost quoting level. If the -pp option is

given, quoting is done as if there is some prefix before the values of the parameters, so that a leading equal sign will not be quoted.

The return value is non-zero in case of an error and zero other-

wise. ccoommppttaaggss ccoommppttrryy These implement the internals of the tags mechanism. ccoommppvvaalluueess Like ccoommppaarrgguummeennttss, but for the vvaalluueess function. TTHHEE ZZSSHH//DDAATTEETTIIMMEE MMOODDUULLEE The zzsshh//ddaatteettiimmee module makes available one builtin command:

ssttrrffttiimmee [ -ss scalar ] format epochtime

Output the date denoted by epochtime in the format specified.

If -ss scalar is given, assign the date to scalar instead of

printing it. The zzsshh//ddaatteettiimmee module makes available one parameter: EEPPOOCCHHSSEECCOONNDDSS An integer value representing the number of seconds since the epoch. TTHHEE ZZSSHH//DDEELLTTOOCCHHAARR MMOODDUULLEE The zzsshh//ddeellttoocchhaarr module makes available two ZLE functions:

ddeelleettee-ttoo-cchhaarr

Read a character from the keyboard, and delete from the cursor position up to and including the next (or, with repeat count n, the nth) instance of that character. Negative repeat counts mean delete backwards.

zzaapp-ttoo-cchhaarr

This behaves like ddeelleettee-ttoo-cchhaarr, except that the final occur-

rence of the character itself is not deleted. TTHHEE ZZSSHH//EEXXAAMMPPLLEE MMOODDUULLEE The zzsshh//eexxaammppllee module makes available one builtin command:

eexxaammppllee [ -ffllaaggss ] [ args ... ]

Displays the flags and arguments it is invoked with. The purpose of the module is to serve as an example of how to write a module. THE ZSH/FILES MODULE The zzsshh//ffiilleess module makes some standard commands available as builtins:

cchhggrrpp [ -RRss ] group filename ...

Changes group of files specified. This is equivalent to cchhoowwnn

with a user-spec argument of `::group'.

cchhoowwnn [ -RRss ] user-spec filename ...

Changes ownership and group of files specified.

The user-spec can be in four forms:

user change owner to user; do not change group user:::: change owner to user; do not change group user:: change owner to user; change group to user's primary group user::group change owner to user; change group to group ::group do not change owner; change group to group In each case, the `::' may instead be a `..'. The rule is that if there is a `::' then the separator is `::', otherwise if there is

a `..' then the separator is `..', otherwise there is no separa-

tor. Each of user and group may be either a username (or group name, as appropriate) or a decimal user ID (group ID). Interpretation

as a name takes precedence, if there is an all-numeric username

(or group name).

The -RR option causes cchhoowwnn to recursively descend into directo-

ries, changing the ownership of all files in the directory after changing the ownership of the directory itself.

The -ss option is a zsh extension to cchhoowwnn functionality. It

enables paranoid behaviour, intended to avoid security problems involving a cchhoowwnn being tricked into affecting files other than the ones intended. It will refuse to follow symbolic links, so

that (for example) ``cchhoowwnn lluusseerr //ttmmpp//ffoooo//ppaasssswwdd'' can't acci-

dentally chown //eettcc//ppaasssswwdd if //ttmmpp//ffoooo happens to be a link to //eettcc. It will also check where it is after leaving directories, so that a recursive chown of a deep directory tree can't end up recursively chowning //uussrr as a result of directories being moved up the tree.

llnn [ -ddffiiss ] filename dest

llnn [ -ddffiiss ] filename ... dir

Creates hard (or, with -ss, symbolic) links. In the first form,

the specified destination is created, as a link to the specified filename. In the second form, each of the filenames is taken in turn, and linked to a pathname in the specified directory that has the same last pathname component.

Normally, llnn will not attempt to create hard links to directo-

ries. This check can be overridden using the -dd option. Typi-

cally only the super-user can actually succeed in creating hard

links to directories. This does not apply to symbolic links in any case.

By default, existing files cannot be replaced by links. The -ii

option causes the user to be queried about replacing existing

files. The -ff option causes existing files to be silently

deleted, without querying. -ff takes precedence.

mmkkddiirr [ -pp ] [ -mm mode ] dir ...

Creates directories. With the -pp option, non-existing parent

directories are first created if necessary, and there will be no

complaint if the directory already exists. The -mm option can be

used to specify (in octal) a set of file permissions for the created directories, otherwise mode 777 modified by the current uummaasskk (see umask(2)) is used.

mmvv [ -ffii ] filename dest

mmvv [ -ffii ] filename ... dir

Moves files. In the first form, the specified filename is moved to the specified destination. In the second form, each of the

filenames is taken in turn, and moved to a pathname in the spec-

ified directory that has the same last pathname component. By default, the user will be queried before replacing any file that the user cannot write to, but writable files will be

silently removed. The -ii option causes the user to be queried

about replacing any existing files. The -ff option causes any

existing files to be silently deleted, without querying. -ff

takes precedence.

Note that this mmvv will not move files across devices. Histori-

cal versions of mmvv, when actual renaming is impossible, fall back on copying and removing files; if this behaviour is desired, use ccpp and rrmm manually. This may change in a future version.

rrmm [ -ddffiirrss ] filename ...

Removes files and directories specified.

Normally, rrmm will not remove directories (except with the -rr

option). The -dd option causes rrmm to try removing directories

with uunnlliinnkk (see unlink(2)), the same method used for files.

Typically only the super-user can actually succeed in unlinking

directories in this way. -dd takes precedence over -rr.

By default, the user will be queried before removing any file that the user cannot write to, but writable files will be

silently removed. The -ii option causes the user to be queried

about removing any files. The -ff option causes files to be

silently deleted, without querying, and suppresses all error

indications. -ff takes precedence.

The -rr option causes rrmm to recursively descend into directories,

deleting all files in the directory before removing the direc-

tory with the rrmmddiirr system call (see rmdir(2)).

The -ss option is a zsh extension to rrmm functionality. It

enables paranoid behaviour, intended to avoid common security

problems involving a root-run rrmm being tricked into removing

files other than the ones intended. It will refuse to follow symbolic links, so that (for example) ``rrmm //ttmmpp//ffoooo//ppaasssswwdd'' can't accidentally remove //eettcc//ppaasssswwdd if //ttmmpp//ffoooo happens to be a link to //eettcc. It will also check where it is after leaving directories, so that a recursive removal of a deep directory tree can't end up recursively removing //uussrr as a result of directories being moved up the tree. rrmmddiirr dir ... Removes empty directories specified. ssyynncc Calls the system call of the same name (see sync(2)), which flushes dirty buffers to disk. It might return before the I/O has actually been completed. TTHHEE ZZSSHH//MMAAPPFFIILLEE MMOODDUULLEE The zzsshh//mmaappffiillee module provides one special associative array parameter of the same name. mmaappffiillee This associative array takes as keys the names of files; the resulting value is the content of the file. The value is treated identically to any other text coming from a parameter. The value may also be assigned to, in which case the file in question is written (whether or not it originally existed); or an element may be unset, which will delete the file in question. For example, `vvaarreedd mmaappffiillee[[mmyyffiillee]]' works as expected, editing the file `mmyyffiillee'. When the array is accessed as a whole, the keys are the names of files in the current directory, and the values are empty (to

save a huge overhead in memory). Thus $${{((kk))mmaappffiillee}} has the

same affect as the glob operator **((DD)), since files beginning with a dot are not special. Care must be taken with expressions

such as rrmm $${{((kk))mmaappffiillee}}, which will delete every file in the

current directory without the usual `rrmm **' test.

The parameter mmaappffiillee may be made read-only; in that case, files

referenced may not be written or deleted. LLiimmiittaattiioonnss Although reading and writing of the file in question is efficiently handled, zsh's internal memory management may be arbitrarily baroque.

Thus it should not automatically be assumed that use of mmaappffiillee repre-

sents a gain in efficiency over use of other mechanisms. Note in par-

ticular that the whole contents of the file will always reside physi-

cally in memory when accessed (possibly multiple times, due to standard parameter substitution operations). In particular, this means handling of sufficiently long files (greater than the machine's swap space, or than the range of the pointer type) will be incorrect.

No errors are printed or flagged for non-existent, unreadable, or

unwritable files, as the parameter mechanism is too low in the shell execution hierarchy to make this convenient. It is unfortunate that the mechanism for loading modules does not yet allow the user to specify the name of the shell parameter to be given the special behaviour. TTHHEE ZZSSHH//MMAATTHHFFUUNNCC MMOODDUULLEE The zzsshh//mmaatthhffuunncc module provides standard mathematical functions for

use when evaluating mathematical formulae. The syntax agrees with nor-

mal C and FORTRAN conventions, for example, (((( ff == ssiinn((00..33)) )))) assigns the sine of 0.3 to the parameter f. Most functions take floating point arguments and return a floating point value. However, any necessary conversions from or to integer type will be performed automatically by the shell. Apart from aattaann

with a second argument and the aabbss, iinntt and ffllooaatt functions, all func-

tions behave as noted in the manual page for the corresponding C func-

tion, except that any arguments out of range for the function in ques-

tion will be detected by the shell and an error reported. The following functions take a single floating point argument: aaccooss, aaccoosshh, aassiinn, aassiinnhh, aattaann, aattaannhh, ccbbrrtt, cceeiill, ccooss, ccoosshh, eerrff, eerrffcc, eexxpp, eexxppmm11, ffaabbss, fflloooorr, ggaammmmaa, jj00, jj11, llggaammmmaa, lloogg, lloogg1100, lloogg11pp, llooggbb, ssiinn, ssiinnhh, ssqqrrtt, ttaann, ttaannhh, yy00, yy11. The aattaann function can optionally take a second argument, in which case it behaves like the C function aattaann22. The iillooggbb function takes a single floating point argument, but returns an integer. The function ssiiggnnggaamm takes no arguments, and returns an integer, which is the C variable of the same name, as described in gamma(3). Note that it is therefore only useful immediately after a call to ggaammmmaa or

llggaammmmaa. Note also that `ssiiggnnggaamm(())' and `ssiiggnnggaamm' are distinct expres-

sions. The following functions take two floating point arguments: ccooppyyssiiggnn, ffmmoodd, hhyyppoott, nneexxttaafftteerr.

The following take an integer first argument and a floating point sec-

ond argument: jjnn, yynn.

The following take a floating point first argument and an integer sec-

ond argument: llddeexxpp, ssccaallbb. The function aabbss does not convert the type of its single argument; it returns the absolute value of either a floating point number or an integer. The functions ffllooaatt and iinntt convert their arguments into a floating point or integer value (by truncation) respectively. Note that the C ppooww function is available in ordinary math evaluation as the `****' operator and is not provided here. The function rraanndd4488 is available if your system's mathematical library

has the function eerraanndd4488((33)). It returns a pseudo-random floating point

number between 0 and 1. It takes a single string optional argument. If the argument is not present, the random number seed is initialised

by three calls to the rraanndd((33)) function -- this produces the same ran-

dom numbers as the next three values of $$RRAANNDDOOMM.

If the argument is present, it gives the name of a scalar parameter where the current random number seed will be stored. On the first call, the value must contain at least twelve hexadecimal digits (the remainder of the string is ignored), or the seed will be initialised in the same manner as for a call to rraanndd4488 with no argument. Subsequent calls to rraanndd4488(param) will then maintain the seed in the parameter param as a string of twelve hexadecimal digits, with no base signifier. The random number sequences for different parameters are completely independent, and are also independent from that used by calls to rraanndd4488 with no argument. For example, consider

pprriinntt $$(((( rraanndd4488((sseeeedd)) ))))

pprriinntt $$(((( rraanndd4488(()) ))))

pprriinntt $$(((( rraanndd4488((sseeeedd)) ))))

Assuming $$sseeeedd does not exist, it will be initialised by the first

call. In the second call, the default seed is initialised; note, how-

ever, that because of the properties of rraanndd(()) there is a correlation between the seeds used for the two initialisations, so for more secure

uses, you should generate your own 12-byte seed. The third call

returns to the same sequence of random numbers used in the first call, unaffected by the intervening rraanndd4488(()). TTHHEE ZZSSHH//PPAARRAAMMEETTEERR MMOODDUULLEE The zzsshh//ppaarraammeetteerr module gives access to some of the internal hash tables used by the shell by defining some special parameters. ooppttiioonnss The keys for this associative array are the names of the options that can be set and unset using the sseettoopptt and uunnsseettoopptt builtins. The value of each key is either the string oonn if the option is currently set, or the string ooffff if the option is unset. Setting a key to one of these strings is like setting or unsetting the option, respectively. Unsetting a key in this array is like setting it to the value ooffff. ccoommmmaannddss This array gives access to the command hash table. The keys are the names of external commands, the values are the pathnames of the files that would be executed when the command would be invoked. Setting a key in this array defines a new entry in this table in the same way as with the hhaasshh builtin. Unsetting a key as in `uunnsseett ""ccoommmmaannddss[[ffoooo]]""' removes the entry for the given key from the command hash table. ffuunnccttiioonnss This associative array maps names of enabled functions to their definitions. Setting a key in it is like defining a function with the name given by the key and the body given by the value. Unsetting a key removes the definition for the function named by the key. ddiissffuunnccttiioonnss Like ffuunnccttiioonnss but for disabled functions. bbuuiillttiinnss

This associative array gives information about the builtin com-

mands currently enabled. The keys are the names of the builtin

commands and the values are either `uunnddeeffiinneedd' for builtin com-

mands that will automatically be loaded from a module if invoked or `ddeeffiinneedd' for builtin commands that are already loaded. ddiissbbuuiillttiinnss Like bbuuiillttiinnss but for disabled builtin commands. rreesswwoorrddss This array contains the enabled reserved words. ddiissrreesswwoorrddss Like rreesswwoorrddss but for disabled reserved words. aalliiaasseess This maps the names of the regular aliases currently enabled to their expansions. ddiissaalliiaasseess Like aalliiaasseess but for disabled regular aliases. ggaalliiaasseess Like aalliiaasseess, but for global aliases. ddiissggaalliiaasseess Like ggaalliiaasseess but for disabled global aliases. ssaalliiaasseess Like rraalliiaasseess, but for suffix aliases. ddiissssaalliiaasseess Like ssaalliiaasseess but for disabled suffix aliases. ppaarraammeetteerrss

The keys in this associative array are the names of the parame-

ters currently defined. The values are strings describing the

type of the parameter, in the same format used by the tt parame-

ter flag, see zshexpn(1) . Setting or unsetting keys in this array is not possible. mmoodduulleess An associative array giving information about modules. The keys are the names of the modules loaded, registered to be autoloaded, or aliased. The value says which state the named module is in and is one of the strings `llooaaddeedd', `aauuttoollooaaddeedd', or `aalliiaass::name', where name is the name the module is aliased to. Setting or unsetting keys in this array is not possible. ddiirrssttaacckk A normal array holding the elements of the directory stack. Note that the output of the ddiirrss builtin command includes one more directory, the current working directory. hhiissttoorryy This associative array maps history event numbers to the full history lines. hhiissttoorryywwoorrddss A special array containing the words stored in the history. jjoobbddiirrss This associative array maps job numbers to the directories from

which the job was started (which may not be the current direc-

tory of the job). jjoobbtteexxttss

This associative array maps job numbers to the texts of the com-

mand lines that were used to start the jobs. jjoobbssttaatteess This associative array gives information about the states of the

jobs currently known. The keys are the job numbers and the val-

ues are strings of the form `job-state:mark:pid==state......'. The

job-state gives the state the whole job is currently in, one of

`rruunnnniinngg', `ssuussppeennddeedd', or `ddoonnee'. The mark is `++' for the cur-

rent job, `-' for the previous job and empty otherwise. This is

followed by one `pid==state' for every process in the job. The pids are, of course, the process IDs and the state describes the state of that process. nnaammeeddddiirrss This associative array maps the names of named directories to the pathnames they stand for. uusseerrddiirrss This associative array maps user names to the pathnames of their home directories. ffuunnccssttaacckk This array contains the names of the functions currently being executed. The first element is the name of the function using the parameter. TTHHEE ZZSSHH//PPCCRREE MMOODDUULLEE The zzsshh//ppccrree module makes some commands available as builtins:

ppccrreeccoommppiillee [ -aaiimmxx ] PCRE

Compiles a perl-compatible regular expression.

Option -aa will force the pattern to be anchored. Option -ii will

compile a case-insensitive pattern. Option -mm will compile a

multi-line pattern; that is, ^^ and $$ will match newlines within

the pattern. Option -xx will compile an extended pattern,

wherein whitespace and ## comments are ignored.

ppccrreessttuuddyy

Studies the previously-compiled PCRE which may result in faster

matching.

ppccrreemmaattcchh [ -aa arr ] string

Returns successfully if ssttrriinngg matches the previously-compiled

PCRE. If the expression captures substrings within parentheses,

ppccrreemmaattcchh will set the array $match to those substrings, unless

the -aa option is given, in which case it will set the array arr.

The zzsshh//ppccrree module makes available the following test condition:

expr -ppccrree-mmaattcchh pcre

Matches a string against a perl-compatible regular expression.

For example,

[[ "$text" -pcre-match ^d+$ ]] && print text variable contains

only "d's". TTHHEE ZZSSHH//SSCCHHEEDD MMOODDUULLEE The zzsshh//sscchheedd module makes available one builtin command: sscchheedd [++]hh::mm command ...

sscchheedd [ -item ]

Make an entry in the scheduled list of commands to execute. The time may be specified in either absolute or relative time. With no arguments, prints the list of scheduled commands. With the

argument `-item', removes the given item from the list.

TTHHEE ZZSSHH//NNEETT//SSOOCCKKEETT MMOODDUULLEE The zzsshh//nneett//ssoocckkeett module makes available one builtin command:

zzssoocckkeett [ -aallttvv ] [ -dd fd ] [ args ]

zzssoocckkeett is implemented as a builtin to allow full use of shell command line editing, file I/O, and job control mechanisms. OOuuttbboouunndd CCoonnnneeccttiioonnss

zzssoocckkeett [ -vv ] [ -dd fd ] filename

Open a new Unix domain connection to filename. The shell param-

eter RREEPPLLYY will be set to the file descriptor associated with

that connection. Currently, only stream connections are sup-

ported.

If -dd is specified, its argument will be taken as the target

file descriptor for the connection.

In order to elicit more verbose output, use -vv.

IInnbboouunndd CCoonnnneeccttiioonnss

zzssoocckkeett -ll [ -vv ] [ -dd fd ] filename

zzssoocckkeett -ll will open a socket listening on filename. The shell

parameter RREEPPLLYY will be set to the file descriptor associated with that listener.

If -dd is specified, its argument will be taken as the target

file descriptor for the connection.

In order to elicit more verbose output, use -vv.

zzssoocckkeett -aa [ -ttvv ] [ -dd targetfd ] listenfd

zzssoocckkeett -aa will accept an incoming connection to the socket

associated with listenfd. The shell parameter RREEPPLLYY will be set to the file descriptor associated with the inbound connection.

If -dd is specified, its argument will be taken as the target

file descriptor for the connection.

If -tt is specified, zzssoocckkeett will return if no incoming connec-

tion is pending. Otherwise it will wait for one.

In order to elicit more verbose output, use -vv.

TTHHEE ZZSSHH//SSTTAATT MMOODDUULLEE The zzsshh//ssttaatt module makes available one builtin command:

ssttaatt [ -ggnnNNoollLLttTTrrss ] [ -ff fd ] [ -HH hash ] [ -AA array ] [ -FF fmt ] [

++element ] [ file ... ] The command acts as a front end to the ssttaatt system call (see stat(2)). If the ssttaatt call fails, the appropriate system error message printed and status 1 is returned. The fields of ssttrruucctt ssttaatt give information about the files provided as arguments to the command. In addition to those available from the ssttaatt call, an extra element `lliinnkk' is provided. These elements are: ddeevviiccee The number of the device on which the file resides. iinnooddee The unique number of the file on this device (`inode' number). mmooddee The mode of the file; that is, the file's type and access

permissions. With the -ss option, this will be returned

as a string corresponding to the first column in the dis-

play of the llss -ll command.

nnlliinnkk The number of hard links to the file.

uuiidd The user ID of the owner of the file. With the -ss

option, this is displayed as a user name.

ggiidd The group ID of the file. With the -ss option, this is

displayed as a group name. rrddeevv The raw device number. This is only useful for special devices. ssiizzee The size of the file in bytes. aattiimmee mmttiimmee ccttiimmee The last access, modification and inode change times of the file, respectively, as the number of seconds since

midnight GMT on 1st January, 1970. With the -ss option,

these are printed as strings for the local time zone; the

format can be altered with the -FF option, and with the -gg

option the times are in GMT. bbllkkssiizzee The number of bytes in one allocation block on the device on which the file resides. bblloocckk The number of disk blocks used by the file.

lliinnkk If the file is a link and the -LL option is in effect,

this contains the name of the file linked to, otherwise it is empty. Note that if this element is selected

(``ssttaatt ++lliinnkk'') then the -LL option is automatically

used.

A particular element may be selected by including its name pre-

ceded by a `++' in the option list; only one element is allowed.

The element may be shortened to any unique set of leading char-

acters. Otherwise, all elements will be shown for all files. Options:

-AA array

Instead of displaying the results on standard output, assign them to an array, one ssttrruucctt ssttaatt element per

array element for each file in order. In this case nei-

ther the name of the element nor the name of the files

appears in array unless the -tt or -nn options were given,

respectively. If -tt is given, the element name appears

as a prefix to the appropriate array element; if -nn is

given, the file name appears as a separate array element preceding all the others. Other formatting options are respected.

-HH hash

Similar to -AA, but instead assign the values to hash.

The keys are the elements listed above. If the -nn option

is provided then the name of the file is included in the hash with key nnaammee.

-ff fd Use the file on file descriptor fd instead of named

files; no list of file names is allowed in this case.

-FF fmt Supplies a ssttrrffttiimmee (see strftime(3)) string for the for-

matting of the time elements. The -ss option is implied.

-gg Show the time elements in the GMT time zone. The -ss

option is implied.

-ll List the names of the type elements (to standard output

or an array as appropriate) and return immediately;

options other than -AA and arguments are ignored.

-LL Perform an llssttaatt (see lstat(2)) rather than a ssttaatt system

call. In this case, if the file is a link, information about the link itself rather than the target file is

returned. This option is required to make the lliinnkk ele-

ment useful.

-nn Always show the names of files. Usually these are only

shown when output is to standard output and there is more than one file in the list.

-NN Never show the names of files.

-oo If a raw file mode is printed, show it in octal, which is

more useful for human consumption than the default of decimal. A leading zero will be printed in this case. Note that this does not affect whether a raw or formatted

file mode is shown, which is controlled by the -rr and -ss

options, nor whether a mode is shown at all.

-rr Print raw data (the default format) alongside string data

(the -ss format); the string data appears in parentheses

after the raw data.

-ss Print mmooddee, uuiidd, ggiidd and the three time elements as

strings instead of numbers. In each case the format is

like that of llss -ll.

-tt Always show the type names for the elements of ssttrruucctt

ssttaatt. Usually these are only shown when output is to standard output and no individual element has been selected.

-TT Never show the type names of the ssttrruucctt ssttaatt elements.

TTHHEE ZZSSHH//SSYYSSTTEEMM MMOODDUULLEE The zzsshh//ssyysstteemm module makes available three builtin commands and a parameter. BBUUIILLTTIINNSS

ssyysseerrrroorr [[ -ee errvar ]] [[ -pp prefix ]] [[ errno || errname ]]

This command prints out the error message associated with errno, a system error number, followed by a newline to standard error. Instead of the error number, a name errname, for example EENNOOEENNTT, may be used. The set of names is the same as the contents of the array eerrrrnnooss, see below. If the string prefix is given, it is printed in front of the error message, with no intervening space. If errvar is supplied, the entire message, without a newline, is assigned to the parameter names errvar and nothing is output. A return value of 0 indicates the message was successfully printed (although it may not be useful if the error number was out of the system's range), a return value of 1 indicates an error in the parameters, and a return value of 2 indicates the error name was not recognised (no message is printed for this).

ssyyssrreeaadd [[ -cc countvar ]] [[ -ii infd ]] [[ -oo outfd ]]

[[ -ss bufsize ]] [[ -tt timeout ]] [[ param ]]

Perform a single system read from file descriptor infd, or zero if that is not given. The result of the read is stored in param or REPLY if that is not given. If countvar is given, the number of bytes read is assigned to the parameter named by countvar. The maximum number of bytes read is bufsize or 8192 if that is not given, however the command returns as soon as any number of bytes was successfully read. If timeout is given, it specifies a timeout in seconds, which may be zero to poll the file descriptor. This is handled by the ppoollll system call if available, otherwise the sseelleecctt system call if available. If outfd is given, an attempt is made to write all the bytes just read to the file descriptor outfd. If this fails, because of a system error other than EEIINNTTRR or because of an internal zsh error during an interrupt, the bytes read but not written are stored in the parameter named by param if supplied (no default is used in this case), and the number of bytes read but not written is stored in the parameter named by countvar if that is

supplied. If it was successful, countvar contains the full num-

ber of bytes transferred, as usual, and param is not set. The error EEIINNTTRR (interrupted system call) is handled internally so that shell interrupts are transparent to the caller. Any other error causes a return. The possible return values are 0 At least one byte of data was successfully read and, if appropriate, written. 1 There was an error in the parameters to the command. This is the only error for which a message is printed to standard error. 2 There was an error on the read, or on polling the input file descriptor for a timeout. The parameter EERRRRNNOO gives the error.

3 Data were successfully read, but there was an error writ-

ing them to outfd. The parameter EERRRRNNOO gives the error. 4 The attempt to read timed out. Note this does not set EERRRRNNOO as this is not a system error. 5 No system error occurred, but zero bytes were read. This usually indicates end of file. The parameters are set according to the usual rules; no write to outfd is attempted.

ssyysswwrriittee [[ -cc countvar ]] [[ -oo outfd ]] data

The data (a single string of bytes) are written to the file descriptor outfd, or 1 if that is not given, using the wwrriittee system call. Multiple write operations may be used if the first does not write all the data. If countvar is given, the number of byte written is stored in the parameter named by countvar; this may not be the full length of data if an error occurred. The error EEIINNTTRR (interrupted system call) is handled internally by retrying; otherwise an error causes the command to return.

For example, if the file descriptor is set to non-blocking out-

put, an error EEAAGGAAIINN (on some systems, EEWWOOUULLDDBBLLOOCCKK) may result in the command returning early. The return status may be 0 for success, 1 for an error in the parameters to the command, or 2 for an error on the write; no error message is printed in the last case, but the parameter EERRRRNNOO will reflect the error that occurred. PPAARRAAMMEETTEERRSS eerrrrnnooss A readonly array of the names of errors defined on the system. These are typically macros defined in C by including the system header file eerrrrnnoo..hh. The index of each name (assuming the option KKSSHHAARRRRAAYYSS is unset) corresponds to the error number. Error numbers num before the last known error which have no name are given the name EEnum in the array. Note that aliases for errors are not handled; only the canonical name is used. TTHHEE ZZSSHH//NNEETT//TTCCPP MMOODDUULLEE The zzsshh//nneett//ttccpp module makes available one builtin command:

zzttccpp [ -aaccffllLLttvv ] [ -dd fd ] [ args ]

zzttccpp is implemented as a builtin to allow full use of shell com-

mand line editing, file I/O, and job control mechanisms. If zzttccpp is run with no options, it will output the contents of its session table.

If it is run with only the option -LL, it will output the con-

tents of the session table in a format suitable for automatic parsing. The option is ignored if given with a command to open or close a session. The output consists of a set of lines, one per session, each containing the following elements separated by spaces: File descriptor

The file descriptor in use for the connection. For nor-

mal inbound (II) and outbound (OO) connections this may be read and written by the usual shell mechanisms. However,

it should only be close with `zzttccpp -cc'.

Connection type A letter indicating how the session was created: ZZ A session created with the zzffttpp command.

LL A connection opened for listening with `zzttccpp -ll'.

II An inbound connection accepted with `zzttccpp -aa'.

OO An outbound connection created with `zzttccpp host ...'. The local host

This is usually set to an all-zero IP address as the

address of the localhost is irrelevant. The local port This is likely to be zero unless the connection is for listening. The remote host This is the fully qualified domain name of the peer, if

available, else an IP address. It is an all-zero IP

address for a session opened for listening. The remote port This is zero for a connection opened for listening. OOuuttbboouunndd CCoonnnneeccttiioonnss

zzttccpp [ -vv ] [ -dd fd ] host [ port ]

Open a new TCP connection to host. If the port is omitted, it will default to port 23. The connection will be added to the session table and the shell parameter RREEPPLLYY will be set to the file descriptor associated with that connection.

If -dd is specified, its argument will be taken as the target

file descriptor for the connection.

In order to elicit more verbose output, use -vv.

IInnbboouunndd CCoonnnneeccttiioonnss

zzttccpp -ll [ -vv ] [ -dd fd ] port

zzttccpp -ll will open a socket listening on TCP port. The socket

will be added to the session table and the shell parameter RREEPPLLYY

will be set to the file descriptor associated with that lis-

tener.

If -dd is specified, its argument will be taken as the target

file descriptor for the connection.

In order to elicit more verbose output, use -vv.

zzttccpp -aa [ -ttvv ] [ -dd targetfd ] listenfd

zzttccpp -aa will accept an incoming connection to the port associ-

ated with listenfd. The connection will be added to the session table and the shell parameter RREEPPLLYY will be set to the file descriptor associated with the inbound connection.

If -dd is specified, its argument will be taken as the target

file descriptor for the connection.

If -tt is specified, zzttccpp will return if no incoming connection

is pending. Otherwise it will wait for one.

In order to elicit more verbose output, use -vv.

CClloossiinngg CCoonnnneeccttiioonnss

zzttccpp -ccff [ -vv ] [ fd ]

zzttccpp -cc [ -vv ] [ fd ]

zzttccpp -cc will close the socket associated with fd. The socket

will be removed from the session table. If fd is not specified, zzttccpp will close everything in the session table. Normally, sockets registered by zftp (see zshmodules(1) ) cannot be closed this way. In order to force such a socket closed, use

-ff.

In order to elicit more verbose output, use -vv.

EExxaammppllee Here is how to create a TCP connection between two instances of zsh. We need to pick an unassigned port; here we use the randomly chosen 5123. On hhoosstt11, zzmmooddllooaadd zzsshh//nneett//ttccpp

zzttccpp -ll 55112233

lliisstteennffdd==$$RREEPPLLYY

zzttccpp -aa $$lliisstteennffdd

ffdd==$$RREEPPLLYY

The second from last command blocks until there is an incoming connec-

tion. Now create a connection from hhoosstt22 (which may, of course, be the same machine): zzmmooddllooaadd zzsshh//nneett//ttccpp zzttccpp hhoosstt11 55112233

ffdd==$$RREEPPLLYY

Now on each host, $$ffdd contains a file descriptor for talking to the

other. For example, on hhoosstt11:

pprriinntt TThhiiss iiss aa mmeessssaaggee >>&&$$ffdd

and on hhoosstt22:

rreeaadd -rr lliinnee <<&&$$ffdd;; pprriinntt -rr - $$lliinnee

prints `TThhiiss iiss aa mmeessssaaggee'. To tidy up, on hhoosstt11:

zzttccpp -cc $$lliisstteennffdd

zzttccpp -cc $$ffdd

and on hhoosstt22

zzttccpp -cc $$ffdd

TTHHEE ZZSSHH//TTEERRMMCCAAPP MMOODDUULLEE The zzsshh//tteerrmmccaapp module makes available one builtin command: eecchhoottcc cap [ arg ... ] Output the termcap value corresponding to the capability cap, with optional arguments. The zzsshh//tteerrmmccaapp module makes available one parameter: tteerrmmccaapp An associative array that maps termcap capability codes to their values. TTHHEE ZZSSHH//TTEERRMMIINNFFOO MMOODDUULLEE The zzsshh//tteerrmmiinnffoo module makes available one builtin command: eecchhoottii cap [ arg ] Output the terminfo value corresponding to the capability cap, instantiated with arg if applicable. The zzsshh//tteerrmmiinnffoo module makes available one parameter: tteerrmmiinnffoo An associative array that maps terminfo capability names to their values. TTHHEE ZZSSHH//ZZFFTTPP MMOODDUULLEE The zzsshh//zzffttpp module makes available one builtin command: zzffttpp subcommand [ args ]

The zzsshh//zzffttpp module is a client for FTP (file transfer proto-

col). It is implemented as a builtin to allow full use of shell command line editing, file I/O, and job control mechanisms. Often, users will access it via shell functions providing a more powerful interface; a set is provided with the zzsshh distribution and is described in zshzftpsys(1). However, the zzffttpp command is entirely usable in its own right. All commands consist of the command name zzffttpp followed by the

name of a subcommand. These are listed below. The return sta-

tus of each subcommand is supposed to reflect the success or

failure of the remote operation. See a description of the vari-

able ZZFFTTPPVVEERRBBOOSSEE for more information on how responses from the server may be printed. SSuubbccoommmmaannddss ooppeenn host[::port] [ user [ password [ account ] ] ] Open a new FTP session to host, which may be the name of a

TCP/IP connected host or an IP number in the standard dot nota-

tion. If the argument is in the form host::port, open a connec-

tion to TCP port port instead of the standard FTP port 21. This

may be the name of a TCP service or a number: see the descrip-

tion of ZZFFTTPPPPOORRTT below for more information. If IPv6 addresses in colon format are used, the host should be surrounded by quoted square brackets to distinguish it from the port, for example ''[[ffee8800::::220033::bbaaffff::ffee0022::88bb5566]]''. For consistency this is allowed with all forms of host. Remaining arguments are passed to the llooggiinn subcommand. Note that if no arguments beyond host are supplied, ooppeenn will not automatically call llooggiinn. If no arguments at all are supplied, ooppeenn will use the parameters set by the ppaarraammss subcommand. After a successful open, the shell variables ZZFFTTPPHHOOSSTT,

ZZFFTTPPPPOORRTT, ZZFFTTPPIIPP and ZZFFTTPPSSYYSSTTEEMM are available; see `Vari-

ables' below. llooggiinn [ name [ password [ account ] ] ] uusseerr [ name [ password [ account ] ] ] Login the user name with parameters password and account. Any of the parameters can be omitted, and will be read from standard input if needed (name is always needed). If standard input is a terminal, a prompt for each one will be printed on standard error and password will not be echoed. If any of the parameters are not used, a warning message is printed. After a successful login, the shell variables ZZFFTTPPUUSSEERR, ZZFFTTPPAACCCCOOUUNNTT and ZZFFTTPPPPWWDD are available; see `Variables' below.

This command may be re-issued when a user is already logged in,

and the server will first be reinitialized for a new user. ppaarraammss [ host [ user [ password [ account ] ] ] ]

ppaarraammss -

Store the given parameters for a later ooppeenn command with no

arguments. Only those given on the command line will be remem-

bered. If no arguments are given, the parameters currently set are printed, although the password will appear as a line of stars; the return value is one if no parameters were set, zero otherwise. Any of the parameters may be specified as a `??', which may need to be quoted to protect it from shell expansion. In this case, the appropriate parameter will be read from stdin as with the llooggiinn subcommand, including special handling of password. If the `??' is followed by a string, that is used as the prompt for

reading the parameter instead of the default message (any neces-

sary punctuation and whitespace should be included at the end of the prompt). The first letter of the parameter (only) may be

quoted with a `\\'; hence an argument ""\\\\$$wwoorrdd"" guarantees that

the string from the shell parameter $$wwoorrdd will be treated liter-

ally, whether or not it begins with a `??'.

If instead a single `-' is given, the existing parameters, if

any, are deleted. In that case, calling ooppeenn with no arguments will cause an error. The list of parameters is not deleted after a cclloossee, however it will be deleted if the zzsshh//zzffttpp module is unloaded. For example, zzffttpp ppaarraammss ffttpp..eellsseewwhheerree..xxxx jjuusseerr ''??PPaasssswwoorrdd ffoorr jjuusseerr:: '' will store the host ffttpp..eellsseewwhheerree..xxxx and the user jjuusseerr and then prompt the user for the corresponding password with the given prompt. tteesstt Test the connection; if the server has reported that it has closed the connection (maybe due to a timeout), return status 2; if no connection was open anyway, return status 1; else return status 0. The tteesstt subcommand is silent, apart from messages

printed by the $$ZZFFTTPPVVEERRBBOOSSEE mechanism, or error messages if the

connection closes. There is no network overhead for this test. The test is only supported on systems with either the sseelleecctt((22)) or ppoollll((22)) system calls; otherwise the message `nnoott ssuuppppoorrtteedd oonn tthhiiss ssyysstteemm' is printed instead. The tteesstt subcommand will automatically be called at the start of any other subcommand for the current session when a connection is open. ccdd directory Change the remote directory to directory. Also alters the shell variable ZZFFTTPPPPWWDD. ccdduupp Change the remote directory to the one higher in the directory

tree. Note that ccdd .... will also work correctly on non-UNIX sys-

tems. ddiirr [ args... ] Give a (verbose) listing of the remote directory. The args are

passed directly to the server. The command's behaviour is imple-

mentation dependent, but a UNIX server will typically interpret args as arguments to the llss command and with no arguments return

the result of `llss -ll'. The directory is listed to standard out-

put. llss [ args ] Give a (short) listing of the remote directory. With no args, produces a raw list of the files in the directory, one per line. Otherwise, up to vagaries of the server implementation, behaves similar to ddiirr. ttyyppee [ type ] Change the type for the transfer to type, or print the current type if type is absent. The allowed values are `AA' (ASCII), `II' (Image, i.e. binary), or `BB' (a synonym for `II'). The FTP default for a transfer is ASCII. However, if zzffttpp finds

that the remote host is a UNIX machine with 8-bit byes, it will

automatically switch to using binary for file transfers upon ooppeenn. This can subsequently be overridden. The transfer type is only passed to the remote host when a data connection is established; this command involves no network overhead. aasscciiii The same as ttyyppee AA. bbiinnaarryy The same as ttyyppee II. mmooddee [ SS | BB ] Set the mode type to stream (SS) or block (BB). Stream mode is the default; block mode is not widely supported. rreemmoottee files... llooccaall [ files... ] Print the size and last modification time of the remote or local files. If there is more than one item on the list, the name of the file is printed first. The first number is the file size,

the second is the last modification time of the file in the for-

mat CCCCYYYYMMMMDDDDhhhhmmmmSSSS consisting of year, month, date, hour, min-

utes and seconds in GMT. Note that this format, including the

length, is guaranteed, so that time strings can be directly com-

pared via the [[[[ builtin's << and >> operators, even if they are too long to be represented as integers.

Not all servers support the commands for retrieving this infor-

mation. In that case, the rreemmoottee command will print nothing and return status 2, compared with status 1 for a file not found.

The llooccaall command (but not rreemmoottee) may be used with no argu-

ments, in which case the information comes from examining file descriptor zero. This is the same file as seen by a ppuutt command with no further redirection. ggeett file [...]

Retrieve all files from the server, concatenating them and send-

ing them to standard output. ppuutt file [...] For each file, read a file from standard input and send that to the remote host with the given name. aappppeenndd file [...] As ppuutt, but if the remote file already exists, data is appended to it instead of overwriting it. ggeettaatt file point ppuuttaatt file point aappppeennddaatt file point Versions of ggeett, ppuutt and aappppeenndd which will start the transfer at

the given point in the remote file. This is useful for append-

ing to an incomplete local file. However, note that this abil-

ity is not universally supported by servers (and is not quite the behaviour specified by the standard). ddeelleettee file [...] Delete the list of files on the server. mmkkddiirr directory Create a new directory directory on the server. rrmmddiirr directory Delete the directory directory on the server.

rreennaammee old-name new-name

Rename file old-name to new-name on the server.

ssiittee args...

Send a host-specific command to the server. You will probably

only need this if instructed by the server to use it. qquuoottee args... Send the raw FTP command sequence to the server. You should be familiar with the FTP command set as defined in RFC959 before doing this. Useful commands may include SSTTAATT and HHEELLPP. Note also the mechanism for returning messages as described for the variable ZZFFTTPPVVEERRBBOOSSEE below, in particular that all messages from the control connection are sent to standard error. cclloossee

qquuiitt Close the current data connection. This unsets the shell param-

eters ZZFFTTPPHHOOSSTT, ZZFFTTPPPPOORRTT, ZZFFTTPPIIPP, ZZFFTTPPSSYYSSTTEEMM, ZZFFTTPPUUSSEERR, ZZFFTTPPAACCCCOOUUNNTT, ZZFFTTPPPPWWDD, ZZFFTTPPTTYYPPEE and ZZFFTTPPMMOODDEE. sseessssiioonn [ sessname ] Allows multiple FTP sessions to be used at once. The name of the session is an arbitrary string of characters; the default session is called `ddeeffaauulltt'. If this command is called without an argument, it will list all the current sessions; with an argument, it will either switch to the existing session called sessname, or create a new session of that name. Each session remembers the status of the connection, the set of

connection-specific shell parameters (the same set as are unset

when a connection closes, as given in the description of cclloossee), and any user parameters specified with the ppaarraammss subcommand. Changing to a previous session restores those values; changing to a new session initialises them in the same way as if zzffttpp had just been loaded. The name of the current session is given by the parameter ZZFFTTPPSSEESSSSIIOONN. rrmmsseessssiioonn [ sessname ] Delete a session; if a name is not given, the current session is

deleted. If the current session is deleted, the earliest exist-

ing session becomes the new current session, otherwise the cur-

rent session is not changed. If the session being deleted is the only one, a new session called `ddeeffaauulltt' is created and becomes the current session; note that this is a new session even if the session being deleted is also called `ddeeffaauulltt'. It is recommended that sessions not be deleted while background commands which use zzffttpp are still active. PPaarraammeetteerrss The following shell parameters are used by zzffttpp. Currently none of them are special. ZZFFTTPPTTMMOOUUTT Integer. The time in seconds to wait for a network operation to complete before returning an error. If this is not set when the module is loaded, it will be given the default value 60. A value of zero turns off timeouts. If a timeout occurs on the control connection it will be closed. Use a larger value if this occurs too frequently. ZZFFTTPPIIPP

Readonly. The IP address of the current connection in dot nota-

tion. ZZFFTTPPHHOOSSTT Readonly. The hostname of the current remote server. If the host was opened as an IP number, ZZFFTTPPHHOOSSTT contains that

instead; this saves the overhead for a name lookup, as IP num-

bers are most commonly used when a nameserver is unavailable. ZZFFTTPPPPOORRTT

Readonly. The number of the remote TCP port to which the con-

nection is open (even if the port was originally specified as a named service). Usually this is the standard FTP port, 21.

In the unlikely event that your system does not have the appro-

priate conversion functions, this appears in network byte order.

If your system is little-endian, the port then consists of two

swapped bytes and the standard port will be reported as 5376. In that case, numeric ports passed to zzffttpp ooppeenn will also need to be in this format. ZZFFTTPPSSYYSSTTEEMM Readonly. The system type string returned by the server in response to an FTP SSYYSSTT request. The most interesting case is a

string beginning ""UUNNIIXX TTyyppee:: LL88"", which ensures maximum compati-

bility with a local UNIX host. ZZFFTTPPTTYYPPEE Readonly. The type to be used for data transfers , either `AA' or `II'. Use the ttyyppee subcommand to change this. ZZFFTTPPUUSSEERR Readonly. The username currently logged in, if any. ZZFFTTPPAACCCCOOUUNNTT Readonly. The account name of the current user, if any. Most servers do not require an account name. ZZFFTTPPPPWWDD Readonly. The current directory on the server. ZZFFTTPPCCOODDEE Readonly. The three digit code of the last FTP reply from the server as a string. This can still be read after the connection is closed, and is not changed when the current session changes. ZZFFTTPPRREEPPLLYY Readonly. The last line of the last reply sent by the server. This can still be read after the connection is closed, and is not changed when the current session changes. ZZFFTTPPSSEESSSSIIOONN

Readonly. The name of the current FTP session; see the descrip-

tion of the sseessssiioonn subcommand. ZZFFTTPPPPRREEFFSS

A string of preferences for altering aspects of zzffttpp's behav-

iour. Each preference is a single character. The following are defined: PP Passive: attempt to make the remote server initiate data transfers. This is slightly more efficient than sendport mode. If the letter SS occurs later in the string, zzffttpp will use sendport mode if passive mode is not available. SS Sendport: initiate transfers by the FTP PPOORRTT command. If this occurs before any PP in the string, passive mode will never be attempted. DD Dumb: use only the bare minimum of FTP commands. This prevents the variables ZZFFTTPPSSYYSSTTEEMM and ZZFFTTPPPPWWDD from being set, and will mean all connections default to ASCII type. It may prevent ZZFFTTPPSSIIZZEE from being set during a transfer if the server does not send it anyway (many servers do). If ZZFFTTPPPPRREEFFSS is not set when zzffttpp is loaded, it will be set to a default of `PPSS', i.e. use passive mode if available, otherwise fall back to sendport mode. ZZFFTTPPVVEERRBBOOSSEE A string of digits between 0 and 5 inclusive, specifying which responses from the server should be printed. All responses go to standard error. If any of the numbers 1 to 5 appear in the string, raw responses from the server with reply codes beginning with that digit will be printed to standard error. The first

digit of the three digit reply code is defined by RFC959 to cor-

respond to: 1. A positive preliminary reply. 2. A positive completion reply. 3. A positive intermediate reply. 4. A transient negative completion reply. 5. A permanent negative completion reply. It should be noted that, for unknown reasons, the reply `Service not available', which forces termination of a connection, is classified as 421, i.e. `transient negative', an interesting interpretation of the word `transient'. The code 0 is special: it indicates that all but the last line of multiline replies read from the server will be printed to standard error in a processed format. By convention, servers use this mechanism for sending information for the user to read. The appropriate reply code, if it matches the same response, takes priority. If ZZFFTTPPVVEERRBBOOSSEE is not set when zzffttpp is loaded, it will be set to the default value 445500, i.e., messages destined for the user and all errors will be printed. A null string is valid and specifies that no messages should be printed. FFuunnccttiioonnss zzffttppcchhppwwdd If this function is set by the user, it is called every time the directory changes on the server, including when a user is logged

in, or when a connection is closed. In the last case, $$ZZFFTTPPPPWWDD

will be unset; otherwise it will reflect the new directory. zzffttpppprrooggrreessss If this function is set by the user, it will be called during a ggeett, ppuutt or aappppeenndd operation each time sufficient data has been

received from the host. During a ggeett, the data is sent to stan-

dard output, so it is vital that this function should write to

standard error or directly to the terminal, not to standard out-

put. When it is called with a transfer in progress, the following additional shell parameters are set: ZZFFTTPPFFIILLEE The name of the remote file being transferred from or to. ZZFFTTPPTTRRAANNSSFFEERR A GG for a ggeett operation and a PP for a ppuutt operation. ZZFFTTPPSSIIZZEE The total size of the complete file being transferred: the same as the first value provided by the rreemmoottee and llooccaall subcommands for a particular file. If the server cannot supply this value for a remote file being retrieved, it will not be set. If input is from a pipe the value may be incorrect and correspond simply to a full pipe buffer. ZZFFTTPPCCOOUUNNTT The amount of data so far transferred; a number between

zero and $$ZZFFTTPPSSIIZZEE, if that is set. This number is

always available.

The function is initially called with ZZFFTTPPTTRRAANNSSFFEERR set appro-

priately and ZZFFTTPPCCOOUUNNTT set to zero. After the transfer is fin-

ished, the function will be called one more time with ZZFFTTPPTTRRAANNSSFFEERR set to GGFF or PPFF, in case it wishes to tidy up. It is otherwise never called twice with the same value of ZZFFTTPPCCOOUUNNTT. Sometimes the progress meter may cause disruption. It is up to the user to decide whether the function should be defined and to use uunnffuunnccttiioonn when necessary. PPrroobblleemmss A connection may not be opened in the left hand side of a pipe as this occurs in a subshell and the file information is not updated in the

main shell. In the case of type or mode changes or closing the connec-

tion in a subshell, the information is returned but variables are not updated until the next call to zzffttpp. Other status changes in subshells

will not be reflected by changes to the variables (but should be other-

wise harmless). Deleting sessions while a zzffttpp command is active in the background can have unexpected effects, even if it does not use the session being deleted. This is because all shell subprocesses share information on

the state of all connections, and deleting a session changes the order-

ing of that information. On some operating systems, the control connection is not valid after a fork(), so that operations in subshells, on the left hand side of a pipeline, or in the background are not possible, as they should be. This is presumably a bug in the operating system. TTHHEE ZZSSHH//ZZLLEE MMOODDUULLEE The zzsshh//zzllee module contains the Zsh Line Editor. See zshzle(1). TTHHEE ZZSSHH//ZZLLEEPPAARRAAMMEETTEERR MMOODDUULLEE The zzsshh//zzlleeppaarraammeetteerr module defines two special parameters that can be

used to access internal information of the Zsh Line Editor (see zsh-

zle(1)). kkeeyymmaappss This array contains the names of the keymaps currently defined. wwiiddggeettss This associative array contains one entry per widget defined.

The name of the widget is the key and the value gives informa-

tion about the widget. It is either the string `bbuuiillttiinn' for builtin widgets, a string of the form `uusseerr::name' for

user-defined widgets, where name is the name of the shell func-

tion implementing the widget, or it is a string of the form `ccoommpplleettiioonn::type::name', for completion widgets. In the last case type is the name of the builtin widgets the completion widget

imitates in its behavior and name is the name of the shell func-

tion implementing the completion widget. TTHHEE ZZSSHH//ZZPPRROOFF MMOODDUULLEE When loaded, the zzsshh//zzpprrooff causes shell functions to be profiled. The profiling results can be obtained with the zzpprrooff builtin command made available by this module. There is no way to turn profiling off other than unloading the module.

zzpprrooff [ -cc ]

Without the -cc option, zzpprrooff lists profiling results to standard

output. The format is comparable to that of commands like ggpprrooff. At the top there is a summary listing all functions that were called at least once. This summary is sorted in decreasing order of the amount of time spent in each. The lines contain the number of the function in order, which is used in other parts of the list in suffixes of the form `[[num]]'.RE, then the number of calls made to the function. The next three columns list the time in milliseconds spent in the function and its

descendents, the average time in milliseconds spent in the func-

tion and its descendents per call and the percentage of time spent in all shell functions used in this function and its

descendents. The following three columns give the same informa-

tion, but counting only the time spent in the function itself. The final column shows the name of the function. After the summary, detailed information about every function that was invoked is listed, sorted in decreasing order of the amount of time spent in each function and its descendents. Each of these entries consists of descriptions for the functions that called the function described, the function itself, and the functions that were called from it. The description for the function itself has the same format as in the summary (and shows the same information). The other lines don't show the number of the function at the beginning and have their function named indented to make it easier to distinguish the line showing the function described in the section from the surrounding lines. The information shown in this case is almost the same as in the summary, but only refers to the call hierarchy being displayed. For example, for a calling function the column showing the total running time lists the time spent in the described function and its descendents only for the times when it was called from that particular calling function. Likewise, for a called function, this columns lists the total time spent in the called function and its descendents only for the times when it was called from the function described. Also in this case, the column showing the number of calls to a

function also shows a slash and then the total number of invoca-

tions made to the called function. As long as the zzsshh//zzpprrooff module is loaded, profiling will be done and multiple invocations of the zzpprrooff builtin command will show the times and numbers of calls since the module was loaded.

With the -cc option, the zzpprrooff builtin command will reset its

internal counters and will not show the listing. ) TTHHEE ZZSSHH//ZZPPTTYY MMOODDUULLEE The zzsshh//zzppttyy module offers one builtin:

zzppttyy [ -ee ] [ -bb ] name [ arg ... ]

The arguments following name are concatenated with spaces between, then executed as a command, as if passed to the eevvaall

builtin. The command runs under a newly assigned pseudo-termi-

nal; this is useful for running commands non-interactively which

expect an interactive environment. The name is not part of the command, but is used to refer to this command in later calls to zzppttyy.

With the -ee option, the pseudo-terminal is set up so that input

characters are echoed.

With the -bb option, input to and output from the pseudo-terminal

are made non-blocking.

zzppttyy -dd [ names ... ]

The second form, with the -dd option, is used to delete commands

previously started, by supplying a list of their names. If no names are given, all commands are deleted. Deleting a command causes the HUP signal to be sent to the corresponding process.

zzppttyy -ww [ -nn ] name [ strings ... ]

The -ww option can be used to send the to command name the given

strings as input (separated by spaces). If the -nn option is not

given, a newline is added at the end. If no strings are provided, the standard input is copied to the

pseudo-terminal; this may stop before copying the full input if

the pseudo-terminal is non-blocking.

Note that the command under the pseudo-terminal sees this input

as if it were typed, so beware when sending special tty driver

characters such as word-erase, line-kill, and end-of-file.

zzppttyy -rr [ -tt ] name [ param [ pattern ] ]

The -rr option can be used to read the output of the command

name. With only a name argument, the output read is copied to

the standard output. Unless the pseudo-terminal is non-block-

ing, copying continues until the command under the pseudo-termi-

nal exits; when non-blocking, only as much output as is immedi-

ately available is copied. The return value is zero if any out-

put is copied. When also given a param argument, at most one line is read and stored in the parameter named param. Less than a full line may

be read if the pseudo-terminal is non-blocking. The return

value is zero if at least one character is stored in param. If a pattern is given as well, output is read until the whole

string read matches the pattern, even in the non-blocking case.

The return value is zero if the string read matches the pattern, or if the command has exited but at least one character could still be read. As of this writing, a maximum of one megabyte of output can be consumed this way; if a full megabyte is read

without matching the pattern, the return value is non-zero.

In all cases, the return value is non-zero if nothing could be

read, and is 22 if this is because the command has finished.

If the -rr option is combined with the -tt option, zzppttyy tests

whether output is available before trying to read. If no output is available, zzppttyy immediately returns the value 11.

zzppttyy -tt name

The -tt option without the -rr option can be used to test whether

the command name is still running. It returns a zero value if

the command is running and a non-zero value otherwise.

zzppttyy [ -LL ]

The last form, without any arguments, is used to list the com-

mands currently defined. If the -LL option is given, this is

done in the form of calls to the zzppttyy builtin. TTHHEE ZZSSHH//ZZSSEELLEECCTT MMOODDUULLEE The zzsshh//zzsseelleecctt module makes available one builtin command:

zzsseelleecctt [ -rrwwee -tt timeout -aa array ] [ fd ... ]

The zzsseelleecctt builtin is a front-end to the `select' system call,

which blocks until a file descriptor is ready for reading or writing, or has an error condition, with an optional timeout. If this is not available on your system, the command prints an error message and returns status 2 (normal errors return status 1). For more information, see your systems documentation for select(3). Note there is no connection with the shell builtin of the same name. Arguments and options may be intermingled in any order.

Non-option arguments are file descriptors, which must be decimal

integers. By default, file descriptors are to be tested for reading, i.e. zzsseelleecctt will return when data is available to be read from the file descriptor, or more precisely, when a read

operation from the file descriptor will not block. After a -rr,

-ww and -ee, the given file descriptors are to be tested for read-

ing, writing, or error conditions. These options and an arbi-

trary list of file descriptors may be given in any order. (The presence of an `error condition' is not well defined in the documentation for many implementations of the select system call. According to recent versions of the POSIX specification, it is really an exception condition, of which the only standard

example is out-of-band data received on a socket. So zsh users

are unlikely to find the -ee option useful.)

The option `-tt timeout' specifies a timeout in hundredths of a

second. This may be zero, in which case the file descriptors will simply be polled and zzsseelleecctt will return immediately. It is possible to call zselect with no file descriptors and a

non-zero timeout for use as a finer-grained replacement for

`sleep'; not, however, the return status is always 1 for a time-

out.

The option `-aa array' indicates that aarrrraayy should be set to

indicate the file descriptor(s) which are ready. If the option is not given, the array rreeppllyy will be used for this purpose. The array will contain a string similar to the arguments for zzsseelleecctt. For example,

zzsseelleecctt -tt 00 -rr 00 -ww 11

might return immediately with status 0 and $$rreeppllyy containing `-rr

00 -ww 11' to show that both file descriptors are ready for the

requested operations.

The option `-AA assoc' indicates that the associative array aassssoocc

should be set to indicate the file descriptor(s) which are

ready. This option overrides the option -aa, nor will rreeppllyy be

modified. The keys of aassssoocc are the file descriptors, and the corresponding values are any of the characters `rrwwee' to indicate the condition. The command returns 0 if some file descriptors are ready for reading. If the operation timed out, or a timeout of 0 was given and no file descriptors were ready, or there was an error, it returns status 1 and the array will not be set (nor modified in any way). If there was an error in the select operation the appropriate error message is printed. TTHHEE ZZSSHH//ZZUUTTIILL MMOODDUULLEE The zzsshh//zzuuttiill module only adds some builtins:

zzssttyyllee [ -LL ]

zzssttyyllee [ -ee | - | -- ] pattern style strings ...

zzssttyyllee -dd [ pattern [ styles ... ] ]

zzssttyyllee -gg name [ pattern [ style ] ]

zzssttyyllee -aabbss context style name [ sep ]

zzssttyyllee -TTtt context style [ strings ...]

zzssttyyllee -mm context style pattern

This builtin command is used to define and lookup styles. Styles are pairs of names and values, where the values consist

of any number of strings. They are stored together with pat-

terns and lookup is done by giving a string, called the `con-

text', which is compared to the patterns. The definition stored for the first matching pattern will be returned. For ordering of comparisons, patterns are searched from most

specific to least specific, and patterns that are equally spe-

cific keep the order in which they were defined. A pattern is considered to be more specific than another if it contains more components (substrings separated by colons) or if the patterns for the components are more specific, where simple strings are

considered to be more specific than patterns and complex pat-

terns are considered to be more specific than the pattern `**'. The first form (without arguments) lists the definitions in the

order zzssttyyllee will test them. If the -LL option is given, listing

is done in the form of calls to zzssttyyllee. Forms with arguments:

zzssttyyllee [ - | -- | -ee ] pattern style strings ...

Defines the given style for the pattern with the strings

as the value. If the -ee option is given, the strings

will be concatenated (separated by spaces) and the resulting string will be evaluated (in the same way as it is done by the eevvaall builtin command) when the style is looked up. In this case the parameter `rreeppllyy' must be

assigned to set the strings returned after the evalua-

tion. Before evaluating the value, rreeppllyy is unset, and if it is still unset after the evaluation, the style is treated as if it were not set.

zzssttyyllee -dd [ pattern [ styles ... ] ]

Delete style definitions. Without arguments all defini-

tions are deleted, with a pattern all definitions for that pattern are deleted and if any styles are given, then only those styles are deleted for the pattern.

zzssttyyllee -gg name [ pattern [ style ] ]

Retrieve a style definition. The name is used as the name of an array in which the results are stored. Without any further arguments, all patterns defined are returned. With a pattern the styles defined for that pattern are returned and with both a pattern and a style, the value strings of that combination is returned. The other forms can be used to look up or test patterns.

zzssttyyllee -ss context style name [ sep ]

The parameter name is set to the value of the style interpreted as a string. If the value contains several strings they are concatenated with spaces (or with the sep string if that is given) between them.

zzssttyyllee -bb context style name

The value is stored in name as a boolean, i.e. as the string `yyeess' if the value has only one string and that string is equal to one of `yyeess', `ttrruuee', `oonn', or `11'. If the value is any other string or has more than one string, the parameter is set to `nnoo'.

zzssttyyllee -aa context style name

The value is stored in name as an array. If name is declared as an associative array, the first, third, etc. strings are used as the keys and the other strings are used as the values.

zzssttyyllee -tt context style [ strings ...]

zzssttyyllee -TT context style [ strings ...]

Test the value of a style, i.e. the -tt option only

returns a status (sets $$??). Without any strings the

return status is zero if the style is defined for at least one matching pattern, has only one string in its value, and that is equal to one of `ttrruuee', `yyeess', `oonn' or `11'. If any strings are given the status is zero if and only if at least one of the strings is equal to at least one of the strings in the value. If the style is not defined, the status is 22.

The -TT option tests the values of the style like -tt, but

it returns zero (rather than 22) if the style is not defined for any matching pattern.

zzssttyyllee -mm context style pattern

Match a value. Returns status zero if the pattern matches at least one of the strings in the value.

zzffoorrmmaatt -ff param format specs ...

zzffoorrmmaatt -aa array sep specs ...

This builtin provides two different forms of formatting. The

first form is selected with the -ff option. In this case the for-

mat string will be modified by replacing sequences starting with a percent sign in it with strings from the specs. Each spec should be of the form `char::string' which will cause every

appearance of the sequence `%%char' in format to be replaced by

the string. The `%%' sequence may also contain optional minimum

and maximum field width specifications between the `%%' and the

`char' in the form `%%min..maxcc', i.e. the minimum field width is

given first and if the maximum field width is used, it has to be preceded by a dot. Specifying a minimum field width makes the result be padded with spaces to the right if the string is shorter than the requested width. Padding to the left can be achieved by giving a negative minimum field width. If a maximum field width is specified, the string will be truncated after

that many characters. After all `%%' sequences for the given

specs have been processed, the resulting string is stored in the parameter param.

The %%-escapes also understand ternary expressions in the form

used by prompts. The %% is followed by a `((' and then an ordi-

nary format specifier character as described above. There may be a set of digits either before or after the `(('; these specify a test number, which defaults to zero. Negative numbers are

also allowed. An arbitrary delimiter character follows the for-

mat specifier, which is followed by a piece of `true' text, the

delimiter character again, a piece of `false' text, and a clos-

ing parenthesis. The complete expression (without the digits)

thus looks like `%%((X..text1..text2))', except that the `..' charac-

ter is arbitrary. The value given for the format specifier in the char::string expressions is evaluated as a mathematical expression, and compared with the test number. If they are the same, text1 is output, else text2 is output. A parenthesis may

be escaped in text2 as %%)). Either of text1 or text2 may contain

nested %%-escapes.

For example:

zformat f REPLY "The answer is '%3(c.yes.no)'." c:3

outputs "The answer is 'yes'." to RREEPPLLYY since the value for the format specifier cc is 3, agreeing with the digit argument to the ternary expression.

The second form, using the -aa option, can be used for aligning

strings. Here, the specs are of the form `left::right' where `left' and `right' are arbitrary strings. These strings are modified by replacing the colons by the sep string and padding the left strings with spaces to the right so that the sep strings in the result (and hence the right strings after them) are all aligned if the strings are printed below each other. All strings without a colon are left unchanged and all strings with an empty right string have the trailing colon removed. In both cases the lengths of the strings are not used to determine how the other strings are to be aligned. The resulting strings are stored in the array. zzrreeggeexxppaarrssee This implements some internals of the rreeggeexxaarrgguummeennttss function.

zzppaarrsseeooppttss [ -DD ] [ -KK ] [ -EE ] [ -aa array ] [ -AA assoc ] specs

This builtin simplifies the parsing of options in positional

parameters, i.e. the set of arguments given by $$**. Each spec

describes one option and must be of the form `opt[==array]'. If an option described by opt is found in the positional parameters

it is copied into the array specified with the -aa option; if the

optional `==array' is given, it is instead copied into that array. Note that it is an error to give any spec without an `==array'

unless one of the -aa or -AA options is used.

Unless the -EE option is given, parsing stops at the first string

that isn't described by one of the specs. Even with -EE, parsing

always stops at a positional parameter equal to `-' or `--'.

The opt description must be one of the following. Any of the special characters can appear in the option name provided it is preceded by a backslash. name name++ The name is the name of the option without the leading

`-'. To specify a GNU-style long option, one of the

usual two leading `-' must be included in name; for exam-

ple, a `--ffiillee' option is represented by a name of

`-ffiillee'.

If a `++' appears after name, the option is appended to array each time it is found in the positional parameters; without the `++' only the last occurrence of the option is preserved.

If one of these forms is used, the option takes no argu-

ment, so parsing stops if the next positional parameter

does not also begin with `-' (unless the -EE option is

used). name::

name::-

name:::: If one or two colons are given, the option takes an argu-

ment; with one colon, the argument is mandatory and with two colons it is optional. The argument is appended to the array after the option itself. An optional argument is put into the same array element as the option name (note that this makes empty strings as arguments indistinguishable). A mandatory argument is

added as a separate element unless the `::-' form is used,

in which case the argument is put into the same element. A `++' as described above may appear between the name and the first colon. The options of zzppaarrsseeooppttss itself are:

-aa array

As described above, this names the default array in which to store the recognised options.

-AA assoc

If this is given, the options and their values are also put into

an associative array with the option names as keys and the argu-

ments (if any) as the values.

-DD If this option is given, all options found are removed from the

positional parameters of the calling shell or shell function, up to but not including any not described by the specs. This is similar to using the sshhiifftt builtin.

-KK With this option, the arrays specified with the -aa and -AA

options and with the `==array' forms are kept unchanged when none of the specs for them is used. This allows assignment of default values to them before calling zzppaarrsseeooppttss.

-EE This changes the parsing rules to not stop at the first string

that isn't described by one of the specs. It can be used to

test for or (if used together with -DD) extract options and their

arguments, ignoring all other options and arguments that may be in the positional parameters. For example,

sseett -- -aa -bbxx -cc yy -cczz bbaazz -cceenndd

zzppaarrsseeooppttss aa==ffoooo bb::==bbaarr cc++::==bbaarr will have the effect of

ffoooo==((-aa))

bbaarr==((-bb xx -cc yy -cc zz))

The arguments from `bbaazz' on will not be used.

As an example for the -EE option, consider:

sseett -- -aa xx -bb yy -cc zz aarrgg11 aarrgg22

zzppaarrsseeooppttss -EE -DD bb::==bbaarr

will have the effect of

bbaarr==((-bb yy))

sseett -- -aa xx -cc zz aarrgg11 aarrgg22

I.e., the option -bb and its arguments are taken from the positional

parameters and put into the array bbaarr. ZSHTCPSYS(1) ZSHTCPSYS(1)

NAME

zshtcpsys - zsh tcp system

DESCRIPTION

A module zzsshh//nneett//ttccpp is provided to provide network I/O over TCP/IP from within the shell; see its description in zshmodules(1) . This manual page describes a function suite based on the module. If the module is installed, the functions are usually installed at the same time, in which case they will be available for autoloading in the default function search path. In addition to the zzsshh//nneett//ttccpp module,

the zzsshh//zzsseelleecctt module is used to implement timeouts on read opera-

tions. For troubleshooting tips, consult the corresponding advice for the zzffttpp functions described in zshftpsys(1) . There are functions corresponding to the basic I/O operations open, close, read and send, named ttccppooppeenn etc., as well as a function

ttccppeexxppeecctt for pattern match analysis of data read as input. The sys-

tem makes it easy to receive data from and send data to multiple named sessions at once. In addition, it can be linked with the shell's line

editor in such a way that input data is automatically shown at the ter-

minal. Other facilities available including logging, filtering and configurable output prompts. To use the system where it is available, it should be enough to

`aauuttoollooaadd -UU ttccppooppeenn' and run ttccppooppeenn as documented below to start a

session. The ttccppooppeenn function will autoload the remaining functions. TTCCPP UUSSEERR FFUUNNCCTTIIOONNSS BBaassiicc II//OO

ttccppooppeenn [[-qqzz]] host port [[ sess ]]

ttccppooppeenn [[-qqzz]] [[ -ss sess || -ll sess,,...... ]] ......

ttccppooppeenn [[-qqzz]] [[-aa fd || -ff fd ]] [[ sess ]]

Open a new session. In the first and simplest form, open a TCP connection to host host at port port; numeric and symbolic forms are understood for both. If sess is given, this becomes the name of the session which can be used to refer to multiple different TCP connections. If sess is not given, the function will invent a numeric name value (note this is not the same as the file descriptor to which the session is attached). It is recommended that session names not include `funny' characters, where funny characters are not

well-defined but certainly do not include alphanumerics or

underscores, and certainly do include whitespace. In the second case, one or more sessions to be opened are given

by name. A single session name is given after -ss and a

comma-separated list after -ll; both options may be repeated as

many times as necessary. The host and port are read from the

file ..zzttccppsseessssiioonnss in the same directory as the user's zsh ini-

tialisation files, i.e. usually the home directory, but $$ZZDDOOTTDDIIRR

if that is set. The file consists of lines each giving a ses-

sion name and the corresponding host and port, in that order (note the session name comes first, not last), separated by whitespace. The third form allows passive and fake TCP connections. If the

option -aa is used, its argument is a file descriptor open for

listening for connections. No function front-end is provided to

open such a file descriptor, but a call to `zzttccpp -ll port' will

create one with the file descriptor stored in the parameter

$$RREEPPLLYY. The listening port can be closed with `zzttccpp -cc fd'. A

call to `ttccppooppeenn -aa fd' will block until a remote TCP connec-

tion is made to port on the local machine. At this point, a

session is created in the usual way and is largely indistin-

guishable from an active connection created with one of the first two forms.

If the option -ff is used, its argument is a file descriptor

which is used directly as if it were a TCP session. How well the remainder of the TCP function system copes with this depends on what actually underlies this file descriptor. A regular file is likely to be unusable; a FIFO (pipe) of some sort will work better, but note that it is not a good idea for two different sessions to attempt to read from the same FIFO at once.

If the option -qq is given with any of the three forms, ttccppooppeenn

will not print informational messages, although it will in any case exit with an appropriate status. If the line editor (zle) is in use, which is typically the case if the shell is interactive, ttccppooppeenn installs a handler inside zzllee which will check for new data at the same time as it checks for keyboard input. This is convenient as the shell consumes no CPU time while waiting; the test is performed by the operating

system. Giving the option -zz to any of the forms of ttccppooppeenn

prevents the handler from being installed, so data must be read explicitly. Note, however, this is not necessary for executing complete sets of send and read commands from a function, as zle is not active at this point. Generally speaking, the handler is only active when the shell is waiting for input at a command prompt or in the vvaarreedd builtin. The option has no effect if zle

is not active; `[[[[ -oo zzllee]]]]' will test for this.

The first session to be opened becomes the current session and

subsequent calls to ttccppooppeenn do not change it. The current ses-

sion is stored in the parameter $$TTCCPPSSEESSSS; see below for more

detail about the parameters used by the system.

ttccppcclloossee [[-qqnn]] [[ -aa || -ll sess,,...... || sess ...... ]]

Close the named sessions, or the current session if none is

given, or all open sessions if -aa is given. The options -ll and

-ss are both handled for consistency with ttccppooppeenn, although the

latter is redundant.

If the session being closed is the current one, $$TTCCPPSSEESSSS is

unset, leaving no current session, even if there are other ses-

sions still open.

If the session was opened with ttccppooppeenn -ff, the file descriptor

is closed so long as it is in the range 0 to 9 accessible

directly from the command line. If the option -nn is given, no

attempt will be made to close file descriptors in this case.

The -nn option is not used for genuine zzttccpp session; the file

descriptors are always closed with the session.

If the option -qq is given, no informational messages will be

printed.

ttccpprreeaadd [[-bbddqq]] [[ -tt TO ]] [[ -TT TO ]]

[[ -aa || -uu fd ...... || -ll sess,,...... || -ss sess ......]]

Perform a read operation on the current session, or on a list of

sessions if any are given with -uu, -ll or -ss, or all open ses-

sions if the option -aa is given. Any of the -uu, -ll or -ss

options may be repeated or mixed together. The -uu option speci-

fies a file descriptor directly (only those managed by this sys-

tem are useful), the other two specify sessions as described for ttccppooppeenn above. The function checks for new data available on all the sessions

listed. Unless the -bb option is given, it will not block wait-

ing for new data. Any one line of data from any of the avail-

able sessions will be read, stored in the parameter $$TTCCPPLLIINNEE,

and displayed to standard output unless $$TTCCPPSSIILLEENNTT contains a

non-empty string. When printed to standard output the string

$$TTCCPPPPRROOMMPPTT will be shown at the start of the line; the default

form for this includes the name of the session being read. See below for more information on these parameters. In this mode, ttccpprreeaadd can be called repeatedly until it returns status 2 which indicates all pending input from all specified sessions has been handled.

With the option -bb, equivalent to an infinite timeout, the func-

tion will block until a line is available to read from one of the specified sessions. However, only a single line is returned.

The option -dd indicates that all pending input should be

drained. In this case ttccpprreeaadd may process multiple lines in

the manner given above; only the last is stored in $$TTCCPPLLIINNEE,

but the complete set is stored in the array $$ttccpplliinneess. This is

cleared at the start of each call to ttccpprreeaadd.

The options -tt and -TT specify a timeout in seconds, which may be

a floating point number for increased accuracy. With -tt the

timeout is applied before each line read. With -TT, the timeout

applies to the overall operation, possibly including multiple

read operations if the option -dd is present; without this

option, there is no distinction between -tt and -TT.

The function does not print informational messages, but if the

option -qq is given, no error message is printed for a non-exis-

tent session. A return value of 2 indicates a timeout or no data to read. Any

other non-zero return value indicates some error condition.

See ttccpplloogg for how to control where data is sent by ttccpprreeaadd.

ttccppsseenndd [[-nnqq]] [[ -ss sess || -ll sess,,...... ]] data ......

ttccppsseenndd [[-nnqq]] -aa data ......

Send the supplied data strings to all the specified sessions in

turn. The underlying operation differs little from a `pprriinntt -rr'

to the session's file descriptor, although it attempts to pre-

vent the shell from dying owing to a SSIIGGPPIIPPEE caused by an attempt to write to a defunct session.

The option -nn prevents ttccppsseenndd from putting a newline at the

end of the data strings. The remaining options all behave as for ttccpprreeaadd. The data arguments are not further processed once they have been

passed to ttccppsseenndd; they are simply passed down to pprriinntt -rr.

If the parameter $$TTCCPPOOUUTTPPUUTT is a non-empty string and logging

is enabled then the data sent to each session will be echoed to

the log file(s) with $$TTCCPPOOUUTTPPUUTT in front where appropriate,

much in the manner of $$TTCCPPPPRROOMMPPTT.

SSeessssiioonn MMaannaaggeemmeenntt

ttccppaalliiaass [[-qq]] alias==sess ......

ttccppaalliiaass [[-qq]] [[ alias ]] ......

ttccppaalliiaass -dd [[-qq]] alias ......

This function is not particularly well tested. The first form creates an alias for a session name; alias can then be used to refer to the existing session sess. As many aliases may be listed as required. The second form lists any aliases specified, or all aliases if none. The third form deletes all the aliases listed. The underlying sessions are not affected.

The option -qq suppresses an inconsistently chosen subset of

error messages.

ttccpplloogg [[-aasscc]] [[ -nn || -NN ]] [[ logfile ]]

With an argument logfile, all future input from ttccpprreeaadd will be

logged to the named file. Unless -aa (append) is given, this

file will first be truncated or created empty. With no argu-

ments, show the current status of logging.

With the option -ss, per-session logging is enabled. Input from

ttccpprreeaadd is output to the file logfile.sess. As the session is automatically discriminated by the filename, the contents are

raw (no $$TTCCPPPPRROOMMPPTT). The option -aa applies as above.

Per-session logging and logging of all data in one file are not

mutually exclusive.

The option -cc closes all logging, both complete and per-session

logs.

The options -nn and -NN respectively turn off or restore output of

data read by ttccpprreeaadd to standard output; hence `ttccpplloogg -ccnn'

turns off all output by ttccpprreeaadd. The function is purely a convenient front end to setting the

parameters $$TTCCPPLLOOGG, $$TTCCPPLLOOGGSSEESSSS, $$TTCCPPSSIILLEENNTT, which are

described below. ttccpprreennaammee old new Rename session old to session new. The old name becomes invalid. ttccppsseessss [[ sess [[ command ...... ]] ]] With no arguments, list all the open sessions and associated file descriptors. The current session is marked with a star. For use in functions, direct access to the parameters

$$ttccppbbyynnaammee, $$ttccppbbyyffdd and $$TTCCPPSSEESSSS is probably more conve-

nient; see below. With a sess argument, set the current session to sess. This is

equivalent to changing $$TTCCPPSSEESSSS directly.

With additional arguments, temporarily set the current session while executing the string ccoommmmaanndd ....... The first argument is

re-evaluated so as to expand aliases etc., but the remaining

arguments are passed through as the appear to ttccppsseessss. The original session is restored when ttccppsseessss exits. AAddvvaanncceedd II//OO

ttccppccoommmmaanndd send-options ...... send-arguments ......

This is a convenient front-end to ttccppsseenndd. All arguments are

passed to ttccppsseenndd, then the function pauses waiting for data.

While data is arriving at least every $$TTCCPPTTIIMMEEOOUUTT (default 0.3)

seconds, data is handled and printed out according to the cur-

rent settings. Status 0 is always returned. This is generally only useful for interactive use, to prevent

the display becoming fragmented by output returned from the con-

nection. Within a programme or function it is generally better to handle reading data by a more explicit method.

ttccppeexxppeecctt [[ -qq ]] [[ -pp var ]] [[ -tt to || -TT TO]]

[[ -aa || -ss sess ...... || -ll sess,,...... ]] pattern ...

Wait for input matching any of the given patterns from any of the specified sessions. Input is ignored until an input line matches one of the given patterns; at this point status zero is

returned, the matching line is stored in $$TTCCPPLLIINNEE, and the full

set of lines read during the call to ttccppeexxppeecctt is stored in the

array $$ttccppeexxppeeccttlliinneess.

Sessions are specified in the same way as ttccpprreeaadd: the default is to use the current session, otherwise the sessions specified

by -aa, -ss, or -ll are used.

Each pattern is a standard zsh extended-globbing pattern; note

that it needs to be quoted to avoid it being expanded immedi-

ately by filename generation. It must match the full line, so to match a substring there must be a `**' at the start and end.

The line matched against includes the $$TTCCPPPPRROOMMPPTT added by

ttccpprreeaadd. It is possible to include the globbing flags `##bb' or

`##mm' in the patterns to make backreferences available in the

parameters $$MMAATTCCHH, $$mmaattcchh, etc., as described in the base zsh

documentation on pattern matching. Unlike ttccpprreeaadd, the default behaviour of ttccppeexxppeecctt is to block indefinitely until the required input is found. This can be

modified by specifying a timeout with -tt or -TT; these function

as in ttccpprreeaadd, specifying a per-read or overall timeout,

respectively, in seconds, as an integer or floating-point num-

ber. As ttccpprreeaadd, the function returns status 2 if a timeout occurs. The function returns as soon as any one of the patterns given match. If the caller needs to know which of the patterns

matched, the option -pp var can be used; on return, $$vvaarr is set

to the number of the pattern using ordinary zsh indexing, i.e.

the first is 1, and so on. Note the absence of a `$$' in front

of var. To avoid clashes, the parameter cannot begin with `eexxppeecctt'.

The option -qq is passed directly down to ttccpprreeaadd.

As all input is done via ttccpprreeaadd, all the usual rules about output of lines read apply. One exception is that the parameter

$$ttccpplliinneess will only reflect the line actually matched by

ttccppeexxppeecctt; use $$ttccppeexxppeeccttlliinneess for the full set of lines read

during the function call. ttccpppprrooxxyy

This is a simple-minded function to accept a TCP connection and

execute a command with I/O redirected to the connection.

Extreme caution should be taken as there is no security whatso-

ever and this can leave your computer open to the world. Ide-

ally, it should only be used behind a firewall.

The first argument is a TCP port on which the function will lis-

ten.

The remaining arguments give a command and its arguments to exe-

cute with standard input, standard output and standard error redirected to the file descriptor on which the TCP session has been accepted. If no command is given, a new zsh is started. This gives everyone on your network direct access to your account, which in many cases will be a bad thing. The command is run in the background, so ttccpppprrooxxyy can then accept new connections. It continues to accept new connections until interrupted.

ttccppssppaamm [[-eerrttvv]] [[ -aa || -ss sess || -ll sess,,...... ]] cmd ......

Execute `cmd ......' for each session in turn. Note this executes the command and arguments; it does not send the command line as

data unless the -tt (transmit) option is given.

The sessions may be selected explicitly with the standard -aa, -ss

or -ll options, or may be chosen implicitly. If none of the

three options is given the rules are: first, if the array

$$ttccppssppaammlliisstt is set, this is taken as the list of sessions,

otherwise all sessions are taken. Second, any sessions given in

the array $$ttccppnnoossppaammlliisstt are removed from the list of ses-

sions.

Normally, any sessions added by the `-aa' flag or when all ses-

sions are chosen implicitly are spammed in alphabetic order;

sessions given by the $$ttccppssppaammlliisstt array or on the command

line are spammed in the order given. The -rr flag reverses the

order however it was arrived it.

The -vv flag specifies that a $$TTCCPPPPRROOMMPPTT will be output before

each session. This is output after any modification to TCPSESS

by the user-defined ttccppoonnssppaamm function described below.

(Obviously that function is able to generate its own output.)

If the option -ee is present, the line given as cmd ... is exe-

cuted using eevvaall, otherwise it is executed without any further processing. ttccppttaallkk

This is a fairly simple-minded attempt to force input to the

line editor to go straight to the default TCPSESSION.

An escape string, $$TTCCPPTTAALLKKEESSCCAAPPEE, default `:', is used to

allow access to normal shell operation. If it is on its own at the start of the line, or followed only by whitespace, the line editor returns to normal operation. Otherwise, the string and any following whitespace are skipped and the remainder of the

line executed as shell input without any change of the line edi-

tor's operating mode. The current implementation is somewhat deficient in terms of use of the command history. For this reason, many users will prefer to use some form of alternative approach for sending data easily to the current session. One simple approach is to alias some

special character (such as `%%') to `ttccppccoommmmaanndd --'.

ttccppwwaaiitt The sole argument is an integer or floating point number which gives the seconds to delay. The shell will do nothing for that period except wait for input on all TCP sessions by calling

ttccpprreeaadd -aa. This is similar to the interactive behaviour at

the command prompt when zle handlers are installed.

``OOnnee-sshhoott'' ffiillee ttrraannssffeerr

ttccppppooiinntt port ttccppsshhoooott host port This pair of functions provide a simple way to transfer a file between two hosts within the shell. Note, however, that bulk data transfer is currently done using ccaatt. ttccppppooiinntt reads any data arriving at port and sends it to standard output; ttccppsshhoooott connects to port on host and sends its standard input. Any unused port may be used; the standard mechanism for picking a

port is to think of a random four-digit number above 1024 until

one works. To transfer a file from host wwooooddccoocckk to host sspprriinnggeess, on sspprriinnggeess: ttccppppooiinntt 88009911 >>oouuttppuuttffiillee and on wwooooddccoocckk: ttccppsshhoooott sspprriinnggeess 88009911 <TTCCPP UUSSEERR-DDEEFFIINNEEDD FFUUNNCCTTIIOONNSS

Certain functions, if defined by the user, will be called by the func-

tion system in certain contexts. This facility depends on the module zzsshh//ppaarraammeetteerr, which is usually available in interactive shells as the completion system depends on it. None of the functions need be defined; they simply provide convenient hooks when necessary. Typically, these are called after the requested action has been taken, so that the various parameters will reflect the new state. ttccppoonnaalliiaass alias fd When an alias is defined, this function will be called with two arguments: the name of the alias, and the file descriptor of the corresponding session. ttccppoonncclloossee sess fd This is called with the name of a session being closed and the file descriptor which corresponded to that session. Both will be invalid by the time the function is called. ttccppoonnooppeenn sess fd This is called after a new session has been defined with the session name and file descriptor as arguments. ttccppoonnrreennaammee oldsess fd newsess This is called after a session has been renamed with the three arguments old session name, file descriptor, new session name. ttccppoonnssppaamm sess command ......

This is called once for each session spammed, just before a com-

mand is executed for a session by ttccppssppaamm. The arguments are the session name followed by the command list to be executed.

If ttccppssppaamm was called with the option -tt, the first command

will be ttccppsseenndd.

This function is called after $$TTCCPPSSEESSSS is set to reflect the

session to be spammed, but before any use of it is made. Hence

it is possible to alter the value of $$TTCCPPSSEESSSS within this func-

tion. For example, the session arguments to ttccppssppaamm could include extra information to be stripped off and processed in ttccppoonnssppaamm.

If the function sets the parameter $$RREEPPLLYY to `ddoonnee', the command

line is not executed; in addition, no prompt is printed for the

-vv option to ttccppssppaamm.

ttccppoonnuunnaalliiaass alias fd This is called with the name of an alias and the corresponding session's file descriptor after an alias has been deleted. TTCCPP UUTTIILLIITTYY FFUUNNCCTTIIOONNSS The following functions are used by the TCP function system but will rarely if ever need to be called directly. ttccppffddhhaannddlleerr This is the function installed by ttccppooppeenn for handling input from within the line editor, if that is required. It is in the

format documented for the builtin `zzllee -FF' in zshzle(1) .

While active, the function sets the parameter TTCCPPHHAANNDDLLEERRAACCTTIIVVEE to 1. This allows shell code called internally (for example, by setting ttccppoonnrreeaadd) to tell if is being called when the shell is otherwise idle at the editor prompt.

ttccppoouuttppuutt [[ -qq ]] -PP prompt -FF fd -SS sess

This function is used for both logging and handling output to

standard output, from within ttccpprreeaadd and (if $$TTCCPPOOUUTTPPUUTT is

set) ttccppsseenndd.

The prompt to use is specified by -PP; the default is the empty

string. It can contain:

%%cc Expands to 1 if the session is the current session, oth-

erwise 0. Used with ternary expresions such as

`%%((cc..-..++))' to output `++' for the current session and `-'

otherwise.

%%ff Replaced by the session's file descriptor.

%%ss Replaced by the session name.

%%%% Replaced by a single `%%'.

The option -qq suppresses output to standard output, but not to

any log files which are configured.

The -SS and -FF options are used to pass in the session name and

file descriptor for possible replacement in the prompt. TTCCPP UUSSEERR PPAARRAAMMEETTEERRSS Parameters follow the usual convention that uppercase is used for

scalars and integers, while lowercase is used for normal and associa-

tive array. It is always safe for user code to read these parameters. Some parameters may also be set; these are noted explicitly. Others are included in this group as they are set by the function system for the user's benefit, i.e. setting them is typically not useful but is benign.

It is often also useful to make settable parameters local to a func-

tion. For example, `llooccaall TTCCPPSSIILLEENNTT==11' specifies that data read dur-

ing the function call will not be printed to standard output, regard-

less of the setting outside the function. Likewise, `llooccaall TTCCPPSSEESSSS==sess' sets a session for the duration of a function, and `llooccaall TTCCPPPPRROOMMPPTT==' specifies that no prompt is used for input during the function. ttccppeexxppeeccttlliinneess Array. The set of lines read during the last call to

ttccppeexxppeecctt, including the last ($$TTCCPPLLIINNEE).

ttccppffiilltteerr Array. May be set directly. A set of extended globbing patterns which, if matched in ttccppoouuttppuutt, will cause the line not to be printed to standard output. The patterns should be defined as described for the arguments to ttccppeexxppeecctt. Output of line to log files is not affected. TTCCPPHHAANNDDLLEERRAACCTTIIVVEE Scalar. Set to 1 within ttccppffddhhaannddlleerr to indicate to functions called recursively that they have been called during an editor session. Otherwise unset. TTCCPPLLIINNEE The last line read by ttccpprreeaadd, and hence also ttccppeexxppeecctt. TTCCPPLLIINNEEFFDD

The file descriptor from which $$TTCCPPLLIINNEE was read.

$${{ttccppbbyyffdd[[$$TTCCPPLLIINNEEFFDD]]}} will give the corresponding session

name. ttccpplliinneess Array. The set of lines read during the last call to ttccpprreeaadd,

including the last ($$TTCCPPLLIINNEE).

TTCCPPLLOOGG May be set directly, although it is also controlled by ttccpplloogg. The name of a file to which output from all sessions will be

sent. The output is proceeded by the usual $$TTCCPPPPRROOMMPPTT. If it

is not an absolute path name, it will follow the user's current directory. TTCCPPLLOOGGSSEESSSS May be set directly, although it is also controlled by ttccpplloogg. The prefix for a set of files to which output from each session separately will be sent; the full filename is

$${{TTCCPPLLOOGGSSEESSSS}}..sess. Output to each file is raw; no prompt is

added. If it is not an absolute path name, it will follow the user's current directory. ttccppnnoossppaammlliisstt Array. May be set directly. See ttccppssppaamm for how this is used. TTCCPPOOUUTTPPUUTT

May be set directly. If a non-empty string, any data sent to a

session by ttccppsseenndd will be logged. This parameter gives the

prompt to be used in a file specified by $$TTCCPPLLOOGG but not in a

file generated from $$TTCCPPLLOOGGSSEESSSS. The prompt string has the

same format as TTCCPPPPRROOMMPPTT and the same rules for its use apply. TTCCPPPPRROOMMPPTT May be set directly. Used as the prefix for data read by ttccpprreeaadd which is printed to standard output or to the log file

given by $$TTCCPPLLOOGG, if any. Any `%%ss', `%%ff' or `%%%%' occurring in

the string will be replaced by the name of the session, the ses-

sion's underlying file descriptor, or a single `%%', respec-

tively. The expression `%%cc' expands to 1 if the session being

read is the current session, else 0; this is most useful in

ternary expressions such as `%%((cc..-..++))' which outputs `++' if the

session is the current one, else `-'.

TTCCPPRREEAADDDDEEBBUUGG

May be set directly. If this has non-zero length, ttccpprreeaadd will

give some limited diagnostics about data being read. TTCCPPSSEECCOONNDDSSSSTTAARRTT This value is created and initialised to zero by tcpopen. The functions ttccpprreeaadd and ttccppeexxppeecctt use the shell's SSEECCOONNDDSS parameter for their own timing purposes. If that parameter is not of floating point type on entry to one of the functions, it will create a local parameter SSEECCOONNDDSS which is floating point and set the parameter TTCCPPSSEECCOONNDDSSSSTTAARRTT to the previous value of

$$SSEECCOONNDDSS. If the parameter is already floating point, it is

used without a local copy being created and TTCCPPSSEECCOONNDDSSSSTTAARRTT is not set. As the global value is zero, the shell elapsed time is

guaranteed to be the sum of $$SSEECCOONNDDSS and $$TTCCPPSSEECCOONNDDSSSSTTAARRTT.

This can be avoided by setting SSEECCOONNDDSS globally to a floating

point value using `ttyyppeesseett -FF SSEECCOONNDDSS'; then the TCP functions

will never make a local copy and never set TTCCPPSSEECCOONNDDSSSSTTAARRTT to

a non-zero value.

TTCCPPSSEESSSS May be set directly. The current session; must refer to one of the sessions established by ttccppooppeenn. TTCCPPSSIILLEENNTT May be set directly, although it is also controlled by ttccpplloogg.

If of non-zero length, data read by ttccpprreeaadd will not be written

to standard output, though may still be written to a log file. ttccppssppaammlliisstt

Array. May be set directly. See the description of the func-

tion ttccppssppaamm for how this is used. TTCCPPTTAALLKKEESSCCAAPPEE May be set directly. See the description of the function ttccppttaallkk for how this is used. TTCCPPTTIIMMEEOOUUTT

May be set directly. Currently this is only used by the func-

tion ttccppccoommmmaanndd, see above.

TTCCPP UUSSEERR-DDEEFFIINNEEDD PPAARRAAMMEETTEERRSS

The following parameters are not set by the function system, but have a special effect if set by the user. ttccppoonnrreeaadd This should be an associative array; if it is not, the behaviour is undefined. Each key is the name of a shell function or other command, and the corresponding value is a shell pattern (using EEXXTTEENNDDEEDDGGLLOOBB). Every line read from a TCP session directly or indirectly using ttccpprreeaadd (which includes lines read by ttccppeexxppeecctt) is compared against the pattern. If the line

matches, the command given in the key is called with two argu-

ments: the name of the session from which the line was read, and the line itself.

If any function called to handle a line returns a non-zero sta-

tus, the line is not output. Thus a ttccppoonnrreeaadd handler con-

taining only the instruction `rreettuurrnn 11' can be used to suppress output of particular lines (see, however, ttccppffiilltteerr above). However, the line is still stored in TTCCPPLLIINNEE and ttccpplliinneess; this occurs after all ttccppoonnrreeaadd processing. TTCCPP UUTTIILLIITTYY PPAARRAAMMEETTEERRSS These parameters are controlled by the function system; they may be read directly, but should not usually be set by user code. ttccppaalliiaasseess

Associative array. The keys are the names of sessions estab-

lished with ttccppooppeenn; each value is a space-separated list of

aliases which refer to that session. ttccppbbyyffdd Associative array. The keys are session file descriptors; each value is the name of that session. ttccppbbyynnaammee Associative array. The keys are the names of sessions; each value is the file descriptor associated with that session. TTCCPP EEXXAAMMPPLLEESS Here is a trivial example using a remote calculator. TO create a calculator server on port 7337 (see the ddcc manual page for quite how infuriating the underlying command is): ttccpppprrooxxyy 77333377 ddcc To connect to this from the same host with a session also named `ddcc': ttccppooppeenn llooccaallhhoosstt 77333377 ddcc

To send a command to the remote session and wait a short while for out-

put (assuming ddcc is the current session): ttccppccoommmmaanndd 22 44 ++ pp To close the session: ttccppcclloossee The ttccpppprrooxxyy needs to be killed to be stopped. Note this will not usually kill any connections which have already been accepted, and also that the port is not immediately available for reuse. The following chunk of code puts a list of sessions into an xterm header, with the current session followed by a star.

pprriinntt -nn ""\\003333]]22;;TTCCPP::"" $${{((kk))ttccppbbyynnaammee:://$$TTCCPPSSEESSSS//$$TTCCPPSSEESSSS\\**}} ""\\aa""

TCP BUGS

The function ttccpprreeaadd uses the shell's normal rreeaadd builtin. As this

reads a complete line at once, data arriving without a terminating new-

line can cause the function to block indefinitely. Though the function suite works well for interactive use and for data arriving in small amounts, the performance when large amounts of data are being exchanged is likely to be extremely poor. ZSHZFTPSYS(1) ZSHZFTPSYS(1)

NAME

zshzftpsys - zftp function front-end

DESCRIPTION

This describes the set of shell functions supplied with the source dis-

tribution as an interface to the zzffttpp builtin command, allowing you to perform FTP operations from the shell command line or within functions or scripts. The interface is similar to a traditional FTP client (e.g. the ffttpp command itself, see ftp(1)), but as it is entirely done within the shell all the familiar completion, editing and globbing features, and so on, are present, and macros are particularly simple to write as they are just ordinary shell functions.

The prerequisite is that the zzffttpp command, as described in zshmod-

ules(1) , must be available in the version of zzsshh installed at your site. If the shell is configured to load new commands at run time, it probably is: typing `zzmmooddllooaadd zzsshh//zzffttpp' will make sure (if that runs silently, it has worked). If this is not the case, it is possible zzffttpp was linked into the shell anyway: to test this, type `wwhhiicchh zzffttpp' and

if zzffttpp is available you will get the message `zzffttpp:: sshheellll bbuuiilltt-iinn

ccoommmmaanndd'. Commands given directly with zzffttpp builtin may be interspersed between the functions in this suite; in a few cases, using zzffttpp directly may cause some of the status information stored in shell parameters to become invalid. Note in particular the description of the variables

$$ZZFFTTPPTTMMOOUUTT, $$ZZFFTTPPPPRREEFFSS and $$ZZFFTTPPVVEERRBBOOSSEE for zzffttpp.

IINNSSTTAALLLLAATTIIOONN

You should make sure all the functions from the FFuunnccttiioonnss//ZZffttpp direc-

tory of the source distribution are available; they all begin with the two letters `zzff'. They may already have been installed on your system; otherwise, you will need to find them and copy them. The directory

should appear as one of the elements of the $$ffppaatthh array (this should

already be the case if they were installed), and at least the function zzffiinniitt should be autoloaded; it will autoload the rest. Finally, to initialize the use of the system you need to call the zzffiinniitt function. The following code in your ..zzsshhrrcc will arrange for this; assume the functions are stored in the directory ~~//mmyyffnnss:

ffppaatthh==((~~//mmyyffnnss $$ffppaatthh))

aauuttoollooaadd -UU zzffiinniitt

zzffiinniitt Note that zzffiinniitt assumes you are using the zzmmooddllooaadd method to load the zzffttpp command. If it is already built into the shell, change zzffiinniitt to

zzffiinniitt -nn. It is helpful (though not essential) if the call to zzffiinniitt

appears after any code to initialize the new completion system, else unnecessary ccoommppccttll commands will be given. FFUUNNCCTTIIOONNSS The sequence of operations in performing a file transfer is essentially the same as that in a standard FTP client. Note that, due to a quirk of the shell's ggeettooppttss builtin, for those functions that handle options

you must use `--' rather than `-' to ensure the remaining arguments are

treated literally (a single `-' is treated as an argument).

OOppeenniinngg aa ccoonnnneeccttiioonn zzffppaarraammss [[ host [[ user [[ password ...... ]] ]] ]]

Set or show the parameters for a future zzffooppeenn with no argu-

ments. If no arguments are given, the current parameters are displayed (the password will be shown as a line of asterisks). If a host is given, and either the user or password is not, they will be prompted for; also, any parameter given as `??' will be prompted for, and if the `??' is followed by a string, that will be used as the prompt. As zzffooppeenn calls zzffppaarraammss to store the parameters, this usually need not be called directly.

A single argument `-' will delete the stored parameters. This

will also cause the memory of the last directory (and so on) on the other host to be deleted.

zzffooppeenn [[ -11 ]] [[ host [[ user [[ password [[ account ]] ]] ]] ]]

If host is present, open a connection to that host under user-

name user with password password (and, on the rare occasions

when it is necessary, account account). If a necessary parame-

ter is missing or given as `??' it will be prompted for. If host is not present, use a previously stored set of parameters. If the command was successful, and the terminal is compatible

with xxtteerrmm or is ssuunn-ccmmdd, a summary will appear in the title

bar, giving the local hhoosstt::ddiirreeccttoorryy and the remote hhoosstt::ddiirreecc-

ttoorryy; this is handled by the function zzffttppcchhppwwdd, described below. Normally, the host, user and password are internally recorded

for later re-opening, either by a zzffooppeenn with no arguments, or

automatically (see below). With the option `-11', no information

is stored. Also, if an open command with arguments failed, the parameters will not be retained (and any previous parameters

will also be deleted). A zzffooppeenn on its own, or a zzffooppeenn -11,

never alters the stored parameters. Both zzffooppeenn and zzffaannoonn (but not zzffppaarraammss) understand URLs of the form ffttpp::////host/path... as meaning to connect to the host, then change directory to path (which must be a directory, not a file). The `ffttpp::////' can be omitted; the trailing `//' is enough to trigger recognition of the path. Note prefixes other than `ffttpp::' are not recognized, and that all characters after the first slash beyond host are significant in path.

zzffaannoonn [[ -11 ]] host

Open a connection host for anonymous FTP. The username used is `aannoonnyymmoouuss'. The password (which will be reported the first time) is generated as user@@host; this is then stored in the

shell parameter $$EEMMAAIILLAADDDDRR which can alternatively be set manu-

ally to a suitable string. DDiirreeccttoorryy mmaannaaggeemmeenntt zzffccdd [[ dir ]]

zzffccdd -

zzffccdd old new Change the current directory on the remote server: this is implemented to have many of the features of the shell builtin ccdd. In the first form with dir present, change to the directory dir. The command `zzffccdd ....' is treated specially, so is guaranteed to

work on non-UNIX servers (note this is handled internally by

zzffttpp). If dir is omitted, has the effect of `zzffccdd ~~'. The second form changes to the directory previously current. The third form attempts to change the current directory by replacing the first occurrence of the string old with the string new in the current directory. Note that in this command, and indeed anywhere a remote filename is expected, the string which on the local host corresponds to `~~' is converted back to a `~~' before being passed to the remote machine. This is convenient because of the way expansion is performed on the command line before zzffccdd receives a string. For example, suppose the command is `zzffccdd ~~//ffoooo'. The shell will expand this to a full path such as `zzffccdd

//hhoommee//uusseerr22//ppwwss//ffoooo'. At this stage, zzffccdd recognises the ini-

tial path as corresponding to `~~' and will send the directory to the remote host as ~~//ffoooo, so that the `~~' will be expanded by the server to the correct remote host directory. Other named directories of the form `~~nnaammee' are not treated in this fashion. zzffhheerree Change directory on the remote server to the one corresponding to the current local directory, with special handling of `~~' as in zzffccdd. For example, if the current local directory is ~~//ffoooo//bbaarr, then zzffhheerree performs the effect of `zzffccdd ~~//ffoooo//bbaarr'.

zzffddiirr [[ -rrffdd ]] [[ - ]] [[ dir-options ]] [[ dir ]]

Produce a long directory listing. The arguments dir-options and

dir are passed directly to the server and their effect is imple-

mentation dependent, but specifying a particular remote direc-

tory dir is usually possible. The output is passed through a

pager given by the environment variable $$PPAAGGEERR, or `mmoorree' if

that is not set.

The directory is usually cached for re-use. In fact, two caches

are maintained. One is for use when there is no dir-options or

dir, i.e. a full listing of the current remote directory; it is flushed when the current remote directory changes. The other is kept for repeated use of zzffddiirr with the same arguments; for example, repeated use of `zzffddiirr //ppuubb//ggnnuu' will only require the directory to be retrieved on the first call. Alternatively,

this cache can be re-viewed with the -rr option. As relative

directories will confuse zzffddiirr, the -ff option can be used to

force the cache to be flushed before the directory is listed.

The option -dd will delete both caches without showing a direc-

tory listing; it will also delete the cache of file names in the current remote directory, if any.

zzffllss [ ls-options ] [ dir ]

List files on the remote server. With no arguments, this will produce a simple list of file names for the current remote directory. Any arguments are passed directly to the server. No pager and no caching is used. SSttaattuuss ccoommmmaannddss zzffttyyppee [ type ]

With no arguments, show the type of data to be transferred, usu-

ally ASCII or binary. With an argument, change the type: the types `AA' or `AASSCCIIII' for ASCII data and `BB' or `BBIINNAARRYY', `II' or

`IIMMAAGGEE' for binary data are understood case-insensitively.

zzffssttaatt [ -v ]

Show the status of the current or last connection, as well as

the status of some of zzffttpp's status variables. With the -vv

option, a more verbose listing is produced by querying the server for its version of events, too. RReettrriieevviinngg ffiilleess

The commands for retrieving files all take at least two options. -GG

suppresses remote filename expansion which would otherwise be performed

(see below for a more detailed description of that). -tt attempts to

set the modification time of the local file to that of the remote file: this requires version 5 of ppeerrll, see the description of the function zzffrrttiimmee below for more information.

zzffggeett [[ -GGttcc ]] file1 ......

Retrieve all the listed files file1 ... one at a time from the remote server. If a file contains a `//', the full name is passed to the remote server, but the file is stored locally under the name given by the part after the final `//'. The

option -cc (cat) forces all files to be sent as a single stream

to standard output; in this case the -tt option has no effect.

zzffuuggeett [[ -GGvvsstt ]] file1 ......

As zzffggeett, but only retrieve files where the version on the remote server is newer (has a later modification time), or where the local file does not exist. If the remote file is older but the files have different sizes, or if the sizes are the same but the remote file is newer, the user will usually be queried.

With the option -ss, the command runs silently and will always

retrieve the file in either of those two cases. With the option

-vv, the command prints more information about the files while it

is working out whether or not to transfer them.

zzffccggeett [[ -GGtt ]] file1 ......

As zzffggeett, but if any of the local files exists, and is shorter than the corresponding remote file, the command assumes that it is the result of a partially completed transfer and attempts to

transfer the rest of the file. This is useful on a poor connec-

tion which keeps failing.

Note that this requires a commonly implemented, but non-stan-

dard, version of the FTP protocol, so is not guaranteed to work on all servers.

zzffggccpp [[ -GGtt ]] remote-file local-file

zzffggccpp [[ -GGtt ]] rfile1 ...... ldir

This retrieves files from the remote server with arguments behaving similarly to the ccpp command.

In the first form, copy remote-file from the server to the local

file local-file.

In the second form, copy all the remote files rfile1 ... into the local directory ldir retaining the same basenames. This assumes UNIX directory semantics. SSeennddiinngg ffiilleess

zzffppuutt [[ -rr ]] file1 ......

Send all the file1 ... given separately to the remote server. If a filename contains a `//', the full filename is used locally to find the file, but only the basename is used for the remote file name.

With the option -rr, if any of the files are directories they are

sent recursively with all their subdirectories, including files beginning with `..'. This requires that the remote machine understand UNIX file semantics, since `//' is used as a directory separator.

zzffuuppuutt [[ -vvss ]] file1 ......

As zzffppuutt, but only send files which are newer than their local equivalents, or if the remote file does not exist. The logic is the same as for zzffuuggeett, but reversed between local and remote files. zzffccppuutt file1 ...... As zzffppuutt, but if any remote file already exists and is shorter

than the local equivalent, assume it is the result of an incom-

plete transfer and send the rest of the file to append to the

existing part. As the FTP append command is part of the stan-

dard set, this is in principle more likely to work than zzffccggeett.

zzffppccpp local-file remote-file

zzffppccpp lfile1 ...... rdir This sends files to the remote server with arguments behaving similarly to the ccpp command.

With two arguments, copy local-file to the server as

remote-file.

With more than two arguments, copy all the local files lfile1 ... into the existing remote directory rdir retaining the same basenames. This assumes UNIX directory semantics. A problem arises if you attempt to use zzffppccpp lfile1 rdir, i.e.

the second form of copying but with two arguments, as the com-

mand has no simple way of knowing if rdir corresponds to a directory or a filename. It attempts to resolve this in various ways. First, if the rdir argument is `..' or `....' or ends in a

slash, it is assumed to be a directory. Secondly, if the opera-

tion of copying to a remote file in the first form failed, and the remote server sends back the expected failure code 553 and a reply including the string `IIss aa ddiirreeccttoorryy', then zzffppccpp will retry using the second form. CClloossiinngg tthhee ccoonnnneeccttiioonn zzffcclloossee Close the connection. SSeessssiioonn mmaannaaggeemmeenntt

zzffsseessssiioonn [ -llvvoodd ] [ sessname ]

Allows you to manage multiple FTP sessions at once. By default, connections take place in a session called `ddeeffaauulltt'; by giving the command `zzffsseessssiioonn sessname' you can change to a new or existing session with a name of your choice. The new session

remembers its own connection, as well as associated shell param-

eters, and also the host/user parameters set by zzffppaarraammss. Hence you can have different sessions set up to connect to different hosts, each remembering the appropriate host, user and password.

With no arguments, zzffsseessssiioonn prints the name of the current ses-

sion; with the option -ll it lists all sessions which currently

exist, and with the option -vv it gives a verbose list showing

the host and directory for each session, where the current ses-

sion is marked with an asterisk. With -oo, it will switch to the

most recent previous session.

With -dd, the given session (or else the current one) is removed;

everything to do with it is completely forgotten. If it was the only session, a new session called `ddeeffaauulltt' is created and made current. It is safest not to delete sessions while background commands using zzffttpp are active. zzffttrraannssffeerr sess1::file1 sess2::file2 Transfer files between two sessions; no local copy is made. The

file is read from the session sess1 as file1 and written to ses-

sion sess2 as file file2; file1 and file2 may be relative to the current directories of the session. Either sess1 or sess2 may be omitted (though the colon should be retained if there is a possibility of a colon appearing in the file name) and defaults to the current session; file2 may be omitted or may end with a slash, in which case the basename of file1 will be added. The sessions sess1 and sess2 must be distinct. The operation is performed using pipes, so it is required that the connections still be valid in a subshell, which is not the case under versions of some operating systems, presumably due to a system bug. BBooookkmmaarrkkss The two functions zzffmmaarrkk and zzffggoottoo allow you to `bookmark' the present location (host, user and directory) of the current FTP connection for later use. The file to be used for storing and retrieving bookmarks is

given by the parameter $$ZZFFTTPPBBMMFFIILLEE; if not set when one of the two

functions is called, it will be set to the file ..zzffbbkkmmaarrkkss in the directory where your zsh startup files live (usually ~~). zzffmmaarrkk [[ bookmark ]] If given an argument, mark the current host, user and directory under the name bookmark for later use by zzffggoottoo. If there is no

connection open, use the values for the last connection immedi-

ately before it was closed; it is an error if there was none. Any existing bookmark under the same name will be silently replaced. If not given an argument, list the existing bookmarks and the points to which they refer in the form user@@host::directory; this is the format in which they are stored, and the file may be edited directly.

zzffggoottoo [[ -nn ]] bookmark

Return to the location given by bookmark, as previously set by zzffmmaarrkk. If the location has user `ffttpp' or `aannoonnyymmoouuss', open the connection with zzffaannoonn, so that no password is required. If the

user and host parameters match those stored for the current ses-

sion, if any, those will be used, and again no password is required. Otherwise a password will be prompted for.

With the option -nn, the bookmark is taken to be a nickname

stored by the nnccffttpp program in its bookmark file, which is

assumed to be ~~//..nnccffttpp//bbooookkmmaarrkkss. The function works identi-

cally in other ways. Note that there is no mechanism for adding or modifying nnccffttpp bookmarks from the zftp functions. OOtthheerr ffuunnccttiioonnss Mostly, these functions will not be called directly (apart from zzffiinniitt), but are described here for completeness. You may wish to alter zzffttppcchhppwwdd and zzffttpppprrooggrreessss, in particular.

zzffiinniitt [[ -nn ]]

As described above, this is used to initialize the zftp function

system. The -nn option should be used if the zftp command is

already built into the shell.

zzffaauuttoocchheecckk [[ -ddnn ]]

This function is called to implement automatic reopening behav-

iour, as described in more detail below. The options must

appear in the first argument; -nn prevents the command from

changing to the old directory, while -dd prevents it from setting

the variable ddoocclloossee, which it otherwise does as a flag for automatically closing the connection after a transfer. The host and directory for the last session are stored in the variable

$$zzffllaassttsseessssiioonn, but the internal host/user/password parameters

must also be correctly set. zzffccddmmaattcchh prefix suffix This performs matching for completion of remote directory names. If the remote server is UNIX, it will attempt to persuade the server to list the remote directory with subdirectories marked, which usually works but is not guaranteed. On other hosts it simply calls zzffggeettmmaattcchh and hence completes all files, not just directories. On some systems, directories may not even look like filenames. zzffggeettmmaattcchh prefix suffix This performs matching for completion of remote filenames. It caches files for the current directory (only) in the shell

parameter $$zzffttppffccaacchhee. It is in the form to be called by the

-KK option of ccoommppccttll, but also works when called from a wid-

get-style completion function with prefix and suffix set appro-

priately. zzffrrgglloobb varname Perform remote globbing, as describes in more detail below. varname is the name of a variable containing the pattern to be expanded; if there were any matches, the same variable will be set to the expanded set of filenames on return. zzffrrttiimmee lfile rfile [[ time ]] Set the local file lfile to have the same modification time as the remote file rfile, or the explicit time time in FTP format CCCCYYYYMMMMDDDDhhhhmmmmSSSS for the GMT timezone. Currently this requires ppeerrll version 5 to perform the conversion from GMT to local time. This is unfortunately difficult to do using shell code alone. zzffttppcchhppwwdd This function is called every time a connection is opened, or closed, or the remote directory changes. This version alters

the title bar of an xxtteerrmm-compatible or ssuunn-ccmmdd terminal emula-

tor to reflect the local and remote hostnames and current direc-

tories. It works best when combined with the function cchhppwwdd. In particular, a function of the form cchhppwwdd(()) {{

iiff [[[[ -nn $$ZZFFTTPPUUSSEERR ]]]];; tthheenn

zzffttppcchhppwwdd eellssee

## uussuuaall cchhppwwdd ee..gg ppuutt hhoosstt::ddiirreeccttoorryy iinn ttiittllee bbaarr

ffii }} fits in well. zzffttpppprrooggrreessss This function shows the status of the transfer. It will not

write anything unless the output is going to a terminal; how-

ever, if you transfer files in the background, you should turn off progress reports by hand using `zzssttyyllee ''::zzffttpp::**'' pprrooggrreessss nnoonnee'. Note also that if you alter it, any output must be to standard error, as standard output may be a file being received. The form of the progress meter, or whether it is used at all, can be configured without altering the function, as described in the next section. zzffffccaacchhee

This is used to implement caching of files in the current direc-

tory for each session separately. It is used by zzffggeettmmaattcchh and zzffrrgglloobb. MMIISSCCEELLLLAANNEEOOUUSS FFEEAATTUURREESS CCoonnffiigguurraattiioonn Various styles are available using the standard shell style mechanism, described in zshmodules(1). Briefly, the command `zzssttyyllee ''::zzffttpp::**'' style value ...'. defines the style to have value value; more than one value may be given, although that is not useful in the cases described

here. These values will then be used throughout the zftp function sys-

tem. For more precise control, the first argument, which gives a con-

text in which the style applies, can be modified to include a particu-

lar function, as for example `::zzffttpp::zzffggeett': the style will then have the given value only in the zzffggeett function. Values for the same style in different contexts may be set; the most specific function will be used, where strings are held to be more specific than patterns, and longer patterns and shorter patterns. Note that only the top level function name, as called by the user, is used; calling of lower level functions is transparent to the user. Hence modifications to the title bar in zzffttppcchhppwwdd use the contexts ::zzffttpp::zzffooppeenn, ::zzffttpp::zzffccdd, etc.,

depending where it was called from. The following styles are under-

stood: pprrooggrreessss Controls the way that zzffttpppprrooggrreessss reports on the progress of a transfer. If empty, unset, or `nnoonnee', no progress report is

made; if `bbaarr' a growing bar of inverse video is shown; if `ppeerr-

cceenntt' (or any other string, though this may change in future), the percentage of the file transferred is shown. The bar meter requires that the width of the terminal be available via the

$$CCOOLLUUMMNNSS parameter (normally this is set automatically). If the

size of the file being transferred is not available, bbaarr and ppeerrcceenntt meters will simply show the number of bytes transferred so far. When zzffiinniitt is run, if this style is not defined for the context ::zzffttpp::**, it will be set to `bar'. uuppddaattee Specifies the minimum time interval between updates of the progress meter in seconds. No update is made unless new data has been received, so the actual time interval is limited only

by $$ZZFFTTPPTTIIMMEEOOUUTT.

As described for pprrooggrreessss, zzffiinniitt will force this to default to 1.

rreemmoottee-gglloobb

If set to `1', `yes' or `true', filename generation (globbing) is performed on the remote machine instead of by zsh itself; see below. ttiittlleebbaarr If set to `1', `yes' or `true', zzffttppcchhppwwdd will put the remote

host and remote directory into the titlebar of terminal emula-

tors such as xterm or sun-cmd that allow this.

As described for pprrooggrreessss, zzffiinniitt will force this to default to 1. cchhppwwdd If set to `1' `yes' or `true', zzffttppcchhppwwdd will call the function cchhppwwdd when a connection is closed. This is useful if the remote host details were put into the terminal title bar by zzffttppcchhppwwdd and your usual cchhppwwdd also modifies the title bar. When zzffiinniitt is run, it will determine whether cchhppwwdd exists and if so it will set the default value for the style to 1 if none exists already. Note that there is also an associative array zzffccoonnffiigg which contains values used by the function system. This should not be modified or overwritten. RReemmoottee gglloobbbbiinngg The commands for retrieving files usually perform filename generation (globbing) on their arguments; this can be turned off by passing the

option -GG to each of the commands. Normally this operates by retriev-

ing a complete list of files for the directory in question, then match-

ing these locally against the pattern supplied. This has the advantage that the full range of zsh patterns (respecting the setting of the

option EEXXTTEENNDDEEDDGGLLOOBB) can be used. However, it means that the direc-

tory part of a filename will not be expanded and must be given exactly. If the remote server does not support the UNIX directory semantics, directory handling is problematic and it is recommended that globbing only be used within the current directory. The list of files in the current directory, if retrieved, will be cached, so that subsequent globs in the same directory without an intervening zzffccdd are much faster.

If the rreemmoottee-gglloobb style (see above) is set, globbing is instead per-

formed on the remote host: the server is asked for a list of matching files. This is highly dependent on how the server is implemented,

though typically UNIX servers will provide support for basic glob pat-

terns. This may in some cases be faster, as it avoids retrieving the entire list of directory contents. AAuuttoommaattiicc aanndd tteemmppoorraarryy rreeooppeenniinngg

As described for the zzffooppeenn command, a subsequent zzffooppeenn with no param-

eters will reopen the connection to the last host (this includes con-

nections made with the zzffaannoonn command). Opened in this fashion, the connection starts in the default remote directory and will remain open until explicitly closed.

Automatic re-opening is also available. If a connection is not cur-

rently open and a command requiring a connection is given, the last connection is implicitly reopened. In this case the directory which was current when the connection was closed again becomes the current directory (unless, of course, the command given changes it). Automatic reopening will also take place if the connection was close by the

remote server for whatever reason (e.g. a timeout). It is not avail-

able if the -11 option to zzffooppeenn or zzffaannoonn was used.

Furthermore, if the command issued is a file transfer, the connection will be closed after the transfer is finished, hence providing a

one-shot mode for transfers. This does not apply to directory changing

or listing commands; for example a zzffddiirr may reopen a connection but will leave it open. Also, automatic closure will only ever happen in the same command as automatic opening, i.e a zzffddiirr directly followed by a zzffggeett will never close the connection automatically.

Information about the previous connection is given by the zzffssttaatt func-

tion. So, for example, if that reports: SSeessssiioonn:: ddeeffaauulltt NNoott ccoonnnneecctteedd.. LLaasstt sseessssiioonn:: ffttpp..bbaarr..ccoomm:://ppuubb//tteexxttffiilleess then the command zzffggeett ffiillee..ttxxtt will attempt to reopen a connection to ffttpp..bbaarr..ccoomm, retrieve the file //ppuubb//tteexxttffiilleess//ffiillee..ttxxtt, and immediately close the connection again. On the other hand, zzffccdd .... will open the connection in the directory //ppuubb and leave it open. Note that all the above is local to each session; if you return to a previous session, the connection for that session is the one which will be reopened. CCoommpplleettiioonn

Completion of local and remote files, directories, sessions and book-

marks is supported. The older, ccoommppccttll-style completion is defined

when zzffiinniitt is called; support for the new widget-based completion sys-

tem is provided in the function CCoommpplleettiioonn//ZZsshh//CCoommmmaanndd//zzffttpp, which should be installed with the other functions of the completion system and hence should automatically be available. ZSHCONTRIB(1) ZSHCONTRIB(1)

NAME

zshcontrib - user contributions to zsh

DESCRIPTION

The Zsh source distribution includes a number of items contributed by the user community. These are not inherently a part of the shell, and

some may not be available in every zsh installation. The most signifi-

cant of these are documented here. For documentation on other contrib-

uted items such as shell functions, look for comments in the function source files. UUTTIILLIITTIIEESS

AAcccceessssiinngg OOnn-LLiinnee HHeellpp

The key sequence EESSCC hh is normally bound by ZLE to execute the rruunn-hheellpp

widget (see zshzle(1)). This invokes the rruunn-hheellpp command with the

command word from the current input line as its argument. By default,

rruunn-hheellpp is an alias for the mmaann command, so this often fails when the

command word is a shell builtin or a user-defined function. By

redefining the rruunn-hheellpp alias, one can improve the on-line help pro-

vided by the shell. The hheellppffiilleess utility, found in the UUttiill directory of the distribution, is a Perl program that can be used to process the zsh manual to produce a separate help file for each shell builtin and for many other shell

features as well. The autoloadable rruunn-hheellpp function, found in FFuunncc-

ttiioonnss//MMiisscc, searches for these helpfiles and performs several other tests to produce the most complete help possible for the command. There may already be a directory of help files on your system; look in //uussrr//sshhaarree//zzsshh or //uussrr//llooccaall//sshhaarree//zzsshh and subdirectories below those, or ask your system administrator.

To create your own help files with hheellppffiilleess, choose or create a direc-

tory where the individual command help files will reside. For example, you might choose ~~//zzsshhhheellpp. If you unpacked the zsh distribution in your home directory, you would use the commands: mmkkddiirr ~~//zzsshhhheellpp ccdd ~~//zzsshhhheellpp

mmaann zzsshhaallll || ccoollccrrtt - || \\

ppeerrll ~~//zzsshh-44..22..33//UUttiill//hheellppffiilleess

Next, to use the rruunn-hheellpp function, you need to add lines something

like the following to your ..zzsshhrrcc or equivalent startup file:

uunnaalliiaass rruunn-hheellpp

aauuttoollooaadd rruunn-hheellpp

HHEELLPPDDIIRR==~~//zzsshhhheellpp

The HHEELLPPDDIIRR parameter tells rruunn-hheellpp where to look for the help files.

If your system already has a help file directory installed, set HHEELLPPDDIIRR to the path of that directory instead.

Note that in order for `aauuttoollooaadd rruunn-hheellpp' to work, the rruunn-hheellpp file

must be in one of the directories named in your ffppaatthh array (see zsh-

param(1)). This should already be the case if you have a standard zsh

installation; if it is not, copy FFuunnccttiioonnss//MMiisscc//rruunn-hheellpp to an appro-

priate directory. RReeccoommppiilliinngg FFuunnccttiioonnss If you frequently edit your zsh functions, or periodically update your zsh installation to track the latest developments, you may find that function digests compiled with the zzccoommppiillee builtin are frequently out of date with respect to the function source files. This is not usually a problem, because zsh always looks for the newest file when loading a function, but it may cause slower shell startup and function loading. Also, if a digest file is explicitly used as an element of ffppaatthh, zsh won't check whether any of its source files has changed. The zzrreeccoommppiillee autoloadable function, found in FFuunnccttiioonnss//MMiisscc, can be used to keep function digests up to date.

zzrreeccoommppiillee [ -qqtt ] [ name ... ]

zzrreeccoommppiillee [ -qqtt ] -pp args [ -- args ... ]

This tries to find **..zzwwcc files and automatically re-compile them

if at least one of the original files is newer than the compiled file. This works only if the names stored in the compiled files are full paths or are relative to the directory that contains the ..zzwwcc file. In the first form, each name is the name of a compiled file or a directory containing **..zzwwcc files that should be checked. If no arguments are given, the directories and **..zzwwcc files in ffppaatthh are used.

When -tt is given, no compilation is performed, but a return sta-

tus of zero (true) is set if there are files that need to be

re-compiled and non-zero (false) otherwise. The -qq option qui-

ets the chatty output that describes what zzrreeccoommppiillee is doing.

Without the -tt option, the return status is zero if all files

that needed re-compilation could be compiled and non-zero if

compilation for at least one of the files failed.

If the -pp option is given, the args are interpreted as one or

more sets of arguments for zzccoommppiillee, separated by `--'. For

example:

zzrreeccoommppiillee -pp \\

-RR ~~//..zzsshhrrcc -- \\

-MM ~~//..zzccoommppdduummpp -- \\

~~//zzsshh//ccoommpp..zzwwcc ~~//zzsshh//CCoommpplleettiioonn//**//** This compiles ~~//..zzsshhrrcc into ~~//..zzsshhrrcc..zzwwcc if that doesn't exist or if it is older than ~~//..zzsshhrrcc. The compiled file will be marked for reading instead of mapping. The same is done for ~~//..zzccoommppdduummpp and ~~//..zzccoommppdduummpp..zzwwcc, but this compiled file is

marked for mapping. The last line re-creates the file

~~//zzsshh//ccoommpp..zzwwcc if any of the files matching the given pattern is newer than it.

Without the -pp option, zzrreeccoommppiillee does not create function

digests that do not already exist, nor does it add new functions to the digest.

The following shell loop is an example of a method for creating func-

tion digests for all functions in your ffppaatthh, assuming that you have write permission to the directories:

ffoorr ((((ii==11;; ii <<== $$##ffppaatthh;; ++++ii))));; ddoo

ddiirr==$$ffppaatthh[[ii]]

zzwwcc==$${{ddiirr::tt}}..zzwwcc

iiff [[[[ $$ddiirr ==== ((..||....)) |||| $$ddiirr ==== ((..||....))//** ]]]];; tthheenn

ccoonnttiinnuuee ffii

ffiilleess==(($$ddiirr//**((NN-..))))

iiff [[[[ -ww $$ddiirr::hh &&&& -nn $$ffiilleess ]]]];; tthheenn

ffiilleess==(($${{$${{((MM))ffiilleess%%//**//**}}##//}}))

iiff (( ccdd $$ddiirr::hh &&&&

zzrreeccoommppiillee -pp -UU -zz $$zzwwcc $$ffiilleess ));; tthheenn

ffppaatthh[[ii]]==$$ffppaatthh[[ii]]..zzwwcc

ffii ffii ddoonnee

The -UU and -zz options are appropriate for functions in the default zsh

installation ffppaatthh; you may need to use different options for your per-

sonal function directories. Once the digests have been created and your ffppaatthh modified to refer to

them, you can keep them up to date by running zzrreeccoommppiillee with no argu-

ments. KKeeyybbooaarrdd DDeeffiinniittiioonn The large number of possible combinations of keyboards, workstations, terminals, emulators, and window systems makes it impossible for zsh to

have built-in key bindings for every situation. The zzkkbbdd utility,

found in Functions/Misc, can help you quickly create key bindings for your configuration. Run zzkkbbdd either as an autoloaded function, or as a shell script:

zzsshh -ff ~~//zzsshh-44..22..33//FFuunnccttiioonnss//MMiisscc//zzkkbbdd

When you run zzkkbbdd, it first asks you to enter your terminal type; if the default it offers is correct, just press return. It then asks you to press a number of different keys to determine characteristics of your keyboard and terminal; zzkkbbdd warns you if it finds anything out of the ordinary, such as a Delete key that sends neither ^^HH nor ^^??.

The keystrokes read by zzkkbbdd are recorded as a definition for an asso-

ciative array named kkeeyy, written to a file in the subdirectory ..zzkkbbdd within either your HHOOMMEE or ZZDDOOTTDDIIRR directory. The name of the file is composed from the TTEERRMM, VVEENNDDOORR and OOSSTTYYPPEE parameters, joined by hyphens. You may read this file into your ..zzsshhrrcc or another startup file with

the "source" or "." commands, then reference the kkeeyy parameter in bind-

key commands, like this:

ssoouurrccee $${{ZZDDOOTTDDIIRR::-$$HHOOMMEE}}//..zzkkbbdd//$$TTEERRMM-$$VVEENNDDOORR-$$OOSSTTYYPPEE

[[[[ -nn $${{kkeeyy[[LLeefftt]]}} ]]]] &&&& bbiinnddkkeeyy ""$${{kkeeyy[[LLeefftt]]}}"" bbaacckkwwaarrdd-cchhaarr

[[[[ -nn $${{kkeeyy[[RRiigghhtt]]}} ]]]] &&&& bbiinnddkkeeyy ""$${{kkeeyy[[RRiigghhtt]]}}"" ffoorrwwaarrdd-cchhaarr

## eettcc..

Note that in order for `aauuttoollooaadd zzkkbbdd' to work, the zzkkddbb file must be in one of the directories named in your ffppaatthh array (see zshparam(1)).

This should already be the case if you have a standard zsh installa-

tion; if it is not, copy FFuunnccttiioonnss//MMiisscc//zzkkbbdd to an appropriate direc-

tory. DDuummppiinngg SShheellll SSttaattee Occasionally you may encounter what appears to be a bug in the shell, particularly if you are using a beta version of zsh or a development release. Usually it is sufficient to send a description of the problem to one of the zsh mailing lists (see zsh(1)), but sometimes one of the zsh developers will need to recreate your environment in order to track the problem down.

The script named rreeppoorrtteerr, found in the UUttiill directory of the distribu-

tion, is provided for this purpose. (It is also possible to aauuttoollooaadd rreeppoorrtteerr, but rreeppoorrtteerr is not installed in ffppaatthh by default.) This script outputs a detailed dump of the shell state, in the form of

another script that can be read with `zzsshh -ff' to recreate that state.

To use rreeppoorrtteerr, read the script into your shell with the `..' command and redirect the output into a file:

.. ~~//zzsshh-44..22..33//UUttiill//rreeppoorrtteerr >> zzsshh..rreeppoorrtt

You should check the zzsshh..rreeppoorrtt file for any sensitive information such as passwords and delete them by hand before sending the script to the developers. Also, as the output can be voluminous, it's best to wait for the developers to ask for this information before sending it. You can also use rreeppoorrtteerr to dump only a subset of the shell state. This is sometimes useful for creating startup files for the first time. Most of the output from reporter is far more detailed than usually is necessary for a startup file, but the aalliiaasseess, ooppttiioonnss, and zzssttyylleess states may be useful because they include only changes from the defaults. The bbiinnddiinnggss state may be useful if you have created any of your own keymaps, because rreeppoorrtteerr arranges to dump the keymap creation commands as well as the bindings for every keymap. As is usual with automated tools, if you create a startup file with rreeppoorrtteerr, you should edit the results to remove unnecessary commands. Note that if you're using the new completion system, you should not dump the ffuunnccttiioonnss state to your startup files with rreeppoorrtteerr; use the ccoommppdduummpp function instead (see zshcompsys(1)). rreeppoorrtteerr [ state ... ] Print to standard output the indicated subset of the current shell state. The state arguments may be one or more of: aallll Output everything listed below. aalliiaasseess Output alias definitions. bbiinnddiinnggss Output ZLE key maps and bindings. ccoommpplleettiioonn

Output old-style ccoommppccttll commands. New completion is

covered by ffuunnccttiioonnss and zzssttyylleess. ffuunnccttiioonnss Output autoloads and function definitions. lliimmiittss Output lliimmiitt commands. ooppttiioonnss Output sseettoopptt commands. ssttyylleess Same as zzssttyylleess. vvaarriiaabblleess Output shell parameter assignments, plus eexxppoorrtt commands for any environment variables. zzssttyylleess Output zzssttyyllee commands. If the state is omitted, aallll is assumed.

With the exception of `aallll', every state can be abbreviated by any pre-

fix, even a single letter; thus aa is the same as aalliiaasseess, zz is the same as zzssttyylleess, etc. PPRROOMMPPTT TTHHEEMMEESS IInnssttaallllaattiioonn You should make sure all the functions from the FFuunnccttiioonnss//PPrroommppttss directory of the source distribution are available; they all begin with the string `pprroommpptt' except for the special function`pprroommppttiinniitt'. You also need the `ccoolloorrss' function from FFuunnccttiioonnss//MMiisscc. All of these functions may already have been installed on your system; if not, you will need to find them and copy them. The directory should appear as one of the elements of the ffppaatthh array (this should already be the case if they were installed), and at least the function pprroommppttiinniitt should be autoloaded; it will autoload the rest. Finally, to initialize the use of the system you need to call the pprroommppttiinniitt function. The following code in your ..zzsshhrrcc will arrange for this; assume the functions are stored in the directory ~~//mmyyffnnss:

ffppaatthh==((~~//mmyyffnnss $$ffppaatthh))

aauuttoollooaadd -UU pprroommppttiinniitt

pprroommppttiinniitt Theme Selection Use the pprroommpptt command to select your preferred theme. This command may be added to your ..zzsshhrrcc following the call to pprroommppttiinniitt in order to start zsh with a theme already selected.

pprroommpptt [ -cc | -ll ]

pprroommpptt [ -pp | -hh ] [ theme ... ]

pprroommpptt [ -ss ] theme [ arg ... ]

Set or examine the prompt theme. With no options and a theme argument, the theme with that name is set as the current theme.

The available themes are determined at run time; use the -ll

option to see a list. The special theme `rraannddoomm' selects at random one of the available themes and sets your prompt to that.

In some cases the theme may be modified by one or more argu-

ments, which should be given after the theme name. See the help for each theme for descriptions of these arguments. Options are:

-cc Show the currently selected theme and its parameters, if

any.

-ll List all available prompt themes.

-pp Preview the theme named by theme, or all themes if no

theme is given.

-hh Show help for the theme named by theme, or for the pprroommpptt

function if no theme is given.

-ss Set theme as the current theme and save state.

pprroommppttthemesseettuupp Each available theme has a setup function which is called by the pprroommpptt function to install that theme. This function may define other functions as necessary to maintain the prompt, including functions used to preview the prompt or provide help for its use. You should not normally call a theme's setup function directly. ZZLLEE FFUUNNCCTTIIOONNSS WWiiddggeettss

These functions all implement user-defined ZLE widgets (see zshzle(1))

which can be bound to keystrokes in interactive shells. To use them, your ..zzsshhrrcc should contain lines of the form aauuttoollooaadd function

zzllee -NN function

followed by an appropriate bbiinnddkkeeyy command to associate the function with a key sequence. Suggested bindings are described below.

bash-style word functions

If you are looking for functions to implement moving over and editing words in the manner of bash, where only alphanumeric

characters are considered word characters, you can use the func-

tions described in the next section. The following is suffi-

cient:

aauuttoollooaadd -UU sseelleecctt-wwoorrdd-ssttyyllee

sseelleecctt-wwoorrdd-ssttyyllee bbaasshh

ffoorrwwaarrdd-wwoorrdd-mmaattcchh, bbaacckkwwaarrdd-wwoorrdd-mmaattcchh

kkiillll-wwoorrdd-mmaattcchh, bbaacckkwwaarrdd-kkiillll-wwoorrdd-mmaattcchh

ttrraannssppoossee-wwoorrddss-mmaattcchh, ccaappiittaalliizzee-wwoorrdd-mmaattcchh

uupp-ccaassee-wwoorrdd-mmaattcchh, ddoowwnn-ccaassee-wwoorrdd-mmaattcchh

sseelleecctt-wwoorrdd-ssttyyllee, mmaattcchh-wwoorrddss-bbyy-ssttyyllee

The eight `-mmaattcchh' functions are drop-in replacements for the

builtin widgets without the suffix. By default they behave in a similar way. However, by the use of styles and the function

sseelleecctt-wwoorrdd-ssttyyllee, the way words are matched can be altered.

The simplest way of configuring the functions is to use

sseelleecctt-wwoorrdd-ssttyyllee, which can either be called as a normal func-

tion with the appropriate argument, or invoked as a user-defined

widget that will prompt for the first character of the word style to be used. The first time it is invoked, the eight

-mmaattcchh functions will automatically replace the builtin ver-

sions, so they do not need to be loaded explicitly.

The word styles available are as follows. Only the first char-

acter is examined. bbaasshh Word characters are alphanumeric characters only. nnoorrmmaall As in normal shell operation: word characters are alphanumeric characters plus any characters present in

the string given by the parameter $$WWOORRDDCCHHAARRSS.

sshheellll Words are complete shell command arguments, possibly including complete quoted strings, or any tokens special to the shell. wwhhiitteessppaaccee Words are any set of characters delimited by whitespace. ddeeffaauulltt Restore the default settings; this is usually the same as `nnoorrmmaall'. More control can be obtained using the zzssttyyllee command, as

described in zshmodules(1). Each style is looked up in the con-

text ::zzllee::widget where widget is the name of the user-defined

widget, not the name of the function implementing it, so in the

case of the definitions supplied by sseelleecctt-wwoorrdd-ssttyyllee the appro-

priate contexts are ::zzllee::ffoorrwwaarrdd-wwoorrdd, and so on. The function

sseelleecctt-wwoorrdd-ssttyyllee itself always defines styles for the context

`::zzllee::**' which can be overridden by more specific (longer) pat-

terns as well as explicit contexts.

The style wwoorrdd-ssttyyllee specifies the rules to use. This may have

the following values. nnoorrmmaall Use the standard shell rules, i.e. alphanumerics and

$$WWOORRDDCCHHAARRSS, unless overridden by the styles wwoorrdd-cchhaarrss or

wwoorrdd-ccllaassss.

ssppeecciiffiieedd Similar to nnoorrmmaall, but only the specified characters, and not also alphanumerics, are considered word characters. uunnssppeecciiffiieedd The negation of specified. The given characters are those which will not be considered part of a word.

sshheellll Words are obtained by using the syntactic rules for gen-

erating shell command arguments. In addition, special tokens which are never command arguments such as `(())' are also treated as words. wwhhiitteessppaaccee

Words are whitespace-delimited strings of characters.

The first three of those styles usually use $$WWOORRDDCCHHAARRSS, but the

value in the parameter can be overridden by the style

wwoorrdd-cchhaarrss, which works in exactly the same way as $$WWOORRDDCCHHAARRSS.

In addition, the style wwoorrdd-ccllaassss uses character class syntax to

group characters and takes precedence over wwoorrdd-cchhaarrss if both

are set. The wwoorrdd-ccllaassss style does not include the surrounding

brackets of the character class; for example, `-::[[::aallnnuumm::]]' is a

valid wwoorrdd-ccllaassss to include all alphanumerics plus the charac-

ters `-' and `::'. Be careful including `]]', `^^' and `-' as

these are special inside character classes.

The final style is sskkiipp-cchhaarrss. This is mostly useful for ttrraannss-

ppoossee-wwoorrddss and similar functions. If set, it gives a count of

characters starting at the cursor position which will not be considered part of the word and are treated as space, regardless of what they actually are. For example, if

zzssttyyllee ''::zzllee::ttrraannssppoossee-wwoorrddss'' sskkiipp-cchhaarrss 11

has been set, and ttrraannssppoossee-wwoorrddss-mmaattcchh is called with the cur-

sor on the X of ffooooXbbaarr, where X can be any character, then the resulting expression is bbaarrXffoooo. Here are some examples of use of the styles, actually taken from

the simplified interface in sseelleecctt-wwoorrdd-ssttyyllee:

zzssttyyllee ''::zzllee::**'' wwoorrdd-ssttyyllee ssttaannddaarrdd

zzssttyyllee ''::zzllee::**'' wwoorrdd-cchhaarrss ''''

Implements bash-style word handling for all widgets, i.e. only

alphanumerics are word characters; equivalent to setting the parameter WWOORRDDCCHHAARRSS empty for the given context.

ssttyyllee ''::zzllee::**kkiillll**'' wwoorrdd-ssttyyllee ssppaaccee

Uses space-delimited words for widgets with the word `kill' in

the name. Neither of the styles wwoorrdd-cchhaarrss nor wwoorrdd-ccllaassss is

used in this case. The word matching and all the handling of zzssttyyllee settings is

actually implemented by the function mmaattcchh-wwoorrddss-bbyy-ssttyyllee. This

can be used to create new user-defined widgets. The calling

function should set the local parameter ccuurrccoonntteexxtt to ::zzllee::wid-

get, create the local parameter mmaattcchheeddwwoorrddss and call

mmaattcchh-wwoorrddss-bbyy-ssttyyllee with no arguments. On return,

mmaattcchheeddwwoorrddss will be set to an array with the elements: (1) the start of the line (2) the word before the cursor (3) any

non-word characters between that word and the cursor (4) any

non-word character at the cursor position plus any remaining

non-word characters before the next word, including all charac-

ters specified by the sskkiipp-cchhaarrss style, (5) the word at or fol-

lowing the cursor (6) any non-word characters following that

word (7) the remainder of the line. Any of the elements may be an empty string; the calling function should test for this to decide whether it can perform its function. It is possible to pass options with arguments to

mmaattcchh-wwoorrddss-bbyy-ssttyyllee to override the use of styles. The options

are:

-ww word-style

-ss skip-chars

-cc word-class

-CC word-chars

For example, mmaattcchh-wwoorrddss-bbyy-ssttyyllee -ww sshheellll -cc 00 may be used to

extract the command argument around the cursor.

ddeelleettee-wwhhoollee-wwoorrdd-mmaattcchh

This is another function which works like the -mmaattcchh functions

described immediately above, i.e. using styles to decide the word boundaries. However, it is not a replacement for any existing function. The basic behaviour is to delete the word around the cursor. There is no numeric prefix handling; only the single word around the cursor is considered. If the widget contains the string kkiillll, the removed text will be placed in the cutbuffer for future yanking. This can be obtained by defining

kkiillll-wwhhoollee-wwoorrdd-mmaattcchh as follows:

zzllee -NN kkiillll-wwhhoollee-wwoorrdd-mmaattcchh ddeelleettee-wwhhoollee-wwoorrdd-mmaattcchh

and then binding the widget kkiillll-wwhhoollee-wwoorrdd-mmaattcchh.

ccooppyy-eeaarrlliieerr-wwoorrdd

This widget works like a combination of iinnsseerrtt-llaasstt-wwoorrdd and

ccooppyy-pprreevv-sshheellll-wwoorrdd. Repeated invocations of the widget

retrieve earlier words on the relevant history line. With a numeric argument N, insert the Nth word from the history line; N may be negative to count from the end of the line.

If iinnsseerrtt-llaasstt-wwoorrdd has been used to retrieve the last word on a

previous history line, repeated invocations will replace that word with earlier words from the same line. Otherwise, the widget applies to words on the line currently being edited. The wwiiddggeett style can be set to the name of another widget that should be called to retrieve words. This

widget must accept the same three arguments as iinnsseerrtt-llaasstt-wwoorrdd.

ccyyccllee-ccoommpplleettiioonn-ppoossiittiioonnss

After inserting an unambiguous string into the command line, the new function based completion system may know about multiple places in this string where characters are missing or differ from at least one of the possible matches. It will then place

the cursor on the position it considers to be the most interest-

ing one, i.e. the one where one can disambiguate between as many matches as possible with as little typing as possible. This widget allows the cursor to be easily moved to the other interesting spots. It can be invoked repeatedly to cycle between all positions reported by the completion system.

eeddiitt-ccoommmmaanndd-lliinnee

Edit the command line using your visual editor, as in kksshh.

bbiinnddkkeeyy -MM vviiccmmdd vv eeddiitt-ccoommmmaanndd-lliinnee

hhiissttoorryy-sseeaarrcchh-eenndd

This function implements the widgets hhiissttoorryy-bbeeggiinn-

nniinngg-sseeaarrcchh-bbaacckkwwaarrdd-eenndd and hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-ffoorr-

wwaarrdd-eenndd. These commands work by first calling the correspond-

ing builtin widget (see `History Control' in zshzle(1)) and then moving the cursor to the end of the line. The original cursor position is remembered and restored before calling the builtin widget a second time, so that the same search is repeated to look farther through the history. Although you aauuttoollooaadd only one function, the commands to use it are slightly different because it implements two widgets.

zzllee -NN hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-bbaacckkwwaarrdd-eenndd \\

hhiissttoorryy-sseeaarrcchh-eenndd

zzllee -NN hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-ffoorrwwaarrdd-eenndd \\

hhiissttoorryy-sseeaarrcchh-eenndd

bbiinnddkkeeyy ''\\ee^^PP'' hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-bbaacckkwwaarrdd-eenndd

bbiinnddkkeeyy ''\\ee^^NN'' hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-ffoorrwwaarrdd-eenndd

hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh

The function hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh implements widgets which

prompt for a pattern with which to search the history backwards or forwards. The pattern is in the usual zsh format, however the first character may be ^^ to anchor the search to the start

of the line, and the last character may be $$ to anchor the

search to the end of the line. If the search was not anchored to the end of the line the cursor is positioned just after the pattern found. The commands to create bindable widgets are similar to those in the example immediately above:

aauuttoollooaadd -UU hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh

zzllee -NN hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh-bbaacckkwwaarrdd hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh

zzllee -NN hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh-ffoorrwwaarrdd hhiissttoorryy-ppaatttteerrnn-sseeaarrcchh

uupp-lliinnee-oorr-bbeeggiinnnniinngg-sseeaarrcchh, ddoowwnn-lliinnee-oorr-bbeeggiinnnniinngg-sseeaarrcchh

These widgets are similar to the builtin functions

uupp-lliinnee-oorr-sseeaarrcchh and ddoowwnn-lliinnee-oorr-sseeaarrcchh: if in a multiline

buffer they move up or down within the buffer, otherwise they search for a history line matching the start of the current line. In this case, however, they search for a line which matches the current line up to the current cursor position, in

the manner of hhiissttoorryy-bbeeggiinnnniinngg-sseeaarrcchh-bbaacckkwwaarrdd and -ffoorrwwaarrdd,

rather than the first word on the line. iinnccaarrgg Typing the keystrokes for this widget with the cursor placed on

or to the left of an integer causes that integer to be incre-

mented by one. With a numeric prefix argument, the number is incremented by the amount of the argument (decremented if the prefix argument is negative). The shell parameter iinnccaarrgg may be set to change the default increment something other than one. bbiinnddkkeeyy ''^^XX++'' iinnccaarrgg

iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd

This allows incremental completion of a word. After starting this command, a list of completion choices can be shown after every character you type, which you can delete with ^^HH or DDEELL. Pressing return accepts the completion so far and returns you to normal editing (that is, the command line is not immediately executed). You can hit TTAABB to do normal completion, ^^GG to abort back to the state when you started, and ^^DD to list the matches. This works only with the new function based completion system.

bbiinnddkkeeyy ''^^XXii'' iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd

iinnsseerrtt-ffiilleess

This function allows you type a file pattern, and see the results of the expansion at each step. When you hit return, all expansions are inserted into the command line.

bbiinnddkkeeyy ''^^XXff'' iinnsseerrtt-ffiilleess

nnaarrrrooww-ttoo-rreeggiioonn [[ -pp pre ]] [[ -PP post ]]

[[ -SS statepm || -RR statepm ]] [[ -nn ]] [[ start end ]])

nnaarrrrooww-ttoo-rreeggiioonn-iinnvviissiibbllee

Narrow the editable portion of the buffer to the region between the cursor and the mark, which may be in either order. The region may not be empty.

nnaarrrrooww-ttoo-rreeggiioonn may be used as a widget or called as a function

from a user-defined widget; by default, the text outside the

editable area remains visible. A rreeccuurrssiivvee-eeddiitt is performed

and the original widening status is then restored. Various

options and arguments are available when it is called as a func-

tion.

The options -pp pretext and -PP posttext may be used to replace

the text before and after the display for the duration of the function; either or both may be an empty string.

If the option -nn is also given, pretext or posttext will only be

inserted if there is text before or after the region respec-

tively which will be made invisible. Two numeric arguments may be given which will be used instead of the cursor and mark positions.

The option -SS statepm is used to narrow according to the other

options while saving the original state in the parameter with

name statepm, while the option -RR statepm is used to restore the

state from the parameter; note in both cases the name of the parameter is required. In the second case, other options and

arguments are irrelevant. When this method is used, no rreeccuurr-

ssiivvee-eeddiitt is performed; the calling widget should call this

function with the option -SS, perform its own editing on the com-

mand line or pass control to the user via `zzllee rreeccuurrssiivvee-eeddiitt',

then call this function with the option -RR. The argument

statepm must be a suitable name for an ordinary parameter, except that parameters beginning with the prefix nnttrr are

reserved for use within nnaarrrrooww-ttoo-rreeggiioonn. Typically the parame-

ter will be local to the calling function.

nnaarrrrooww-ttoo-rreeggiioonn-iinnvviissiibbllee is a simple widget which calls nnaarr-

rrooww-ttoo-rreeggiioonn with arguments which replace any text outside the

region with `......'. The display is restored (and the widget returns) upon any zle command which would usually cause the line to be accepted or aborted. Hence an additional such command is required to accept or abort the current line. The return status of both widgets is zero if the line was

accepted, else non-zero.

Here is a trivial example of a widget using this feature. llooccaall ssttaattee

nnaarrrrooww-ttoo-rreeggiioonn -pp $$''EEddiittiinngg rreessttrriicctteedd rreeggiioonn\\nn'' \\

-PP '''' -SS ssttaattee

zzllee rreeccuurrssiivvee-eeddiitt

nnaarrrrooww-ttoo-rreeggiioonn -RR ssttaattee

pprreeddiicctt-oonn

This set of functions implements predictive typing using history

search. After pprreeddiicctt-oonn, typing characters causes the editor

to look backward in the history for the first line beginning

with what you have typed so far. After pprreeddiicctt-ooffff, editing

returns to normal for the line found. In fact, you often don't

even need to use pprreeddiicctt-ooffff, because if the line doesn't match

something in the history, adding a key performs standard comple-

tion, and then inserts itself if no completions were found. However, editing in the middle of a line is liable to confuse prediction; see the ttooggggllee style below. With the function based completion system (which is needed for this), you should be able to type TTAABB at almost any point to

advance the cursor to the next ``interesting'' character posi-

tion (usually the end of the current word, but sometimes some-

where in the middle of the word). And of course as soon as the

entire line is what you want, you can accept with return, with-

out needing to move the cursor to the end first.

The first time pprreeddiicctt-oonn is used, it creates several additional

widget functions:

ddeelleettee-bbaacckkwwaarrdd-aanndd-pprreeddiicctt

Replaces the bbaacckkwwaarrdd-ddeelleettee-cchhaarr widget. You do not

need to bind this yourself.

iinnsseerrtt-aanndd-pprreeddiicctt

Implements predictive typing by replacing the sseellff-iinnsseerrtt

widget. You do not need to bind this yourself.

pprreeddiicctt-ooffff

Turns off predictive typing.

Although you aauuttoollooaadd only the pprreeddiicctt-oonn function, it is neces-

sary to create a keybinding for pprreeddiicctt-ooffff as well.

zzllee -NN pprreeddiicctt-oonn

zzllee -NN pprreeddiicctt-ooffff

bbiinnddkkeeyy ''^^XX^^ZZ'' pprreeddiicctt-oonn

bbiinnddkkeeyy ''^^ZZ'' pprreeddiicctt-ooffff

rreeaadd-ffrroomm-mmiinniibbuuffffeerr

This is most useful when called as a function from inside a wid-

get, but will work correctly as a widget in its own right. It prompts for a value below the current command line; a value may be input using all of the standard zle operations (and not merely the restricted set available when executing, for example,

eexxeeccuuttee-nnaammeedd-ccmmdd). The value is then returned to the calling

function in the parameter $$RREEPPLLYY and the editing buffer restored

to its previous state. If the read was aborted by a keyboard

break (typically ^^GG), the function returns status 1 and $$RREEPPLLYY

is not set. If one argument is supplied to the function it is taken as a prompt, otherwise `?? ' is used. If two arguments are supplied,

they are the prompt and the initial value of $$LLBBUUFFFFEERR, and if a

third argument is given it is the initial value of $$RRBBUUFFFFEERR.

This provides a default value and starting cursor placement.

Upon return the entire buffer is the value of $$RREEPPLLYY.

One option is available: `-kk num' specifies that num characters

are to be read instead of a whole line. The line editor is not invoked recursively in this case, so depending on the terminal settings the input may not be visible, and only the input keys

are placed in $$RREEPPLLYY, not the entire buffer. Note that unlike

the rreeaadd builtin num must be given; there is no default. The name is a slight misnomer, as in fact the shell's own

minibuffer is not used. Hence it is still possible to call eexxee-

ccuutteedd-nnaammeedd-ccmmdd and similar functions while reading a value.

rreeppllaaccee-ssttrriinngg, rreeppllaaccee-ppaatttteerrnn

The function rreeppllaaccee-ssttrriinngg implements two widgets. If defined

under the same name as the function, it prompts for two strings;

the first (source) string will be replaced by the second every-

where it occurs in the line editing buffer. If the widget name contains the word `ppaatttteerrnn', for example by

defining the widget using the command `zzllee -NN rreeppllaaccee-ppaatttteerrnn

rreeppllaaccee-ssttrriinngg', then the replacement is done by pattern match-

ing. All zsh extended globbing patterns can be used in the source string; note that unlike filename generation the pattern does not need to match an entire word, nor do glob qualifiers

have any effect. In addition, the replacement string can con-

tain parameter or command substitutions. Furthermore, a `&&' in the replacement string will be replaced with the matched source string, and a backquoted digit `\\N' will be replaced by the Nth parenthesised expression matched. The form `\\{{N}}' may be used to protect the digit from following digits. For example, starting from the line: pprriinntt TThhiiss lliinnee ccoonnttaaiinnss ffaann aanndd ffoonndd

and invoking rreeppllaaccee-ppaatttteerrnn with the source string `ff((??))nn' and

the replacment string `cc\\11rr' produces the not very useful line: pprriinntt TThhiiss lliinnee ccoonnttaaiinnss ccaarr aanndd ccoorrdd The range of the replacement string can be limited by using the

nnaarrrrooww-ttoo-rreeggiioonn-iinnvviissiibbllee widget. One limitation of the cur-

rent version is that uunnddoo will cycle through changes to the replacement and source strings before undoing the replacement itself.

ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd

This function may replace the iinnsseerrtt-llaasstt-wwoorrdd widget, like so:

zzllee -NN iinnsseerrtt-llaasstt-wwoorrdd ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd

With a numeric prefix, or when passed command line arguments in

a call from another widget, it behaves like iinnsseerrtt-llaasstt-wwoorrdd,

except that words in comments are ignored when IINNTTEERRAACCTTIIVVEECCOOMM-

MMEENNTTSS is set. Otherwise, the rightmost ``interesting'' word from the previous command is found and inserted. The default definition of

``interesting'' is that the word contains at least one alpha-

betic character, slash, or backslash. This definition may be overridden by use of the mmaattcchh style. The context used to look up the style is the widget name, so usually the context is

::iinnsseerrtt-llaasstt-wwoorrdd. However, you can bind this function to dif-

ferent widgets to use different patterns:

zzllee -NN iinnsseerrtt-llaasstt-aassssiiggnnmmeenntt ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd

zzssttyyllee ::iinnsseerrtt-llaasstt-aassssiiggnnmmeenntt mmaattcchh ''[[[[::aallpphhaa::]]]][[]][[[[::aallnnuumm::]]]]##==**''

bbiinnddkkeeyy ''\\ee=='' iinnsseerrtt-llaasstt-aassssiiggnnmmeenntt

SSttyylleess The behavior of several of the above widgets can be controlled by the use of the zzssttyyllee mechanism. In particular, widgets that interact with the completion system pass along their context to any completions that they invoke.

bbrreeaakk-kkeeyyss

This style is used by the iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd widget. Its

value should be a pattern, and all keys matching this pattern will cause the widget to stop incremental completion without the key having any further effect. Like all styles used directly by

iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd, this style is looked up using the

context `::iinnccrreemmeennttaall'. ccoommpplleetteerr

The iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd and iinnsseerrtt-aanndd-pprreeddiicctt widgets set

up their top-level context name before calling completion. This

allows one to define different sets of completer functions for normal completion and for these widgets. For example, to use completion, approximation and correction for normal completion, completion and correction for incremental completion and only completion for prediction one could use: zzssttyyllee ''::ccoommpplleettiioonn::**'' ccoommpplleetteerr \\ ccoommpplleettee ccoorrrreecctt aapppprrooxxiimmaattee zzssttyyllee ''::ccoommpplleettiioonn::iinnccrreemmeennttaall::**'' ccoommpplleetteerr \\ ccoommpplleettee ccoorrrreecctt zzssttyyllee ''::ccoommpplleettiioonn::pprreeddiicctt::**'' ccoommpplleetteerr \\ ccoommpplleettee It is a good idea to restrict the completers used in prediction, because they may be automatically invoked as you type. The lliisstt and mmeennuu completers should never be used with prediction. The aapppprrooxxiimmaattee, ccoorrrreecctt, eexxppaanndd, and mmaattcchh completers may be used, but be aware that they may change characters anywhere in the word behind the cursor, so you need to watch carefully that the result is what you intended.

ccuurrssoorr The iinnsseerrtt-aanndd-pprreeddiicctt widget uses this style, in the context

`::pprreeddiicctt', to decide where to place the cursor after completion has been tried. Values are: ccoommpplleettee The cursor is left where it was when completion finished, but only if it is after a character equal to the one just inserted by the user. If it is after another character, this value is the same as `kkeeyy'.

kkeeyy The cursor is left after the nth occurrence of the char-

acter just inserted, where n is the number of times that character appeared in the word before completion was attempted. In short, this has the effect of leaving the

cursor after the character just typed even if the comple-

tion code found out that no other characters need to be inserted at that position. Any other value for this style unconditionally leaves the cursor at the position where the completion code left it.

lliisstt When using the iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd widget, this style says

if the matches should be listed on every key press (if they fit

on the screen). Use the context prefix `::ccoommpplleettiioonn::iinnccrreemmeenn-

ttaall'.

The iinnsseerrtt-aanndd-pprreeddiicctt widget uses this style to decide if the

completion should be shown even if there is only one possible completion. This is done if the value of this style is the string aallwwaayyss. In this case the context is `::pprreeddiicctt' (not `::ccoommpplleettiioonn::pprreeddiicctt').

mmaattcchh This style is used by ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd to provide a pat-

tern (using full EEXXTTEENNDDEEDDGGLLOOBB syntax) that matches an interest-

ing word. The context is the name of the widget to which

ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd is bound (see above). The default behav-

ior of ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd is equivalent to:

zzssttyyllee ::iinnsseerrtt-llaasstt-wwoorrdd mmaattcchh ''**[[[[::aallpphhaa::]]//\\\\]]**''

However, you might want to include words that contain spaces:

zzssttyyllee ::iinnsseerrtt-llaasstt-wwoorrdd mmaattcchh ''**[[[[::aallpphhaa::]][[::ssppaaccee::]]//\\\\]]**''

Or include numbers as long as the word is at least two charac-

ters long:

zzssttyyllee ::iinnsseerrtt-llaasstt-wwoorrdd mmaattcchh ''**(([[[[::ddiiggiitt::]]]]??||[[[[::aallpphhaa::]]//\\\\]]))**''

The above example causes redirections like "2>" to be included.

pprroommpptt The iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd widget shows the value of this

style in the status line during incremental completion. The string value may contain any of the following substrings in the manner of the PPSS11 and other prompt parameters:

%%cc Replaced by the name of the completer function that gen-

erated the matches (without the leading underscore).

%%ll When the lliisstt style is set, replaced by `......' if the list

of matches is too long to fit on the screen and with an empty string otherwise. If the lliisstt style is `false' or

not set, `%%ll' is always removed.

%%nn Replaced by the number of matches generated.

%%ss Replaced by `-nnoo mmaattcchh-', `-nnoo pprreeffiixx-', or an empty

string if there is no completion matching the word on the line, if the matches have no common prefix different from

the word on the line, or if there is such a common pre-

fix, respectively.

%%uu Replaced by the unambiguous part of all matches, if there

is any, and if it is different from the word on the line.

Like `bbrreeaakk-kkeeyyss', this uses the `::iinnccrreemmeennttaall' context.

ssttoopp-kkeeyyss

This style is used by the iinnccrreemmeennttaall-ccoommpplleettee-wwoorrdd widget. Its

value is treated similarly to the one for the bbrreeaakk-kkeeyyss style

(and uses the same context: `::iinnccrreemmeennttaall'). However, in this case all keys matching the pattern given as its value will stop

incremental completion and will then execute their usual func-

tion.

ttooggggllee This boolean style is used by pprreeddiicctt-oonn and its related widgets

in the context `::pprreeddiicctt'. If set to one of the standard `true'

values, predictive typing is automatically toggled off in situa-

tions where it is unlikely to be useful, such as when editing a

multi-line buffer or after moving into the middle of a line and

then deleting a character. The default is to leave prediction

turned on until an explicit call to pprreeddiicctt-ooffff.

vveerrbboossee

This boolean style is used by pprreeddiicctt-oonn and its related widgets

in the context `::pprreeddiicctt'. If set to one of the standard `true' values, these widgets display a message below the prompt when

the predictive state is toggled. This is most useful in combi-

nation with the ttooggggllee style. The default does not display these messages. wwiiddggeett This style is similar to the ccoommmmaanndd style: For widget functions that use zzllee to call other widgets, this style can sometimes be used to override the widget which is called. The context for this style is the name of the calling widget (not the name of

the calling function, because one function may be bound to mul-

tiple widget names).

zzssttyyllee ::ccooppyy-eeaarrlliieerr-wwoorrdd wwiiddggeett ssmmaarrtt-iinnsseerrtt-llaasstt-wwoorrdd

Check the documentation for the calling widget or function to determine whether the wwiiddggeett style is used. MMIIMMEE FFUUNNCCTTIIOONNSS Three functions are available to provide handling of files recognised by extension, for example to dispatch a file tteexxtt..ppss when executed as a command to an appropriate viewer.

zzsshh-mmiimmee-sseettuupp [[-ffllvv]]

zzsshh-mmiimmee-hhaannddlleerr

These two functions use the files ~~//..mmiimmee..ttyyppeess and //eettcc//mmiimmee..ttyyppeess, which associate types and extensions, as well as ~~//..mmaaiillccaapp and //eettcc//mmaaiillccaapp files, which associate types and

the programs that handle them. These are provided on many sys-

tems with the Multimedia Internet Mail Extensions.

To enable the system, the function zzsshh-mmiimmee-sseettuupp should be

autoloaded and run. This allows files with extensions to be treated as executable; such files be completed by the function

completion system. The function zzsshh-mmiimmee-hhaannddlleerr should not

need to be called by the user.

The system works by setting up suffix aliases with `aalliiaass -ss'.

Suffix aliases already installed by the user will not be over-

written.

Repeated calls to zzsshh-mmiimmee-sseettuupp do not override the existing

mapping between suffixes and executable files unless the option

-ff is given. Note, however, that this does not override exist-

ing suffix aliases assigned to handlers other than zzsshh-mmiimmee-hhaann-

ddlleerr. Calling zzsshh-mmiimmee-sseettuupp with the option -ll lists the

existing mapping without altering it. Calling zzsshh-mmiimmee-sseettuupp

with the option -vv causes verbose output to be shown during the

setup operation.

The system respects the mmaaiillccaapp flags nneeeeddsstteerrmmiinnaall and ccooppii-

oouussoouuttppuutt, see mailcap(4). The functions use the following styles, which are defined with the zzssttyyllee builtin command (see zshmodules(1)). They should be

defined before zzsshh-mmiimmee-sseettuupp is run. The contexts used all

start with ::mmiimmee::, with additional components in some cases. It is recommended that a trailing ** (suitably quoted) be appended to style patterns in case the system is extended in future. Some examples are given below.

mime-types

A list of files in the format of ~~//..mmiimmee..ttyyppeess and //eettcc//mmiimmee..ttyyppeess to be read during setup, replacing the

default list which consists of those two files. The con-

text is ::mmiimmee::. A ++ in the list will be replaced by the default files. mailcap A list of files in the format of ~~//..mmaaiillccaapp and //eettcc//mmaaiillccaapp to be read during setup, replacing the

default list which consists of those two files. The con-

text is ::mmiimmee::. A ++ in the list will be replaced by the default files. handler Specifies a handler for a suffix; the suffix is given by

the context as ::mmiimmee::..suffix::, and the format of the han-

dler is exactly that in mmaaiillccaapp. Note in particular the `..' and trailing colon to distinguish this use of the context. This overrides any handler specified by the mmaaiillccaapp files. If the handler requires a terminal, the

ffllaaggss style should be set to include the word nneeeeddsstteerrmmii-

nnaall, or if the output is to be displayed through a pager (but not if the handler is itself a pager), it should include ccooppiioouussoouuttppuutt. flags Defines flags to go with a handler; the context is as for the hhaannddlleerr style, and the format is as for the flags in mmaaiillccaapp.

pager If set, will be used instead of $$PPAAGGEERR or mmoorree to handle

suffixes where the ccooppiioouussoouuttppuutt flag is set. The con-

text is as for hhaannddlleerr, i.e. ::mmiimmee::..suffix:: for handling a file with the given suffix. Examples: zzssttyyllee ''::mmiimmee::**'' mmaaiillccaapp ~~//..mmaaiillccaapp //uussrr//llooccaall//eettcc//mmaaiillccaapp

zzssttyyllee ''::mmiimmee::..ttxxtt'' hhaannddlleerr lleessss %%ss

zzssttyyllee ''::mmiimmee::..ttxxtt'' ffllaaggss nneeeeddsstteerrmmiinnaall

When zzsshh-mmiimmee-sseettuupp is subsequently run, it will look for mmaaiill-

ccaapp entries in the two files given. Files of suffix ..ttxxtt will be handled by running `lleessss file.txt'. The flag nneeeeddsstteerrmmiinnaall

is set to show that this program must run attached to a termi-

nal.

As there are several steps to dispatching a command, the follow-

ing should be checked if attempting to execute a file by exten-

sion ..ext does not have the expected effect. starteit() eit()(

The command `aalliiaass -ss ext' should show `ppss==zzsshh-mmiimmee-hhaannddlleerr'.

If it shows something else, another suffix alias was already

installed and was not overwritten. If it shows nothing, no han-

dler was installed: this is most likely because no handler was found in the ..mmiimmee..ttyyppeess and mmaaiillccaapp combination for ..eexxtt files. In that case, appropriate handling should be added to ~~//..mmiimmee..ttyyppeess and mmaaiillccaapp. ) eit()( If the extension is handled

by zzsshh-mmiimmee-hhaannddlleerr but the file is not opened correctly, either

the handler defined for the type is incorrect, or the flags

associated with it are in appropriate. Running zzsshh-mmiimmee-sseettuupp

-ll will show the handler and, if there are any, the flags. A %%ss

in the handler is replaced by the file (suitably quoted if nec-

essary). Check that the handler program listed lists and can be run in the way shown. Also check that the flags nneeeeddsstteerrmmiinnaall or ccooppiioouussoouuttppuutt are set if the handler needs to be run under a terminal; the second flag is used if the output should be sent to a pager. An example of a suitable mmaaiillccaapp entry for such a program is:

tteexxtt//hhttmmll;; //uussrr//bbiinn//llyynnxx ''%%ss'';; nneeeeddsstteerrmmiinnaall

) endeit()

ppiicckk-wweebb-bbrroowwsseerr

This function is separate from the two MIME functions described above and can be assigned directly to a suffix:

aauuttoollooaadd -UU ppiicckk-wweebb-bbrroowwsseerr

aalliiaass -ss hhttmmll==ppiicckk-wweebb-bbrroowwsseerr

It is provided as an intelligent front end to dispatch a web browser. It will check if an X Windows display is available, and if so if there is already a browser running which can accept a remote connection. In that case, the file will be displayed in that browser; you should check explicitly if it has appeared in the running browser's window. Otherwise, it will start a new browser according to a builtin set of preferences.

Alternatively, ppiicckk-wweebb-bbrroowwsseerr can be run as a zsh script.

Two styles are available to customize the choice of browsers:

xx-bbrroowwsseerrss when running under the X Windows System, and

ttttyy-bbrroowwsseerrss otherwise. These are arrays in decreasing order of

preference consiting of the command name under which to start the browser. They are looked up in the context ::mmiimmee:: (which may be extended in future, so appending `**' is recommended). For example,

zzssttyyllee ''::mmiimmee::**'' xx-bbrroowwsseerrss ooppeerraa kkoonnqquueerroorr nneettssccaappee

specifies that ppiicckk-wweebb-bbrroowwsseerr should first look for a runing

instance of Opera, Konqueror or Netscape, in that order, and if it fails to find any should attempt to start Opera. OOTTHHEERR FFUUNNCCTTIIOONNSS There are a large number of helpful functions in the FFuunnccttiioonnss//MMiisscc directory of the zsh distribution. Most are very simple and do not require documentation here, but a few are worthy of special mention. DDeessccrriippttiioonnss ccoolloorrss This function initializes several associative arrays to map

color names to (and from) the ANSI standard eight-color terminal

codes. These are used by the prompt theme system (see above). You seldom should need to run ccoolloorrss more than once. The eight base colors are: black, red, green, yellow, blue,

magenta, cyan, and white. Each of these has codes for fore-

ground and background. In addition there are eight intensity attributes: bold, faint, standout, underline, blink, reverse, and conceal. Finally, there are six codes used to negate attributes: none (reset all attributes to the defaults), normal

(neither bold nor faint), no-standout, no-underline, no-blink,

and no-reverse.

Some terminals do not support all combinations of colors and intensities. The associative arrays are: color

colour Map all the color names to their integer codes, and inte-

ger codes to the color names. The eight base names map to the foreground color codes, as do names prefixed with

`ffgg-', such as `ffgg-rreedd'. Names prefixed with `bbgg-', such

as `bbgg-bblluuee', refer to the background codes. The reverse

mapping from code to color yields base name for fore-

ground codes and the bbgg- form for backgrounds.

Although it is a misnomer to call them `colors', these arrays also map the other fourteen attributes from names to codes and codes to names. fg fgbold fgnobold Map the eight basic color names to ANSI terminal escape sequences that set the corresponding foreground text properties. The ffgg sequences change the color without changing the eight intensity attributes. bg bgbold bgnobold Map the eight basic color names to ANSI terminal escape

sequences that set the corresponding background proper-

ties. The bbgg sequences change the color without changing the eight intensity attributes. In addition, the scalar parameters rreesseettccoolloorr and bboollddccoolloorr are set to the ANSI terminal escapes that turn off all attributes and turn on bold intensity, respectively. ffnneedd name

Same as zzeedd -ff. This function does not appear in the zsh dis-

tribution, but can be created by linking zzeedd to the name ffnneedd in some directory in your ffppaatthh.

iiss-aatt-lleeaasstt needed [ present ]

Perform a greater-than-or-equal-to comparison of two strings

having the format of a zsh version number; that is, a string of numbers and text with segments separated by dots or dashes. If

the present string is not provided, $$ZZSSHHVVEERRSSIIOONN is used. Seg-

ments are paired left-to-right in the two strings with leading

non-number parts ignored. If one string has fewer segments than

the other, the missing segments are considered zero. This is useful in startup files to set options and other state that are not available in all versions of zsh.

iiss-aatt-lleeaasstt 33..11..66-1155 &&&& sseettoopptt NNOOGGLLOOBBAALLRRCCSS

iiss-aatt-lleeaasstt 33..11..00 &&&& sseettoopptt HHIISSTTRREEDDUUCCEEBBLLAANNKKSS

iiss-aatt-lleeaasstt 22..66-1177 |||| pprriinntt ""YYoouu ccaann''tt uussee iiss-aatt-lleeaasstt hheerree..""

nnssllooookkuupp [ arg ... ] This wrapper function for the nnssllooookkuupp command requires the zzsshh//zzppttyy module (see zshmodules(1)). It behaves exactly like the standard nnssllooookkuupp except that it provides customizable

prompts (including a right-side prompt) and completion of

nslookup commands, host names, etc. (if you use the func-

tion-based completion system). Completion styles may be set

with the context prefix `::ccoommpplleettiioonn::nnssllooookkuupp'. See also the ppaaggeerr, pprroommpptt and rrpprroommpptt styles below.

rruunn-hheellpp

See `Accessing On-Line Help' above.

tteettrriiss Zsh was once accused of not being as complete as Emacs, because it lacked a Tetris game. This function was written to refute this vicious slander. This function must be used as a ZLE widget:

aauuttoollooaadd -UU tteettrriiss

zzllee -NN tteettrriiss

bbiinnddkkeeyy keys tteettrriiss

To start a game, execute the widget by typing the keys. What-

ever command line you were editing disappears temporarily, and your keymap is also temporarily replaced by the Tetris control keys. The previous editor state is restored when you quit the game (by pressing `qq') or when you lose. If you quit in the middle of a game, the next invocation of the tteettrriiss widget will continue where you left off. If you lost, it will start a new game.

zzaarrggss [ option ... -- ] [ input ... ] [ -- command [ arg ... ] ]

This function works like GNU xargs, except that instead of read-

ing lines of arguments from the standard input, it takes them from the command line. This is useful because zsh, especially with recursive glob operators, often can construct a command line for a shell function that is longer than can be accepted by an external command. The option list represents options of the zzaarrggss command itself, which are the same as those of xxaarrggss. The input list is the

collection of strings (often file names) that become the argu-

ments of the ccoommmmaanndd, analogous to the standard input of xxaarrggss. Finally, the arg list consists of those arguments (usually options) that are passed to the command each time it runs. The arg list precedes the elements from the iinnppuutt list in each run. If no command is provided, then no arg list may be provided, and

in that event the default command is `pprriinntt' with arguments `-rr

--'.

For example, to get a long llss listing of all plain files in the current directory or its subdirectories:

aauuttoollooaadd -UU zzaarrggss

zzaarrggss -- ****//**((..)) -- llss -ll

Note that `--' is used both to mark the end of the option list

and to mark the end of the input list, so it must appear twice whenever the input list may be empty. If there is guaranteed to be at least one input and the first input does not begin with a

`-', then the first `--' may be omitted.

In the event that the string `--' is or may be an input, the -ee

option may be used to change the end-of-inputs marker. Note

that this does not change the end-of-options marker. For exam-

ple, to use `....' as the marker:

zzaarrggss -ee.... -- ****//**((..)) .... llss -ll

This is a good choice in that example because no plain file can

be named `....', but the best end-marker depends on the circum-

stances. For details of the other zzaarrggss options, see xargs(1) or run

zzaarrggss with the --hheellpp option.

zzccaallcc [ expression ... ]

A reasonably powerful calculator based on zsh's arithmetic eval-

uation facility. The syntax is similar to that of formulae in

most programming languages; see the section `Arithmetic Evalua-

tion' in zshmisc(1) for details. The mathematical library zzsshh//mmaatthhffuunncc will be loaded if it is available; see the section `The zsh/mathfunc Module' in zshmodules(1). The mathematical

functions correspond to the raw system libraries, so trigonomet-

ric functions are evaluated using radians, and so on. Each line typed is evaluated as an expression. The prompt shows a number, which corresponds to a positional parameter where the result of that calculation is stored. For example, the result of the calculation on the line preceded by `44>> ' is available as

$$44. Full command line editing, including the history of previ-

ous calculations, is available; the history is saved in the file ~~//..zzccaallcchhiissttoorryy. To exit, enter a blank line or type `qq' on its own. If arguments are given to zzccaallcc on start up, they are used to prime the first few positional parameters. A visual indication of this is given when the calculator starts. The constants PPII (3.14159...) and EE (2.71828...) are provided. Parameter assignment is possible, but note that all parameters will be put into the global namespace. An extra facility is provided for changing the default output

base. Use, for example, `[[##1166]]' to display hexadecimal output

preceded by an indication of the base, or `[[####1166]]' just to dis-

play the raw number in the given base. Bases themselves are

always specified in decimal. `[[##]]' restores the normal output

format. The output base can be initialised by passing the option

`-##base', for example `zzccaallcc -##1166' (the `##' may have to be

quoted, depending on the globbing options set). The prompt is configurable via the parameter ZZCCAALLCCPPRROOMMPPTT, which undergoes standard prompt expansion. The index of the current entry is stored locally in the first element of the array ppssvvaarr,

which can be referred to in ZZCCAALLCCPPRROOMMPPTT as `%%11vv'. The default

prompt is `%%11vv>> '.

See the comments in the function for a few extra tips.

zzeedd [ -ff ] name

zzeedd -bb This function uses the ZLE editor to edit a file or function.

Only one name argument is allowed. If the -ff option is given,

the name is taken to be that of a function; if the function is marked for autoloading, zzeedd searches for it in the ffppaatthh and loads it. Note that functions edited this way are installed into the current shell, but not written back to the autoload file.

Without -ff, name is the path name of the file to edit, which

need not exist; it is created on write, if necessary. While editing, the function sets the main keymap to zzeedd and the

vi command keymap to zzeedd-vviiccmmdd. These will be copied from the

existing mmaaiinn and vviiccmmdd keymaps if they do not exist the first

time zzeedd is run. They can be used to provide special key bind-

ings used only in zed. If it creates the keymap, zzeedd rebinds the return key to insert a line break and `^^XX^^WW' to accept the edit in the zzeedd keymap, and

binds `ZZZZ' to accept the edit in the zzeedd-vviiccmmdd keymap.

The bindings alone can be installed by running `zzeedd -bb'. This

is suitable for putting into a startup file. Note that, if

rerun, this will overwrite the existing zzeedd and zzeedd-vviiccmmdd

keymaps. Completion is available, and styles may be set with the context prefix `::ccoommpplleettiioonn::zzeedd'.

A zle widget zzeedd-sseett-ffiillee-nnaammee is available. This can be called

by name from within zed using `\\eexx zzeedd-sseett-ffiillee-nnaammee' (note,

however, that because of zed's rebindings you will have to type ^^jj at the end instead of the return key), or can be bound to a

key in either of the zzeedd or zzeedd-vviiccmmdd keymaps after `zzeedd -bb' has

been run. When the widget is called, it prompts for a new name for the file being edited. When zed exits the file will be written under that name and the original file will be left

alone. The widget has no effect with `zzeedd -ff'.

While zzeedd-sseett-ffiillee-nnaammee is running, zed uses the keymap zzeedd-nnoorr-

mmaall-kkeeyymmaapp, which is linked from the main keymap in effect at

the time zed initialised its bindings. (This is to make the return key operate normally.) The result is that if the main keymap has been changed, the widget won't notice. This is not a concern for most users.

zzccpp [ -ffiinnqqQQvvwwWW ] srcpat dest

zzllnn [ -ffiinnqqQQssvvwwWW ] srcpat dest

Same as zzmmvv -CC and zzmmvv -LL, respectively. These functions do not

appear in the zsh distribution, but can be created by linking zzmmvv to the names zzccpp and zzllnn in some directory in your ffppaatthh. zzkkbbdd See `Keyboard Definition' above.

zzmmvv [ -ffiinnqqQQssvvwwWW ] [ -C | -L | -M | -p program ] [ -o optstring ] src-

pat dest

Move (usually, rename) files matching the pattern srcpat to cor-

responding files having names of the form given by dest, where srcpat contains parentheses surrounding patterns which will be

replaced in turn by $1, $2, ... in dest. For example,

zzmmvv ''((**))..lliiss'' ''$$11..ttxxtt''

renames `ffoooo..lliiss' to `ffoooo..ttxxtt', `mmyy..oolldd..ssttuuffff..lliiss' to `mmyy..oolldd..ssttuuffff..ttxxtt', and so on. The pattern is always treated as an EEXXTTEENNDDEEDDGGLLOOBB pattern. Any file whose name is not changed by the substitution is simply ignored. Any error (a substitution resulted in an empty string, two substitutions gave the same result, the destination was an

existing regular file and -ff was not given) causes the entire

function to abort without doing anything. Options:

-ff Force overwriting of destination files. Not currently

passed down to the mmvv/ccpp/llnn command due to vagaries of

implementations (but you can use -oo-ff to do that).

-ii Interactive: show each line to be executed and ask the

user whether to execute it. `Y' or `y' will execute it, anything else will skip it. Note that you just need to type one character.

-nn No execution: print what would happen, but don't do it.

-qq Turn bare glob qualifiers off: now assumed by default, so

this has no effect.

-QQ Force bare glob qualifiers on. Don't turn this on unless

you are actually using glob qualifiers in a pattern.

-ss Symbolic, passed down to llnn; only works with -LL.

-vv Verbose: print each command as it's being executed.

-ww Pick out wildcard parts of the pattern, as described

above, and implicitly add parentheses for referring to them.

-WW Just like -ww, with the addition of turning wildcards in

the replacement pattern into sequential ${1} .. ${N} ref-

erences.

-CC

-LL

-MM Force ccpp, llnn or mmvv, respectively, regardless of the name

of the function.

-pp program

Call program instead of ccpp, llnn or mmvv. Whatever it does,

it should at least understand the form `program -- old-

name newname' where oldname and newname are filenames generated by zzmmvv.

-oo optstring

The optstring is split into words and passed down verba-

tim to the ccpp, llnn or mmvv command called to perform the

work. It should probably begin with a `-'.

For more complete examples and other implementation details, see the zzmmvv source file, usually located in one of the directories

named in your ffppaatthh, or in FFuunnccttiioonnss//MMiisscc//zzmmvv in the zsh distri-

bution. zzrreeccoommppiillee See `Recompiling Functions' above. zzssttyyllee++ context style value [ + subcontext style value ... ] This makes defining styles a bit simpler by using a single `++' as a special token that allows you to append a context name to the previously used context name. Like this: zzssttyyllee++ ''::ffoooo::bbaarr'' ssttyyllee11 vvaalluuee11 \\ ++ ''::bbaazz'' ssttyyllee22 vvaalluuee22 \\ ++ ''::ffrroobb'' ssttyyllee33 vvaalluuee33 This defines `style1' with `value1' for the context ::ffoooo::bbaarr as

usual, but it also defines `style2' with `value2' for the con-

text ::ffoooo::bbaarr::bbaazz and `style3' with `value3' for ::ffoooo::bbaarr::ffrroobb.

Any subcontext may be the empty string to re-use the first con-

text unchanged. SSttyylleess

iinnsseerrtt-ttaabb

The zzeedd function sets this style in context `::ccoommpplleettiioonn::zzeedd::**' to turn off completion when TTAABB is typed at the beginning of a line. You may override this by setting your own value for this context and style. ppaaggeerr The nnssllooookkuupp function looks up this style in the context `::nnssllooookkuupp' to determine the program used to display output that does not fit on a single screen. pprroommpptt rrpprroommpptt The nnssllooookkuupp function looks up this style in the context

`::nnssllooookkuupp' to set the prompt and the right-side prompt, respec-

tively. The usual expansions for the PPSS11 and RRPPSS11 parameters may be used (see zshmisc(1)). ZSHALL(1) ZSHALL(1) FILES

$$ZZDDOOTTDDIIRR//..zzsshheennvv

$$ZZDDOOTTDDIIRR//..zzpprrooffiillee

$$ZZDDOOTTDDIIRR//..zzsshhrrcc

$$ZZDDOOTTDDIIRR//..zzllooggiinn

$$ZZDDOOTTDDIIRR//..zzllooggoouutt

$${{TTMMPPPPRREEFFIIXX}}** (default is /tmp/zsh*)

//eettcc//zzsshheennvv //eettcc//zzpprrooffiillee //eettcc//zzsshhrrcc //eettcc//zzllooggiinn

//eettcc//zzllooggoouutt (installation-specific - //eettcc is the default)

SEE ALSO

sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1)

IIEEEEEE SSttaannddaarrdd ffoorr iinnffoorrmmaattiioonn TTeecchhnnoollooggyy - PPoorrttaabbllee OOppeerraattiinngg SSyysstteemm

IInntteerrffaaccee ((PPOOSSIIXX)) - PPaarrtt 22:: SShheellll aanndd UUttiilliittiieess, IEEE Inc, 1993, ISBN

1-55937-255-9.

zsh 4.2.3 January 13, 2005 ZSHALL(1)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™