26.8 MIME Functions
===================

Three functions are available to provide handling of files recognised by
extension, for example to dispatch a file text.ps when executed as a
command to an appropriate viewer.

zsh-mime-setup [ -fv ] [ -l [ SUFFIX ... ] ]
zsh-mime-handler [-l] COMMAND ARGUMENTS ...
     These two functions use the files ~/.mime.types and
     /etc/mime.types, which associate types and extensions, as well as
     ~/.mailcap and /etc/mailcap files, which associate types and the
     programs that handle them.  These are provided on many systems
     with the Multimedia Internet Mail Extensions.

     To enable the system, the function zsh-mime-setup 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 zsh-mime-handler should not need
     to be called by the user.

     The system works by setting up suffix aliases with `alias -s'.
     Suffix aliases already installed by the user will not be
     overwritten.

     For suffixes defined in lower case, upper case variants will also
     automatically be handled (e.g. PDF is automatically handled if
     handling for the suffix pdf is defined), but not vice versa.

     Repeated calls to zsh-mime-setup do not override the existing
     mapping between suffixes and executable files unless the option -f
     is given.  Note, however, that this does not override existing
     suffix aliases assigned to handlers other than zsh-mime-handler.

     Calling zsh-mime-setup with the option -l lists the existing
     mappings without altering them.  Suffixes to list (which may
     contain pattern characters that should be quoted from immediate
     interpretation on the command line) may be given as additional
     arguments, otherwise all suffixes are listed.

     Calling zsh-mime-setup with the option -v causes verbose output to
     be shown during the setup operation.

     The system respects the mailcap flags needsterminal and
     copiousoutput, see man page mailcap(4).

     The functions use the following styles, which are defined with the
     zstyle builtin command (see The zsh/zutil Module).  They
     should be defined before zsh-mime-setup is run.  The contexts used
     all start with :mime:, 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.
    current-shell
          If this boolean style is true, the mailcap handler for the
          context in question is run using the eval builtin instead of
          by starting a new sh process.  This is more efficient, but
          may not work in the occasional cases where the mailcap
          handler uses strict POSIX syntax.

    execute-as-is
          This style gives a list of patterns to be matched against
          files passed for execution with a handler program.  If the
          file matches the pattern, the entire command line is executed
          in its current form, with no handler.  This is useful for
          files which might have suffixes but nonetheless be executable
          in their own right.  If the style is not set, the pattern
          *(*) *(/) is used; hence executable files are executed
          directly and not passed to a handler, and the option AUTO_CD
          may be used to change to directories that happen to have MIME
          suffixes.

    file-path
          Used if the style find-file-in-path is true for the same
          context.  Set to an array of directories that are used for
          searching for the file to be handled; the default is the
          command path given by the special parameter path.  The shell
          option PATH_DIRS is respected; if that is set, the
          appropriate path will be searched even if the name of the
          file to be handled as it appears on the command line contains
          a `/'.  The full context is :mime:.SUFFIX:, as described for
          the style handler.

    find-file-in-path
          If set, allows files whose names do not contain absolute paths
          to be searched for in the command path or the path specified
          by the file-path style.  If the file is not found in the
          path, it is looked for locally (whether or not the current
          directory is in the path); if it is not found locally, the
          handler will abort unless the handle-nonexistent style is
          set.  Files found in the path are tested as described for the
          style execute-as-is.  The full context is :mime:.SUFFIX:, as
          described for the style handler.

    flags
          Defines flags to go with a handler; the context is as for the
          handler style, and the format is as for the flags in mailcap.

    handle-nonexistent
          By default, arguments that don't correspond to files are not
          passed to the MIME handler in order to prevent it from
          intercepting commands found in the path that happen to have
          suffixes.  This style may be set to an array of extended glob
          patterns for arguments that will be passed to the handler
          even if they don't exist.  If it is not explicitly set it
          defaults to [[:alpha:]]#:/* which allows URLs to be passed to
          the MIME handler even though they don't exist in that format
          in the file system.  The full context is :mime:.SUFFIX:, as
          described for the style handler.

    handler
          Specifies a handler for a suffix; the suffix is given by the
          context as :mime:.SUFFIX:, and the format of the handler is
          exactly that in mailcap.  Note in particular the `.' and
          trailing colon to distinguish this use of the context.  This
          overrides any handler specified by the mailcap files.  If the
          handler requires a terminal, the flags style should be set to
          include the word needsterminal, or if the output is to be
          displayed through a pager (but not if the handler is itself a
          pager), it should include copiousoutput.

    mailcap
          A list of files in the format of ~/.mailcap and /etc/mailcap
          to be read during setup, replacing the default list which
          consists of those two files.  The context is :mime:.  A + in
          the list will be replaced by the default files.

    mailcap-priorities
          This style is used to resolve multiple mailcap entries for
          the same MIME type.  It consists of an array of the following
          elements, in descending order of priority; later entries will
          be used if earlier entries are unable to resolve the entries
          being compared.  If none of the tests resolve the entries,
          the first entry encountered is retained.

         files
               The order of files (entries in the mailcap style) read.
               Earlier files are preferred.  (Note this does not
               resolve entries in the same file.)

         priority
               The priority flag from the mailcap entry.  The priority
               is an integer from 0 to 9 with the default value being 5.

         flags
               The test given by the mailcap-prio-flags option is used
               to resolve entries.

         place
               Later entries are preferred; as the entries are strictly
               ordered, this test always succeeds.

          Note that as this style is handled during initialisation, the
          context is always :mime:, with no discrimination by suffix.

    mailcap-prio-flags
          This style is used when the keyword flags is encountered in
          the list of tests specified by the mailcap-priorities style.
          It should be set to a list of patterns, each of which is
          tested against the flags specified in the mailcap entry (in
          other words, the sets of assignments found with some entries
          in the mailcap file).  Earlier patterns in the list are
          preferred to later ones, and matched patterns are preferred
          to unmatched ones.

    mime-types
          A list of files in the format of ~/.mime.types and
          /etc/mime.types to be read during setup, replacing the
          default list which consists of those two files.  The context
          is :mime:.  A + in the list will be replaced by the default
          files.

    never-background
          If this boolean style is set, the handler for the given
          context is always run in the foreground, even if the flags
          provided in the mailcap entry suggest it need not be (for
          example, it doesn't require a terminal).

    pager
          If set, will be used instead of $PAGER or more to handle
          suffixes where the copiousoutput flag is set.  The context is
          as for handler, i.e. :mime:.SUFFIX: for handling a file with
          the given SUFFIX.

     Examples:

          zstyle ':mime:*' mailcap ~/.mailcap /usr/local/etc/mailcap
          zstyle ':mime:.txt:' handler less %s
          zstyle ':mime:.txt:' flags needsterminal

     When zsh-mime-setup is subsequently run, it will look for mailcap
     entries in the two files given.  Files of suffix .txt will be
     handled by running `less FILE.TXT'.  The flag needsterminal is set
     to show that this program must run attached to a terminal.

     As there are several steps to dispatching a command, the following
     should be checked if attempting to execute a file by extension
     .EXT does not have the expected effect.

     The command `alias -s EXT' should show `ps=zsh-mime-handler'.  If
     it shows something else, another suffix alias was already
     installed and was not overwritten.  If it shows nothing, no
     handler was installed:  this is most likely because no handler was
     found in the .mime.types and mailcap combination for .ext files.
     In that case, appropriate handling should be added to
     ~/.mime.types and mailcap.

     If the extension is handled by zsh-mime-handler 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 zsh-mime-setup -l will show the handler and, if there are
     any, the flags.  A %s in the handler is replaced by the file
     (suitably quoted if necessary).  Check that the handler program
     listed lists and can be run in the way shown.  Also check that the
     flags needsterminal or copiousoutput 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 mailcap entry
     for such a program is:

          text/html; /usr/bin/lynx '%s'; needsterminal

     Running `zsh-mime-handler -l COMMAND LINE' prints the command line
     that would be executed, simplified to remove the effect of any
     flags, and quoted so that the output can be run as a complete zsh
     command line.  This is used by the completion system to decide how
     to complete after a file handled by zsh-mime-setup.

pick-web-browser
     This function is separate from the two MIME functions described
     above and can be assigned directly to a suffix:

          autoload -U pick-web-browser
          alias -s html=pick-web-browser

     It is provided as an intelligent front end to dispatch a web
     browser.  It may be run as either a function or a shell script.
     The status 255 is returned if no browser could be started.

     Various styles are available to customize the choice of browsers:

    browser-style
          The value of the style is an array giving preferences in
          decreasing order for the type of browser to use.  The values
          of elements may be

         running
               Use a GUI browser that is already running when an X
               Window display is available.  The browsers listed in the
               x-browsers style are tried in order until one is found;
               if it is, the file will be displayed in that browser, so
               the user may need to check whether it has appeared.  If
               no running browser is found, one is not started.
               Browsers other than Firefox, Opera and Konqueror are
               assumed to understand the Mozilla syntax for opening a
               URL remotely.

         x
               Start a new GUI browser when an X Window display is
               available.  Search for the availability of one of the
               browsers listed in the x-browsers style and start the
               first one that is found.  No check is made for an already
               running browser.

         tty
               Start a terminal-based browser.  Search for the
               availability of one of the browsers listed in the
               tty-browsers style and start the first one that is found.

          If the style is not set the default running x tty is used.

    x-browsers
          An array in decreasing order of preference of browsers to use
          when running under the X Window System.  The array consists
          of the command name under which to start the browser.  They
          are looked up in the context :mime: (which may be extended in
          future, so appending `*' is recommended).  For example,

               zstyle ':mime:*' x-browsers opera konqueror firefox

          specifies that pick-web-browser should first look for a
          running instance of Opera, Konqueror or Firefox, in that
          order, and if it fails to find any should attempt to start
          Opera.  The default is firefox mozilla netscape opera
          konqueror.

    tty-browsers
          An array similar to x-browsers, except that it gives browsers
          to use use when no X Window display is available.  The
          default is elinks links lynx.

    command
          If it is set this style is used to pick the command used to
          open a page for a browser.  The context is
          :mime:browser:new:$browser: to start a new browser or
          :mime:browser:running:$browser: to open a URL in a browser
          already running on the current X display, where $browser is
          the value matched in the x-browsers or tty-browsers style.
          The escape sequence %b in the style's value will be replaced
          by the browser, while %u will be replaced by the URL.  If the
          style is not set, the default for all new instances is
          equivalent to %b %u and the defaults for using running
          browsers are equivalent to the values kfmclient openURL %u for
          Konqueror, firefox -new-tab %u for Firefox, opera -newpage %u
          for Opera, and %b -remote "openUrl(%u)" for all others.

26.9 Mathematical Functions
===========================

zcalc [ EXPRESSION ... ]
     A reasonably powerful calculator based on zsh's arithmetic
     evaluation facility.  The syntax is similar to that of formulae in
     most programming languages; see Arithmetic Evaluation for
     details.  The mathematical library zsh/mathfunc will be loaded if
     it is available; see The zsh/mathfunc Module.  The
     mathematical functions correspond to the raw system libraries, so
     trigonometric 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 `4> ' is available as $4.
     The last value calculated is available as ans.  Full command line
     editing, including the history of previous calculations, is
     available; the history is saved in the file ~/.zcalc_history.  To
     exit, enter a blank line or type `:q' on its own (`q' is allowed
     for historical compatibility).

     If arguments are given to zcalc 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 PI (3.14159...) and E (2.71828...) are provided.
     Parameter assignment is possible, but note that all parameters
     will be put into the global namespace.

     The output base can be initialised by passing the option `-#BASE',
     for example `zcalc -#16' (the `#' may have to be quoted, depending
     on the globbing options set).

     The prompt is configurable via the parameter ZCALCPROMPT, which
     undergoes standard prompt expansion.  The index of the current
     entry is stored locally in the first element of the array psvar,
     which can be referred to in ZCALCPROMPT as `%1v'.  The default
     prompt is `%1v> '.

     A few special commands are available; these are introduced by a
     colon.  For backward compatibility, the colon may be omitted for
     certain commands.  Completion is available if compinit has been
     run.

     The output precision may be specified within zcalc by special
     commands familiar from many calculators.
    :norm
          The default output format.  It corresponds to the printf %g
          specification.  Typically this shows six decimal digits.

    :sci DIGITS
          Scientific notation, corresponding to the printf %g output
          format with the precision given by DIGITS.  This produces
          either fixed point or exponential notation depending on the
          value output.

    :fix DIGITS
          Fixed point notation, corresponding to the printf %f output
          format with the precision given by DIGITS.

    :eng DIGITS
          Exponential notation, corresponding to the printf %E output
          format with the precision given by DIGITS.

    :raw
          Raw output:  this is the default form of the output from a
          math evaluation.  This may show more precision than the
          number actually possesses.

     Other special commands:
    :!LINE...
          Execute LINE... as a normal shell command line.  Note that it
          is executed in the context of the function, i.e. with local
          variables.  Space is optional after :!.

    :local ARG ...
          Declare variables local to the function.  Note that certain
          variables are used by the function for its own purposes.
          Other variables may be used, too, but they will be taken from
          or put into the global scope.

    :function NAME [ BODY ]
          Define a mathematical function or (with no BODY) delete it.
          The function is defined using zmathfuncdef, see below.

          Note that zcalc takes care of all quoting.  Hence for example:

               function cube $1 * $1 * $1

          defines a function to cube the sole argument.

    [#BASE]
          This is not a special command, rather part of normal
          arithmetic syntax; however, when this form appears on a line
          by itself the default output radix is set to BASE.  Use, for
          example, `[#16]' to display hexadecimal output preceded by an
          indication of the base, or `[##16]' just to display the raw
          number in the given base.  Bases themselves are always
          specified in decimal. `[#]' restores the normal output format.
          Note that setting an output base suppresses floating point
          output; use `[#]' to return to normal operation.

     See the comments in the function for a few extra tips.

zmathfuncdef [ MATHFUNC [ BODY ] ]
     A convenient front end to functions -M.

     With two arguments, define a mathematical function named MATHFUNC
     which can be used in any form of arithmetic evaluation.  BODY is a
     mathematical expression to implement the function.  It may contain
     references to position parameters $1, $2, ...  to refer to
     mandatory parameters and ${1:-DEFVALUE} ...  to refer to optional
     parameters.  Note that the forms must be strictly adhered to for
     the function to calculate the correct number of arguments.  The
     implementation is held in a shell function named
     zsh_math_func_MATHFUNC; usually the user will not need to refer to
     the shell function directly.  Any existing function of the same
     name is silently replaced.

     With one argument, remove the mathematical function MATHFUNC as
     well as the shell function implementation.

     With no arguments, list all MATHFUNC functions in a form suitable
     for restoring the definition.  The functions have not necessarily
     been defined by zmathfuncdef.

26.10 User Configuration Functions
==================================

The zsh/newuser module comes with a function to aid in configuring
shell options for new users.  If the module is installed, this function
can also be run by hand.  It is available even if the module's default
behaviour, namely running the function for a new user logging in without
startup files, is inhibited.

zsh-newuser-install [ -f ]
     The function presents the user with various options for customizing
     their initialization scripts.  Currently only ~/.zshrc is handled.
     $ZDOTDIR/.zshrc is used instead if the parameter ZDOTDIR is set;
     this provides a way for the user to configure a file without
     altering an existing .zshrc.

     By default the function exits immediately if it finds any of the
     files .zshenv, .zprofile, .zshrc, or .zlogin in the appropriate
     directory.  The option -f is required in order to force the
     function to continue.  Note this may happen even if .zshrc itself
     does not exist.

     As currently configured, the function will exit immediately if the
     user has root privileges; this behaviour cannot be overridden.

     Once activated, the function's behaviour is supposed to be
     self-explanatory.  Menus are present allowing the user to alter
     the value of options and parameters.  Suggestions for improvements
     are always welcome.

     When the script exits, the user is given the opportunity to save
     the new file or not; changes are not irreversible until this
     point.  However, the script is careful to restrict changes to the
     file only to a group marked by the lines `# Lines configured by
     zsh-newuser-install' and `# End of lines configured by
     zsh-newuser-install'.  In addition, the old version of .zshrc is
     saved to a file with the suffix .zni appended.

     If the function edits an existing .zshrc, it is up to the user to
     ensure that the changes made will take effect.  For example, if
     control usually returns early from the existing .zshrc the lines
     will not be executed; or a later initialization file may override
     options or parameters, and so on.  The function itself does not
     attempt to detect any such conflicts.

26.11 Other Functions
=====================

There are a large number of helpful functions in the Functions/Misc
directory of the zsh distribution.  Most are very simple and do not
require documentation here, but a few are worthy of special mention.

26.11.1 Descriptions
--------------------

colors
     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 Prompt Themes).
     You seldom should need to run colors more than once.

     The eight base colors are: black, red, green, yellow, blue,
     magenta, cyan, and white.  Each of these has codes for foreground
     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 integer
          codes to the color names.  The eight base names map to the
          foreground color codes, as do names prefixed with `fg-', such
          as `fg-red'.  Names prefixed with `bg-', such as `bg-blue',
          refer to the background codes.  The reverse mapping from code
          to color yields base name for foreground codes and the bg-
          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
    fg_bold
    fg_no_bold
          Map the eight basic color names to ANSI terminal escape
          sequences that set the corresponding foreground text
          properties.  The fg sequences change the color without
          changing the eight intensity attributes.

    bg
    bg_bold
    bg_no_bold
          Map the eight basic color names to ANSI terminal escape
          sequences that set the corresponding background properties.
          The bg sequences change the color without changing the eight
          intensity attributes.

     In addition, the scalar parameters reset_color and bold_color are
     set to the ANSI terminal escapes that turn off all attributes and
     turn on bold intensity, respectively.

fned NAME
     Same as zed -f.  This function does not appear in the zsh
     distribution, but can be created by linking zed to the name fned
     in some directory in your fpath.

is-at-least 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, $ZSH_VERSION is used.
     Segments 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.

          is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS
          is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS
          is-at-least 2.6-17 || print "You can't use is-at-least here."

nslookup [ ARG ... ]
     This wrapper function for the nslookup command requires the
     zsh/zpty module (see The zsh/zpty Module).  It behaves
     exactly like the standard nslookup except that it provides
     customizable prompts (including a right-side prompt) and
     completion of nslookup commands, host names, etc. (if you use the
     function-based completion system).  Completion styles may be set
     with the context prefix `:completion:nslookup'.

     See also the pager, prompt and rprompt styles below.

regexp-replace VAR REGEXP REPLACE
     Use regular expressions to perform a global search and replace
     operation on a variable.  If the option RE_MATCH_PCRE is not set,
     POSIX extended regular expressions are used, else Perl-compatible
     regular expressions (this requires the shell to be linked against
     the pcre library).

     VAR is the name of the variable containing the string to be
     matched.  The variable will be modified directly by the function.
     The variables MATCH, MBEGIN, MEND, match, mbegin, mend should be
     avoided as these are used by the regular expression code.

     REGEXP is the regular expression to match against the string.

     REPLACE is the replacement text.  This can contain parameter,
     command and arithmetic expressions which will be replaced:  in
     particular, a reference to $MATCH will be replaced by the text
     matched by the pattern.

     The return status is 0 if at least one match was performed, else 1.

run-help CMD
     This function is designed to be invoked by the run-help ZLE widget,
     in place of the default alias.  See `Accessing On-Line Help'
     (see Utilities) for setup instructions.

     In the discussion which follows, if CMD is a file system path, it
     is first reduced to its rightmost component (the file name).

     Help is first sought by looking for a file named CMD in the
     directory named by the HELPDIR parameter.  If no file is found, an
     assistant function, alias, or command named run-help-CMD is
     sought.  If found, the assistant is executed with the rest of the
     current command line (everything after the command name CMD) as
     its arguments.  When neither file nor assistant is found, the
     external command `man CMD' is run.

     An example assistant for the "ssh" command:

          run-help-ssh() {
              emulate -LR zsh
              local -a args
              # Delete the "-l username" option
              zparseopts -D -E -a args l:
              # Delete other options, leaving: host command
              args=(${@:#-*})
              if [[ ${#args} -lt 2 ]]; then
                  man ssh
              else
                  run-help $args[2]
              fi
          }

     Several of these assistants are provided in the Functions/Misc
     directory.  These must be autoloaded, or placed as executable
     scripts in your search path, in order to be found and used by
     run-help.

    run-help-git
    run-help-svk
    run-help-svn
          Assistant functions for the git, svk, and svn commands.

tetris
     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:

          autoload -U tetris
          zle -N tetris
          bindkey KEYS tetris

     To start a game, execute the widget by typing the KEYS.  Whatever
     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 `q') or when you lose.

     If you quit in the middle of a game, the next invocation of the
     tetris widget will continue where you left off.  If you lost, it
     will start a new game.

zargs [ OPTION ... -- ] [ INPUT ... ] [ -- COMMAND [ ARG ... ] ]
     This function works like GNU xargs, except that instead of reading
     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 zargs command itself,
     which are the same as those of xargs.  The INPUT list is the
     collection of strings (often file names) that become the arguments
     of the command, analogous to the standard input of xargs.
     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 input list in each run.
     If no COMMAND is provided, then no ARG list may be provided, and
     in that event the default command is `print' with arguments `-r
     --'.

     For example, to get a long ls listing of all plain files in the
     current directory or its subdirectories:

          autoload -U zargs
          zargs -- **/*(.) -- ls -l

     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 -e
     option may be used to change the end-of-inputs marker.  Note that
     this does _not_ change the end-of-options marker.  For example, to
     use `..' as the marker:

          zargs -e.. -- **/*(.) .. ls -l

     This is a good choice in that example because no plain file can be
     named `..', but the best end-marker depends on the circumstances.

     For details of the other zargs options, see man page xargs(1) or
     run zargs with the --help option.

zed [ -f ] NAME
zed -b
     This function uses the ZLE editor to edit a file or function.

     Only one NAME argument is allowed.  If the -f option is given, the
     name is taken to be that of a function; if the function is marked
     for autoloading, zed searches for it in the fpath and loads it.
     Note that functions edited this way are installed into the current
     shell, but _not_ written back to the autoload file.

     Without -f, 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 zed and the vi
     command keymap to zed-vicmd.  These will be copied from the
     existing main and vicmd keymaps if they do not exist the first
     time zed is run.  They can be used to provide special key bindings
     used only in zed.

     If it creates the keymap, zed rebinds the return key to insert a
     line break and `^X^W' to accept the edit in the zed keymap, and
     binds `ZZ' to accept the edit in the zed-vicmd keymap.

     The bindings alone can be installed by running `zed -b'.  This is
     suitable for putting into a startup file.  Note that, if rerun,
     this will overwrite the existing zed and zed-vicmd keymaps.

     Completion is available, and styles may be set with the context
     prefix `:completion:zed'.

     A zle widget zed-set-file-name is available.  This can be called by
     name from within zed using `\ex zed-set-file-name' (note, however,
     that because of zed's rebindings you will have to type ^j at the
     end instead of the return key), or can be bound to a key in either
     of the zed or zed-vicmd keymaps after `zed -b' 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 `zed -f'.

     While zed-set-file-name is running, zed uses the keymap
     zed-normal-keymap, 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.

zcp [ -finqQvwW ] SRCPAT DEST
zln [ -finqQsvwW ] SRCPAT DEST
     Same as zmv -C and zmv -L, respectively.  These functions do not
     appear in the zsh distribution, but can be created by linking zmv
     to the names zcp and zln in some directory in your fpath.

zkbd
     See `Keyboard Definition' (see Utilities).

zmv [ -finqQsvwW ] [ -C | -L | -M | -p PROGRAM ] [ -o OPTSTRING ] SRCPAT DEST
     Move (usually, rename) files matching the pattern SRCPAT to
     corresponding 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,

          zmv '(*).lis' '$1.txt'

     renames `foo.lis' to `foo.txt', `my.old.stuff.lis' to
     `my.old.stuff.txt', and so on.

     The pattern is always treated as an EXTENDED_GLOB 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 -f was not given) causes the entire
     function to abort without doing anything.

     Options:

    -f
          Force overwriting of destination files.  Not currently passed
          down to the mv/cp/ln command due to vagaries of
          implementations (but you can use -o-f to do that).

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

    -n
          No execution: print what would happen, but don't do it.

    -q
          Turn bare glob qualifiers off: now assumed by default, so
          this has no effect.

    -Q
          Force bare glob qualifiers on.  Don't turn this on unless you
          are actually using glob qualifiers in a pattern.

    -s
          Symbolic, passed down to ln; only works with -L.

    -v
          Verbose: print each command as it's being executed.

    -w
          Pick out wildcard parts of the pattern, as described above,
          and implicitly add parentheses for referring to them.

    -W
          Just like -w, with the addition of turning wildcards in the
          replacement pattern into sequential ${1} .. ${N} references.

    -C
    -L
    -M
          Force cp, ln or mv, respectively, regardless of the name of
          the function.

    -p PROGRAM
          Call PROGRAM instead of cp, ln or mv.  Whatever it does, it
          should at least understand the form
               PROGRAM -- OLDNAME NEWNAME
          where OLDNAME and NEWNAME are filenames generated by zmv.

    -o OPTSTRING
          The OPTSTRING is split into words and passed down verbatim to
          the cp, ln or mv command called to perform the work.  It
          should probably begin with a `-'.

     Further examples:

          zmv -v '(* *)' '${1// /_}'

     For any file in the current directory with at least one space in
     the name, replace every space by an underscore and display the
     commands executed.

     For more complete examples and other implementation details, see
     the zmv source file, usually located in one of the directories
     named in your fpath, or in Functions/Misc/zmv in the zsh
     distribution.

zrecompile
     See `Recompiling Functions' (see Utilities).

zstyle+ 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:

          zstyle+ ':foo:bar' style1 value1 \
                + ':baz'     style2 value2 \
                + ':frob'    style3 value3

     This defines `style1' with `value1' for the context :foo:bar as
     usual, but it also defines `style2' with `value2' for the context
     :foo:bar:baz and `style3' with `value3' for :foo:bar:frob.  Any
     SUBCONTEXT may be the empty string to re-use the first context
     unchanged.

26.11.2 Styles
--------------

insert-tab
     The zed function _sets_ this style in context `:completion:zed:*'
     to turn off completion when TAB is typed at the beginning of a
     line.  You may override this by setting your own value for this
     context and style.

pager
     The nslookup function looks up this style in the context
     `:nslookup' to determine the program used to display output that
     does not fit on a single screen.

prompt
rprompt
     The nslookup function looks up this style in the context
     `:nslookup' to set the prompt and the right-side prompt,
     respectively.  The usual expansions for the PS1 and RPS1
     parameters may be used (see Prompt Expansion).