This is zsh.info, produced by makeinfo version 4.5 from ./zsh.texi.

INFO-DIR-SECTION Utilities
START-INFO-DIR-ENTRY
* ZSH: (zsh).                     The Z Shell Manual.
END-INFO-DIR-ENTRY


File: zsh.info,  Node: Zftp Functions,  Next: Miscellaneous Features,  Prev: Installation,  Up: Zftp Function System

Functions
=========

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 getopts 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).

Opening a connection
--------------------

zfparams [ HOST [ USER [ PASSWORD ... ] ] ]
     Set or show the parameters for a future zfopen with no arguments.
     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 zfopen calls zfparams 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.

zfopen [ -1 ] [ HOST [ USER [ PASSWORD [ ACCOUNT ] ] ] ]
     If HOST is present, open a connection to that host under username
     USER with password PASSWORD (and, on the rare occasions when it is
     necessary, account ACCOUNT).  If a necessary parameter 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
     xterm or is sun-cmd, a summary will appear in the title bar,
     giving the local host:directory and the remote host:directory;
     this is handled by the function zftp_chpwd, described below.

     Normally, the HOST, USER and PASSWORD are internally recorded for
     later re-opening, either by a zfopen with no arguments, or
     automatically (see below).  With the option `-1', 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 zfopen on its own, or a zfopen -1, never
     alters the stored parameters.

     Both zfopen and zfanon (but not zfparams) understand URLs of the
     form ftp://HOST/PATH... as meaning to connect to the HOST, then
     change directory to PATH (which must be a directory, not a file).
     The `ftp://' can be omitted; the trailing `/' is enough to trigger
     recognition of the PATH.  Note prefixes other than `ftp:' are not
     recognized, and that all characters after the first slash beyond
     HOST are significant in PATH.

zfanon [ -1 ] HOST
     Open a connection HOST for anonymous FTP.  The username used is
     `anonymous'.  The password (which will be reported the first time)
     is generated as USER@HOST; this is then stored in the shell
     parameter $EMAIL_ADDR which can alternatively be set manually to a
     suitable string.


Directory management
--------------------

zfcd [ DIR ]
zfcd -
zfcd OLD NEW
     Change the current directory on the remote server:  this is
     implemented to have many of the features of the shell builtin cd.

     In the first form with DIR present, change to the directory DIR.
     The command `zfcd ..' is treated specially, so is guaranteed to
     work on non-UNIX servers (note this is handled internally by
     zftp).  If DIR is omitted, has the effect of `zfcd ~'.

     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 zfcd receives a string.  For example,
     suppose the command is `zfcd ~/foo'.  The shell will expand this
     to a full path such as `zfcd /home/user2/pws/foo'.  At this stage,
     zfcd recognises the initial path as corresponding to `~' and will
     send the directory to the remote host as ~/foo, so that the `~'
     will be expanded by the server to the correct remote host
     directory.  Other named directories of the form `~name' are not
     treated in this fashion.

zfhere
     Change directory on the remote server to the one corresponding to
     the current local directory, with special handling of `~' as in
     zfcd.  For example, if the current local directory is ~/foo/bar,
     then zfhere performs the effect of `zfcd ~/foo/bar'.

zfdir [ -rfd ] [ - ] [ DIR-OPTIONS ] [ DIR ]
     Produce a long directory listing.  The arguments DIR-OPTIONS and
     DIR are passed directly to the server and their effect is
     implementation dependent, but specifying a particular remote
     directory DIR is usually possible.  The output is passed through a
     pager given by the environment variable $PAGER, or `more' 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 zfdir with the same arguments; for
     example, repeated use of `zfdir /pub/gnu' will only require the
     directory to be retrieved on the first call.  Alternatively, this
     cache can be re-viewed with the -r option.  As relative
     directories will confuse zfdir, the -f option can be used to force
     the cache to be flushed before the directory is listed.  The
     option -d will delete both caches without showing a directory
     listing; it will also delete the cache of file names in the
     current remote directory, if any.

zfls [ 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.


Status commands
---------------

zftype [ TYPE ]
     With no arguments, show the type of data to be transferred,
     usually ASCII or binary.  With an argument, change the type: the
     types `A' or `ASCII' for ASCII data and `B' or `BINARY', `I' or
     `IMAGE' for binary data are understood case-insensitively.

zfstat [ -v ]
     Show the status of the current or last connection, as well as the
     status of some of zftp's status variables.  With the -v option, a
     more verbose listing is produced by querying the server for its
     version of events, too.


Retrieving files
----------------

The commands for retrieving files all take at least two options. -G
suppresses remote filename expansion which would otherwise be performed
(see below for a more detailed description of that).  -t attempts to
set the modification time of the local file to that of the remote file:
this requires version 5 of perl, see the description of the function
zfrtime below for more information.

zfget [ -Gtc ] 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 -c (cat)
     forces all files to be sent as a single stream to standard output;
     in this case the -t option has no effect.

zfuget [ -Gvst ] FILE1 ...
     As zfget, 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 -s, the command runs silently and will always retrieve the
     file in either of those two cases.  With the option -v, the
     command prints more information about the files while it is
     working out whether or not to transfer them.

zfcget [ -Gt ] FILE1 ...
     As zfget, 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 connection which
     keeps failing.

     Note that this requires a commonly implemented, but non-standard,
     version of the FTP protocol, so is not guaranteed to work on all
     servers.

zfgcp [ -Gt ] REMOTE-FILE LOCAL-FILE
zfgcp [ -Gt ] RFILE1 ... LDIR
     This retrieves files from the remote server with arguments behaving
     similarly to the cp 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.


Sending files
-------------

zfput [ -r ] 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 -r, 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.

zfuput [ -vs ] FILE1 ...
     As zfput, 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 zfuget, but reversed between local and remote
     files.

zfcput FILE1 ...
     As zfput, but if any remote file already exists and is shorter
     than the local equivalent, assume it is the result of an
     incomplete transfer and send the rest of the file to append to the
     existing part.  As the FTP append command is part of the standard
     set, this is in principle more likely to work than zfcget.

zfpcp LOCAL-FILE REMOTE-FILE
zfpcp LFILE1 ... RDIR
     This sends files to the remote server with arguments behaving
     similarly to the cp 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 zfpcp LFILE1 RDIR, i.e. the
     second form of copying but with two arguments, as the command 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 operation 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 `Is a directory', then zfpcp will retry using the second
     form.


Closing the connection
----------------------

zfclose
     Close the connection.


Session management
------------------

zfsession [ -lvod ] [ SESSNAME ]
     Allows you to manage multiple FTP sessions at once.  By default,
     connections take place in a session called `default'; by giving the
     command `zfsession 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 parameters, and also
     the host/user parameters set by zfparams.  Hence you can have
     different sessions set up to connect to different hosts, each
     remembering the appropriate host, user and password.

     With no arguments, zfsession prints the name of the current
     session; with the option -l it lists all sessions which currently
     exist, and with the option -v it gives a verbose list showing the
     host and directory for each session, where the current session is
     marked with an asterisk.  With -o, it will switch to the most
     recent previous session.

     With -d, 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 `default' is created and made
     current.  It is safest not to delete sessions while background
     commands using zftp are active.

zftransfer 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 session
     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.


Bookmarks
---------

The two functions zfmark and zfgoto 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 $ZFTP_BMFILE; if not set when one of the two
functions is called, it will be set to the file .zfbkmarks in the
directory where your zsh startup files live (usually ~).

zfmark [ BOOKMARK ]
     If given an argument, mark the current host, user and directory
     under the name BOOKMARK for later use by zfgoto.  If there is no
     connection open, use the values for the last connection
     immediately 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.

zfgoto [ -n ] BOOKMARK
     Return to the location given by BOOKMARK, as previously set by
     zfmark.  If the location has user `ftp' or `anonymous', open the
     connection with zfanon, so that no password is required.  If the
     user and host parameters match those stored for the current
     session, if any, those will be used, and again no password is
     required.  Otherwise a password will be prompted for.

     With the option -n, the bookmark is taken to be a nickname stored
     by the ncftp program in its bookmark file, which is assumed to be
     ~/.ncftp/bookmarks.  The function works identically in other ways.
     Note that there is no mechanism for adding or modifying ncftp
     bookmarks from the zftp functions.


Other functions
---------------

Mostly, these functions will not be called directly (apart from
zfinit), but are described here for completeness.  You may wish to
alter zftp_chpwd and zftp_progress, in particular.

zfinit [ -n ]
     As described above, this is used to initialize the zftp function
     system.  The -n option should be used if the zftp command is
     already built into the shell.

zfautocheck [ -dn ]
     This function is called to implement automatic reopening
     behaviour, as described in more detail below.  The options must
     appear in the first argument; -n prevents the command from
     changing to the old directory, while -d prevents it from setting
     the variable do_close, 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
     $zflastsession, but the internal host/user/password parameters
     must also be correctly set.

zfcd_match 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 zfget_match and hence completes all files, not just
     directories.  On some systems, directories may not even look like
     filenames.

zfget_match PREFIX SUFFIX
     This performs matching for completion of remote filenames.  It
     caches files for the current directory (only) in the shell
     parameter $zftp_fcache.  It is in the form to be called by the -K
     option of compctl, but also works when called from a widget-style
     completion function with PREFIX and SUFFIX set appropriately.

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

zfrtime 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
     CCYYMMDDhhmmSS for the GMT timezone.

     Currently this requires perl version 5 to perform the conversion
     from GMT to local time.  This is unfortunately difficult to do
     using shell code alone.

zftp_chpwd
     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 xterm-compatible or sun-cmd terminal emulator to
     reflect the local and remote hostnames and current directories.
     It works best when combined with the function chpwd.  In
     particular, a function of the form

          chpwd() {
            if [[ -n $ZFTP_USER ]]; then
              zftp_chpwd
            else
              # usual chpwd e.g put host:directory in title bar
            fi
          }

     fits in well.

zftp_progress
     This function shows the status of the transfer.  It will not write
     anything unless the output is going to a terminal; however, if you
     transfer files in the background, you should turn off progress
     reports by hand using `zstyle ':zftp:*' progress none'.  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.

zffcache
     This is used to implement caching of files in the current
     directory for each session separately.  It is used by zfget_match
     and zfrglob.



File: zsh.info,  Node: Miscellaneous Features,  Prev: Zftp Functions,  Up: Zftp Function System

Miscellaneous Features
======================

Configuration
-------------

Various styles are available using the standard shell style mechanism,
described in *Note The zsh/zutil Module::. Briefly, the command `zstyle
':zftp:*' 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 system.  For more precise control, the first argument,
which gives a context in which the style applies, can be modified to
include a particular function, as for example `:zftp:zfget': the style
will then have the given value only in the zfget 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 zftp_chpwd use the contexts :zftp:zfopen,
:zftp:zfcd, etc., depending where it was called from.  The following
styles are understood:

progress
     Controls the way that zftp_progress reports on the progress of a
     transfer.  If empty, unset, or `none', no progress report is made;
     if `bar' a growing bar of inverse video is shown; if `percent' (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
     $COLUMNS parameter (normally this is set automatically).  If the
     size of the file being transferred is not available, bar and
     percent meters will simply show the number of bytes transferred so
     far.

     When zfinit is run, if this style is not defined for the context
     :zftp:*, it will be set to `bar'.

update
     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
     $ZFTP_TIMEOUT.

     As described for progress, zfinit will force this to default to 1.

remote-glob
     If set to `1', `yes' or `true', filename generation (globbing) is
     performed on the remote machine instead of by zsh itself; see
     below.

titlebar
     If set to `1', `yes' or `true', zftp_chpwd will put the remote
     host and remote directory into the titlebar of terminal emulators
     such as xterm or sun-cmd that allow this.

     As described for progress, zfinit will force this to default to 1.

chpwd
     If set to `1' `yes' or `true', zftp_chpwd will call the function
     chpwd when a connection is closed.  This is useful if the remote
     host details were put into the terminal title bar by zftp_chpwd
     and your usual chpwd also modifies the title bar.

     When zfinit is run, it will determine whether chpwd 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 zfconfig which contains
values used by the function system.  This should not be modified or
overwritten.

Remote globbing
---------------

The commands for retrieving files usually perform filename generation
(globbing) on their arguments; this can be turned off by passing the
option -G to each of the commands.  Normally this operates by
retrieving a complete list of files for the directory in question, then
matching these locally against the pattern supplied.  This has the
advantage that the full range of zsh patterns (respecting the setting
of the option EXTENDED_GLOB) can be used.  However, it means that the
directory 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 zfcd are
much faster.

If the remote-glob style (see above) is set, globbing is instead
performed 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
patterns.  This may in some cases be faster, as it avoids retrieving
the entire list of directory contents.

Automatic and temporary reopening
---------------------------------

As described for the zfopen command, a subsequent zfopen with no
parameters will reopen the connection to the last host (this includes
connections made with the zfanon 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
currently 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
available if the -1 option to zfopen or zfanon 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 zfdir 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 zfdir directly followed by
a zfget will never close the connection automatically.

Information about the previous connection is given by the zfstat
function.  So, for example, if that reports:

     Session:        default
     Not connected.
     Last session:   ftp.bar.com:/pub/textfiles

then the command zfget file.txt will attempt to reopen a connection to
ftp.bar.com, retrieve the file /pub/textfiles/file.txt, and immediately
close the connection again.  On the other hand, zfcd ..  will open the
connection in the directory /pub 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.

Completion
----------

Completion of local and remote files, directories, sessions and
bookmarks is supported.  The older, compctl-style completion is defined
when zfinit is called; support for the new widget-based completion
system is provided in the function Completion/Zsh/Command/_zftp, which
should be installed with the other functions of the completion system
and hence should automatically be available.


File: zsh.info,  Node: User Contributions,  Prev: Zftp Function System,  Up: Top

User Contributions
******************

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
significant of these are documented here.  For documentation on other
contributed items such as shell functions, look for comments in the
function source files.

* Menu:

* Utilities::
* Prompt Themes::
* ZLE Functions::
* MIME Functions::
* Other Functions::


File: zsh.info,  Node: Utilities,  Next: Prompt Themes,  Up: User Contributions

Utilities
=========

Accessing On-Line Help
----------------------

The key sequence ESC h is normally bound by ZLE to execute the run-help
widget (see *Note Zsh Line Editor::).  This invokes the run-help
command with the command word from the current input line as its
argument.  By default, run-help is an alias for the man command, so
this often fails when the command word is a shell builtin or a
user-defined function.  By redefining the run-help alias, one can
improve the on-line help provided by the shell.

The helpfiles utility, found in the Util 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 run-help function, found in
Functions/Misc, 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
/usr/share/zsh or /usr/local/share/zsh and subdirectories below those,
or ask your system administrator.

To create your own help files with helpfiles, choose or create a
directory where the individual command help files will reside.  For
example, you might choose ~/zsh_help.  If you unpacked the zsh
distribution in your home directory, you would use the commands:

     mkdir ~/zsh_help
     cd ~/zsh_help
     man zshall | colcrt - | \
     perl ~/zsh-4.2.0-pre-4/Util/helpfiles

Next, to use the run-help function, you need to add lines something
like the following to your .zshrc or equivalent startup file:

     unalias run-help
     autoload run-help
     HELPDIR=~/zsh_help

The HELPDIR parameter tells run-help where to look for the help files.
If your system already has a help file directory installed, set HELPDIR
to the path of that directory instead.

Note that in order for `autoload run-help' to work, the run-help file
must be in one of the directories named in your fpath array (see *Note
Parameters Used By The Shell::).  This should already be the case if
you have a standard zsh installation; if it is not, copy
Functions/Misc/run-help to an appropriate directory.

Recompiling Functions
---------------------

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 zcompile 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 fpath, zsh
won't check whether any of its source files has changed.

The zrecompile autoloadable function, found in Functions/Misc, can be
used to keep function digests up to date.

zrecompile [ -qt ] [ NAME ... ]
zrecompile [ -qt ] -p ARGS [ -- ARGS ... ]
     This tries to find *.zwc 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
     .zwc file.

     In the first form, each NAME is the name of a compiled file or a
     directory containing *.zwc files that should be checked.  If no
     arguments are given, the directories and *.zwc files in fpath are
     used.

     When -t is given, no compilation is performed, but a return status
     of zero (true) is set if there are files that need to be
     re-compiled and non-zero (false) otherwise.  The -q option quiets
     the chatty output that describes what zrecompile is doing.

     Without the -t 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 -p option is given, the ARGS are interpreted as one or more
     sets of arguments for zcompile, separated by `--'.  For example:

          zrecompile -p \
                     -R ~/.zshrc -- \
                     -M ~/.zcompdump -- \
                     ~/zsh/comp.zwc ~/zsh/Completion/*/_*

     This compiles ~/.zshrc into ~/.zshrc.zwc if that doesn't exist or
     if it is older than ~/.zshrc. The compiled file will be marked for
     reading instead of mapping. The same is done for ~/.zcompdump and
     ~/.zcompdump.zwc, but this compiled file is marked for mapping. The
     last line re-creates the file ~/zsh/comp.zwc if any of the files
     matching the given pattern is newer than it.

     Without the -p option, zrecompile 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 function
digests for all functions in your fpath, assuming that you have write
permission to the directories:

     for ((i=1; i <= $#fpath; ++i)); do
       dir=$fpath[i]
       zwc=${dir:t}.zwc
       if [[ $dir == (.|..) || $dir == (.|..)/* ]]; then
         continue
       fi
       files=($dir/*(N-.))
       if [[ -w $dir:h && -n $files ]]; then
         files=(${${(M)files%/*/*}#/})
         if ( cd $dir:h &&
              zrecompile -p -U -z $zwc $files ); then
           fpath[i]=$fpath[i].zwc
         fi
       fi
     done

The -U and -z options are appropriate for functions in the default zsh
installation fpath; you may need to use different options for your
personal function directories.

Once the digests have been created and your fpath modified to refer to
them, you can keep them up to date by running zrecompile with no
arguments.

Keyboard Definition
-------------------

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 zkbd utility,
found in Functions/Misc, can help you quickly create key bindings for
your configuration.

Run zkbd either as an autoloaded function, or as a shell script:

     zsh -f ~/zsh-4.2.0-pre-4/Functions/Misc/zkbd

When you run zkbd, 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; zkbd warns you if it finds anything out of the
ordinary, such as a Delete key that sends neither ^H nor ^?.

The keystrokes read by zkbd are recorded as a definition for an
associative array named key, written to a file in the subdirectory
.zkbd within either your HOME or ZDOTDIR directory.  The name of the
file is composed from the TERM, VENDOR and OSTYPE parameters, joined by
hyphens.

You may read this file into your .zshrc or another startup file with
the "source" or "." commands, then reference the key parameter in
bindkey commands, like this:

     source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE
     [[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
     [[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char
     # etc.

Note that in order for `autoload zkbd' to work, the zkdb file must be
in one of the directories named in your fpath array (see *Note
Parameters Used By The Shell::).  This should already be the case if
you have a standard zsh installation; if it is not, copy
Functions/Misc/zkbd to an appropriate directory.

Dumping Shell State
-------------------

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 *Note Mailing Lists::), but
sometimes one of the zsh developers will need to recreate your
environment in order to track the problem down.

The script named reporter, found in the Util directory of the
distribution, is provided for this purpose.  (It is also possible to
autoload reporter, but reporter is not installed in fpath by default.)
This script outputs a detailed dump of the shell state, in the form of
another script that can be read with `zsh -f' to recreate that state.

To use reporter, read the script into your shell with the `.'  command
and redirect the output into a file:

     . ~/zsh-4.2.0-pre-4/Util/reporter > zsh.report

You should check the zsh.report 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 reporter 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 aliases, options, and zstyles
states may be useful because they include only changes from the
defaults.  The bindings state may be useful if you have created any of
your own keymaps, because reporter 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
reporter, you should edit the results to remove unnecessary commands.
Note that if you're using the new completion system, you should _not_
dump the functions state to your startup files with reporter; use the
compdump function instead (see *Note Completion System::).

reporter [ STATE ... ]
     Print to standard output the indicated subset of the current shell
     state.  The STATE arguments may be one or more of:

    all
          Output everything listed below.

    aliases
          Output alias definitions.

    bindings
          Output ZLE key maps and bindings.

    completion
          Output old-style compctl commands.  New completion is covered
          by functions and zstyles.

    functions
          Output autoloads and function definitions.

    limits
          Output limit commands.

    options
          Output setopt commands.

    styles
          Same as zstyles.

    variables
          Output shell parameter assignments, plus export commands for
          any environment variables.

    zstyles
          Output zstyle commands.

     If the STATE is omitted, all is assumed.

     With the exception of `all', every STATE can be abbreviated by any
     prefix, even a single letter; thus a is the same as aliases, z is
     the same as zstyles, etc.


File: zsh.info,  Node: Prompt Themes,  Next: ZLE Functions,  Prev: Utilities,  Up: User Contributions

Prompt Themes
=============

Installation
------------

You should make sure all the functions from the Functions/Prompts
directory of the source distribution are available; they all begin with
the string `prompt_' except for the special function`promptinit'.  You
also need the `colors' function from Functions/Misc.  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 fpath array (this should already be the case
if they were installed), and at least the function promptinit should be
autoloaded; it will autoload the rest.  Finally, to initialize the use
of the system you need to call the promptinit function.  The following
code in your .zshrc will arrange for this; assume the functions are
stored in the directory ~/myfns:

     fpath=(~/myfns $fpath)
     autoload -U promptinit
     promptinit

Theme Selection
---------------

Use the prompt command to select your preferred theme.  This command
may be added to your .zshrc following the call to promptinit in order
to start zsh with a theme already selected.

prompt [ -c | -l ]
prompt [ -p | -h ] [ THEME ... ]
prompt [ -s ] 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 -l option
     to see a list.  The special THEME `random' 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 arguments,
     which should be given after the theme name.  See the help for each
     theme for descriptions of these arguments.

     Options are:

    -c
          Show the currently selected theme and its parameters, if any.

    -l
          List all available prompt themes.

    -p
          Preview the theme named by THEME, or all themes if no THEME
          is given.

    -h
          Show help for the theme named by THEME, or for the prompt
          function if no THEME is given.

    -s
          Set THEME as the current theme and save state.

prompt_THEME_setup
     Each available THEME has a setup function which is called by the
     prompt 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.


