fish home | Main documentation page | Design document | External commands | Builtin commands | FAQ | License

External commands

fish is shipped with commands which do not use any internal parts of the shell, and are therefore not written as builtins, but separate commands.

contains - Test if a word is present in a list

Synopsis

contains [OPTIONS] KEY [VALUES...]

Description

Test if the set VALUES contains the string KEY. Return status is 0 if yes, 1 otherwise

Example

for i in ~/bin /usr/local/bin if not contains $i $PATH set PATH $PATH i end end

The above code tests if ~/bin and /usr/local/bin are in the path and if they are not, they are added.

count - Count the number of elements of an array

Synopsis

count $VARIABLE

Description

count returns 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.

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. fish performs a special check when invoking the count program, 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 be passed on to the count program.

Example

count $PATH

returns the number of directories in the users PATH variable.

count *.txt

returns the number of files in the current working directory ending with the suffix '.txt'.

dirh

Synopsis

dirh

Description

dirh prints the current directory history. The current position in the history is highlighted using $fish_color_history_current.

dirs

Synopsis

dirs

Description

dirs prints the current directory stack.

fish_pager - Internal command used by fish

Description

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.

fishd - Universal variable daemon

Synopsis

fishd [(-h|--help|-v|--version)]

Description

The fishd 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.

Files

~/.fishd.HOSTNAME permanent storage location for universal variable data. The data is stored as a set of set and set_export commands such as would be parsed by fishd. If an instance of fishd is running (which is generally the case), manual modifications to ~/.fishd.HOSTNAME will be lost.

help - Display fish documentation

Synopsis

help [SECTION]

Description

The help command is used to display a section of the fish help documentation.

If the BROWSER environment variable is set, it will be used to display the documentation, otherwise fish will search for a suitable browser.

Example

help fg shows the documentation for the fg builtin.

mimedb - Lookup file information via the mime database

Synopsis

mimedb [OPTIONS] FILES...

Description

nextd

Synopsis

nextd [-l | --list] [pos]

Description <tt>nextd</tt> moves

forwards pos positions in the history of visited directories; if the end of the history has been hit, a warning is printed. If the -l> or --list flag is specified, the current history is also displayed.

open - Open file in it's default application

Synopsis

open FILES...

Description

The open command is used to open a file in it's default application. open is implemented using the mimedb command.

Example

open *.txt opens all the text files in the current directory using your systems default text editor.

popd

Synopsis

popd

Description

popd removes the top directory from the directory stack and cd's to the new top directory.

prevd

Synopsis

prevd [-l | --list] [pos]

Description <tt>prevd</tt> moves

backwards pos positions in the history of visited directories; if the beginning of the history has been hit, a warning is printed. If the -l or --list flag is specified, the current history is also displayed.

psub - Perform process substitution

Synopsis

COMMAND1 (COMMAND2|psub)

Description

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.

Example

diff (sort a.txt|psub) (sort b.txt|psub) shows the difference between the sorted versions of files a.txt and b.txt.

pushd

Synopsis

pushd [DIRECTORY]

Description

The pushd function adds DIRECTORY to the top of the directory stack and makes it the current directory. Use popd to pop it off and and return to the original directory.

set_color - Set the terminal color

Synopsis

set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR]

Description

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.

Calling set_color normal will set the terminal color to whatever is the default color of the terminal.

Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color.

trap - perform an action when the shell receives a signal

Synopsis

trap [OPTIONS] [[ARG] SIGSPEC ... ]

Description

Trap is a shellscript wrapper around the fish event delivery framework. IT is defined for backwards compatibility reasons. For other uses, it is recommended to define a event handler.

If ARG and SIGSPEC are both specified, ARG is the command to be executed when the signal specified by SIGSPEC is delivered.

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.

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.

Signal names are case insensitive and the SIG prefix is optional.

The return status is 1 if any SIGSPEC is invalid; otherwise trap returns 0.

type - Indicate how a name would be interpreted if used as a command name

Synopsis

type [OPTIONS] name [name ...]

Description

With no options, indicate how each name would be interpreted if used as a command name.

Example

type fg outputs the string 'fg is a shell builtin'.

umask - Set or get the shells resource usage limits

Synopsis

umask [OPTIONS] [MASK]

Description

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.

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:

If the first and second parts are skipped, they are assumed to be a and =, respectively. As an example, r,u+w means all users should have read access and the file owner should also have write access.

The umask implementation in fish should behave identically to the one in bash.

Example

umask 177 or umask u=rwsets the file creation mask to read and write for the owner and no permissions at all for any other users.

vared - Interactively edit the value of an environment variable

Synopsis

vared VARIABLE_NAME

Description

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.

Example

vared PATH[3] edits the third element of the PATH array
Generated on Fri Jun 2 04:11:24 2006 for fish by doxygen 1.3.5