Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3f0657a9f30ee88f296a400e5fdb1578 > files > 11

fish-1.23.0-2mdv2010.0.i586.rpm

<html>
<head>
<title>fish user documentation</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<!--
Override the default doxygen stylesheet to make the difference between different header levels larger
-->
<style type='text/css'>
H1
{
	font-size: 180%;
}
H2
{
	font-size: 150%;
}
H3
{
	padding-left:10%;
	font-size: 120%;
}
H4
{
	padding-left:10%;
	font-style: italic;
	font-weight: normal;
	font-size: 90%;
}
</style>
</head>
<body>

<div class="qindex">

 <a class="qindex" href="http://www.fishshell.org"><tt>fish</tt> home</a> 
|
 <a class="qindex" href="index.html">Main documentation page</a> 
|
<a class="qindex" href="design.html">Design document</a>
|
<a class="qindex" href="commands.html">Commands</a>
|
<a class="qindex" href="faq.html">FAQ</a>
|
<a class="qindex" href="license.html">License</a>
 
</div>

<!-- Generated by Doxygen 1.4.4 -->
<h1><a class="anchor" name="commands">Commands, functions and builtins bundled with fish</a></h1>Fish ships with a large number of builtin commands, shellscript functions and external commands.<p>
These are all described below.<p>
<hr>
 <h2><a class="anchor" name="alias">
alias - create a function</a></h2>
<h3><a class="anchor" name="alias-synopsis">
Synopsis</a></h3>
<pre>alias NAME DEFINITION
alias NAME=DEFINITION</pre><h3><a class="anchor" name="alias-description">
Description</a></h3>
Alias is a shellscript wrapper around the function builtin. It exists for backwards compatibility with Posix shells. For other uses, it is recommended to define a function.<p>
Alias does not keep track of which functions have been defined using alias, nor does it allow erasing of aliases.<p>
<ul>
<li>NAME is the name of the function to define</li><li>DEFINITION is the body of the function. The string " $argv" will be appended to the body.</li></ul>
<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="and">
and - conditionally execute a command</a></h2>
<h3><a class="anchor" name="and-synopsis">
Synopsis</a></h3>
<code>COMMAND1; and COMMAND2</code><h3><a class="anchor" name="and-description">
Description</a></h3>
The <code>and</code> builtin is used to execute a command if the current exit status (as set by the last previous command) is 0.<p>
The and command does not change the current exit status.<p>
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.<h3><a class="anchor" name="and-example">
Example</a></h3>
The following code runs the <code>make</code> command to build a program, if the build succceeds, the program is installed. If either step fails, <code>make clean</code> is run, which removes the files created by the build process<p>
<pre>
make; and make install; or make clean
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="begin">
begin - start a new block of code</a></h2>
<h3><a class="anchor" name="begin-synopsis">
Synopsis</a></h3>
<code>begin; [COMMANDS...;] end</code><h3><a class="anchor" name="begin-description">
Description</a></h3>
The <code>begin</code> builtin is used to create a new block of code. The block is unconditionally executed. <code>begin; ...; end</code> is equivalent to <code>if true; ...; end</code>. The begin command is used to group any number of commands into a block. The reason for doing so is usually either to introduce a new variable scope, to redirect the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like <code>and</code>.<p>
The <code>begin</code> command does not change the current exit status.<h3><a class="anchor" name="begin-example">
Example</a></h3>
The following code sets a number of variables inside of a block scope. Since the variables are set inside the block and have local scope, they will be automatically deleted when the block ends.<p>
<pre>
begin
	set -l PIRATE Yarrr
	...
end
# This will not output anything, since the PIRATE variable went out
# of scope at the end of the block
echo $PIRATE
</pre><p>
In the following code, all output is redirected to the file out.html.<p>
<pre>
begin
	echo $xml_header
	echo $html_header
	if test -e $file 
		...
	end
	...</pre><p>
<pre>end &gt; out.html
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="bg">
bg - send to background</a></h2>
<h3><a class="anchor" name="bg-synopsis">
Synopsis</a></h3>
<code>bg [PID...]</code><h3><a class="anchor" name="bg-description">
Description</a></h3>
Sends the specified jobs to the background. A background job is executed simultaneously with fish, and does not have access to the keyboard. If no job is specified, the last job to be used is put in the background. If PID is specified, the jobs with the specified group ids are put in the background.<p>
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.<h3><a class="anchor" name="bg-example">
Example</a></h3>
<code>bg %0</code> will put the job with job id 0 in the background.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="bind">
bind - handle fish key bindings</a></h2>
<h3><a class="anchor" name="bind-synopsis">
Synopsis</a></h3>
<code>bind [OPTIONS] SEQUENCE COMMAND</code><h3><a class="anchor" name="bind-description">
Description</a></h3>
The <code>bind</code> builtin causes fish to add a key binding from the specified sequence.<p>
SEQUENCE is the character sequence to bind to. Usually, one would use fish escape sequences to express them. For example, Alt-w can be written as <code>\ew</code>, and Control-x can be written as <code>\cx</code>.<p>
If SEQUENCE is the empty string, i.e. an empty set of quotes, this is interpreted as the default keybinding. It will be used whenever no other binding matches. For most key bindings, it makes sense to use the <code>self-insert</code> function (i.e. <code>bind '' self-insert</code> as the default keybining. This will insert any keystrokes not specifically bound to into the editor. Non-printable characters are ignored by the editor, so this will not result in e.g. control sequences being printable.<p>
If the -k switch is used, the name of the key (such as down, up or backspace) is used instead of a sequence. The names used are the same as the corresponding curses variables, but without the 'key_' prefix. (See man 5 terminfo for more information, or use <code>bind --key-names</code> for a list of all available named keys)<p>
COMMAND can be any fish command, but it can also be one of a set of special input functions. These include functions for moving the cursor, operating on the kill-ring, performing tab completion, etc. Use 'bind --function-names' for a complete list of these input functions.<p>
When COMMAND is a shellscript command, it is a good practice to put the actual code into a <a href="#function">function</a> and simply bind to the function name. This way it becomes significantly easier to test the function while editing, and the result is usually more readable as well.<p>
<ul>
<li><code>-a</code> or <code>--all</code> If --key-names is specified, show all key names, not only the ones that actually are defined for the current terminal. If erase mode is specified, this switch will cause all current bindings to be erased.</li><li><code>-e</code> or <code>--erase</code> Erase mode. All non-switch arguments are interpreted as character sequences and any commands associated with those sequences are erased.</li><li><code>-h</code> or <code>--help</code> Display help and exit</li><li><code>-k</code> or <code>--key</code> Specify a key name, such as 'left' or 'backspace' instead of a character sequence</li><li><code>-K</code> or <code>--key-names</code> Display a list of available key names</li><li><code>-f</code> or <code>--function-names</code> Display a list of available input functions</li></ul>
<h3><a class="anchor" name="bind-example">
Example</a></h3>
<code>bind \cd 'exit'</code> causes fish to exit on Control-d<p>
<code>bind -k ppage history-search-backward</code> Causes fish to perform a history search when the page up key is pressed<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="block">
block - temporarily block delivery of events</a></h2>
<h3><a class="anchor" name="block-synopsis">
Synopsis</a></h3>
<code>block [OPTIONS...]</code><h3><a class="anchor" name="block-description">
Description</a></h3>
<ul>
<li><code>-l</code> or <code>--local</code> Release the block at the end of the currently innermost block scope</li><li><code>-g</code> or <code>--global</code> Never automatically release the lock</li><li><code>-e</code> or <code>--erase</code> Release global block</li></ul>
<h3><a class="anchor" name="block-example">
Example</a></h3>
<pre>
block -g
#Do something that should not be interrupted
block -e
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="breakpoint">
breakpoint - Launch debug mode</a></h2>
<h3><a class="anchor" name="breakpoint-synopsis">
Synopsis</a></h3>
<code>breakpoint</code><h3><a class="anchor" name="breakpoint-description">
Description</a></h3>
The <code>breakpoint</code> builtin is used to halt a running script and launch an interactive debug prompt.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="break">
break - stop the innermost currently evaluated loop</a></h2>
<h3><a class="anchor" name="break-synopsis">
Synopsis</a></h3>
<code>LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end</code><h3><a class="anchor" name="break-description">
Description</a></h3>
The <code>break</code> builtin is used to halt a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.<h3><a class="anchor" name="break-example">
Example</a></h3>
The following code searches all .c files for smurfs, and halts at the first occurrence.<p>
<pre>
for i in *.c
    if grep smurf $i
        echo Smurfs are present in $i
        break
    end
end
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="builtin">
builtin - run a builtin command</a></h2>
<h3><a class="anchor" name="builtin-synopsis">
Synopsis</a></h3>
<code>builtin BUILTINNAME [OPTIONS...]</code><h3><a class="anchor" name="builtin-description">
Description</a></h3>
<ul>
<li><code>-n</code> or <code>--names</code> List the names of all defined builtins</li></ul>
<p>
Prefixing a command with the word 'builtin' forces fish to ignore any functions with the same name.<h3><a class="anchor" name="builtin-example">
Example</a></h3>
<code>builtin jobs</code><p>
causes fish to execute the jobs builtin, even if a function named jobs exists.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="case">
case - conditionally execute a block of commands</a></h2>
<h3><a class="anchor" name="case-synopsis">
Synopsis</a></h3>
<code>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</code><h3><a class="anchor" name="case-description">
Description</a></h3>
The <code>switch</code> statement is used to perform one of several blocks of commands depending on whether a specified value equals one of several wildcarded values. The <code>case</code> statement is used together with the <code>switch</code> statement in order to determine which block should be performed.<p>
Each <code>case</code> command is given one or more parameter. The first <code>case</code> command with a parameter that matches the string specified in the switch command will be evaluated. <code>case</code> parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames.<p>
Note that fish does not fall through on case statements. Though the syntax may look a bit like C switch statements, it behaves more like the case statementes of traditional shells.<p>
Also note that command substitutions in a case statement will be evaluated even if it's body is not taken. This may seem counterintuitive at first, but it is unavoidable, since it would be impossible to know if a case command will evaluate to true before all forms of parameter expansion have been performed for the case command.<h3><a class="anchor" name="case-example">
Example</a></h3>
If the variable $animal contains the name of an animal, the following code would attempt to classify it:<p>
<pre>
switch $animal
    case cat
        echo evil
    case wolf dog human moose dolphin whale
        echo mammal
    case duck goose albatross
        echo bird
    case shark trout stingray
        echo fish
    case '*'
        echo I have no idea what a $animal is
end
</pre><p>
If the above code was run with <code>$animal</code> set to <code>whale</code>, the output would be <code>mammal</code>.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="cd">
cd - change directory</a></h2>
<h3><a class="anchor" name="cd-synopsis">
Synopsis</a></h3>
<code>cd [DIRECTORY]</code><h3><a class="anchor" name="cd-description">
Description Changes the current</a></h3>
directory. If <code>DIRECTORY</code> is supplied it will become the new directory. If <code>DIRECTORY</code> is a relative path, the paths found in the CDPATH environment variable array will be tried as prefixes for the specified path. If CDPATH is not set, it is assumed to be '.'. If <code>DIRECTORY</code> is not specified, $HOME will be the new directory.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="commandline">
commandline - set or get the current commandline buffer</a></h2>
<h3><a class="anchor" name="commandline-synopsis">
Synopsis</a></h3>
<code>commandline [OPTIONS] [CMD]</code><h3><a class="anchor" name="commandline-description">
Description</a></h3>
<ul>
<li><code>CMD</code> is the new value of the commandline. If unspecified, the current value of the commandline is written to standard output. All output from the commandline builtin is escaped, i.e. quotes are removed, backslash escapes are expanded, etc..</li></ul>
<p>
The following switches change what the commandline builtin does<p>
<ul>
<li><code>-C</code> or <code>--cursor</code> set or get the current cursor position, not the contents of the buffer. If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position.</li><li><code>-f</code> or <code>--function</code> inject readline functions into the reader. This option can not be combined with any other option. It will cause any additional arguments to be interpreted as readline functions, and these functions will be injected into the reader, so that they will be returned to the reader before any additional actual key presses are read.</li></ul>
<p>
The following switches change the way <code>commandline</code> updates the commandline buffer<p>
<ul>
<li><code>-a</code> or <code>--append</code> do not remove the current commandline, append the specified string at the end of it</li><li><code>-i</code> or <code>--insert</code> do not remove the current commandline, insert the specified string at the current cursor position</li><li><code>-r</code> or <code>--replace</code> remove the current commandline and replace it with the specified string (default)</li></ul>
<p>
The following switches change what part of the commandline is printed or updated<p>
<ul>
<li><code>-b</code> or <code>--current-buffer</code> select the entire buffer (default)</li><li><code>-j</code> or <code>--current-job</code> select the current job</li><li><code>-p</code> or <code>--current-process</code> select the current process</li><li><code>-t</code> or <code>--current-token</code> select the current token.</li></ul>
<p>
The following switch changes the way <code>commandline</code> prints the current commandline buffer<p>
<ul>
<li><code>-c</code> or <code>--cut-at-cursor</code> only print selection up until the current cursor position</li><li><code>-o</code> or <code>--tokenize</code> tokenize the selection and print one string-type token per line</li></ul>
<p>
If commandline is called during a call to complete a given string using <code>complete -C STRING</code>, commandline will consider the specified string to be the current contents of the commandline.<h3><a class="anchor" name="commandline-example">
Example</a></h3>
<code>commandline -j $history[3]</code><p>
replaces the job under the cursor with the third item from the commandline history.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="command">
command - run a program</a></h2>
<h3><a class="anchor" name="command-synopsis">
Synopsis</a></h3>
<code>command COMMANDNAME [OPTIONS...]</code><h3><a class="anchor" name="command-description">
Description</a></h3>
prefixing a command with the word 'command' forces fish to ignore any functions or builtins with the same name.<h3><a class="anchor" name="command-example">
Example</a></h3>
<code>command ls</code><p>
causes fish to execute the ls program, even if there exists a 'ls' function.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="complete">
complete - edit command specific tab-completions.</a></h2>
<h3><a class="anchor" name="complete-synopsis">
Synopsis</a></h3>
<code>complete (-c|--command|-p|--path) COMMAND [(-s|--short-option) SHORT_OPTION] [(-l|--long-option|-o|--old-option) LONG_OPTION [(-a||--arguments) OPTION_ARGUMENTS] [(-d|--description) DESCRIPTION] </code><h3><a class="anchor" name="complete-description">
Description</a></h3>
For an introduction to how to specify completions, see the section Writing your own completions of the fish manual.<p>
<ul>
<li><code>COMMAND</code> is the name of the command for which to add a completion</li><li><code>SHORT_OPTION</code> is a one character option for the command</li><li><code>LONG_OPTION</code> is a multi character option for the command</li><li><code>OPTION_ARGUMENTS</code> is parameter containing a space-separated list of possible option-arguments, which may contain subshells</li><li><code>DESCRIPTION</code> is a description of what the option and/or option arguments do</li><li><code>-C STRING</code> or <code>--do-complete=STRING</code> makes complete try to find all possible completions for the specified string</li><li><code>-e</code> or <code>--erase</code> implies that the specified completion should be deleted</li><li><code>-f</code> or <code>--no-files</code> specifies that the option specified by this completion may not be followed by a filename</li><li><code>-n</code> or <code>--condition</code> specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.</li><li><code>-o</code> or <code>--old-option</code> implies that the command uses old long style options with only one dash</li><li><code>-p</code> or <code>--path</code> implies that the string COMMAND is the full path of the command</li><li><code>-r</code> or <code>--require-parameter</code> specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option</li><li><code>-u</code> or <code>--unauthoritative</code> implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors</li><li><code>-A</code> or <code>--authoritative</code> implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors</li><li><code>-x</code> or <code>--exclusive</code> implies both <code>-r</code> and <code>-f</code></li></ul>
<p>
Command specific tab-completions in <code>fish</code> are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as '-h', '-help' or '--help'. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU version of the getopt library. These styles are:<p>
<ul>
<li>Short options, like '-a'. Short options are a single character long, are preceded by a single hyphen and may be grouped together (like '-la', which is equivalent to '-l -a'). Option arguments may be specified in the following parameter ('-w 32') or by appending the option with the value ('-w32').</li><li>Old style long options, like '-Wall'. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter ('-ao null').</li><li>GNU style long options, like '--colors'. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('--quoting-style shell') or by appending the option with a '=' and the value ('--quoting-style=shell'). GNU style long options may be abbreviated so long as the abbreviation is unique ('--h' is equivalent to '--help' if help is the only long option beginning with an 'h').</li></ul>
<p>
The options for specifying command name, command path, or command switches may all be used multiple times to specify multiple commands which have the same completion or multiple switches accepted by a command.<p>
When erasing completions, it is possible to either erase all completions for a specific command by specifying <code>complete -e -c COMMAND</code>, or by specifying a specific completion option to delete by specifying either a long, short or old style option.<h3><a class="anchor" name="complete-example">
Example</a></h3>
The short style option <code>-o</code> for the <code>gcc</code> command requires that a file follows it. This can be done using writing <code>complete -c gcc -s o -r</code>.<p>
The short style option <code>-d</code> for the <code>grep</code> command requires that one of the strings 'read', 'skip' or 'recurse' is used. This can be specified writing <code>complete -c grep -s d -x -a "read skip recurse"</code>.<p>
The <code>su</code> command takes any username as an argument. Usernames are given as the first colon-separated field in the file /etc/passwd. This can be specified as: <code>complete -x -c su -d "Username" -a "(cat /etc/passwd|cut -d : -f 1)" </code>.<p>
The <code>rpm</code> command has several different modes. If the <code>-e</code> or <code>--erase</code> flag has been specified, <code>rpm</code> should delete one or more packages, in which case several switches related to deleting packages are valid, like the <code>nodeps</code> switch.<p>
This can be written as:<p>
<code>complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d "Don't check dependencies"</code><p>
where <code>__fish_contains_opt</code> is a function that checks the commandline buffer for the presence of a specified set of options.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="contains">
contains - test if a word is present in a list</a></h2>
<h3><a class="anchor" name="contains-synopsis">
Synopsis</a></h3>
<code>contains [OPTIONS] KEY [VALUES...]</code><h3><a class="anchor" name="contains-description">
Description</a></h3>
<ul>
<li><code>-h</code> or <code>--help</code> display this message</li></ul>
<p>
Test if the set VALUES contains the string KEY. Return status is 0 if yes, 1 otherwise<h3><a class="anchor" name="contains-example">
Example</a></h3>
<pre>
for i in ~/bin /usr/local/bin
	if not contains $i $PATH
		set PATH $PATH i
	end
end
</pre><p>
The above code tests if ~/bin and /usr/local/bin are in the path and if they are not, they are added.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="continue">
continue - skip the rest of the current lap of the innermost currently evaluated loop</a></h2>
<h3><a class="anchor" name="continue-synopsis">
Synopsis</a></h3>
<code>LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end</code><h3><a class="anchor" name="continue-description">
Description</a></h3>
The <code>continue</code> builtin is used to skip the current lap of the innermost currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.<h3><a class="anchor" name="continue-example">
Example</a></h3>
The following code removes all tmp files without smurfs.<p>
<pre>
for i in *.tmp
    if grep smurf $i
        continue
    end
    rm $i
end
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="count">
count - count the number of elements of an array</a></h2>
<h3><a class="anchor" name="count-synopsis">
Synopsis</a></h3>
<code>count $VARIABLE</code><h3><a class="anchor" name="count-description">
Description</a></h3>
The <code>count</code> builtin prints the number of arguments that were passed to it. This is usually used to find out how many elements an environment variable array contains, but this is not the only potential usage for the count command.<p>
The count command does not accept any options, not even '-h'. This way the user does not have to worry about an array containing elements such as dashes. <code>fish</code> performs a special check when invoking the count command, and if the user uses a help option, this help page is displayed, but if a help option is contained inside of a variable or is the result of expansion, it will simply be counted like any other argument.<p>
Count exits with a non-zero exit status if no arguments where passed to it, with zero otherwise.<h3><a class="anchor" name="count-example">
Example</a></h3>
<pre>
count $PATH
</pre><p>
returns the number of directories in the users PATH variable.<p>
<pre>
count *.txt
</pre><p>
returns the number of files in the current working directory ending with the suffix '.txt'.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="dirh">
dirh - print directory history</a></h2>
<h3><a class="anchor" name="dirh-synopsis">
Synopsis</a></h3>
<code>dirh</code><h3><a class="anchor" name="dirh-description">
Description</a></h3>
<code>dirh</code> prints the current directory history. The current position in the history is highlighted using <code>$fish_color_history_current</code>.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="dirs">
dirs - print directory stack</a></h2>
<h3><a class="anchor" name="dirs-synopsis">
Synopsis</a></h3>
<code>dirs</code><h3><a class="anchor" name="dirs-description">
Description</a></h3>
<code>dirs</code> prints the current directory stack.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="else">
else - execute command if a condition is not met</a></h2>
<h3><a class="anchor" name="else-synopsis">
Synopsis</a></h3>
<code>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</code><h3><a class="anchor" name="else-description">
Description</a></h3>
<code>if</code> will execute the command CONDITION. If the condition's exit status is 0, the commands COMMANDS_TRUE will execute. If it is not 0 and <code>else</code> is given, COMMANDS_FALSE will be executed. Hint: use <a href="#begin"><code>begin; ...; end</code></a> for complex conditions.<h3><a class="anchor" name="else-example">
Example</a></h3>
The command <code>if test -f foo.txt; echo foo.txt exists; else; echo foo.txt does not exist; end</code> will print <code>foo.txt exists</code> if the file foo.txt exists and is a regular file, otherwise it will print <code>foo.txt does not exist</code>.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="emit">
emit - Emit a generic event</a></h2>
<h3><a class="anchor" name="block-synopsis">
Synopsis</a></h3>
<code>emit EVENT_NAME</code><h3><a class="anchor" name="emit-description">
Description</a></h3>
The emit builtin fires a generic fish event. Such events can be caught by special functions called event handlers.<h3><a class="anchor" name="emit-example">
Example</a></h3>
The following code first defines an event handler for the generic event named 'test_event', and then emits an event of that type.<p>
<pre>function event_test --on-event test_event
    echo event test!!!
end</pre><p>
<pre>emit test_event</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="end">
end - end a block of commands.</a></h2>
<h3><a class="anchor" name="end-synopsis">
Synopsis</a></h3>
<pre>
begin; [COMMANDS...] end
if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
while CONDITION; COMMANDS...; end
for VARNAME in [VALUES...]; COMMANDS...; end
switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
</pre><h3><a class="anchor" name="end-description">
Description</a></h3>
<code>end</code> ends a block of commands. For more information, read the documentation for the block constructs, such as <code>if</code>, <code>for</code> and <code>while</code>.<p>
The <code>end</code> command does not change the current exit status.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="eval">
eval - evaluate the specified commands</a></h2>
<h3><a class="anchor" name="eval-synopsis">
Synopsis</a></h3>
<code>eval [COMMANDS...]</code><h3><a class="anchor" name="eval-description">
Description</a></h3>
The <code>eval</code> function causes fish to evaluate the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.<h3><a class="anchor" name="eval-example">
Example</a></h3>
<pre>
set cmd ls
eval $cmd
</pre><p>
will call the ls command.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="exec">
exec - execute command in current process</a></h2>
<h3><a class="anchor" name="exec-synopsis">
Synopsis</a></h3>
<code>exec COMMAND [OPTIONS...]</code><h3><a class="anchor" name="exec-description">
Description</a></h3>
The <code>exec</code> builtin is used to replace the currently running shells process image with a new command. On successful completion, exec never returns. exec can not be used inside a pipeline.<h3><a class="anchor" name="exec-example">
Example</a></h3>
<code>exec emacs</code> starts up the emacs text editor. When emacs exits, the session will terminate.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="exit">
exit - exit the shell.</a></h2>
<h3><a class="anchor" name="exit-synopsis">
Synopsis</a></h3>
<code>exit [STATUS]</code><h3><a class="anchor" name="exit-description">
Description</a></h3>
The <code>exit</code> builtin causes fish to exit. If <code>STATUS</code> is supplied, it will be converted to an integer and used as the exit code. Otherwise the exit code will be that of the last command executed.<p>
If exit is called while sourcing a file (using the . builtin) the rest of the file will be skipped, but the shell itself will not exit.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="fg">
fg - send job to foreground</a></h2>
<h3><a class="anchor" name="fg-synopsis">
Synopsis</a></h3>
<code>fg [PID]</code><h3><a class="anchor" name="fg-description">
Description</a></h3>
Sends the specified job to the foreground. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group id is put in the foreground.<p>
The PID of the desired process is usually found by using <a href="index.html#expand-process">process expansion</a>.<h3><a class="anchor" name="fg-example">
Example</a></h3>
<code>fg %0</code> will put the job with job id 0 in the foreground.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="fishd">
fishd - universal variable daemon</a></h2>
<h3><a class="anchor" name="fishd-synopsis">
Synopsis</a></h3>
<code>fishd [(-h|--help|-v|--version)]</code><h3><a class="anchor" name="fishd-description">
Description</a></h3>
The <code>fishd</code> daemon is used to load, save and distribute universal variable information. fish automatically connects to fishd via a socket on startup. If no instance of fishd is running, fish spawns a new fishd instance. fishd will create a socket in /tmp, and wait for incoming connections from universal variable clients, such as fish, When no clients are connected, fishd will automatically shut down.<p>
<ul>
<li><code>-h</code> or <code>--help</code> displays this help message and then exits</li><li><code>-v</code> or <code>--version</code> displays the current fish version and then exits</li></ul>
<h3><a class="anchor" name="fishd-files">
Files</a></h3>
<code>~/</code>.config/fish/fishd.HOSTNAME permanent storage location for universal variable data. The data is stored as a set of <code>set</code> and <code>set_export</code> commands such as would be parsed by fishd. The file must always be stored in ASCII format. If an instance of fishd is running (which is generally the case), manual modifications to ~/.fishd.HOSTNAME will be lost. Do NOT edit this file manually!<p>
<code>/tmp/fishd</code>.socket.USERNAME the socket which fishd uses to communicate with all clients.<p>
/tmp/fishd.log.USERNAME the fishd log file<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="fish_indent">
fish_indent - indenter and prettyfier</a></h2>
<h3><a class="anchor" name="fish_indent-synopsis">
Synopsis</a></h3>
<code>fish_indent [options]</code><h3><a class="anchor" name="fish_indent-description">
Description</a></h3>
<code>fish_indent</code> is used to indent or otherwise prettyfy a piece of fish code. <code>fish_indent</code> reads commands from standard input and outputs them to standard output.<p>
<code>fish_indent</code> underatands the following options:<p>
<ul>
<li><code>-h</code> or <code>--help</code> displays this help message and then exits</li><li><code>-i</code> or <code>--no-indent</code> do not indent commands</li><li><code>-v</code> or <code>--version</code> displays the current fish version and then exits</li></ul>
<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="fish_pager">
fish_pager - internal command used by fish</a></h2>
<h3><a class="anchor" name="fish_pager-description">
Description</a></h3>
This command is used internally by fish to display a list of completions. It should not be used by other commands, as it's interface is liable to change in the future.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="fish_prompt">
fish_prompt - define the apperance of the command line promp</a></h2>
<h3><a class="anchor" name="fish_promt-synopsis">
Synopsis</a></h3>
<pre>function fish_prompt
    ...
end</pre><h3><a class="anchor" name="fish_prompt-description">
Description</a></h3>
By defining the <code>fish_prompt</code> function, the user can choose a custom prompt. The <code>fish_prompt</code> function is executed when the prompt is to be shown, and the output is used as a prompt.<h3><a class="anchor" name="fish_prompt-example">
Example</a></h3>
A simple prompt:<p>
<pre>
function fish_prompt -d "Write out the prompt"
	printf '%s@%s%s%s%s&gt; ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="fish">
fish - the friendly interactive shell</a></h2>
<h3><a class="anchor" name="fish-synopsis">
Synopsis</a></h3>
fish [-h] [-v] [-c command] [FILE [ARGUMENTS...]]<h3><a class="anchor" name="fish-description">
Description</a></h3>
A commandline shell written mainly with interactive use in mind. The full manual is available <a href="index.html">in html</a> by using the <a href="#help">help</a> command from inside fish.<p>
<ul>
<li><code>-c</code> or <code>--command=COMMANDS</code> evaluate the specified commands instead of reading from the commandline</li><li><code>-d</code> or <code>--debug-level=DEBUG_LEVEL</code> specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.</li><li><code>-h</code> or <code>--help</code> display help and exit</li><li><code>-i</code> or <code>--interactive</code> specify that fish is to run in interactive mode</li><li><code>-l</code> or <code>--login</code> specify that fish is to run as a login shell</li><li><code>-n</code> or <code>--no-execute</code> do not execute any commands, only perform syntax checking</li><li><code>-p</code> or <code>--profile=PROFILE_FILE</code> when fish exits, output timing information on all executed commands to the specified file</li><li><code>-v</code> or <code>--version</code> display version and exit</li></ul>
<p>
The fish exit status is generally the exit status of the last foreground command. If fish is exiting because of a parse error, the exit status is 127.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="for">
for - perform a set of commands multiple times.</a></h2>
<h3><a class="anchor" name="for-synopsis">
Synopsis</a></h3>
<code>for VARNAME in [VALUES...]; COMMANDS...; end</code><h3><a class="anchor" name="for-description">
Description</a></h3>
<code>for</code> is a loop construct. It will perform the commands specified by COMMANDS multiple times. Each time the environment variable specified by VARNAME is assigned a new value from VALUES. If VALUES is empty, COMMANDS will not be executed at all.<h3><a class="anchor" name="for-example">
Example</a></h3>
The command<p>
<code>for i in foo bar baz; echo $i; end</code><p>
would output:<p>
<pre>
foo
bar
baz
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="functions">
functions - print or erase functions</a></h2>
<h3><a class="anchor" name="function-synopsis">
Synopsis</a></h3>
<code>functions [-e] FUNCTIONS...</code><h3><a class="anchor" name="functions-description">
Description</a></h3>
This builtin command is used to print or erase functions.<p>
<ul>
<li><code>-a</code> or <code>--all</code> list all functions, even those whose name start with an underscore.</li><li><code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function</li><li><code>-e</code> or <code>--erase</code> causes the specified functions to be erased.</li><li><code>-h</code> or <code>--help</code> display a help message and exit</li><li><code>-n</code> or <code>--names</code> list only the names of all defined functions, not their definition</li><li><code>-q</code> or <code>--query</code> test if the specified functions exist. Does not output anything, but the builtins exit status is the number of functions specified that were not defined.</li></ul>
<p>
The default behavior of <code>functions</code> when called with no arguments, is to print the names and definitions of all defined functions. If any non-switch parameters are given, only the definition of the specified functions are printed.<p>
Automatically loaded functions can not be removed using functions -e. Either remove the definition file or change the $fish_function_path variable to remove autoloaded functions.<p>
The exit status of the functions builtin is the number functions specified in the argument list that do not exist.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="function">
function - create a function</a></h2>
<h3><a class="anchor" name="function-synopsis">
Synopsis</a></h3>
<code>function [OPTIONS] NAME; BODY; end </code><h3><a class="anchor" name="function-description">
Description</a></h3>
<ul>
<li><code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> is a description of what the function does, suitable as a completion description</li><li><code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group id PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.</li><li><code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process id PID exits</li><li><code>-s</code> or <code>--on-signal SIGSPEC</code> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP)</li><li><code>-v</code> or <code>--on-variable VARIABLE_NAME</code> tells fish to run this function when the variable VARIABLE_NAME changes value</li></ul>
<p>
This builtin command is used to create a new function. A function is a list of commands that will be executed when the name of the function is entered. The function<p>
<pre>
function hi
	echo hello
end
</pre><p>
will write <code>hello</code> whenever the user enters <code>hi</code>.<p>
If the user enters any additional arguments after the function, they are inserted into the environment <a href="index.html#variables-arrays">variable array</a> argv.<h3><a class="anchor" name="function-example">
Example</a></h3>
<pre>
function ll
	ls -l $argv
end
</pre><p>
will run the <code>ls</code> command, using the <code>-l</code> option, while passing on any additional files and switches to <code>ls</code>.<p>
<pre>
function mkdir -d "Create a directory and set CWD"
	mkdir $argv
	if test $status = 0
		switch $argv[(count $argv)]
			case '-*'</pre><p>
<pre>			case '*'
				cd $argv[(count $argv)]
				return
		end
	end
end
</pre><p>
will run the mkdir command, and if it is successful, change the current working directory to the one just created.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="help">
help - display fish documentation</a></h2>
<h3><a class="anchor" name="help-synopsis">
Synopsis</a></h3>
<code>help [SECTION]</code><h3><a class="anchor" name="help-description">
Description</a></h3>
The <code>help</code> command is used to display a section of the fish help documentation.<p>
If the BROWSER environment variable is set, it will be used to display the documentation, otherwise fish will search for a suitable browser.<p>
Note also that most builtin commands display their help in the terminal when given the <code>--help</code> option.<h3><a class="anchor" name="help-example">
Example</a></h3>
<code>help fg</code> shows the documentation for the <code>fg</code> builtin.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="if">
if - conditionally execute a command</a></h2>
<h3><a class="anchor" name="if-synopsis">
Synopsis</a></h3>
<code>if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end</code><h3><a class="anchor" name="if-description">
Description</a></h3>
<code>if</code> will execute the command CONDITION. If the condition's exit status is 0, the commands COMMANDS_TRUE will execute. If the exit status is not 0 and <code>else</code> is given, COMMANDS_FALSE will be executed.<p>
In order to use the exit status of multiple commands as the condition of an if block, use <a href="#begin"><code>begin; ...; end</code></a> and the short circuit commands <a href="commands.html#and">and</a> and or.<p>
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.<h3><a class="anchor" name="if-example">
Example</a></h3>
<pre>
if test -f foo.txt
	echo foo.txt exists
else
	echo foo.txt does not exist
end
</pre> will print <code>foo.txt exists</code> if the file foo.txt exists and is a regular file, otherwise it will print <code>foo.txt does not exist</code>.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="isatty">
isatty - test if the specified file descriptor is a tty</a></h2>
<h3><a class="anchor" name="isatty-synopsis">
Synopsis</a></h3>
<code>isatty [FILE DESCRIPTOR]</code><p>
where FILE DESCRIPTOR may be either the number of a file descriptor, or one of the strings stdin, stdout and stderr.<p>
If the specified file descriptor is a tty, the exit status of the command is zero, otherwise, it is non-zero.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="jobs">
jobs - print currently running jobs</a></h2>
<h3><a class="anchor" name="jobs-synopsis">
jobs-synopsis</a></h3>
<code>jobs [OPTIONS] [PID]</code><h3><a class="anchor" name="jobs-description">
Description</a></h3>
The <code>jobs</code> builtin causes fish to print a list of the currently running jobs and their status.<p>
jobs accepts the following switches:<p>
<ul>
<li><code>-c</code> or <code>--command</code> print the command name for each process in jobs</li><li><code>-g</code> or <code>--group</code> only print the group id of each job</li><li><code>-h</code> or <code>--help</code> display a help message and exit</li><li><code>-l</code> or <code>--last</code> only the last job to be started is printed</li><li><code>-p</code> or <code>--pid</code> print the process id for each process in all jobs</li></ul>
<p>
On systems that supports this feature, jobs will print the CPU usage of each job since the last command was executed. The CPU usage is expressed as a percentage of full CPU activity. Note that on multiprocessor systems, the total activity may be more than 100%.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
<h2><a class="anchor" name="math">
math - Perform mathematics calculations</a></h2>
<h3><a class="anchor" name="math-synopsis">
Synopsis</a></h3>
<code>math EXPRESSION</code><h3><a class="anchor" name="math-description">
Description</a></h3>
math is used to perform mathematical calculations. It is only a very thin wrapper for the bc program, that makes it possible to specify an expression from the command line without using non-standard extensions or a pipeline. Simply use a command like <code>math 1+1</code>.<p>
For a description of the syntax supported by math, see the manual for the bc program. Keep in mind that parameter expansion takes place on any expressions before they are evaluated. This can be very useful in order to perform calculations involving environment variables or the output of command substitutions, but it also means that parenthesis have to be escaped.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="mimedb">
mimedb - lookup file information via the mime database</a></h2>
<h3><a class="anchor" name="mimedb-synopsis">
Synopsis</a></h3>
<code>mimedb [OPTIONS] FILES...</code><h3><a class="anchor" name="mimedb-description">
Description</a></h3>
<ul>
<li><code>FILES</code> is a list of files to analyse</li><li><code>-t</code>, <code>--input-file-data</code> the specified files type should be determined both by their filename and by their contents (Default)</li><li><code>-f</code>, <code>--input-filename</code> the specified files type should be determined by their filename</li><li><code>-i</code>, <code>--input-mime</code> the arguments are not files but mimetypes</li><li><code>-m</code>, <code>--output-mime</code> the output will be the mimetype of each file (Default)</li><li><code>-f</code>, <code>--output-description</code> the output will be the description of each mimetype</li><li><code>-a</code>, <code>--output-action</code> the output will be the default action of each mimetype</li><li><code>-l</code>, <code>--launch</code> launch the default action for the specified file(s)</li><li><code>-h</code>, <code>--help</code> display a help message and exit</li><li><code>-v</code>, <code>--version</code> display version number and exit</li></ul>
<p>
The mimedb command is used to query the mimetype database and the .desktop files installed on the system in order to find information on a file. The information that mimedb can retrieve includes the mimetype for a file, a description of the type and what its default action is. mimedb can also be used to launch the default action for this file.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="nextd">
nextd - move forward through directory history</a></h2>
<h3><a class="anchor" name="nextd-synopsis">
Synopsis</a></h3>
<code>nextd [-l | --list] [pos]</code><h3><a class="anchor" name="nextd-description">
Description</a></h3>
<code>nextd</code> moves forwards <code>pos</code> positions in the history of visited directories; if the end of the history has been hit, a warning is printed. If the <code>-l&gt;</code> or <code>--list</code> flag is specified, the current history is also displayed.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="not">
not - negate the exit status of a job</a></h2>
<h3><a class="anchor" name="not-synopsis">
Synopsis</a></h3>
<code>not COMMAND [OPTIONS...]</code><h3><a class="anchor" name="not-description">
Description</a></h3>
The <code>not</code> builtin is used to negate the exit status of another command.<h3><a class="anchor" name="not-example">
Example</a></h3>
The following code reports an error and exits if no file named spoon can be found. <pre>
if not test -f spoon
	echo There is no spoon
	exit 1
end
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="open">
open - open file in it's default application</a></h2>
<h3><a class="anchor" name="open-synopsis">
Synopsis</a></h3>
<code>open FILES...</code><h3><a class="anchor" name="open-description">
Description</a></h3>
The <code>open</code> command is used to open a file in it's default application. <code>open</code> is implemented using the <a href="commands.html#mimedb">mimedb</a> command.<h3><a class="anchor" name="open-example">
Example</a></h3>
<code>open *.txt</code> opens all the text files in the current directory using your systems default text editor.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="or">
or - conditionally execute a command</a></h2>
<h3><a class="anchor" name="or-synopsis">
Synopsis</a></h3>
<code>COMMAND1; or COMMAND2</code><h3><a class="anchor" name="or-description">
Description</a></h3>
The <code>or</code> builtin is used to execute a command if the current exit status (as set by the last previous command) is not 0.<p>
The or command does not change the current exit status.<p>
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.<h3><a class="anchor" name="or-example">
Example</a></h3>
The following code runs the <code>make</code> command to build a program, if the build succceeds, the program is installed. If either step fails, <code>make clean</code> is run, which removes the files created by the build process<p>
<pre>
make; and make install; or make clean
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="popd">
popd - move through directory stack</a></h2>
<h3><a class="anchor" name="popd-synopsis">
Synopsis</a></h3>
<code>popd</code><h3><a class="anchor" name="popd-description">
Description</a></h3>
<code>popd</code> removes the top directory from the directory stack and cd's to the new top directory.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="prevd">
prevd - move backward through directory history</a></h2>
<h3><a class="anchor" name="prevd-synopsis">
Synopsis</a></h3>
<code>prevd [-l | --list] [pos]</code><h3><a class="anchor" name="prevd-description">
Description</a></h3>
<code>prevd</code> moves backwards <code>pos</code> positions in the history of visited directories; if the beginning of the history has been hit, a warning is printed. If the <code>-l</code> or <code>--list</code> flag is specified, the current history is also displayed.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="psub">
psub - perform process substitution</a></h2>
<h3><a class="anchor" name="psub-synopsis">
Synopsis</a></h3>
<code>COMMAND1 (COMMAND2|psub [-f]) </code><h3><a class="anchor" name="psub-description">
Description</a></h3>
Posix shells feature a syntax that is a mix between command substitution and piping, called process substitution. It is used to send the output of a command into the calling command, much like command substitution, but with the difference that the output is not sent through commandline arguments but through a named pipe, with the filename of the named pipe sent as an argument to the calling program. The psub shellscript function, which when combined with a regular command substitution provides the same functionality.<p>
If the <code>-f</code> or <code>--file</code> switch is given to psub, psub will use a regular file instead of a named pipe to communicate with the calling process. This will cause psub to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream.<h3><a class="anchor" name="psub-example">
Example</a></h3>
<code>diff (sort a.txt|psub) (sort b.txt|psub)</code> shows the difference between the sorted versions of files a.txt and b.txt.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="pushd">
pushd - push directory to directory stack</a></h2>
<h3><a class="anchor" name="pushd-synopsis">
Synopsis</a></h3>
<code>pushd [DIRECTORY]</code><h3><a class="anchor" name="pushd-description">
Description</a></h3>
The <code>pushd</code> function adds DIRECTORY to the top of the directory stack and makes it the current directory. Use <code>popd</code> to pop it off and and return to the original directory.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="random">
random - generate random number</a></h2>
<h3><a class="anchor" name="random-synopsis">
Synopsis</a></h3>
<code>random [SEED]</code><h3><a class="anchor" name="random-description">
Description</a></h3>
The <code>random</code> command is used to generate a random number in the interval 0&lt;=N&lt;32767. If an argument is given, it is used to seed the random number generator. This can be useful for debugging purposes, where it can be desirable to get the same random number sequence multiple times. If the random number generator is called without first seeding it, the current time will be used as the seed.<h3><a class="anchor" name="random-example">
Example</a></h3>
The following code will count down from a random number to 1:<p>
<pre>
for i in (seq (random) -1 1)
	echo $i
	sleep
end
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="read">
read - read line of input into variables</a></h2>
<h3><a class="anchor" name="read-synopsis">
Synopsis</a></h3>
<code>read [OPTIONS] [VARIABLES...]</code><h3><a class="anchor" name="read-description">
Description</a></h3>
The <code>read</code> builtin causes fish to read one line from standard input and store the result in one or more environment variables.<p>
<ul>
<li><code>-c CMD</code> or <code>--command=CMD</code> specifies that the initial string in the interactive mode command buffer should be CMD.</li><li><code>-e</code> or <code>--export</code> specifies that the variables will be exported to subshells.</li><li><code>-g</code> or <code>--global</code> specifies that the variables will be made global.</li><li><code>-m NAME</code> or <code>--mode-name=NAME</code> specifies that the name NAME should be used to save/load the history file. If NAME is fish, the regular fish history will be available.</li><li><code>-p PROMPT_CMD</code> or <code>--prompt=PROMPT_CMD</code> specifies that the output of the shell command PROMPT_CMD should be used as the prompt for the interactive mode prompt. The default prompt command is <code>set_color green; echo read; set_color normal; echo "&gt; "</code>.</li><li><code>-s</code> or <code>--shell</code> Use syntax highlighting, tab completions and command termination suitable for entering shellscript code</li><li><code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes</li><li><code>-U</code> or <code>--universal</code> causes the specified environment variable to be made universal. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.</li><li><code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes</li></ul>
<p>
Read starts by reading a single line of input from stdin, the line is then tokenized using the <code>IFS</code> environment variable. Each variable specified in <code>VARIABLES</code> is then assigned one tokenized string element. If there are more tokens than variables, the complete remainder is assigned to the last variable.<h3><a class="anchor" name="read-example">
Example</a></h3>
<code>echo hello|read foo</code><p>
Will cause the variable $foo to be assigned the value hello.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="return">
return - stop the innermost currently evaluated function</a></h2>
<h3><a class="anchor" name="return-synopsis">
Synopsis</a></h3>
<code>function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end</code><h3><a class="anchor" name="return-description">
Description</a></h3>
The <code>return</code> builtin is used to halt a currently running function. It is usually added inside of a conditional block such as an if statement or a <a href="#switch">switch</a> statement to conditionally stop the executing function and return to the caller, but it can also be used to specify the exit status of a function.<p>
<ul>
<li><code>STATUS</code> is the return status of the function. If unspecified, the status is unchanged.</li></ul>
<h3><a class="anchor" name="return-example">
Example</a></h3>
The following code is an implementation of the false command as a fish function<p>
<pre>
function false
	return 1
end
</pre><p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="save_function">
save_function - save the definition of a function to the users autoload directory</a></h2>
<h3><a class="anchor" name="save_function-synopsis">
Synopsis</a></h3>
<code>save_function FUNCTION_NAME</code><h3><a class="anchor" name="save_function-description">
Description</a></h3>
save_function is used to save the current definition of a function to a file which will be autoloaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="set_color">
set_color - set the terminal color</a></h2>
<h3><a class="anchor" name="set_color-synopsis">
Synopsis</a></h3>
<code>set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR]</code><h3><a class="anchor" name="set_color-description">
Description</a></h3>
Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal.<p>
<ul>
<li><code>-b</code>, <code>--background</code> Set the background color</li><li><code>-c</code>, <code>--print-colors</code> Prints a list of all valid color names</li><li><code>-h</code>, <code>--help</code> Display help message and exit</li><li><code>-o</code>, <code>--bold</code> Set bold or extra bright mode</li><li><code>-u</code>, <code>--underline</code> Set underlined mode</li><li><code>-v</code>, <code>--version</code> Display version and exit</li></ul>
<p>
Calling <code>set_color normal</code> will set the terminal color to whatever is the default color of the terminal.<p>
Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, <code>set_color white</code> will result in a grey font color, while <code>set_color --bold white</code> will result in a white font color.<p>
Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="set">
set - handle environment variables.</a></h2>
<h3><a class="anchor" name="set-synopsis">
Synopsis</a></h3>
<pre>
set [SCOPE_OPTIONS]
set [OPTIONS] VARIABLE_NAME VALUES...
set [OPTIONS] VARIABLE_NAME[INDICES]... VALUES...
set (-q | --query) [SCOPE_OPTIONS] VARIABLE_NAMES...
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME
set (-e | --erase) [SCOPE_OPTIONS] VARIABLE_NAME[INDICES]...
</pre><p>
The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_NAME</code> the values <code>VALUES...</code>.<h3><a class="anchor" name="set-description">
Description</a></h3>
<ul>
<li><code>-e</code> or <code>--erase</code> causes the specified environment variable to be erased</li><li><code>-l</code> or <code>--local</code> forces the specified environment variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local</li><li><code>-g</code> or <code>--global</code> causes the specified environment variable to be given a global scope. Non-global variables disappear when the block they belong to ends</li><li><code>-U</code> or <code>--universal</code> causes the specified environment variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.</li><li><code>-n</code> or <code>--names</code> List only the names of all defined variables, not their value</li><li><code>-q</code> or <code>--query</code> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.</li><li><code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes</li><li><code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes</li></ul>
<p>
If set is called with no arguments, the names and values of all environment variables are printed. If some of the scope or export flags have been given, only the variables matching the specified scope are printed.<p>
If a variable is set to more than one value, the variable will be an array with the specified elements. If a variable is set to zero elements, it will become an array with zero elements.<p>
If the variable name is one or more array elements, such as <code>PATH[1 3 7]</code>, only those array elements specified will be changed. When array indices are specified to set, multiple arguments may be used to specify additional indexes, e.g. <code>set PATH[1] PATH[4] /bin /sbin</code>. If you specify a negative index when expanding or assigning to an array variable, the index will be calculated from the end of the array. For example, the index -1 means the last index of an array.<p>
The scoping rules when creating or updating a variable are:<p>
<ol type=1>
<li>If a variable is explicitly set to either universal, global or local, that setting will be honored. If a variable of the same name exists in a different scope, that variable will not be changed.</li><li>If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previous variable scope is used.</li><li>If a variable is not explicitly set to be either universal, global or local and has never before been defined, the variable will be local to the currently executing functions. If no function is executing, the variable will be global.</li></ol>
<p>
The exporting rules when creating or updating a variable are identical to the scoping rules for variables:<p>
<ol type=1>
<li>If a variable is explicitly set to either be exported or not exported, that setting will be honored.</li><li>If a variable is not explicitly set to be exported or not exported, but has been previously defined, the previous exporting rule for the variable is kept.</li><li>If a variable is not explicitly set to be either exported or unexported and has never before been defined, the variable will not be exported.</li></ol>
<p>
In query mode, the scope to be examined can be specified.<p>
In erase mode, if variable indices are specified, only the specified slices of the array variable will be erased. When erasing an entire variable (i.e. no slicing), the scope of the variable to be erased can be specified. That way, a global variable can be erased even if a local variable with the same name exists. Scope can not be specified when erasing a slice of an array. The innermost scope is always used.<p>
The set command requires all switch arguments to come before any non-switch arguments. For example, <code>set flags -l</code> will have the effect of setting the value of the variable <code>flags</code> to '-l', not making the variable local.<p>
In assignment mode, set exits with an exit status of zero it the variable assignments where sucessfully performed, with a non-zero exit status otherwise. In query mode, the exit status is the number of variables that where not found. In erase mode, set exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.<h3><a class="anchor" name="set-example">
Example</a></h3>
<code>set -xg</code> will print all global, exported variables.<p>
<code>set foo hi</code> sets the value of the variable foo to be hi.<p>
<code>set -e smurf</code> removes the variable <code>smurf</code>.<p>
<code>set PATH[4] ~/bin</code> changes the fourth element of the <code>PATH</code> array to <code>~/bin</code> <p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="source">
. - evaluate contents of file.</a></h2>
<h3><a class="anchor" name="source-synopsis">
Synopsis</a></h3>
<code>. FILENAME [ARGUMENTS...]</code><h3><a class="anchor" name="source-description">
Description</a></h3>
Evaluates the commands of the specified file in the current shell. This is different from starting a new process to perform the commands (i.e. <code>fish &lt; FILENAME</code>) since the commands will be evaluated by the current shell, which means that changes in environment variables, etc., will remain. If additional arguments are specified after the file name, they will be inserted into the $argv variable.<p>
If no file is specified, or if the file name '-' is used, stdin will be read.<p>
The return status of . is the return status of the last job to execute. If something goes wrong while opening or reading the file, . exits with a non-zero status.<h3><a class="anchor" name="source-example">
Example</a></h3>
<code>. ~/.fish</code><p>
causes fish to reread its initialization file.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="status">
status - query fish runtime information</a></h2>
<h3><a class="anchor" name="status-synopsis">
Synopsis</a></h3>
<code>status [OPTION]</code><h3><a class="anchor" name="status-description">
Description</a></h3>
<ul>
<li><code>-c</code> or <code>--is-command-substitution</code> returns 0 if fish is currently executing a command substitution</li><li><code>-b</code> or <code>--is-block</code> returns 0 if fish is currently executing a block of code</li><li><code>-i</code> or <code>--is-interactive</code> returns 0 if fish is interactive, i.e.connected to a keyboard</li><li><code>-l</code> or <code>--is-login</code> returns 0 if fish is a login shell, i.e. if fish should perform login tasks such as setting up the PATH.</li><li><code>--is-full-job-control</code> returns 0 if full job control is enabled</li><li><code>--is-interactive-job-control</code> returns 0 if interactive job control is enabled</li><li><code>--is-no-job-control</code> returns 0 if no job control is enabled</li><li><code>-f</code> or <code>--current-filename</code> prints the filename of the currently running script</li><li><code>-n</code> or <code>--current-line-number</code> prints the line number of the currently running script</li><li><code>-j CONTROLTYPE</code> or <code>--job-control=CONTROLTYPE</code> set the job control type. Can be one of: none, full, interactive</li><li><code>-t</code> or <code>--print-stack-trace</code></li><li><code>-h</code> or <code>--help</code> display a help message and exit</li></ul>
<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="switch">
switch - conditionally execute a block of commands</a></h2>
<h3><a class="anchor" name="switch-synopsis">
Synopsis</a></h3>
<code>switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end</code><h3><a class="anchor" name="switch-description">
Description</a></h3>
The <code>switch</code> statement is used to perform one of several blocks of commands depending on whether a specified value equals one of several wildcarded values. The <code>case</code> statement is used together with the <code>switch</code> statement in order to determine which block should be performed.<p>
Each <code>case</code> command is given one or more parameter. The first <code>case</code> command with a parameter that matches the string specified in the switch command will be evaluated. <code>case</code> parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames.<p>
Note that fish does not fall through on case statements. Though the syntax may look a bit like C switch statements, it behaves more like the case statements of traditional shells.<p>
Also note that command substitutions in a case statement will be evaluated even if it's body is not taken. This may seem counterintuitive at first, but it is unavoidable, since it would be impossible to know if a case command will evaluate to true before all forms of parameter expansion have been performed for the case command.<h3><a class="anchor" name="switch-example">
Example</a></h3>
If the variable $animal contains the name of an animal, the following code would attempt to classify it:<p>
<pre>
switch $animal
    case cat
        echo evil
    case wolf dog human moose dolphin whale
        echo mammal
    case duck goose albatross
        echo bird
    case shark trout stingray
        echo fish
    case '*'
        echo I have no idea what a $animal is
end
</pre><p>
If the above code was run with <code>$animal</code> set to <code>whale</code>, the output would be <code>mammal</code>.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="trap">
trap - perform an action when the shell receives a signal</a></h2>
<h3><a class="anchor" name="trap-synopsis">
Synopsis</a></h3>
<code>trap [OPTIONS] [[ARG] SIGSPEC ... ]</code><h3><a class="anchor" name="trap-description">
Description</a></h3>
Trap is a shellscript wrapper around the fish event delivery framework. It exists for backwards compatibility with Posix shells. For other uses, it is recommended to define a event handler.<p>
<ul>
<li>ARG is the command to be executed on signal delivery</li><li>SIGSPEC is the name of the signal to trap</li><li><code>-h</code> or <code>--help</code> Display help and exit</li><li><code>-l</code> or <code>--list-signals</code> print a list of signal names</li><li><code>-p</code> or <code>--print</code> print all defined signal handlers</li></ul>
<p>
If ARG and SIGSPEC are both specified, ARG is the command to be executed when the signal specified by SIGSPEC is delivered.<p>
If ARG is absent (and there is a single SIGSPEC) or -, each specified signal is reset to its original disposition (the value it had upon entrance to the shell). If ARG is the null string the signal specified by each SIGSPEC is ignored by the shell and by the commands it invokes.<p>
If ARG is not present and -p has been supplied, then the trap commands associated with each SIGSPEC are displayed. If no arguments are supplied or if only -p is given, trap prints the list of commands associated with each signal.<p>
Signal names are case insensitive and the SIG prefix is optional.<p>
The return status is 1 if any SIGSPEC is invalid; otherwise trap returns 0.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="type">
type - indicate how a name would be interpreted if used as a command name</a></h2>
<h3><a class="anchor" name="type-synopsis">
Synopsis</a></h3>
<code>type [OPTIONS] name [name ...]</code><h3><a class="anchor" name="type-description">
Description</a></h3>
With no options, indicate how each name would be interpreted if used as a command name.<p>
<ul>
<li><code>-h</code> or <code>--help</code> print this message</li><li><code>-a</code> or <code>--all</code> print all of possible definitions of the specified names</li><li><code>-f</code> or <code>--no-functions</code> suppresses function and builtin lookup</li><li><code>-t</code> or <code>--type</code> print a string which is one of alias, keyword, function, builtin, or file if name is an alias, shell reserved word, function, builtin, or disk file, respectively</li><li><code>-p</code> or <code>--path</code> either return the name of the disk file that would be executed if name were specified as a command name, or nothing if 'type -t name' would not return 'file'</li><li><code>-P</code> or <code>--force-path</code> either return the name of the disk file that would be executed if name were specified as a command name, or nothing no file with the specified name could be found in the PATH</li></ul>
<p>
<code>type</code> returns a zero exit status if the specified command was found, otherwise the exit status is one.<h3><a class="anchor" name="type-example">
Example</a></h3>
<code>type fg</code> outputs the string 'fg is a shell builtin'.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="ulimit">
ulimit - set or get the shells resource usage limits</a></h2>
<h3><a class="anchor" name="ulimit-synopsis">
Synopsis</a></h3>
<code>ulimit [OPTIONS] [LIMIT]</code><h3><a class="anchor" name="ulimit-description">
Description</a></h3>
The ulimit builtin is used to set the resource usage limits of the shell and any processes spawned by it. If a new limit value is omitted, the current value of the limit of the resource is printed.<p>
Use one of the following switches to specify which resource limit to set or report:<p>
<ul>
<li><code>-c</code> or <code>--core-size</code> The maximum size of core files created. By setting this limit to zero, core dumps can be disabled.</li><li><code>-d</code> or <code>--data-size</code> The maximum size of a process's data segment</li><li><code>-f</code> or <code>--file-size</code> The maximum size of files created by the shell</li><li><code>-l</code> or <code>--lock-size</code> The maximum size that may be locked into memory</li><li><code>-m</code> or <code>--resident-set-size</code> The maximum resident set size</li><li><code>-n</code> or <code>--file-descriptor-count</code> The maximum number of open file descriptors (most systems do not allow this value to be set)</li><li><code>-s</code> or <code>--stack-size</code> The maximum stack size</li><li><code>-t</code> or <code>--cpu-time</code> The maximum amount of cpu time in seconds</li><li><code>-u</code> or <code>--process-count</code> The maximum number of processes available to a single user</li><li><code>-v</code> or <code>--virtual-memory-size</code> The maximum amount of virtual memory available to the shell. If supported by OS.</li></ul>
<p>
Note that not all these limits are available in all operating systems.<p>
The value of limit can be a number in the unit specified for the resource or one of the special values hard, soft, or unlimited, which stand for the current hard limit, the current soft limit, and no limit, respectively.<p>
If limit is given, it is the new value of the specified resource. If no option is given, then -f is assumed. Values are in kilobytes, except for -t, which is in seconds and -n and -u, which are unscaled values. The return status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit.<p>
ulimit also accepts the following switches that determine what type of limit to set:<p>
<ul>
<li><code>-H</code> or <code>--hard</code> Set hard resource limit</li><li><code>-S</code> or <code>--soft</code> Set soft resource limit</li></ul>
<p>
A hard limit can only be decreased, once it is set it can not be increased; a soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are updated when assigning a new limit value, and the soft limit is used when reporting the current value.<p>
The following additional options are also understood by ulimit:<p>
<ul>
<li><code>-a</code> or <code>--all</code> Print all current limits</li><li><code>-h</code> or <code>--help</code> Display help and exit</li></ul>
<p>
The fish implementation of ulimit should behave identically to the implementation in bash, except for these differences:<p>
<ul>
<li>Fish ulimit supports GNU-style long options for all switches</li><li>Fish ulimit does not support the -p option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because it this method of determining pipe sixe is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.</li><li>Fish ulimit does not support getting or setting multiple limits in one command, except reporting all values using the -a switch</li></ul>
<h3><a class="anchor" name="ulimit-example">
Example</a></h3>
<code>ulimit -Hs 64</code><p>
would set the hard stack size limit to 64 kB:<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="umask">
umask - set or get the file-creation mask</a></h2>
<h3><a class="anchor" name="umask-synopsis">
Synopsis</a></h3>
<code>umask [OPTIONS] [MASK]</code><h3><a class="anchor" name="umask-description">
Description</a></h3>
With no argument, the current file-creation mask is printed, if an argument is specified, it is the new file creation mask. The mask may be specified as an octal number, in which case it is interpreted as the rights that should be masked away, i.e. it is the inverse of the file permissions any new files will have.<p>
If a symbolic mask is specified, the actual file permission bits, and not the inverse, should be specified. A symbolic mask is a comma separated list of rights. Each right consists of three parts:<p>
<ul>
<li>The first part specifies to whom this set of right applies, and can be one of <code>u</code>, <code>g</code>, <code>o</code> or <code>a</code>, where <code>u</code> specifies the user who owns the file, <code>g</code> specifies the group owner of the file, <code>o</code> specific other users rights and <code>a</code> specifies all three should be changed.</li><li>The second part of a right specifies the mode, and can be one of <code>=</code>, <code>+</code> or <code>-</code>, where <code>=</code> specifies that the rights should be set to the new value, <code>+</code> specifies that the specified right should be added to those previously specified and <code>-</code> specifies that the specified rights should be removed from those previously specified.</li><li>The third part of a right specifies what rights should be changed and can be any combination of <code>r</code>, <code>w</code> and <code>x</code>, representing read, write and execute rights.</li></ul>
<p>
If the first and second parts are skipped, they are assumed to be <code>a</code> and <code>=</code>, respectively. As an example, <code>r,u+w</code> means all users should have read access and the file owner should also have write access.<p>
<ul>
<li><code>-h</code> or <code>--help</code> print this message</li><li><code>-S</code> or <code>--symbolic</code> prints the file-creation mask in symbolic form instead of octal form. Use <code>man chmod</code> for more information.</li><li><code>-p</code> or <code>--as-command</code> prints any output in a form that may be reused as input</li></ul>
<p>
The umask implementation in fish should behave identically to the one in bash.<h3><a class="anchor" name="umask-example">
Example</a></h3>
<code>umask 177</code> or <code>umask u=rw</code> sets the file creation mask to read and write for the owner and no permissions at all for any other users.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="vared">
vared - interactively edit the value of an environment variable</a></h2>
<h3><a class="anchor" name="vared-synopsis">
Synopsis</a></h3>
<code>vared VARIABLE_NAME</code><h3><a class="anchor" name="vared-description">
Description</a></h3>
vared is used to interactively edit the value of an environment variable. Array variables as a whole can not be edited using vared, but individual array elements can.<h3><a class="anchor" name="vared-example">
Example</a></h3>
<code>vared PATH[3]</code> edits the third element of the PATH array<p>
Back to <a href="index.html#toc-commands">index</a>. <hr>
 <h2><a class="anchor" name="while">
while - perform a command multiple times</a></h2>
<h3><a class="anchor" name="while-synopsis">
Synopsis</a></h3>
<code>while CONDITION; COMMANDS...; end</code><h3><a class="anchor" name="while-description">
Description</a></h3>
The <code>while</code> builtin causes fish to continually execute CONDITION and execute COMMANDS as long as CONDITION returned with status 0. If CONDITION is false on the first time, COMMANDS will not be executed at all. Hints: use <a href="#begin"><code>begin; ...; end</code></a> for complex conditions; more complex control can be achieved with <code>while true</code> containing a <a href="#break">break</a>.<h3><a class="anchor" name="while-example">
Example</a></h3>
<code>while test -f foo.txt; echo file exists; sleep 10; end</code><p>
causes fish to print the line 'file exists' at 10 second intervals as long as the file foo.txt exists.<p>
Back to <a href="index.html#toc-commands">index</a>. <hr size="1"><address style="align: right;"><small>Generated on Sun Jan 13 02:47:39 2008 for fish by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4 </small></address>
</body>
</html>