This is zsh.info, produced by makeinfo version 4.0 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: The zsh/zprof Module,  Next: The zsh/zpty Module,  Prev: The zsh/zleparameter Module,  Up: Zsh Modules

The zsh/zprof Module
====================

When loaded, the zsh/zprof causes shell functions to be profiled.  The
profiling results can be obtained with the zprof builtin command made
available by this module.  There is no way to turn profiling off other
than unloading the module.

zprof [ -c ]
     Without the -c option, zprof lists profiling results to standard
     output.  The format is comparable to that of commands like gprof.

     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]', 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 function 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 information, 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
     invocations made to the called function.

     As long as the zsh/zprof module is loaded, profiling will be done
     and multiple invocations of the zprof builtin command will show the
     times and numbers of calls since the module was loaded.  With the
     -c option, the zprof builtin command will reset its internal
     counters and will not show the listing.  )


File: zsh.info,  Node: The zsh/zpty Module,  Next: The zsh/zutil Module,  Prev: The zsh/zprof Module,  Up: Zsh Modules

The zsh/zpty Module
===================

The zsh/zpty module offers one builtin:

zpty [ -e ] [ -b ] NAME [ ARG ... ]
     The arguments following NAME are concatenated with spaces between,
     then executed as a command, as if passed to the eval builtin.  The
     command runs under a newly assigned pseudo-terminal; 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 zpty.

     With the -e option, the pseudo-terminal is set up so that input
     characters are echoed.

     With the -b option, input to and output from the pseudo-terminal
     are made non-blocking.

zpty -d [ NAMES ... ]
     The second form, with the -d 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.

zpty -w [ -n ] NAME [ STRINGS ... ]
     The -w option can be used to send the to command NAME the given
     STRINGS as input (separated by spaces).  If the -n 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.

zpty -r [ -t ] NAME [ PARAM [ PATTERN ] ]
     The -r 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-blocking,
     copying continues until the command under the pseudo-terminal
     exits; when non-blocking, only as much output as is immediately
     available is copied.  The return value is zero if any output 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 2 if this is because the command has finished.

     If the -r option is combined with the -t option, zpty tests
     whether output is available before trying to read.  If no output is
     available, zpty immediately returns the value 1.

zpty -t NAME
     The -t option without the -r 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.

zpty [ -L ]
     The last form, without any arguments, is used to list the commands
     currently defined.  If the -L option is given, this is done in the
     form of calls to the zpty builtin.


File: zsh.info,  Node: The zsh/zutil Module,  Prev: The zsh/zpty Module,  Up: Zsh Modules

The zsh/zutil Module
====================

The zsh/zutil module only adds some builtins:

zstyle [ -L ]
zstyle [ -e | - | -- ] PATTERN STYLE STRINGS ...
zstyle -d [ PATTERN [ STYLES ... ] ]
zstyle -g NAME [ PATTERN [ STYLE ] ]
zstyle -abs CONTEXT STYLE NAME [ SEP ]
zstyle -Tt CONTEXT STYLE [ STRINGS ...]
zstyle -m 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 patterns and
     lookup is done by giving a string, called the `context', 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 specific
     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 patterns
     are considered to be more specific than the pattern `*'.

     The first form (without arguments) lists the definitions in the
     order zstyle will test them. If the -L option is given, listing is
     done in the form of calls to zstyle.  Forms with arguments:

    zstyle [ - | -- | -e ] PATTERN STYLE STRINGS ...
          Defines the given STYLE for the PATTERN with the STRINGS as
          the value.  If the -e 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 eval
          builtin command) when the style is looked up.  In this case
          the parameter `reply' must be assigned to set the strings
          returned after the evaluation.  Before evaluating the value,
          reply is unset, and if it is still unset after the
          evaluation, the style is treated as if it were not set.

    zstyle -d [ PATTERN [ STYLES ... ] ]
          Delete style definitions. Without arguments all definitions
          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.

    zstyle -g 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.

    zstyle -s 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.

    zstyle -b CONTEXT STYLE NAME
          The value is stored in NAME as a boolean, i.e. as the string
          `yes' if the value has only one string and that string is
          equal to one of `yes', `true', `on', or `1'. If the value is
          any other string or has more than one string, the parameter
          is set to `no'.

    zstyle -a 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.

    zstyle -t CONTEXT STYLE [ STRINGS ...]
    zstyle -T CONTEXT STYLE [ STRINGS ...]
          Test the value of a style, i.e. the -t 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 `true', `yes', `on' or `1'. 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 2.

          The -T option tests the values of the style like -t, but it
          returns zero (rather than 2) if the style is not defined for
          any matching pattern.

    zstyle -m CONTEXT STYLE PATTERN
          Match a value. Returns status zero if the PATTERN matches at
          least one of the strings in the value.

zformat -f PARAM FORMAT SPECS ...
zformat -a ARRAY SEP SPECS ...
     This builtin provides two different forms of formatting. The first
     form is selected with the -f option. In this case the FORMAT
     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.MAXc', 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 second form, using the -a 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.

zregexparse
     This implements some internals of the _regex_arguments function.

zparseopts [ -D ] [ -K ] [ -E ] [ -a ARRAY ] [ -A 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 -a 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 -a or -A options is used.

     Unless the -E option is given, parsing stops at the first string
     that isn't described by one of the SPECS.  Even with -E, 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 example, a `-file'
          option is represented by a NAME of `-file'.

          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 argument,
          so parsing stops if the next positional parameter does not
          also begin with `-' (unless the -E option is used).

    NAME:
    NAME:-
    NAME::
          If one or two colons are given, the option takes an argument;
          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 zparseopts itself are:

    -a ARRAY
          As described above, this names the default array in which to
          store the recognised options.

    -A 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 arguments (if any) as the values.

    -D
          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 shift builtin.

    -K
          With this option, the arrays specified with the -a and -A
          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 zparseopts.

    -E
          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 -D) extract
          options and their arguments, ignoring all other options and
          arguments that may be in the positional parameters.

     For example,

          set -- -a -bx -c y -cz baz -cend
          zparseopts a=foo b:=bar c+:=bar

     will have the effect of

          foo=(-a)
          bar=(-b x -c y -c z)

     The arguments from `baz' on will not be used.

     As an example for the -E option, consider:

          set -- -a x -b y -c z arg1 arg2
          zparseopts -E -D b:=bar

     will have the effect of

          bar=(-b y)
          set -- -a x -c z arg1 arg2

     I.e., the option -b and its arguments are taken from the
     positional parameters and put into the array bar.


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

Zftp Function System
********************

Description
===========

This describes the set of shell functions supplied with the source
distribution as an interface to the zftp 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 ftp command itself, see man page 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 zftp command, as described in *Note The
zsh/zftp Module:: , must be available in the version of zsh installed
at your site.  If the shell is configured to load new commands at run
time, it probably is: typing `zmodload zsh/zftp' will make sure (if
that runs silently, it has worked).  If this is not the case, it is
possible zftp was linked into the shell anyway: to test this, type
`which zftp' and if zftp is available you will get the message `zftp:
shell built-in command'.

Commands given directly with zftp builtin may be interspersed between
the functions in this suite; in a few cases, using zftp directly may
cause some of the status information stored in shell parameters to
become invalid.  Note in particular the description of the variables
$ZFTP_TMOUT, $ZFTP_PREFS and $ZFTP_VERBOSE for zftp.

* Menu:

* Installation::
* Zftp Functions::
* Miscellaneous Features::


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

Installation
============

You should make sure all the functions from the Functions/Zftp
directory of the source distribution are available; they all begin with
the two letters `zf'.  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 $fpath array
(this should already be the case if they were installed), and at least
the function zfinit should be autoloaded; it will autoload the rest.
Finally, to initialize the use of the system you need to call the
zfinit 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 zfinit
     zfinit

Note that zfinit assumes you are using the zmodload method to load the
zftp command.  If it is already built into the shell, change zfinit to
zfinit -n.  It is helpful (though not essential) if the call to zfinit
appears after any code to initialize the new completion system, else
unnecessary compctl commands will be given.


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::
* Other Functions::

