<HTML> <HEAD> <!-- Created by texi2html 1.56k from ./zsh.texi on 26 June 2001 --> <TITLE>zsh - User Contributions</TITLE> </HEAD> <BODY> Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_22.html">previous</A>, <A HREF="zsh_24.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>. <P><HR><P> <H1><A NAME="SEC180" HREF="zsh_toc.html#TOC180">User Contributions</A></H1> <P> <A NAME="IDX1499"></A> <H2><A NAME="SEC181" HREF="zsh_toc.html#TOC181">Description</A></H2> <P> <P> 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. <P> <P> <H2><A NAME="SEC182" HREF="zsh_toc.html#TOC182">Utilities</A></H2> <P> <P> <H3><A NAME="SEC183" HREF="zsh_toc.html#TOC183">Accessing On-Line Help</A></H3> <P> <A NAME="IDX1500"></A> <P> The key sequence <TT>ESC h</TT> is normally bound by ZLE to execute the <TT>run-help</TT> widget (see section <A HREF="zsh_17.html#SEC84">Zsh Line Editor</A>). This invokes the <TT>run-help</TT> command with the command word from the current input line as its argument. By default, <TT>run-help</TT> is an alias for the <TT>man</TT> command, so this often fails when the command word is a shell builtin or a user-defined function. By redefining the <TT>run-help</TT> alias, one can improve the on-line help provided by the shell. <P> The <TT>helpfiles</TT> utility, found in the <TT>Util</TT> 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 <TT>run-help</TT> function, found in <TT>Functions/Misc</TT>, searches for these helpfiles and performs several other tests to produce the most complete help possible for the command. <P> There may already be a directory of help files on your system; look in <TT>/usr/share/zsh</TT> or <TT>/usr/local/share/zsh</TT> and subdirectories below those, or ask your system administrator. <P> To create your own help files with <TT>helpfiles</TT>, choose or create a directory where the individual command help files will reside. For example, you might choose <TT>~/zsh_help</TT>. If you unpacked the zsh distribution in your home directory, you would use the commands: <P> <PRE> mkdir ~/zsh_help cd ~/zsh_help man zshall | colcrt - | \ perl ~/zsh-4.0.1-dev-0/Util/helpfiles </PRE> <P> <A NAME="IDX1501"></A> Next, to use the <TT>run-help</TT> function, you need to add lines something like the following to your <TT>.zshrc</TT> or equivalent startup file: <P> <PRE> unalias run-help autoload run-help HELPDIR=~/zsh_help </PRE> <P> <A NAME="IDX1502"></A> The <TT>HELPDIR</TT> parameter tells <TT>run-help</TT> where to look for the help files. If your system already has a help file directory installed, set <TT>HELPDIR</TT> to the path of that directory instead. <P> Note that in order for `<TT>autoload run-help</TT>' to work, the <TT>run-help</TT> file must be in one of the directories named in your <TT>fpath</TT> array (see section <A HREF="zsh_14.html#SEC74">Parameters Used By The Shell</A>). This should already be the case if you have a standard zsh installation; if it is not, copy <TT>Functions/Misc/run-help</TT> to an appropriate directory. <P> <H3><A NAME="SEC184" HREF="zsh_toc.html#TOC184">Recompiling Functions</A></H3> <P> <A NAME="IDX1503"></A> <A NAME="IDX1504"></A> <P> 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 <TT>zcompile</TT> 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 <TT>fpath</TT>, zsh won't check whether any of its source files has changed. <P> The <TT>zrecompile</TT> autoloadable function, found in <TT>Functions/Misc</TT>, can be used to keep function digests up to date. <P> <DL COMPACT> <DT><TT>zrecompile</TT> [ <TT>-qt</TT> ] [ <VAR>name</VAR> ... ] <DD> <A NAME="IDX1505"></A> <DT><TT>zrecompile</TT> [ <TT>-qt</TT> ] <TT>-p</TT> <VAR>args</VAR> [ <TT>-</TT><TT>-</TT> <VAR>args</VAR> ... ] <DD> This tries to find <TT>*.zwc</TT> 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 <TT>.zwc</TT> file. In the first form, each <VAR>name</VAR> is the name of a compiled file or a directory containing <TT>*.zwc</TT> files that should be checked. If no arguments are given, the directories and <TT>*.zwc</TT> files in <TT>fpath</TT> are used. When <TT>-t</TT> 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 <TT>-q</TT> option quiets the chatty output that describes what <TT>zrecompile</TT> is doing. Without the <TT>-t</TT> option, the return status is zero if all files that needed re-compilation could be compiled and non-zero if compilation for at least one of the files failed. If the <TT>-p</TT> option is given, the <VAR>args</VAR> are interpreted as one or more sets of arguments for <TT>zcompile</TT>, separated by `<TT>-</TT><TT>-</TT>'. For example: <PRE> zrecompile -p \ -R ~/.zshrc -- \ -M ~/.zcompdump -- \ ~/zsh/comp.zwc ~/zsh/Completion/*/_* </PRE> This compiles <TT>~/.zshrc</TT> into <TT>~/.zshrc.zwc</TT> if that doesn't exist or if it is older than <TT>~/.zshrc</TT>. The compiled file will be marked for reading instead of mapping. The same is done for <TT>~/.zcompdump</TT> and <TT>~/.zcompdump.zwc</TT>, but this compiled file is marked for mapping. The last line re-creates the file <TT>~/zsh/comp.zwc</TT> if any of the files matching the given pattern is newer than it. Without the <TT>-p</TT> option, <TT>zrecompile</TT> does not create function digests that do not already exist, nor does it add new functions to the digest. </DL> <P> The following shell loop is an example of a method for creating function digests for all functions in your <TT>fpath</TT>, assuming that you have write permission to the directories: <P> <PRE> 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 </PRE> <P> The <TT>-U</TT> and <TT>-z</TT> options are appropriate for functions in the default zsh installation <TT>fpath</TT>; you may need to use different options for your personal function directories. <P> Once the digests have been created and your <TT>fpath</TT> modified to refer to them, you can keep them up to date by running <TT>zrecompile</TT> with no arguments. <P> <H3><A NAME="SEC185" HREF="zsh_toc.html#TOC185">Keyboard Definition</A></H3> <P> <A NAME="IDX1506"></A> <P> <A NAME="IDX1507"></A> 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 <TT>zkbd</TT> utility, found in Functions/Misc, can help you quickly create key bindings for your configuration. <P> Run <TT>zkbd</TT> either as an autoloaded function, or as a shell script: <P> <PRE> zsh -f ~/zsh-4.0.1-dev-0/Functions/Misc/zkbd </PRE> <P> When you run <TT>zkbd</TT>, 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; <TT>zkbd</TT> warns you if it finds anything out of the ordinary, such as a Delete key that sends neither <TT>^H</TT> nor <TT>^?</TT>. <P> The keystrokes read by <TT>zkbd</TT> are recorded as a definition for an associative array named <TT>key</TT>, written to a file in the subdirectory <TT>.zkbd</TT> within either your <TT>HOME</TT> or <TT>ZDOTDIR</TT> directory. The name of the file is composed from the <TT>TERM</TT>, <TT>VENDOR</TT> and <TT>OSTYPE</TT> parameters, joined by hyphens. <P> You may read this file into your <TT>.zshrc</TT> or another startup file with the "source" or "." commands, then reference the <TT>key</TT> parameter in bindkey commands, like this: <P> <PRE> source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$VENDOR-$OSTYPE [[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char [[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char # etc. </PRE> <P> Note that in order for `<TT>autoload zkbd</TT>' to work, the <TT>zkdb</TT> file must be in one of the directories named in your <TT>fpath</TT> array (see section <A HREF="zsh_14.html#SEC74">Parameters Used By The Shell</A>). This should already be the case if you have a standard zsh installation; if it is not, copy <TT>Functions/Misc/zkbd</TT> to an appropriate directory. <P> <H3><A NAME="SEC186" HREF="zsh_toc.html#TOC186">Dumping Shell State</A></H3> <P> <A NAME="IDX1508"></A> <P> 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 section <A HREF="zsh_2.html#SEC6">Mailing Lists</A>), but sometimes one of the zsh developers will need to recreate your environment in order to track the problem down. <P> The script named <TT>reporter</TT>, found in the <TT>Util</TT> directory of the distribution, is provided for this purpose. (It is also possible to <TT>autoload reporter</TT>, but <TT>reporter</TT> is not installed in <TT>fpath</TT> by default.) This script outputs a detailed dump of the shell state, in the form of another script that can be read with `<TT>zsh -f</TT>' to recreate that state. <P> To use <TT>reporter</TT>, read the script into your shell with the `<TT>.</TT>' command and redirect the output into a file: <P> <PRE> . ~/zsh-4.0.1-dev-0/Util/reporter > zsh.report </PRE> <P> You should check the <TT>zsh.report</TT> 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. <P> You can also use <TT>reporter</TT> 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 <TT>aliases</TT>, <TT>options</TT>, and <TT>zstyles</TT> states may be useful because they include only changes from the defaults. The <TT>bindings</TT> state may be useful if you have created any of your own keymaps, because <TT>reporter</TT> arranges to dump the keymap creation commands as well as the bindings for every keymap. <P> As is usual with automated tools, if you create a startup file with <TT>reporter</TT>, you should edit the results to remove unnecessary commands. Note that if you're using the new completion system, you should <EM>not</EM> dump the <TT>functions</TT> state to your startup files with <TT>reporter</TT>; use the <TT>compdump</TT> function instead (see section <A HREF="zsh_19.html#SEC105">Completion System</A>). <P> <DL COMPACT> <DT><TT>reporter</TT> [ <VAR>state</VAR> ... ] <DD> <A NAME="IDX1509"></A> Print to standard output the indicated subset of the current shell state. The <VAR>state</VAR> arguments may be one or more of: <DL COMPACT> <DT><TT>all</TT> <DD> Output everything listed below. <DT><TT>aliases</TT> <DD> Output alias definitions. <DT><TT>bindings</TT> <DD> Output ZLE key maps and bindings. <DT><TT>completion</TT> <DD> Output old-style <TT>compctl</TT> commands. New completion is covered by <TT>functions</TT> and <TT>zstyles</TT>. <DT><TT>functions</TT> <DD> Output autoloads and function definitions. <DT><TT>limits</TT> <DD> Output <TT>limit</TT> commands. <DT><TT>options</TT> <DD> Output <TT>setopt</TT> commands. <DT><TT>styles</TT> <DD> Same as <TT>zstyles</TT>. <DT><TT>variables</TT> <DD> Output shell parameter assignments, plus <TT>export</TT> commands for any environment variables. <DT><TT>zstyles</TT> <DD> Output <TT>zstyle</TT> commands. </DL> If the <VAR>state</VAR> is omitted, <TT>all</TT> is assumed. With the exception of `<TT>all</TT>', every <VAR>state</VAR> can be abbreviated by any prefix, even a single letter; thus <TT>a</TT> is the same as <TT>aliases</TT>, <TT>z</TT> is the same as <TT>zstyles</TT>, etc. </DL> <P> <H2><A NAME="SEC187" HREF="zsh_toc.html#TOC187">Prompt Themes</A></H2> <P> <P> <H3><A NAME="SEC188" HREF="zsh_toc.html#TOC188">Installation</A></H3> <P> <P> You should make sure all the functions from the <TT>Functions/Prompts</TT> directory of the source distribution are available; they all begin with the string `<TT>prompt_</TT>' except for the special function`<TT>promptinit</TT>'. You also need the `<TT>colors</TT>' function from <TT>Functions/Misc</TT>. 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 <TT>fpath</TT> array (this should already be the case if they were installed), and at least the function <TT>promptinit</TT> should be autoloaded; it will autoload the rest. Finally, to initialize the use of the system you need to call the <TT>promptinit</TT> function. The following code in your <TT>.zshrc</TT> will arrange for this; assume the functions are stored in the directory <TT>~/myfns</TT>: <P> <PRE> fpath=(~/myfns $fpath) autoload -U promptinit promptinit </PRE> <P> <H3><A NAME="SEC189" HREF="zsh_toc.html#TOC189">Theme Selection</A></H3> <P> <P> Use the <TT>prompt</TT> command to select your preferred theme. This command may be added to your <TT>.zshrc</TT> following the call to <TT>promptinit</TT> in order to start zsh with a theme already selected. <P> <DL COMPACT> <DT><TT>prompt</TT> [ <TT>-c</TT> | <TT>-l</TT> ] <DD> <DT><TT>prompt</TT> [ <TT>-p</TT> | <TT>-h</TT> ] [ <VAR>theme</VAR> ... ] <DD> <DT><TT>prompt</TT> [ <TT>-s</TT> ] <VAR>theme</VAR> [ <VAR>arg</VAR> ... ] <DD> Set or examine the prompt theme. With no options and a <VAR>theme</VAR> argument, the theme with that name is set as the current theme. The available themes are determined at run time; use the <TT>-l</TT> option to see a list. The special <VAR>theme</VAR> `<TT>random</TT>' selects at random one of the available themes and sets your prompt to that. In some cases the <VAR>theme</VAR> 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: <DL COMPACT> <DT><TT>-c</TT> <DD> Show the currently selected theme and its parameters, if any. <DT><TT>-l</TT> <DD> List all available prompt themes. <DT><TT>-p</TT> <DD> Preview the theme named by <VAR>theme</VAR>, or all themes if no <VAR>theme</VAR> is given. <DT><TT>-h</TT> <DD> Show help for the theme named by <VAR>theme</VAR>, or for the <TT>prompt</TT> function if no <VAR>theme</VAR> is given. <DT><TT>-s</TT> <DD> Set <VAR>theme</VAR> as the current theme and save state. </DL> <DT><TT>prompt_</TT><VAR>theme</VAR><TT>_setup</TT> <DD> Each available <VAR>theme</VAR> has a setup function which is called by the <TT>prompt</TT> 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. </DL> <P> <H2><A NAME="SEC190" HREF="zsh_toc.html#TOC190">ZLE Functions</A></H2> <P> <P> <H3><A NAME="SEC191" HREF="zsh_toc.html#TOC191">Widgets</A></H3> <P> <P> These functions all implement user-defined ZLE widgets (see section <A HREF="zsh_17.html#SEC84">Zsh Line Editor</A>) which can be bound to keystrokes in interactive shells. To use them, your <TT>.zshrc</TT> should contain lines of the form <P> <PRE> autoload <VAR>function</VAR> zle -N <VAR>function</VAR> </PRE> <P> followed by an appropriate <TT>bindkey</TT> command to associate the function with a key sequence. Suggested bindings are described below. <P> <DL COMPACT> <DT><TT>cycle-completion-positions</TT> <DD> <A NAME="IDX1510"></A> After inserting an unambiguous string into the command line, the new function based completion system may know about multiple places in this string where characters are missing or differ from at least one of the possible matches. It will then place the cursor on the position it considers to be the most interesting one, i.e. the one where one can disambiguate between as many matches as possible with as little typing as possible. This widget allows the cursor to be easily moved to the other interesting spots. It can be invoked repeatedly to cycle between all positions reported by the completion system. <A NAME="IDX1511"></A> <DT><TT>edit-command-line</TT> <DD> Edit the command line using your visual editor, as in <TT>ksh</TT>. <PRE> bindkey -M vicmd v edit-command-line </PRE> <A NAME="IDX1512"></A> <A NAME="IDX1513"></A> <DT><TT>history-search-end</TT> <DD> This function implements the widgets <TT>history-beginning-search-backward-end</TT> and <TT>history-beginning-search-forward-end</TT>. These commands work by first calling the corresponding builtin widget (see section <A HREF="zsh_17.html#SEC93">History Control</A>) and then moving the cursor to the end of the line. The original cursor position is remembered and restored before calling the builtin widget a second time, so that the same search is repeated to look farther through the history. Although you <TT>autoload</TT> only one function, the commands to use it are slightly different because it implements two widgets. <PRE> zle -N history-beginning-search-backward-end \ history-search-end zle -N history-beginning-search-forward-end \ history-search-end bindkey '\e^P' history-beginning-search-backward-end bindkey '\e^N' history-beginning-search-forward-end </PRE> <A NAME="IDX1514"></A> <A NAME="IDX1515"></A> <DT><TT>incarg</TT> <DD> Typing the keystrokes for this widget with the cursor placed on or to the left of an integer causes that integer to be incremented by one. With a numeric prefix argument, the number is incremented by the amount of the argument (decremented if the prefix argument is negative). The shell parameter <TT>incarg</TT> may be set to change the default increment something other than one. <PRE> bindkey '^X+' incarg </PRE> <A NAME="IDX1516"></A> <DT><TT>incremental-complete-word</TT> <DD> This allows incremental completion of a word. After starting this command, a list of completion choices can be shown after every character you type, which you can delete with <TT>^H</TT> or <TT>DEL</TT>. Pressing return accepts the completion so far and returns you to normal editing (that is, the command line is <EM>not</EM> immediately executed). You can hit <TT>TAB</TT> to do normal completion, <TT>^G</TT> to abort back to the state when you started, and <TT>^D</TT> to list the matches. This works only with the new function based completion system. <PRE> bindkey '^Xi' incremental-complete-word </PRE> <A NAME="IDX1517"></A> <DT><TT>insert-files</TT> <DD> This function allows you type a file pattern, and see the results of the expansion at each step. When you hit return, all expansions are inserted into the command line. <PRE> bindkey '^Xf' insert-files </PRE> <A NAME="IDX1518"></A> <A NAME="IDX1519"></A> <DT><TT>predict-on</TT> <DD> This set of functions implements predictive typing using history search. After <TT>predict-on</TT>, typing characters causes the editor to look backward in the history for the first line beginning with what you have typed so far. After <TT>predict-off</TT>, editing returns to normal for the line found. In fact, you often don't even need to use <TT>predict-off</TT>, because if the line doesn't match something in the history, adding a key performs standard completion, and then inserts itself if no completions were found. However, editing in the middle of a line is liable to confuse prediction; see the <TT>toggle</TT> style below. With the function based completion system (which is needed for this), you should be able to type <TT>TAB</TT> at almost any point to advance the cursor to the next ``interesting'' character position (usually the end of the current word, but sometimes somewhere in the middle of the word). And of course as soon as the entire line is what you want, you can accept with return, without needing to move the cursor to the end first. The first time <TT>predict-on</TT> is used, it creates several additional widget functions: <DL COMPACT> <DT><TT>delete-backward-and-predict</TT> <DD> Replaces the <TT>backward-delete-char</TT> widget. You do not need to bind this yourself. <DT><TT>insert-and-predict</TT> <DD> Implements predictive typing by replacing the <TT>self-insert</TT> widget. You do not need to bind this yourself. <DT><TT>predict-off</TT> <DD> Turns off predictive typing. </DL> Although you <TT>autoload</TT> only the <TT>predict-on</TT> function, it is necessary to create a keybinding for <TT>predict-off</TT> as well. <PRE> zle -N predict-on zle -N predict-off bindkey '^X^Z' predict-on bindkey '^Z' predict-off </PRE> <A NAME="IDX1520"></A> <DT><TT>smart-insert-last-word</TT> <DD> This function may replace the <TT>insert-last-word</TT> widget, like so: <PRE> zle -N insert-last-word smart-insert-last-word </PRE> With a numeric prefix, it behaves like <TT>insert-last-word</TT>, except that words in comments are ignored when <TT>INTERACTIVE_COMMENTS</TT> is set. Otherwise, the rightmost ``interesting'' word from the previous command is found and inserted. The default definition of ``interesting'' is that the word contains at least one alphabetic character, slash, or backslash. This definition may be overridden by use of the <TT>match</TT> style. The context used to look up the style is the widget name, so usually the context is <TT>:insert-last-word</TT>. However, you can bind this function to different widgets to use different patterns: <PRE> zle -N insert-last-assignment smart-insert-last-word zstyle :insert-last-assignment match '[[:alpha:]][][[:alnum:]]#=*' bindkey '\e=' insert-last-assignment </PRE> </DL> <P> <H3><A NAME="SEC192" HREF="zsh_toc.html#TOC192">Styles</A></H3> <P> <P> The behavior of several of the above widgets can be controlled by the use of the <TT>zstyle</TT> mechanism. In particular, widgets that interact with the completion system pass along their context to any completions that they invoke. <P> <DL COMPACT> <DT><TT>break-keys</TT> <DD> <A NAME="IDX1521"></A> This style is used by the <TT>incremental-complete-word</TT> widget. Its value should be a pattern, and all keys matching this pattern will cause the widget to stop incremental completion without the key having any further effect. Like all styles used directly by <TT>incremental-complete-word</TT>, this style is looked up using the context `<TT>:incremental</TT>'. <A NAME="IDX1522"></A> <DT><TT>completer</TT> <DD> The <TT>incremental-complete-word</TT> and <TT>insert-and-predict</TT> widgets set up their top-level context name before calling completion. This allows one to define different sets of completer functions for normal completion and for these widgets. For example, to use completion, approximation and correction for normal completion, completion and correction for incremental completion and only completion for prediction one could use: <PRE> zstyle ':completion:*' completer \ _complete _correct _approximate zstyle ':completion:incremental:*' completer \ _complete _correct zstyle ':completion:predict:*' completer \ _complete </PRE> It is a good idea to restrict the completers used in prediction, because they may be automatically invoked as you type. The <TT>_list</TT> and <TT>_menu</TT> completers should never be used with prediction. The <TT>_approximate</TT>, <TT>_correct</TT>, <TT>_expand</TT>, and <TT>_match</TT> completers may be used, but be aware that they may change characters anywhere in the word behind the cursor, so you need to watch carefully that the result is what you intended. <A NAME="IDX1523"></A> <DT><TT>cursor</TT> <DD> The <TT>insert-and-predict</TT> widget uses this style, in the context `<TT>:predict</TT>', to decide where to place the cursor after completion has been tried. Values are: <DL COMPACT> <DT><TT>complete</TT> <DD> The cursor is left where it was when completion finished, but only if it is after a character equal to the one just inserted by the user. If it is after another character, this value is the same as `<TT>key</TT>'. <DT><TT>key</TT> <DD> The cursor is left after the <VAR>n</VAR>th occurrence of the character just inserted, where <VAR>n</VAR> is the number of times that character appeared in the word before completion was attempted. In short, this has the effect of leaving the cursor after the character just typed even if the completion code found out that no other characters need to be inserted at that position. </DL> Any other value for this style unconditionally leaves the cursor at the position where the completion code left it. <A NAME="IDX1524"></A> <DT><TT>list</TT> <DD> When using the <TT>incremental-complete-word</TT> widget, this style says if the matches should be listed on every key press (if they fit on the screen). Use the context prefix `<TT>:completion:incremental</TT>'. The <TT>insert-and-predict</TT> widget uses this style to decide if the completion should be shown even if there is only one possible completion. This is done if the value of this style is the string <TT>always</TT>. In this case the context is `<TT>:predict</TT>' (<EM>not</EM> `<TT>:completion:predict</TT>'). <A NAME="IDX1525"></A> <DT><TT>match</TT> <DD> This style is used by <TT>smart-insert-last-word</TT> to provide a pattern (using full <TT>EXTENDED_GLOB</TT> syntax) that matches an interesting word. The context is the name of the widget to which <TT>smart-insert-last-word</TT> is bound (see above). The default behavior of <TT>smart-insert-last-word</TT> is equivalent to: <PRE> zstyle :insert-last-word match '*[[:alpha:]/\\]*' </PRE> However, you might want to include words that contain spaces: <PRE> zstyle :insert-last-word match '*[[:alpha:][:space:]/\\]*' </PRE> Or include numbers as long as the word is at least two characters long: <PRE> zstyle :insert-last-word match '*([[:digit:]]?|[[:alpha:]/\\])*' </PRE> The above example causes redirections like "2>" to be included. <A NAME="IDX1526"></A> <DT><TT>prompt</TT> <DD> The <TT>incremental-complete-word</TT> widget shows the value of this style in the status line during incremental completion. The string value may contain any of the following substrings in the manner of the <TT>PS1</TT> and other prompt parameters: <DL COMPACT> <DT><TT>%c</TT> <DD> Replaced by the name of the completer function that generated the matches (without the leading underscore). <DT><TT>%l</TT> <DD> When the <TT>list</TT> style is set, replaced by `<TT>...</TT>' if the list of matches is too long to fit on the screen and with an empty string otherwise. If the <TT>list</TT> style is `false' or not set, `<TT>%l</TT>' is always removed. <DT><TT>%n</TT> <DD> Replaced by the number of matches generated. <DT><TT>%s</TT> <DD> Replaced by `<TT>-no match-</TT>', `<TT>-no prefix-</TT>', or an empty string if there is no completion matching the word on the line, if the matches have no common prefix different from the word on the line, or if there is such a common prefix, respectively. <DT><TT>%u</TT> <DD> Replaced by the unambiguous part of all matches, if there is any, and if it is different from the word on the line. </DL> Like `<TT>break-keys</TT>', this uses the `<TT>:incremental</TT>' context. <A NAME="IDX1527"></A> <DT><TT>stop-keys</TT> <DD> This style is used by the <TT>incremental-complete-word</TT> widget. Its value is treated similarly to the one for the <TT>break-keys</TT> style (and uses the same context: `<TT>:incremental</TT>'). However, in this case all keys matching the pattern given as its value will stop incremental completion and will then execute their usual function. <A NAME="IDX1528"></A> <DT><TT>toggle</TT> <DD> This boolean style is used by <TT>predict-on</TT> and its related widgets in the context `<TT>:predict</TT>'. If set to one of the standard `true' values, predictive typing is automatically toggled off in situations where it is unlikely to be useful, such as when editing a multi-line buffer or after moving into the middle of a line and then deleting a character. The default is to leave prediction turned on until an explicit call to <TT>predict-off</TT>. <A NAME="IDX1529"></A> <DT><TT>verbose</TT> <DD> This boolean style is used by <TT>predict-on</TT> and its related widgets in the context `<TT>:predict</TT>'. If set to one of the standard `true' values, these widgets display a message below the prompt when the predictive state is toggled. This is most useful in combination with the <TT>toggle</TT> style. The default does not display these messages. </DL> <P> <H2><A NAME="SEC193" HREF="zsh_toc.html#TOC193">Other Functions</A></H2> <P> <P> There are a large number of helpful functions in the <TT>Functions/Misc</TT> directory of the zsh distribution. Most are very simple and do not require documentation here, but a few are worthy of special mention. <P> <H3><A NAME="SEC194" HREF="zsh_toc.html#TOC194">Descriptions</A></H3> <P> <P> <DL COMPACT> <DT><TT>colors</TT> <DD> <A NAME="IDX1530"></A> 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 (section <A HREF="zsh_23.html#SEC187">Prompt Themes</A>). You seldom should need to run <TT>colors</TT> 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: <DL COMPACT> <DT>color <DD> <DT>colour <DD> 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 `<TT>fg-</TT>', such as `<TT>fg-red</TT>'. Names prefixed with `<TT>bg-</TT>', such as `<TT>bg-blue</TT>', refer to the background codes. The reverse mapping from code to color yields base name for foreground codes and the <TT>bg-</TT> 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. <DT>fg <DD> <DT>fg_bold <DD> <DT>fg_no_bold <DD> Map the eight basic color names to ANSI terminal escape sequences that set the corresponding foreground text properties. The <TT>fg</TT> sequences change the color without changing the eight intensity attributes. <DT>bg <DD> <DT>bg_bold <DD> <DT>bg_no_bold <DD> Map the eight basic color names to ANSI terminal escape sequences that set the corresponding background properties. The <TT>bg</TT> sequences change the color without changing the eight intensity attributes. </DL> In addition, the scalar parameters <TT>reset_color</TT> and <TT>bold_color</TT> are set to the ANSI terminal escapes that turn off all attributes and turn on bold intensity, respectively. <A NAME="IDX1531"></A> <DT><TT>fned</TT> <VAR>name</VAR> <DD> Same as <TT>zed -f</TT>. This function does not appear in the zsh distribution, but can be created by linking <TT>zed</TT> to the name <TT>fned</TT> in some directory in your <TT>fpath</TT>. <A NAME="IDX1532"></A> <DT><TT>is-at-least</TT> <VAR>needed</VAR> [ <VAR>present</VAR> ] <DD> 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 <VAR>present</VAR> string is not provided, <TT>$ZSH_VERSION</TT> 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. <PRE> 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." </PRE> <A NAME="IDX1533"></A> <DT><TT>nslookup</TT> [ <VAR>arg</VAR> ... ] <DD> This wrapper function for the <TT>nslookup</TT> command requires the <TT>zsh/zpty</TT> module (see section <A HREF="zsh_21.html#SEC160">The zsh/zpty Module</A>). It behaves exactly like the standard <TT>nslookup</TT> 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 `<TT>:completion:nslookup</TT>'. See also the <TT>pager</TT>, <TT>prompt</TT> and <TT>rprompt</TT> styles below. <DT><TT>run-help</TT> <DD> See `Accessing On-Line Help' (section <A HREF="zsh_23.html#SEC182">Utilities</A>). <A NAME="IDX1534"></A> <DT><TT>zed</TT> [ <TT>-f</TT> ] <VAR>name</VAR> <DD> This function uses the ZLE editor to edit a file or function. It rebinds the return key to insert a line break, and adds bindings for `<TT>^X^W</TT>' in the <TT>emacs</TT> keymap and `<TT>ZZ</TT>' in the <TT>vicmd</TT> keymap to accept (and therefore write, in the case of a file) the edited file or function. Keybindings are otherwise the standard ones; completion is available, and styles may be set with the context prefix `<TT>:completion:zed</TT>'. Only one <VAR>name</VAR> argument is recognized (additional arguments are ignored). If the <TT>-f</TT> option is given, the name is taken to be that of a function; if the function is marked for autoloading, <TT>zed</TT> searches for it in the <TT>fpath</TT> and loads it. Note that functions edited this way are installed into the current shell, but <EM>not</EM> written back to the autoload file. Without <TT>-f</TT>, <VAR>name</VAR> is the path name of the file to edit, which need not exist; it is created on write, if necessary. <A NAME="IDX1535"></A> <A NAME="IDX1536"></A> <DT><TT>zcp</TT> [ <TT>-finqQvw</TT> ] <VAR>srcpat</VAR> <VAR>dest</VAR> <DD> <DT><TT>zln</TT> [ <TT>-finqQsvw</TT> ] <VAR>srcpat</VAR> <VAR>dest</VAR> <DD> Same as <TT>zmv -C</TT> and <TT>zmv -L</TT>, respectively. These functions do not appear in the zsh distribution, but can be created by linking <TT>zmv</TT> to the names <TT>zcp</TT> and <TT>zln</TT> in some directory in your <TT>fpath</TT>. <DT><TT>zkbd</TT> <DD> See `Keyboard Definition' (section <A HREF="zsh_23.html#SEC182">Utilities</A>). <A NAME="IDX1537"></A> <DT><TT>zmv</TT> [ <TT>-finqQsvw</TT> ] [ -C | -L | -M | -p <VAR>program</VAR> ] [ -o <VAR>optstring</VAR> ] <VAR>srcpat</VAR> <VAR>dest</VAR> <DD> Move (usually, rename) files matching the pattern <VAR>srcpat</VAR> to corresponding files having names of the form given by <VAR>dest</VAR>, where <VAR>srcpat</VAR> contains parentheses surrounding patterns which will be replaced in turn by $1, $2, ... in <VAR>dest</VAR>. For example, <PRE> zmv '(*).lis' '$1.txt' </PRE> renames `<TT>foo.lis</TT>' to `<TT>foo.txt</TT>', `<TT>my.old.stuff.lis</TT>' to `<TT>my.old.stuff.txt</TT>', and so on. The pattern is always treated as an <TT>EXTENDED_GLOB</TT> 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 <TT>-f</TT> was not given) causes the entire function to abort without doing anything. Options: <DL COMPACT> <DT><TT>-f</TT> <DD> Force overwriting of destination files. Not currently passed down to the <TT>mv</TT>/<TT>cp</TT>/<TT>ln</TT> command due to vagaries of implementations (but you can use <TT>-o-f</TT> to do that). <DT><TT>-i</TT> <DD> 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. <DT><TT>-n</TT> <DD> No execution: print what would happen, but don't do it. <DT><TT>-q</TT> <DD> Turn bare glob qualifiers off: now assumed by default, so this has no effect. <DT><TT>-Q</TT> <DD> Force bare glob qualifiers on. Don't turn this on unless you are actually using glob qualifiers in a pattern. <DT><TT>-s</TT> <DD> Symbolic, passed down to <TT>ln</TT>; only works with <TT>-L</TT>. <DT><TT>-v</TT> <DD> Verbose: print each command as it's being executed. <DT><TT>-w</TT> <DD> Pick out wildcard parts of the pattern, as described above, and implicitly add parentheses for referring to them. <DT><TT>-C</TT> <DD> <DT><TT>-L</TT> <DD> <DT><TT>-M</TT> <DD> Force <TT>cp</TT>, <TT>ln</TT> or <TT>mv</TT>, respectively, regardless of the name of the function. <DT><TT>-p</TT> <VAR>program</VAR> <DD> Call <VAR>program</VAR> instead of <TT>cp</TT>, <TT>ln</TT> or <TT>mv</TT>. Whatever it does, it should at least understand the form <PRE> <VAR>program</VAR> <TT>-</TT><TT>-</TT> <VAR>oldname</VAR> <VAR>newname</VAR> </PRE> where <VAR>oldname</VAR> and <VAR>newname</VAR> are filenames generated by <TT>zmv</TT>. <DT><TT>-o</TT> <VAR>optstring</VAR> <DD> The <VAR>optstring</VAR> is split into words and passed down verbatim to the <TT>cp</TT>, <TT>ln</TT> or <TT>mv</TT> command called to perform the work. It should probably begin with a `<TT>-</TT>'. </DL> For more complete examples and other implementation details, see the <TT>zmv</TT> source file, usually located in one of the directories named in your <TT>fpath</TT>, or in <TT>Functions/Misc/zmv</TT> in the zsh distribution. <DT><TT>zrecompile</TT> <DD> See `Recompiling Functions' (section <A HREF="zsh_23.html#SEC182">Utilities</A>). <A NAME="IDX1538"></A> <DT><TT>zstyle+</TT> <VAR>context</VAR> <VAR>style</VAR> <VAR>value</VAR> [ + <VAR>subcontext</VAR> <VAR>style</VAR> <VAR>value</VAR> ... ] <DD> This makes defining styles a bit simpler by using a single `<TT>+</TT>' as a special token that allows you to append a context name to the previously used context name. Like this: <PRE> zstyle+ ':foo:bar' style1 value1 \ + ':baz' style2 value2 \ + ':frob' style3 value3 </PRE> This defines `style1' with `value1' for the context <TT>:foo:bar</TT> as usual, but it also defines `style2' with `value2' for the context <TT>:foo:bar:baz</TT> and `style3' with `value3' for <TT>:foo:bar:frob</TT>. Any <VAR>subcontext</VAR> may be the empty string to re-use the first context unchanged. </DL> <P> <H3><A NAME="SEC195" HREF="zsh_toc.html#TOC195">Styles</A></H3> <P> <P> <DL COMPACT> <DT><TT>insert-tab</TT> <DD> <A NAME="IDX1539"></A> The <TT>zed</TT> function <EM>sets</EM> this style in context `<TT>:completion:zed:*</TT>' to turn off completion when <TT>TAB</TT> is typed at the beginning of a line. You may override this by setting your own value for this context and style. <A NAME="IDX1540"></A> <DT><TT>pager</TT> <DD> The <TT>nslookup</TT> function looks up this style in the context `<TT>:nslookup</TT>' to determine the program used to display output that does not fit on a single screen. <A NAME="IDX1541"></A> <A NAME="IDX1542"></A> <DT><TT>prompt</TT> <DD> <DT><TT>rprompt</TT> <DD> The <TT>nslookup</TT> function looks up this style in the context `<TT>:nslookup</TT>' to set the prompt and the right-side prompt, respectively. The usual expansions for the <TT>PS1</TT> and <TT>RPS1</TT> parameters may be used (see section <A HREF="zsh_12.html#SEC39">Prompt Expansion</A>). </DL> <P><HR><P> Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_22.html">previous</A>, <A HREF="zsh_24.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>. </BODY> </HTML>