Commands — fish-shell 4.0.2 documentation

# Commands

This is a list of all the commands fish ships with.

Broadly speaking, these fall into a few categories:

## Keywords

Core language keywords that make up the syntax, like

- if and else for conditions.

- for and while for loops.

- break and continue to control loops.

- function to define functions.

- return to return a status from a function.

- begin to begin a block and end to end any block (including ifs and loops).

- and, or and not to combine commands logically.

- switch and case to make multiple blocks depending on the value of a variable.

- command or builtin to tell fish what sort of thing to execute

- time to time execution

- exec tells fish to replace itself with a command.

- end to end a block

## Tools

Builtins to do a task, like

- cd to change the current directory.

- echo or printf to produce output.

- set_color to colorize output.

- set to set, query or erase variables.

- read to read input.

- string for string manipulation.

- path for filtering paths and handling their components.

- math does arithmetic.

- argparse to make arguments easier to handle.

- count to count arguments.

- type to find out what sort of thing (command, builtin or function) fish would call, or if it exists at all.

- test checks conditions like if a file exists or a string is empty.

- contains to see if a list contains an entry.

- eval and source to run fish code from a string or file.

- status to get shell information, like whether it’s interactive or a login shell, or which file it is currently running.

- abbr manages Abbreviations.

- bind to change bindings.

- complete manages completions.

- commandline to get or change the commandline contents.

- fish_config to easily change fish’s configuration, like the prompt or colorscheme.

- random to generate random numbers or pick from a list.

## Known functions

Known functions are a customization point. You can change them to change how your fish behaves. This includes:

- fish_prompt and fish_right_prompt and fish_mode_prompt to print your prompt.

- fish_command_not_found to tell fish what to do when a command is not found.

- fish_title to change the terminal’s title.

- fish_greeting to show a greeting when fish starts.

- fish_should_add_to_history to determine if a command should be added to history

## Helper functions

Some helper functions, often to give you information for use in your prompt:

- fish_git_prompt and fish_hg_prompt to print information about the current git or mercurial repository.

- fish_vcs_prompt to print information for either.

- fish_svn_prompt to print information about the current svn repository.

- fish_status_to_signal to give a signal name from a return status.

- prompt_pwd to give the current directory in a nicely formatted and shortened way.

- prompt_login to describe the current login, with user and hostname, and to explain if you are in a chroot or connected via ssh.

- prompt_hostname to give the hostname, shortened for use in the prompt.

- fish_is_root_user to check if the current user is an administrator user like root.

- fish_add_path to easily add a path to $PATH.

- alias to quickly define wrapper functions (“aliases”).

- fish_delta to show what you have changed from the default configuration.

- export as a compatibility function for other shells.

## Helper commands

fish also ships some things as external commands so they can be easily called from elsewhere.

This includes fish_indent to format fish code and fish_key_reader to show you what escape sequence a keypress produces.

## The full list

And here is the full list:

- _ - call fish’s translations
- abbr - manage fish abbreviations
- alias - create a function
- and - conditionally execute a command
- argparse - parse options passed to a fish script or function
- begin - start a new block of code
- bg - send jobs to background
- bind - handle fish key bindings
- block - temporarily block delivery of events
- break - stop the current inner loop
- breakpoint - launch debug mode
- builtin - run a builtin command
- case - conditionally execute a block of commands
- cd - change directory
- cdh - change to a recently visited directory
- command - run a program
- commandline - set or get the current command line buffer
- complete - edit command-specific tab-completions
- contains - test if a word is present in a list
- continue - skip the remainder of the current iteration of the current inner loop
- count - count the number of elements of a list
- dirh - print directory history
- dirs - print directory stack
- disown - remove a process from the list of jobs
- echo - display a line of text
- else - execute command if a condition is not met
- emit - emit a generic event
- end - end a block of commands
- eval - evaluate the specified commands
- exec - execute command in current process
- exit - exit the shell
- export - compatibility function for exporting variables
- false - return an unsuccessful result
- fg - bring job to foreground
- fish - the friendly interactive shell
- fish_add_path - add to the path
- fish_breakpoint_prompt - define the prompt when stopped at a breakpoint
- fish_clipboard_copy - copy text to the system’s clipboard
- fish_clipboard_paste - get text from the system’s clipboard
- fish_command_not_found - what to do when a command wasn’t found
- fish_config - start the web-based configuration interface
- fish_default_key_bindings - set emacs key bindings for fish
- fish_delta - compare functions and completions to the default
- fish_git_prompt - output git information for use in a prompt
- fish_greeting - display a welcome message in interactive shells
- fish_hg_prompt - output Mercurial information for use in a prompt
- fish_indent - indenter and prettifier
- fish_is_root_user - check if the current user is root
- fish_key_reader - explore what characters keyboard keys send
- fish_mode_prompt - define the appearance of the mode indicator
- fish_opt - create an option specification for the argparse command
- fish_prompt - define the appearance of the command line prompt
- fish_right_prompt - define the appearance of the right-side command line prompt
- fish_should_add_to_history - decide whether a command should be added to the history
- fish_status_to_signal - convert exit codes to human-friendly signals
- fish_svn_prompt - output Subversion information for use in a prompt
- fish_title - define the terminal’s title
- fish_update_completions - update completions using manual pages
- fish_vcs_prompt - output version control system information for use in a prompt
- fish_vi_key_bindings - set vi key bindings for fish
- for - perform a set of commands multiple times
- funced - edit a function interactively
- funcsave - save the definition of a function to the user’s autoload directory
- function - create a function
- functions - print or erase functions
- help - display fish documentation
- history - show and manipulate command history
- if - conditionally execute a command
- isatty - test if a file descriptor is a terminal
- jobs - print currently running jobs
- math - perform mathematics calculations
- nextd - move forward through directory history
- not - negate the exit status of a job
- open - open file in its default application
- or - conditionally execute a command
- path - manipulate and check paths
- popd - move through directory stack
- prevd - move backward through directory history
- printf - display text according to a format string
- prompt_hostname - print the hostname, shortened for use in the prompt
- prompt_login - describe the login suitable for prompt
- prompt_pwd - print pwd suitable for prompt
- psub - perform process substitution
- pushd - push directory to directory stack
- pwd - output the current working directory
- random - generate random number
- read - read line of input into variables
- realpath - convert a path to an absolute path without symlinks
- return - stop the current inner function
- set - display and change shell variables
- set_color - set the terminal color
- source - evaluate contents of file
- status - query fish runtime information
- string - manipulate strings
- string-collect - join strings into one
- string-escape - escape special characters
- string-join - join strings with delimiter
- string-join0 - join strings with zero bytes
- string-length - print string lengths
- string-lower - convert strings to lowercase
- string-match - match substrings
- string-pad - pad strings to a fixed width
- string-repeat - multiply a string
- string-replace - replace substrings
- string-shorten - shorten strings to a width, with an ellipsis
- string-split - split strings by delimiter
- string-split0 - split on zero bytes
- string-sub - extract substrings
- string-trim - remove trailing whitespace
- string-unescape - expand escape sequences
- string-upper - convert strings to uppercase
- suspend - suspend the current shell
- switch - conditionally execute a block of commands
- test - perform tests on files and text
- time - measure how long a command or block takes
- trap - perform an action when the shell receives a signal
- true - return a successful result
- type - locate a command and describe its type
- ulimit - set or get resource usage limits
- umask - set or get the file creation mode mask
- vared - interactively edit the value of an environment variable
- wait - wait for jobs to complete
- while - perform a set of commands multiple times