Command reference fish ships with a large number of builtin commands, shellscript functions and external commands. These are all described below. Almost all fish commands respond to the -h or --help options to display their relevant help, also accessible using the help and man commands, like so: echo -h echo --help # Prints help to the terminal window man echo # Displays the man page in the system pager # (normally 'less', 'more' or 'most'). help echo # Open a web browser to show the relevant documentation abbr - manage fish abbreviations Synopsis abbr --add word phrase... abbr --rename word new_word abbr --show abbr --list abbr --erase word Description abbr manipulates the list of abbreviations that fish will expand. Abbreviations are user-defined character sequences or words that are replaced with longer phrases after they are entered. For example, a frequently-run command such as git checkout can be abbreviated to gco. After entering gco and pressing Space or Enter, the full text git checkout will appear in the command line. Abbreviations are stored in a variable named fish_user_abbreviations. This is automatically created as a universal variable the first time an abbreviation is created. If you want your abbreviations to be private to a particular fish session you can put the following in your *~/.config/fish/config.fish* file before you define your first abbrevation: if status --is-interactive set -g fish_user_abbreviations abbr --add first 'echo my first abbreviation' abbr --add second 'echo my second abbreviation' # etcetera end You can create abbreviations directly on the command line and they will be saved automatically and made visible to other fish sessions if fish_user_abbreviations is a universal variable. If you keep the variable as universal, abbr --add statements in config.fish will do nothing but slow down startup slightly. Options The following parameters are available: -a WORD PHRASE or --add WORD PHRASE Adds a new abbreviation, causing WORD to be expanded to PHRASE. -r WORD NEW_WORD or --rename WORD NEW_WORD Renames an abbreviation, from WORD to NEW_WORD. -s or --show Show all abbreviated words and their expanded phrases in a manner suitable for export and import. -l or --list Lists all abbreviated words. -e WORD or --erase WORD Erase the abbreviation WORD. Note: fish version 2.1 supported -a WORD=PHRASE. This syntax is now deprecated but will still be converted. Examples abbr -a gco git checkout Add a new abbreviation where gco will be replaced with git checkout. abbr -r gco gch Renames an existing abbreviation from gco to gch. abbr -e gco Erase the gco abbreviation. ssh another_host abbr -s | source Import the abbreviations defined on another_host over SSH. Back to command index. alias - create a function Synopsis alias alias NAME DEFINITION alias NAME=DEFINITION Description alias is a simple wrapper for the function builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell alias. For other uses, it is recommended to define a function. fish marks functions that have been created by alias by including the command used to create them in the function description. You can list alias-created functions by running alias without arguments. They must be erased using functions -e. NAME is the name of the alias DEFINITION is the actual command to execute. The string $argv will be appended. You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to alias just like at the command line, even inside quoted parts. Example The following code will create rmi, which runs rm with additional arguments on every invocation. alias rmi="rm -i" # This is equivalent to entering the following function: function rmi --wraps rm --description 'alias rmi=rm -i' rm -i $argv end # This needs to have the spaces escaped or "Chrome.app..." will be seen as an argument to "/Applications/Google": alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome banana' Back to command index. and - conditionally execute a command Synopsis COMMAND1; and COMMAND2 Description and is used to execute a command if the current exit status (as set by the previous command) is 0. and statements may be used as part of the condition in an if or while block. See the documentation for if and while for examples. and does not change the current exit status. The exit status of the last foreground command to exit can always be accessed using the $status variable. Example The following code runs the make command to build a program. If the build succeeds, make's exit status is 0, and the program is installed. If either step fails, the exit status is 1, and make clean is run, which removes the files created by the build process. make; and make install; or make clean Back to command index. begin - start a new block of code Synopsis begin; [COMMANDS...;] end Description begin is used to create a new block of code. The block is unconditionally executed. begin; ...; end is equivalent to if true; ...; end. begin is used to group a number of commands into a block. This allows the introduction of a new variable scope, redirection of the input or output of a set of commands as a group, or to specify precedence when using the conditional commands like and. begin does not change the current exit status. Example 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. begin set -l PIRATE Yarrr ... end echo $PIRATE # This will not output anything, since the PIRATE variable # went out of scope at the end of the block In the following code, all output is redirected to the file out.html. begin echo $xml_header echo $html_header if test -e $file ... end ... end > out.html Back to command index. bg - send jobs to background Synopsis bg [PID...] Description bg sends jobs to the background, resuming them if they are stopped. 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 process group IDs are put in the background. The PID of the desired process is usually found by using process expansion. Example bg %1 will put the job with job ID 1 in the background. Back to command index. bind - handle fish key bindings Synopsis bind [(-M | --mode) MODE] [(-m | --sets-mode) NEW_MODE] [(-k | --key)] SEQUENCE COMMAND [COMMAND...] bind [(-M | --mode) MODE] [(-k | --key)] SEQUENCE bind (-K | --key-names) [(-a | --all)] bind (-f | --function-names) bind (-e | --erase) [(-M | --mode) MODE] (-a | --all | [(-k | --key)] SEQUENCE [SEQUENCE...]) Description bind adds a binding for the specified key sequence to the specified command. SEQUENCE is the character sequence to bind to. These should be written as fish escape sequences. For example, because pressing the Alt key and another character sends that character prefixed with an escape character, Alt-based key bindings can be written using the \e escape. For example, Alt-w can be written as \ew. The control character can be written in much the same way using the \c escape, for example Control-X (^X) can be written as \cx. Note that Alt-based key bindings are case sensitive and Control-based key bindings are not. This is a constraint of text-based terminals, not fish. The default key binding can be set by specifying a SEQUENCE of the empty string (that is, '' ). It will be used whenever no other binding matches. For most key bindings, it makes sense to use the self-insert function (i.e. bind '' self-insert) as the default keybinding. 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 control sequences being printable. 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 terminfo(5) for more information, or use bind --key-names for a list of all available named keys.) 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. When COMMAND is a shellscript command, it is a good practice to put the actual code into a function 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. If such a script produces output, the script needs to finish by calling commandline -f repaint in order to tell fish that a repaint is in order. When multiple COMMANDs are provided, they are all run in the specified order when the key is pressed. If no SEQUENCE is provided, all bindings (or just the bindings in the specified MODE) are printed. If SEQUENCE is provided without COMMAND, just the binding matching that sequence is printed. Key bindings are not saved between sessions by default. Bare bind statements in config.fish won't have any effect because it is sourced before the default keybindings are setup. To save custom keybindings, put the bind statements into a function called fish_user_key_bindings, which will be autoloaded. Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default", and every bind applies to a single mode. The mode can be viewed/changed with the $fish_bind_mode variable. The following parameters are available: -k or --key Specify a key name, such as 'left' or 'backspace' instead of a character sequence -K or --key-names Display a list of available key names. Specifying -a or --all includes keys that don't have a known mapping -f or --function-names Display a list of available input functions -M MODE or --mode MODE Specify a bind mode that the bind is used in. Defaults to "default" -m NEW_MODE or --sets-mode NEW_MODE Change the current mode to NEW_MODE after this binding is executed -e or --erase Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying -a or --all with -M or --mode erases all binds in the given mode regardless of sequence. Specifying -a or --all without -M or --mode erases all binds in all modes regardless of sequence. -a or --all See --erase and --key-names The following special input functions are available: accept-autosuggestion, accept the current autosuggestion completely backward-char, moves one character to the left backward-bigword, move one whitespace-delimited word to the left backward-delete-char, deletes one character of input to the left of the cursor backward-kill-bigword, move the whitespace-delimited word to the left of the cursor to the killring backward-kill-line, move everything from the beginning of the line to the cursor to the killring backward-kill-path-component, move one path component to the left of the cursor (everything from the last "/" or whitespace exclusive) to the killring backward-kill-word, move the word to the left of the cursor to the killring backward-word, move one word to the left beginning-of-buffer, moves to the beginning of the buffer, i.e. the start of the first line beginning-of-history, move to the beginning of the history beginning-of-line, move to the beginning of the line begin-selection, start selecting text capitalize-word, make the current word begin with a capital letter complete, guess the remainder of the current token complete-and-search, invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager) delete-char, delete one character to the right of the cursor downcase-word, make the current word lowercase end-of-buffer, moves to the end of the buffer, i.e. the end of the first line end-of-history, move to the end of the history end-of-line, move to the end of the line end-selection, end selecting text forward-bigword, move one whitespace-delimited word to the right forward-char, move one character to the right forward-word, move one word to the right history-search-backward, search the history for the previous match history-search-forward, search the history for the next match kill-bigword, move the next whitespace-delimited word to the killring kill-line, move everything from the cursor to the end of the line to the killring kill-selection, move the selected text to the killring kill-whole-line, move the line to the killring kill-word, move the next word to the killring suppress-autosuggestion, remove the current autosuggestion swap-selection-start-stop, go to the other end of the highlighted text without changing the selection transpose-chars, transpose two characters to the left of the cursor transpose-words, transpose two words to the left of the cursor upcase-word, make the current word uppercase yank, insert the latest entry of the killring into the buffer yank-pop, rotate to the previous entry of the killring Examples bind \cd 'exit' Causes fish to exit when Control-D is pressed. bind -k ppage history-search-backward Performs a history search when the Page Up key is pressed. set -g fish_key_bindings fish_vi_key_bindings bind -M insert \cc kill-whole-line force-repaint Turns on Vi key bindings and rebinds Control-C to clear the input line. Special Case: The escape Character The escape key can be used standalone, for example, to switch from insertion mode to normal mode when using Vi keybindings. Escape may also be used as a "meta" key, to indicate the start of an escape sequence, such as function or arrow keys. Custom bindings can also be defined that begin with an escape character. fish waits for a period after receiving the escape character, to determine whether it is standalone or part of an escape sequence. While waiting, additional key presses make the escape key behave as a meta key. If no other key presses come in, it is handled as a standalone escape. The waiting period is set to 300 milliseconds (0.3 seconds) in the default key bindings and 10 milliseconds in the vi key bindings. It can be configured by setting the fish_escape_delay_ms variable to a value between 10 and 5000 ms. It is recommended that this be a universal variable that you set once from an interactive session. Note: fish 2.2.0 and earlier used a default of 10 milliseconds, and provided no way to configure it. That effectively made it impossible to use escape as a meta key. Back to command index. block - temporarily block delivery of events Synopsis block [OPTIONS...] Description block prevents events triggered by fish or the emit command from being delivered and acted upon while the block is in place. In functions, block can be useful while performing work that should not be interrupted by the shell. The block can be removed. Any events which triggered while the block was in place will then be delivered. Event blocks should not be confused with code blocks, which are created with begin, if, while or for The following parameters are available: -l or --local Release the block automatically at the end of the current innermost code block scope -g or --global Never automatically release the lock -e or --erase Release global block Example # Create a function that listens for events function --on-event foo foo; echo 'foo fired'; end # Block the delivery of events block -g emit foo # No output will be produced block -e # 'foo fired' will now be printed Back to command index. break - stop the current inner loop Synopsis LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end Description break halts a currently running loop, such as a for loop or a while loop. It is usually added inside of a conditional block such as an if statement or a switch statement. There are no parameters for break. Example The following code searches all .c files for "smurf", and halts at the first occurrence. for i in *.c if grep smurf $i echo Smurfs are present in $i break end end Back to command index. breakpoint - Launch debug mode Synopsis breakpoint Description breakpoint is used to halt a running script and launch an interactive debugging prompt. For more details, see Debugging fish scripts in the fish manual. There are no parameters for breakpoint. Back to command index. builtin - run a builtin command Synopsis builtin BUILTINNAME [OPTIONS...] Description builtin forces the shell to use a builtin command, rather than a function or program. The following parameters are available: -n or --names List the names of all defined builtins Example builtin jobs # executes the jobs builtin, even if a function named jobs exists Back to command index. case - conditionally execute a block of commands Synopsis switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end Description switch performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values. case is used together with the switch statement in order to determine which block should be executed. Each case command is given one or more parameters. The first case command with a parameter that matches the string specified in the switch command will be evaluated. case parameters may contain wildcards. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames. Note that fish does not fall through on case statements. Only the first matching case is executed. Note that command substitutions in a case statement will be evaluated even if its body is not taken. All substitutions, including command substitutions, must be performed before the value can be compared against the parameter. Example If the variable $animal contains the name of an animal, the following code would attempt to classify it: 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 # Note that the next case has a wildcard which is quoted case '*' echo I have no idea what a $animal is end If the above code was run with $animal set to whale, the output would be mammal. Back to command index. cd - change directory Synopsis cd [DIRECTORY] Description cd changes the current working directory. If DIRECTORY is supplied, it will become the new directory. If no parameter is given, the contents of the HOME environment variable will be used. If DIRECTORY is a relative path, the paths found in the CDPATH environment variable array will be tried as prefixes for the specified path. Note that the shell will attempt to change directory without requiring cd if the name of a directory is provided (starting with ., / or ~, or ending with /). Fish also ships a wrapper function around the builtin cd that understands cd - as changing to the previous directory. See also prevd. This wrapper function maintains a history of the 25 most recently visited directories in the $dirprev and $dirnext global variables. Examples cd # changes the working directory to your home directory. cd /usr/src/fish-shell # changes the working directory to /usr/src/fish-shell Back to command index. command - run a program Synopsis command [OPTIONS] COMMANDNAME [ARGS...] Description command forces the shell to execute the program COMMANDNAME and ignore any functions or builtins with the same name. The following options are available: -s or --search returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the $PATH. With the -s option, command treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a -q or --quiet option prevents any paths from being printed, like the type -q, for testing only the exit status. For basic compatibility with POSIX command, the -v flag is recognized as an alias for -s. Examples command ls causes fish to execute the ls program, even if an ls function exists. command -s ls returns the path to the ls program. Back to command index. commandline - set or get the current command line buffer Synopsis commandline [OPTIONS] [CMD] Description commandline can be used to set or get the current contents of the command line buffer. With no parameters, commandline returns the current value of the command line. With CMD specified, the command line buffer is erased and replaced with the contents of CMD. The following options are available: -C or --cursor 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. -f or --function inject readline functions into the reader. This option cannot 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. The following options change the way commandline updates the command line buffer: -a or --append do not remove the current commandline, append the specified string at the end of it -i or --insert do not remove the current commandline, insert the specified string at the current cursor position -r or --replace remove the current commandline and replace it with the specified string (default) The following options change what part of the commandline is printed or updated: -b or --current-buffer select the entire buffer (default) -j or --current-job select the current job -p or --current-process select the current process -t or --current-token select the current token. The following options change the way commandline prints the current commandline buffer: -c or --cut-at-cursor only print selection up until the current cursor position -o or --tokenize tokenize the selection and print one string-type token per line If commandline is called during a call to complete a given string using complete -C STRING, commandline will consider the specified string to be the current contents of the command line. The following options output metadata about the commandline state: -L or --line print the line that the cursor is on, with the topmost line starting at 1 -S or --search-mode evaluates to true if the commandline is performing a history search -P or --paging-mode evaluates to true if the commandline is showing pager contents, such as tab completions Example commandline -j $history[3] replaces the job under the cursor with the third item from the command line history. If the commandline contains > echo $flounder >&2 | less; and echo $catfish (with the cursor on the "o" of "flounder") Then the following invocations behave like this: > commandline -t $flounder > commandline -ct $fl > commandline -b ## or just commandline echo $flounder >&2 | less; and echo $catfish > commandline -p echo $flounder >&2 > commandline -j echo $flounder >&2 | less Back to command index. complete - edit command specific tab-completions Synopsis complete ( -c | --command | -p | --path ) COMMAND [( -c | --command | -p | --path ) COMMAND]... [( -e | --erase )] [( -s | --short-option ) SHORT_OPTION]... [( -l | --long-option | -o | --old-option ) LONG_OPTION]... [( -a | --arguments ) OPTION_ARGUMENTS] [( -f | --no-files )] [( -r | --require-parameter )] [( -x | --exclusive )] [( -w | --wraps ) WRAPPED_COMMAND]... [( -n | --condition ) CONDITION] [( -d | --description ) DESCRIPTION] complete ( -C[STRING] | --do-complete[=STRING] ) Description For an introduction to specifying completions, see Writing your own completions in the fish manual. COMMAND is the name of the command for which to add a completion. SHORT_OPTION is a one character option for the command. LONG_OPTION is a multi character option for the command. OPTION_ARGUMENTS is parameter containing a space-separated list of possible option-arguments, which may contain command substitutions. DESCRIPTION is a description of what the option and/or option arguments do. -c COMMAND or --command COMMAND specifies that COMMAND is the name of the command. -p COMMAND or --path COMMAND specifies that COMMAND is the absolute path of the program (optionally containing wildcards). -e or --erase deletes the specified completion. -s SHORT_OPTION or --short-option=SHORT_OPTION adds a short option to the completions list. -l LONG_OPTION or --long-option=LONG_OPTION adds a GNU style long option to the completions list. -o LONG_OPTION or --old-option=LONG_OPTION adds an old style long option to the completions list (See below for details). -a OPTION_ARGUMENTS or --arguments=OPTION_ARGUMENTS adds the specified option arguments to the completions list. -f or --no-files specifies that the options specified by this completion may not be followed by a filename. -r or --require-parameter specifies that the options specified by this completion always must have an option argument, i.e. may not be followed by another option. -x or --exclusive implies both -r and -f. -w WRAPPED_COMMAND or --wraps=WRAPPED_COMMAND causes the specified command to inherit completions from the wrapped command (See below for details). -n or --condition 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. -CSTRING or --do-complete=STRING makes complete try to find all possible completions for the specified string. -C or --do-complete with no argument makes complete try to find all possible completions for the current command line buffer. If the shell is not in interactive mode, an error is returned. -A and --authoritative no longer do anything and are silently ignored. -u and --unauthoritative no longer do anything and are silently ignored. Command specific tab-completions in fish 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: 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'). 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'). 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'). The options for specifying command name and command path may be used multiple times to define the same completions for multiple commands. The options for specifying command switches and wrapped commands may be used multiple times to define multiple completions for the command(s) in a single call. Invoking complete multiple times for the same command adds the new definitions on top of any existing completions defined for the command. When -a or --arguments is specified in conjunction with long, short, or old style options, the specified arguments are only used as completions when attempting to complete an argument for any of the specified options. If -a or --arguments is specified without any long, short, or old style options, the specified arguments are used when completing any argument to the command (except when completing an option argument that was specified with -r or --require-parameter). Command substitutions found in OPTION_ARGUMENTS are not expected to return a space-separated list of arguments. Instead they must return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Any description provided in this way overrides a description given with -d or --description. The -w or --wraps options causes the specified command to inherit completions from another command. The inheriting command is said to "wrap" the inherited command. The wrapping command may have its own completions in addition to inherited ones. A command may wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the -e or --erase options. Note that wrapping only works for completions specified with -c or --command and are ignored when specifying completions with -p or --path. When erasing completions, it is possible to either erase all completions for a specific command by specifying complete -c COMMAND -e, or by specifying a specific completion option to delete by specifying either a long, short or old style option. Example The short style option -o for the gcc command requires that a file follows it. This can be done using writing: complete -c gcc -s o -r The short style option -d for the grep command requires that one of the strings 'read', 'skip' or 'recurse' is used. This can be specified writing: complete -c grep -s d -x -a "read skip recurse" The su 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: complete -x -c su -d "Username" -a "(cat /etc/passwd | cut -d : -f 1)" The rpm command has several different modes. If the -e or --erase flag has been specified, rpm should delete one or more packages, in which case several switches related to deleting packages are valid, like the nodeps switch. This can be written as: complete -c rpm -n "__fish_contains_opt -s e erase" -d nodeps "Don't check dependencies" where __fish_contains_opt is a function that checks the command line buffer for the presence of a specified set of options. To implement an alias, use the -w or --wraps option: complete -c hub -w git Now hub inherits all of the completions from git. Note this can also be specified in a function declaration. Back to command index. contains - test if a word is present in a list Synopsis contains [OPTIONS] KEY [VALUES...] Description contains tests whether the set VALUES contains the string KEY. If so, contains exits with status 0; if not, it exits with status 1. The following options are available: -i or --index print the word index Note that, like GNU tools, contains interprets all arguments starting with a - as options to contains, until it reaches an argument that is -- (two dashes). See the examples below. 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 adds them if not. function hasargs if contains -- -q $argv echo '$argv contains a -q option' end end The above code checks for -q in the argument list, using the -- argument to demarcate options to contains from the key to search for. Back to command index. continue - skip the remainder of the current iteration of the current inner loop Synopsis LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end Description continue skips the remainder of the current iteration of the current inner loop, such as a for loop or a while loop. It is usually added inside of a conditional block such as an if statement or a switch statement. Example The following code removes all tmp files that do not contain the word smurf. for i in *.tmp if grep smurf $i continue end rm $i end Back to command index. count - count the number of elements of an array Synopsis count $VARIABLE Description count 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. count does not accept any options, including -h or --help. count exits with a non-zero exit status if no arguments were passed to it, and with zero if at least one argument was passed. 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'. Back to command index. dirh - print directory history Synopsis dirh Description dirh prints the current directory history. The current position in the history is highlighted using the color defined in the fish_color_history_current environment variable. dirh does not accept any parameters. Note that the cd command limits directory history to the 25 most recently visited directories. The history is stored in the $dirprev and $dirnext variables. Back to command index. dirs - print directory stack Synopsis dirs dirs -c Description dirs prints the current directory stack, as created by the pushd command. With "-c", it clears the directory stack instead. dirs does not accept any parameters. Back to command index. echo - display a line of text Synopsis echo [OPTIONS] [STRING] Description echo displays a string of text. The following options are available: -n, Do not output a newline -s, Do not separate arguments with spaces -E, Disable interpretation of backslash escapes (default) -e, Enable interpretation of backslash escapes Escape Sequences If -e is used, the following sequences are recognized: \ backslash \a alert (BEL) \b backspace \c produce no further output \e escape \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \0NNN byte with octal value NNN (1 to 3 digits) \xHH byte with hexadecimal value HH (1 to 2 digits) Example echo 'Hello World' Print hello world to stdout echo -e 'Top\nBottom' Print Top and Bottom on separate lines, using an escape sequence Back to command index. else - execute command if a condition is not met Synopsis if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end Description if 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 else is given, COMMANDS_FALSE will be executed. Example The following code tests whether a file foo.txt exists as a regular file. if test -f foo.txt echo foo.txt exists else echo foo.txt does not exist end Back to command index. emit - Emit a generic event Synopsis emit EVENT_NAME [ARGUMENTS...] Description emit emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments. Example The following code first defines an event handler for the generic event named 'test_event', and then emits an event of that type. function event_test --on-event test_event echo event test: $argv end emit test_event something Back to command index. end - end a block of commands. Synopsis 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 Description end ends a block of commands. For more information, read the documentation for the block constructs, such as if, for and while. The end command does not change the current exit status. Back to command index. eval - evaluate the specified commands Synopsis eval [COMMANDS...] Description eval evaluates 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. Example The following code will call the ls command. Note that fish does not support the use of shell variables as direct commands; eval can be used to work around this. set cmd ls eval $cmd Back to command index. exec - execute command in current process Synopsis exec COMMAND [OPTIONS...] Description exec replaces the currently running shell with a new command. On successful completion, exec never returns. exec cannot be used inside a pipeline. Example exec emacs starts up the emacs text editor, and exits fish. When emacs exits, the session will terminate. Back to command index. exit - exit the shell Synopsis exit [STATUS] Description exit causes fish to exit. If STATUS 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. If exit is called while sourcing a file (using the source builtin) the rest of the file will be skipped, but the shell itself will not exit. Back to command index. false - return an unsuccessful result Synopsis false Description false sets the exit status to 1. Back to command index. fg - bring job to foreground Synopsis fg [PID] Description fg brings the specified job to the foreground, resuming it if it is stopped. 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. The PID of the desired process is usually found by using process expansion. Fish is capable of expanding far more than just the numeric PID, including referencing itself and finding PIDs by name. Example fg %1 will put the job with job ID 1 in the foreground. Back to command index. fish - the friendly interactive shell Synopsis fish [OPTIONS] [-c command] [FILE [ARGUMENTS...]] Description fish is a command-line shell written mainly with interactive use in mind. The full manual is available in HTML by using the help command from inside fish. The following options are available: -c or --command=COMMANDS evaluate the specified commands instead of reading from the commandline -d or --debug-level=DEBUG_LEVEL specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1. -i or --interactive specify that fish is to run in interactive mode -l or --login specify that fish is to run as a login shell -n or --no-execute do not execute any commands, only perform syntax checking -p or --profile=PROFILE_FILE when fish exits, output timing information on all executed commands to the specified file -v or --version display version and exit -D or --debug-stack-frames=DEBUG_LEVEL specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128. 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. Back to command index. fish_config - start the web-based configuration interface Description fish_config starts the web-based configuration interface. The web interface allows you to view your functions, variables and history, and to make changes to your prompt and color configuration. fish_config starts a local web server and then opens a web browser window; when you have finished, close the browser window and then press the Enter key to terminate the configuration session. fish_config optionally accepts name of the initial configuration tab. For e.g. fish_config history will start configuration interface with history tab. If the BROWSER environment variable is set, it will be used as the name of the web browser to open instead of the system default. Example fish_config opens a new web browser window and allows you to configure certain fish settings. Back to command index. fish_indent - indenter and prettifier Synopsis fish_indent [OPTIONS] Description fish_indent is used to indent a piece of fish code. fish_indent reads commands from standard input and outputs them to standard output or a specified file. The following options are available: -w or --write indents a specified file and immediately writes to that file. -i or --no-indent do not indent commands; only reformat to one job per line. -v or --version displays the current fish version and then exits. --ansi colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as $fish_color_command). --html outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as fish_color_command. -d or --debug-level=DEBUG_LEVEL enables debug output and specifies a verbosity level (like fish -d). Defaults to 0. -D or --debug-stack-frames=DEBUG_LEVEL specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128. --dump-parse-tree dumps information about the parsed statements to stderr. This is likely to be of interest only to people working on the fish source code. Back to command index. fish_key_reader - explore what characters keyboard keys send Synopsis fish_key_reader [OPTIONS] Description fish_key_reader is used to study input received from the terminal and can help with key binds. The program is interactive and works on standard input. Individual characters themselves and their hexadecimal values are displayed. The tool will write an example bind command matching the character sequence captured to stdout. If the character sequence matches a special key name (see bind --key-names), both bind CHARS ... and bind -k KEYNAME ... usage will be shown. Additional details about the characters received, such as the delay between chars, are written to stderr. The following options are available: -c or --continuous begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence. -d or --debug-level=DEBUG_LEVEL enables debug output and specifies a verbosity level (like fish -d). Defaults to 0. -D or --debug-stack-frames=DEBUG_LEVEL specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128. -h or --help prints usage information. Usage Notes The delay in milliseconds since the previous character was received is included in the diagnostic information written to stderr. This information may be useful to determine the optimal fish_escape_delay_ms setting or learn the amount of lag introduced by tools like ssh, mosh or tmux. fish_key_reader intentionally disables handling of many signals. To terminate fish_key_reader in --continuous mode do: press Ctrl-C twice, or press Ctrl-D twice, or type exit, or type quit Back to command index. fish_mode_prompt - define the appearance of the mode indicator Synopsis fish_mode_prompt will output the mode indicator for use in vi-mode. Description The output of fish_mode_prompt will be displayed in the mode indicator position to the left of the regular prompt. Multiple lines are not supported in fish_mode_prompt. Back to command index. fish_prompt - define the appearance of the command line prompt Synopsis function fish_prompt ... end Description By defining the fish_prompt function, the user can choose a custom prompt. The fish_prompt function is executed when the prompt is to be shown, and the output is used as a prompt. The exit status of commands within fish_prompt will not modify the value of $status outside of the fish_prompt function. fish ships with a number of example prompts that can be chosen with the fish_config command. Example A simple prompt: function fish_prompt -d "Write out the prompt" printf '%s@%s%s%s%s> ' (whoami) (hostname | cut -d . -f 1) \ (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) end Back to command index. fish_right_prompt - define the appearance of the right-side command line prompt Synopsis function fish_right_prompt ... end Description fish_right_prompt is similar to fish_prompt, except that it appears on the right side of the terminal window. Multiple lines are not supported in fish_right_prompt. Example A simple right prompt: function fish_right_prompt -d "Write out the right prompt" date '+%m/%d/%y' end Back to command index. fish_update_completions - Update completions using manual pages Description fish_update_completions parses manual pages installed on the system, and attempts to create completion files in the fish configuration directory. This does not overwrite custom completions. There are no parameters for fish_update_completions. Back to command index. fish_vi_mode - Enable vi mode Synopsis fish_vi_mode Description This function is deprecated. Please call fish_vi_key_bindings directly fish_vi_mode enters a vi-like command editing mode. To always start in vi mode, add fish_vi_mode to your config.fish file. Back to command index. for - perform a set of commands multiple times. Synopsis for VARNAME in [VALUES...]; COMMANDS...; end Description for is a loop construct. It will perform the commands specified by COMMANDS multiple times. On each iteration, the local variable specified by VARNAME is assigned a new value from VALUES. If VALUES is empty, COMMANDS will not be larry43@example.org. Example for i in foo bar baz; echo $i; end # would output: foo bar baz Back to command index. funced - edit a function interactively Synopsis funced [OPTIONS] NAME Description funced provides an interface to edit the definition of the function NAME. If the $VISUAL environment variable is set, it will be used as the program to edit the function. If $VISUAL is unset but $EDITOR is set, that will be used. Otherwise, a built-in editor will be used. If there is no function called NAME a new function will be created with the specified name -e command or --editor command Open the function body inside the text editor given by the command (for example, "vi"). The command 'fish' will use the built-in editor. -i or --interactive Open function body in the built-in editor. Back to command index. funcsave - save the definition of a function to the user's autoload directory Synopsis funcsave FUNCTION_NAME Description funcsave saves the current definition of a function to a file in the fish configuration directory. This function will be automatically loaded 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. Note that because fish loads functions on-demand, saved functions will not function as event handlers until they are run or sourced otherwise. To activate an event handler for every new shell, add the function to your shell initialization file instead of using funcsave. Back to command index. function - create a function Synopsis function NAME [OPTIONS]; BODY; end Description function creates a new function NAME with the body BODY. A function is a list of commands that will be executed when the name of the function is given as a command. The following options are available: -a NAMES or --argument-names NAMES assigns the value of successive command-line arguments to the names given in NAMES. -d DESCRIPTION or --description=DESCRIPTION is a description of what the function does, suitable as a completion description. -w WRAPPED_COMMAND or --wraps=WRAPPED_COMMAND causes the function to inherit completions from the given wrapped command. See the documentation for complete for more information. -e or --on-event EVENT_NAME tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt. -v or --on-variable VARIABLE_NAME tells fish to run this function when the variable VARIABLE_NAME changes value. -j PGID or --on-job-exit PGID tells fish to run this function when the job with group ID PGID exits. Instead of PGID, 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. -p PID or --on-process-exit PID tells fish to run this function when the fish child process with process ID PID exits. -s or --on-signal SIGSPEC 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). -S or --no-scope-shadowing allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents is independent of the calling function. -V or --inherit-variable NAME snapshots the value of the variable NAME and defines a local variable with that same name and value when the function is defined. This is similar to a closure in other languages like Python but a bit different. Note the word "snapshot" in the first sentence. If you change the value of the variable after defining the function, even if you do so in the same scope (typically another function) the new value will not be used by the function you just created using this option. See the function notify example below for how this might be used. If the user enters any additional arguments after the function, they are inserted into the environment variable array $argv. If the --argument-names option is provided, the arguments are also assigned to names specified in that option. By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the emit builtin. Fish generates the following named events: fish_prompt, which is emitted whenever a new fish prompt is about to be displayed. fish_command_not_found,
{'path': 'public/docs/fish~2.5/commands.html', 'source': 'DevDocs.IO'}