2005-09-20 21:31:55 +08:00
\section functions functions - print or erase functions
2014-08-01 10:37:32 +08:00
\subsection functions-synopsis Synopsis
2014-08-01 20:25:41 +08:00
\fish{synopsis}
2014-08-27 02:19:24 +08:00
functions [ -a | --all ] [ -n | --names ]
2017-05-01 10:53:13 +08:00
functions [ -D | --details ] [ -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 15:56:01 +08:00
functions -c OLDNAME NEWNAME
functions -d DESCRIPTION FUNCTION
2014-08-27 02:19:24 +08:00
functions [ -e | -q ] FUNCTIONS...
2014-08-01 10:37:32 +08:00
\endfish
2005-09-20 21:31:55 +08:00
\subsection functions-description Description
2014-08-01 10:37:32 +08:00
`functions` prints or erases functions.
2005-09-20 21:31:55 +08: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 15:56:01 +08:00
The following options are available:
2017-01-10 14:49:33 +08:00
- `-a` or `--all` lists all functions, even those whose name starts with an underscore.
2014-08-19 20:41:23 +08:00
2014-08-01 10:37:32 +08:00
- `-c OLDNAME NEWNAME` or `--copy OLDNAME NEWNAME` creates a new function named NEWNAME, using the definition of the OLDNAME function.
2014-08-19 20:41:23 +08:00
2014-08-01 10:37:32 +08:00
- `-d DESCRIPTION` or `--description=DESCRIPTION` changes the description of this function.
2014-08-19 20:41:23 +08:00
2014-08-01 10:37:32 +08:00
- `-e` or `--erase` causes the specified functions to be erased.
2014-08-19 20:41:23 +08:00
2017-05-01 10:53:13 +08:00
- `-D` or `--details` 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 14:49:33 +08: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 08:22:33 +08: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 14:49:33 +08:00
2017-03-14 08:22:33 +08: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 14:49:33 +08:00
2014-08-01 10:37:32 +08:00
- `-n` or `--names` lists the names of all defined functions.
2014-08-19 20:41:23 +08:00
2014-08-01 10:37:32 +08: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 15:56:01 +08:00
2017-01-10 14:49:33 +08:00
- `-v` or `--verbose` will make some output more verbose.
2018-03-10 18:08:33 +08:00
- `-H` or `--handlers` will show all event handlers.
- `-t` or `--handlers-type TYPE` will show all event handlers matching the given type
2014-08-19 20:41:23 +08: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 21:31:55 +08:00
2014-08-19 20:41:23 +08: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 21:31:55 +08:00
2014-08-19 20:41:23 +08: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 21:31:55 +08:00
2014-08-19 20:41:23 +08: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 15:56:01 +08:00
2014-08-19 20:41:23 +08: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 15:56:01 +08:00
\subsection functions-example Examples
2014-08-27 07:30:08 +08: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 15:56:01 +08:00
2014-08-27 07:30:08 +08:00
functions -c foo bar
# Copies the 'foo' function to a new function called 'bar'
2010-09-12 18:29:34 +08:00
2014-08-27 07:30:08 +08:00
functions -e bar
# Erases the function `bar`
\endfish