2005-09-20 13:31:55 +00:00
\section functions functions - print or erase functions
2014-08-01 02:37:32 +00:00
\subsection functions-synopsis Synopsis
2014-08-01 12:25:41 +00:00
\fish{synopsis}
2014-08-26 18:19:24 +00:00
functions [ -a | --all ] [ -n | --names ]
2017-01-10 06:49:33 +00:00
functions [ -m | --metadata ] [ -v ] FUNCTION
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
functions -c OLDNAME NEWNAME
functions -d DESCRIPTION FUNCTION
2014-08-26 18:19:24 +00:00
functions [ -e | -q ] FUNCTIONS...
2014-08-01 02:37:32 +00:00
\endfish
2005-09-20 13:31:55 +00:00
\subsection functions-description Description
2014-08-01 02:37:32 +00:00
`functions` prints or erases functions.
2005-09-20 13:31:55 +00:00
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
The following options are available:
2017-01-10 06:49:33 +00:00
- `-a` or `--all` lists all functions, even those whose name starts with an underscore.
2014-08-19 12:41:23 +00:00
2014-08-01 02:37:32 +00:00
- `-c OLDNAME NEWNAME` or `--copy OLDNAME NEWNAME` creates a new function named NEWNAME, using the definition of the OLDNAME function.
2014-08-19 12:41:23 +00:00
2014-08-01 02:37:32 +00:00
- `-d DESCRIPTION` or `--description=DESCRIPTION` changes the description of this function.
2014-08-19 12:41:23 +00:00
2014-08-01 02:37:32 +00:00
- `-e` or `--erase` causes the specified functions to be erased.
2014-08-19 12:41:23 +00:00
2017-03-14 00:22:33 +00:00
- `-m` or `--metadata` reports the path name where each function is defined or could be autoloaded, `stdin` if the function was defined interactively or on the command line or by reading stdin, and `n/a` if the function isn't available. If the `--verbose` option is also specified then five lines are written:
2017-01-10 06:49:33 +00:00
-# the pathname as already described,
-# `autoloaded`, `not-autoloaded` or `n/a`,
-# the line number within the file or zero if not applicable,
2017-03-14 00:22:33 +00:00
-# `scope-shadowing` if the function shadows the vars in the calling function (the normal case if it wasn't defined with `--no-scope-shadowing`), else `no-scope-shadowing`, or `n/a` if the function isn't defined,
-# the function description minimally escaped so it is a single line or `n/a` if the function isn't defined.
2017-01-10 06:49:33 +00:00
2017-03-14 00:22:33 +00:00
You should not assume that only five lines will be written since we may add additional information to the output in the future.
2017-01-10 06:49:33 +00:00
2014-08-01 02:37:32 +00:00
- `-n` or `--names` lists the names of all defined functions.
2014-08-19 12:41:23 +00:00
2014-08-01 02:37:32 +00:00
- `-q` or `--query` tests if the specified functions exist.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
2017-01-10 06:49:33 +00:00
- `-v` or `--verbose` will make some output more verbose.
2014-08-19 12:41:23 +00:00
The default behavior of `functions`, when called with no arguments, is to print the names of all defined functions. Unless the `-a` option is given, no functions starting with underscores are not included in the output.
If any non-option parameters are given, the definition of the specified functions are printed.
2005-09-20 13:31:55 +00:00
2014-08-19 12:41:23 +00:00
Automatically loaded functions cannot be removed using `functions -e`. Either remove the definition file or change the $fish_function_path variable to remove autoloaded functions.
2005-09-20 13:31:55 +00:00
2014-08-19 12:41:23 +00:00
Copying a function using `-c` copies only the body of the function, and does not attach any event notifications from the original function.
2005-09-20 13:31:55 +00:00
2014-08-19 12:41:23 +00:00
Only one function's description can be changed in a single invocation of `functions -d`.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
2014-08-19 12:41:23 +00:00
The exit status of `functions` is the number of functions specified in the argument list that do not exist, which can be used in concert with the `-q` option.
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
\subsection functions-example Examples
2014-08-26 23:30:08 +00:00
\fish
functions -n
# Displays a list of currently-defined functions
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
2014-08-26 23:30:08 +00:00
functions -c foo bar
# Copies the 'foo' function to a new function called 'bar'
2010-09-12 10:29:34 +00:00
2014-08-26 23:30:08 +00:00
functions -e bar
# Erases the function `bar`
\endfish