diff --git a/doc_src/alias.txt b/doc_src/alias.txt index 079cabff2..028277a35 100644 --- a/doc_src/alias.txt +++ b/doc_src/alias.txt @@ -13,10 +13,12 @@ alias NAME=DEFINITION `fish` does not keep track of which functions have been defined using `alias`. 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. + \subsection alias-example Example The following code will create `rmi`, which runs `rm` with additional arguments on every invocation. diff --git a/doc_src/and.txt b/doc_src/and.txt index 9d71d67ce..0b4f681d1 100644 --- a/doc_src/and.txt +++ b/doc_src/and.txt @@ -7,21 +7,16 @@ COMMAND1; and COMMAND2 \subsection and-description Description -`and` is used to execute a command if the current exit -status (as set by the last previous command) is 0. +`and` is used to execute a command if the current exit status (as set by the last previous command) is 0. `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. +The exit status of the last foreground command to exit can always be accessed using the $status variable. + \subsection and-example 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. +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. \fish make; and make install; or make clean diff --git a/doc_src/begin.txt b/doc_src/begin.txt index 6807fac4e..6d18a6061 100644 --- a/doc_src/begin.txt +++ b/doc_src/begin.txt @@ -9,21 +9,16 @@ begin; [COMMANDS...;] end `begin` is used to create a new block of code. -The block is unconditionally executed. `begin; ...; end` is equivalent -to `if true; ...; end`. +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` 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. + \subsection begin-example 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. +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. \fish begin @@ -32,8 +27,8 @@ begin end echo $PIRATE -# This will not output anything, since the PIRATE variable went out -# of scope at the end of the block +# This will not output anything, since the PIRATE variable +# went out of scope at the end of the block \endfish In the following code, all output is redirected to the file out.html. diff --git a/doc_src/bg.txt b/doc_src/bg.txt index d05bf54d1..8e9ec2444 100644 --- a/doc_src/bg.txt +++ b/doc_src/bg.txt @@ -7,13 +7,11 @@ bg [PID...] \subsection bg-description 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. +`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. + \subsection bg-example Example `bg %1` will put the job with job ID 1 in the background. - diff --git a/doc_src/bind.txt b/doc_src/bind.txt index 9607c8b0c..59a8dec5d 100644 --- a/doc_src/bind.txt +++ b/doc_src/bind.txt @@ -10,82 +10,83 @@ bind [OPTIONS] SEQUENCE COMMAND `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, @key{Alt,w} can be written as `\ew`. The control -character can be written in much the same way using the `\c` escape, for -example @key{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`. +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, @key{Alt,w} can be written as `\ew`. The control character can be written in much the same way using the `\c` escape, for example @key{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. +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.) +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. +`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. +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. +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. -Key bindings are not saved between sessions by default. To save custom -keybindings, edit the `fish_user_key_bindings` function and insert the -appropriate `bind` statements. +Key bindings are not saved between sessions by default. To save custom keybindings, edit the `fish_user_key_bindings` function and insert the appropriate `bind` statements. 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 + - `-f` or `--function-names` Display a list of available input functions The following special input functions are available: - `backward-char`, moves one character to the left + - `backward-delete-char`, deletes one character of input to the left of the cursor + - `backward-kill-line`, move everything from the beginning of the line to the cursor 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-history`, move to the beginning of the history + - `beginning-of-line`, move to the beginning of the line + - `capitalize-word`, make the current word begin with a capital letter + - `complete`, guess the remainder of the current token + - `delete-char`, delete one character to the right of the cursor + - `delete-line`, delete the entire line + - `downcase-word`, make the current word lowercase + - `dump-functions`, print a list of all key-bindings + - `end-of-history`, move to the end of the history + - `end-of-line`, move to the end of the line + - `explain`, print a description of possible problems with the current command + - `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-line`, move everything from the cursor to the end of the line to the killring + - `kill-whole-line`, move the line to the killring + - `kill-word`, move the next word to the killring + - `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 + \subsection bind-example Examples `bind \cd 'exit'` causes `fish` to exit when @key{Control,D} is pressed. diff --git a/doc_src/block.txt b/doc_src/block.txt index f3f741f12..37b2de0c6 100644 --- a/doc_src/block.txt +++ b/doc_src/block.txt @@ -7,26 +7,23 @@ block [OPTIONS...] \subsection block-description Description -`block` prevents events triggered by `fish` or the -`emit` command from -being delivered and acted upon while the block is in place. +`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. +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. +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` +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 + \subsection block-example Example \fish diff --git a/doc_src/break.txt b/doc_src/break.txt index 2056b054a..32672c09f 100644 --- a/doc_src/break.txt +++ b/doc_src/break.txt @@ -5,13 +5,13 @@ LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end \endfish - \subsection break-description 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`. + \subsection break-example Example The following code searches all .c files for "smurf", and halts at the first occurrence. diff --git a/doc_src/breakpoint.txt b/doc_src/breakpoint.txt index 348c779d9..8645c18dd 100644 --- a/doc_src/breakpoint.txt +++ b/doc_src/breakpoint.txt @@ -7,10 +7,8 @@ breakpoint \subsection breakpoint-description Description -`breakpoint` is used to halt a running script and launch -an interactive debugging prompt. +`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. +For more details, see Debugging fish scripts in the `fish` manual. There are no parameters for `breakpoint`. diff --git a/doc_src/builtin.txt b/doc_src/builtin.txt index 2d915fc34..4c465ef18 100644 --- a/doc_src/builtin.txt +++ b/doc_src/builtin.txt @@ -13,6 +13,10 @@ The following parameters are available: - `-n` or `--names` List the names of all defined builtins + \subsection builtin-example Example -`builtin jobs` executes the jobs builtin, even if a function named jobs exists. +\fish +builtin jobs +# executes the jobs builtin, even if a function named jobs exists +\endfish diff --git a/doc_src/case.txt b/doc_src/case.txt index b05006502..24fde2803 100644 --- a/doc_src/case.txt +++ b/doc_src/case.txt @@ -7,24 +7,14 @@ switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end \subsection case-description 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. +`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. +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 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. -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. \subsection case-example Example diff --git a/doc_src/cd.txt b/doc_src/cd.txt index 200d97675..bb4dc488c 100644 --- a/doc_src/cd.txt +++ b/doc_src/cd.txt @@ -8,20 +8,19 @@ cd [DIRECTORY] \subsection cd-description 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 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. +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 `/`). -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 '`/`'). \subsection cd-example Examples -`cd` changes the working directory to your home directory. +\fish +cd +# changes the working directory to your home directory. -`cd /usr/src/fish-shell` changes the working directory to -`/usr/src/fish-shell`. +cd /usr/src/fish-shell +# changes the working directory to /usr/src/fish-shell +\endfish diff --git a/doc_src/command.txt b/doc_src/command.txt index fd2cd98d2..7d286974f 100644 --- a/doc_src/command.txt +++ b/doc_src/command.txt @@ -9,6 +9,7 @@ command COMMANDNAME [OPTIONS...] `command` forces the shell to execute the program `COMMANDNAME` and ignore any functions or builtins with the same name. + \subsection command-example Example `command ls` causes fish to execute the `ls` program, even if an 'ls' function exists. diff --git a/doc_src/commandline.txt b/doc_src/commandline.txt index b3eaba5ad..347f48700 100644 --- a/doc_src/commandline.txt +++ b/doc_src/commandline.txt @@ -7,69 +7,53 @@ commandline [OPTIONS] [CMD] \subsection commandline-description Description -`commandline` can be used to set or get the current contents of the command -line buffer. +`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 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`. +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. +- `-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. -The following options change the way `commandline` updates the -command line buffer: +- `-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. -- `-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 the way `commandline` updates the command line buffer: -The following options change what part of the commandline is printed -or updated: +- `-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: +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 -- `-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. +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 +- `-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 \subsection commandline-example Example -`commandline -j $history[3]` replaces the job under the cursor with the -third item from the command line history. +`commandline -j $history[3]` replaces the job under the cursor with the third item from the command line history. diff --git a/doc_src/complete.txt b/doc_src/complete.txt index 501eac86d..4f17e216a 100644 --- a/doc_src/complete.txt +++ b/doc_src/complete.txt @@ -6,99 +6,88 @@ complete (-c | --command | -p | --path) COMMAND [(-s | --short-option) SHORT_OPTION] [(-l | --long-option | -o | --old-option) LONG_OPTION] [(-a | --arguments) OPTION_ARGUMENTS] - [(-w | --wraps) WRAPPED_COMMAND] + [(-w | --wraps) WRAPPED_COMMAND] [(-d | --description) DESCRIPTION] \endfish - \subsection complete-description Description For an introduction to specifying completions, see Writing your own completions in the fish manual. -<<<<<<< HEAD - `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 subshells. + - `DESCRIPTION` is a description of what the option and/or option arguments do. + - `-C STRING` or `--do-complete=STRING` makes complete try to find all possible completions for the specified string. + - `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the specified command to inherit completions from the wrapped command. + - `-e` or `--erase` implies that the specified completion should be deleted. + - `-f` or `--no-files` specifies that the option specified by this completion may not be followed by a filename. + - `-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. + - `-o` or `--old-option` implies that the command uses old long style options with only one dash. + - `-p` or `--path` implies that the string `COMMAND` is the full path of the command. + - `-r` or `--require-parameter` specifies that the option specified by this completion always must have an option argument, i.e. may not be followed by another option. + - `-u` or `--unauthoritative` implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors. + - `-A` or `--authoritative` implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors. + - `-x` or `--exclusive` implies both `-r` and `-f`. -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: +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`') 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, command path, or command -switches may all be used multiple times to specify multiple commands -which have the same completion or multiple switches accepted by a -command. +The options for specifying command name, command path, or command switches may all be used multiple times to specify multiple commands which have the same completion or multiple switches accepted by a command. -The \c -w or \c --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 \c -e or \c --erase options. +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. + +When erasing completions, it is possible to either erase all completions for a specific command by specifying `complete -e -c COMMAND`, or by specifying a specific completion option to delete by specifying either a long, short or old style option. -When erasing completions, it is possible to either erase all -completions for a specific command by specifying `complete -e -c -COMMAND`, or by specifying a specific completion option to delete -by specifying either a long, short or old style option. \subsection complete-example Example -The short style option `-o` for the `gcc` command requires -that a file follows it. This can be done using writing: +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: +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: +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)"` +`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. +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"` -`-l nodeps -d "Don't check dependencies"` +`complete -c rpm -n "__fish_contains_opt -s e erase" -l nodeps -d "Don't check dependencies"` -where `__fish_contains_opt` is a function that checks the commandline -buffer for the presence of a specified set of options. +where `__fish_contains_opt` is a function that checks the commandline 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. +Now hub inherits all of the completions from git. Note this can also be specified in a function declaration. diff --git a/doc_src/contains.txt b/doc_src/contains.txt index 2ec6e0920..4c947c9df 100644 --- a/doc_src/contains.txt +++ b/doc_src/contains.txt @@ -7,15 +7,14 @@ contains [OPTIONS] KEY [VALUES...] \subsection contains-description 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. +`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 - `-h` or `--help` display this message + \subsection contains-example Example \fish diff --git a/doc_src/continue.txt b/doc_src/continue.txt index cb92c9cf3..1585b04a8 100644 --- a/doc_src/continue.txt +++ b/doc_src/continue.txt @@ -6,9 +6,11 @@ LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end \endfish \subsection continue-description 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. \subsection continue-example Example + The following code removes all tmp files that do not contain the word smurf. \fish diff --git a/doc_src/count.txt b/doc_src/count.txt index bf66d2071..4587209fd 100644 --- a/doc_src/count.txt +++ b/doc_src/count.txt @@ -7,25 +7,21 @@ count $VARIABLE \subsection count-description 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` 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`'. -`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. +`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. + \subsection count-example Example -
+\fish count $PATH --returns the number of directories in the users PATH variable. +# 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'. +# Returns the number of files in the current working directory ending with the suffix '.txt'. +\endfish \ No newline at end of file diff --git a/doc_src/design.hdr b/doc_src/design.hdr index e7d09d4c2..c8f880652 100644 --- a/doc_src/design.hdr +++ b/doc_src/design.hdr @@ -8,135 +8,101 @@ \section design-overview Overview -This is a description of the design principles that have been used to -design fish. The fish design has three high level goals. These are: +This is a description of the design principles that have been used to design fish. The fish design has three high level goals. These are: --# Everything that can be done in other shell languages should be -possible to do in fish, though fish may rely on external commands in -doing so. --# Fish should be user friendly, but not at the expense of expressiveness. -Most tradeoffs between power and ease of use can be avoided with careful design. --# Whenever possible without breaking the above goals, fish should -follow the Posix syntax. +-# Everything that can be done in other shell languages should be possible to do in fish, though fish may rely on external commands in doing so. + +-# Fish should be user friendly, but not at the expense of expressiveness. Most tradeoffs between power and ease of use can be avoided with careful design. + +-# Whenever possible without breaking the above goals, fish should follow the Posix syntax. + +To achieve these high-level goals, the fish design relies on a number of more specific design principles. These are presented below, together with a rationale and a few examples for each. -To achieve these high-level goals, the fish design relies on a number -of more specific design principles. These are presented below, -together with a rationale and a few examples for each. \section ortho The law of orthogonality -The shell language should have a small set of orthogonal features. Any -situation where two features are related but not identical, one of them -should be removed, and the other should be made powerful and general -enough to handle all common use cases of either feature. +The shell language should have a small set of orthogonal features. Any situation where two features are related but not identical, one of them should be removed, and the other should be made powerful and general enough to handle all common use cases of either feature. Rationale: - -Related features make the language larger, which makes it harder to -learn. It also increases the size of the sourcecode, making the -program harder to maintain and update. +Related features make the language larger, which makes it harder to learn. It also increases the size of the sourcecode, making the program harder to maintain and update. Examples: - Here documents are too similar to using echo inside of a pipeline. + - Subshells, command substitution and process substitution are strongly related. `fish` only supports command substitution, the others can be achieved either using a block or the psub shellscript function. + - Having both aliases and functions is confusing, especially since both of them have limitations and problems. `fish` functions have none of the drawbacks of either syntax. + - The many Posix quoting styles are silly, especially $''. -\section sep The law of responsiveness + +\section design-response The law of responsiveness The shell should attempt to remain responsive to the user at all times, even in the face of contended or unresponsive filesystems. It is only acceptable to block in response to a user initiated action, such as running a command. Rationale: - Bad performance increases user-facing complexity, because it trains users to recognize and route around slow use cases. It is also incredibly frustrating. Examples: - Features like syntax highlighting and autosuggestions must perform all of their disk I/O asynchronously. + - Startup should minimize forks and disk I/O, so that fish can be started even if the system is under load. -\section conf Configurability is the root of all evil +\section design-configurability Configurability is the root of all evil -Every configuration option in a program is a place where the program -is too stupid to figure out for itself what the user really wants, and -should be considered a failiure of both the program and the programmer -who implemented it. +Every configuration option in a program is a place where the program is too stupid to figure out for itself what the user really wants, and should be considered a failiure of both the program and the programmer who implemented it. Rationale: - -Different configuration options are a nightmare to maintain, since the -number of potential bugs caused by specific configuration combinations -quickly becomes an issue. Configuration options often imply -assumptions about the code which change when reimplementing the code, -causing issues with backwards compatibility. But mostly, configuration -options should be avoided since they simply should not exist, as the -program should be smart enough to do what is best, or at least a good -enough approximation of it. +Different configuration options are a nightmare to maintain, since the number of potential bugs caused by specific configuration combinations quickly becomes an issue. Configuration options often imply assumptions about the code which change when reimplementing the code, causing issues with backwards compatibility. But mostly, configuration options should be avoided since they simply should not exist, as the program should be smart enough to do what is best, or at least a good enough approximation of it. Examples: - Fish allows the user to set various syntax highlighting colors. This is needed because fish does not know what colors the terminal uses by default, which might make some things unreadable. The proper solution would be for text color preferences to be defined centrally by the user for all programs, and for the terminal emulator to send these color properties to fish. + - Fish does not allow you to set the history filename, the number of history entries, different language substyles or any number of other common shell configuration options. -A special note on the evils of configurability is the long list of -very useful features found in some shells, that are not turned on by -default. Both zsh and bash support command specific completions, but -no such completions are shipped with bash by default, and they are -turned off by default in zsh. Other features that zsh support that are -disabled by default include tab-completion of strings containing -wildcards, a sane completion pager and a history file. +A special note on the evils of configurability is the long list of very useful features found in some shells, that are not turned on by default. Both zsh and bash support command specific completions, but no such completions are shipped with bash by default, and they are turned off by default in zsh. Other features that zsh support that are disabled by default include tab-completion of strings containing wildcards, a sane completion pager and a history file. + \section user The law of user focus -When designing a program, one should first think about how to make a -intuitive and powerful program. Implementation issues should only be -considered once a user interface has been designed. +When designing a program, one should first think about how to make a intuitive and powerful program. Implementation issues should only be considered once a user interface has been designed. Rationale: - -This design rule is different than the others, since it describes how -one should go about designing new features, not what the features -should be. The problem with focusing on what can be done, and what is -easy to do, is that to much of the implementation is exposed. This -means that the user must know a great deal about the underlying system -to be able to guess how the shell works, it also means that the -language will often be rather low-level. +This design rule is different than the others, since it describes how one should go about designing new features, not what the features should be. The problem with focusing on what can be done, and what is easy to do, is that to much of the implementation is exposed. This means that the user must know a great deal about the underlying system to be able to guess how the shell works, it also means that the language will often be rather low-level. Examples: - - There should only be one type of input to the shell, lists of commands. Loops, conditionals and variable assignments are all performed through regular commands. + - The differences between builtin commands and shellscript functions should be made as small as possible. Builtins and shellscript functions should have exactly the same types of argument expansion as other commands, should be possible to use in any position in a pipeline, and should support any io redirection. + - Instead of forking when performing command substitution to provide a fake variable scope, all fish commands are performed from the same process, and fish instead supports true scoping. + - All blocks end with the `end` builtin. + \section disc The law of discoverability -A program should be designed to make its features as -easy as possible to discover for the user. +A program should be designed to make its features as easy as possible to discover for the user. Rationale: +A program whose features are discoverable turns a new user into an expert in a shorter span of time, since the user will become an expert on the program simply by using it. -A program whose features are discoverable turns a new user into an -expert in a shorter span of time, since the user will become an expert -on the program simply by using it. - -The main benefit of a graphical program over a command line-based -program is discoverability. In a graphical program, one can discover -all the common features by simply looking at the user interface and -guessing what the different buttons, menus and other widgets do. The -traditional way to discover features in commandline programs is -through manual pages. This requires both that the user starts to use a -different program, and the she/he then remembers the new information -until the next time she/he uses the same program. +The main benefit of a graphical program over a command line-based program is discoverability. In a graphical program, one can discover all the common features by simply looking at the user interface and guessing what the different buttons, menus and other widgets do. The traditional way to discover features in commandline programs is through manual pages. This requires both that the user starts to use a different program, and the she/he then remembers the new information until the next time she/he uses the same program. Examples: - - Everything should be tab-completable, and every tab completion should have a description. + - Every syntax error and error in a builtin command should contain an error message describing what went wrong and a relevant help page. Whenever possible, errors should be flagged red by the syntax highlighter. + - The help manual should be easy to read, easily available from the shell, complete and contain many examples + - The language should be uniform, so that once the user understands the command/argument syntax, he will know the whole language, and be able to use tab-completion to discover new featues. + + \htmlonly[block] diff --git a/doc_src/dirh.txt b/doc_src/dirh.txt index 00bd581fc..d25b9c2ad 100644 --- a/doc_src/dirh.txt +++ b/doc_src/dirh.txt @@ -7,8 +7,6 @@ dirh \subsection dirh-description 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` 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. diff --git a/doc_src/dirs.txt b/doc_src/dirs.txt index c15834c57..231b678b9 100644 --- a/doc_src/dirs.txt +++ b/doc_src/dirs.txt @@ -6,7 +6,7 @@ dirs \endfish \subsection dirs-description Description -`dirs` prints the current directory stack, as created by the -`pushd` command. + +`dirs` prints the current directory stack, as created by the `pushd` command. `dirs` does not accept any parameters. diff --git a/doc_src/echo.txt b/doc_src/echo.txt index 7b9b03182..d70627161 100644 --- a/doc_src/echo.txt +++ b/doc_src/echo.txt @@ -12,9 +12,13 @@ echo [OPTIONS] [STRING] 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 + - `-h`, `--help` Display this help \subsection echo-escapes Escape Sequences @@ -22,20 +26,35 @@ The following options are available: 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) \subsection echo-example Example -`echo 'Hello World'` Print hello world to stdout +\fish +echo 'Hello World' +# Print hello world to stdout -`echo -e 'Top\nBottom'` Print Top and Bottom on separate lines, using an escape sequence +echo -e 'Top\nBottom' +# Print Top and Bottom on separate lines, using an escape sequence +\endfish diff --git a/doc_src/else.txt b/doc_src/else.txt index a22cfcdb9..76e0c61f3 100644 --- a/doc_src/else.txt +++ b/doc_src/else.txt @@ -6,13 +6,13 @@ if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end \endfish \subsection else-description 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. + +`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. + \subsection else-example Example -The following code tests whether a file `foo`.txt exists as a regular file. +The following code tests whether a file `foo.txt` exists as a regular file. \fish if test -f foo.txt diff --git a/doc_src/emit.txt b/doc_src/emit.txt index d8f17b45e..df154c5df 100644 --- a/doc_src/emit.txt +++ b/doc_src/emit.txt @@ -9,10 +9,10 @@ emit EVENT_NAME [ARGUMENTS...] `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. + \subsection emit-example Example -The following code first defines an event handler for the generic -event named 'test_event', and then emits an event of that type. +The following code first defines an event handler for the generic event named 'test_event', and then emits an event of that type. \fish function event_test --on-event test_event diff --git a/doc_src/end.txt b/doc_src/end.txt index aca294955..76cbe3603 100644 --- a/doc_src/end.txt +++ b/doc_src/end.txt @@ -10,10 +10,10 @@ switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end \endfish \subsection end-description Description + `end` ends a block of commands. For more information, read the -documentation for the block constructs, such as \c if, \c for and \c -while. +documentation for the block constructs, such as `if`, `for` and `while`. -The \c end command does not change the current exit status. +The `end` command does not change the current exit status. diff --git a/doc_src/eval.txt b/doc_src/eval.txt index c966b5761..1ba8f97ee 100644 --- a/doc_src/eval.txt +++ b/doc_src/eval.txt @@ -8,11 +8,10 @@ eval [COMMANDS...] \subsection eval-description 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. + \subsection eval-example Example -The following code will call the ls command. Note that \c fish does not -support the use of shell variables as direct commands; \c eval can -be used to work around this. +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. \fish set cmd ls diff --git a/doc_src/exec.txt b/doc_src/exec.txt index 4bcd39996..f8936101a 100644 --- a/doc_src/exec.txt +++ b/doc_src/exec.txt @@ -7,11 +7,9 @@ exec COMMAND [OPTIONS...] \subsection exec-description Description -`exec` replaces the currently running shell with a new command. -On successful completion, `exec` never returns. `exec` cannot be used -inside a pipeline. +`exec` replaces the currently running shell with a new command. On successful completion, `exec` never returns. `exec` cannot be used inside a pipeline. + \subsection exec-example Example -`exec emacs` starts up the emacs text editor, and exits `fish`. -When emacs exits, the session will terminate. +`exec emacs` starts up the emacs text editor, and exits `fish`. When emacs exits, the session will terminate. diff --git a/doc_src/exit.txt b/doc_src/exit.txt index fcec4b923..5b43b612a 100644 --- a/doc_src/exit.txt +++ b/doc_src/exit.txt @@ -7,10 +7,6 @@ exit [STATUS] \subsection exit-description 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. +`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 . builtin) the rest of the file will be skipped, -but the shell itself will not exit. +If exit is called while sourcing a file (using the . builtin) the rest of the file will be skipped, but the shell itself will not exit. diff --git a/doc_src/faq.hdr b/doc_src/faq.hdr index 6d3ead30a..99c2ada49 100644 --- a/doc_src/faq.hdr +++ b/doc_src/faq.hdr @@ -7,21 +7,37 @@ \endhtmlonly - How do I set or clear an environment variable? + - How do I run a command every login? What's fish's equivalent to `.bashrc`? + - How do I set my prompt? + - How do I run a command from history? + - How do I run a subcommand? The backtick doesn't work! + - How do I get the exit status of a command? + - How do I set an environment variable for just one command? + - How do I customize my syntax highlighting colors? + - How do I update man page completions? + - Why does cd, pwd and other fish commands always resolve symlinked directories to their canonical path? + - I accidentally entered a directory path and fish changed directory. What happened? + - The open command doesn't work. + - How do I make fish my default shell? + - I'm seeing weird output before each prompt when using screen. What's wrong? + - How do I change the greeting message? + - Why doesn't history substitution ("!$" etc.) work? + - How do I uninstall fish? \htmlonly[block] @@ -31,6 +47,7 @@
\\a' escapes the alert character
+
- '\\b' escapes the backspace character
+
- '\\e' escapes the escape character
+
- '\\f' escapes the form feed character
+
- '\\n' escapes a newline character
+
- '\\r' escapes the carriage return character
+
- '\\t' escapes the tab character
+
- '\\v' escapes the vertical tab character
+
- '\\ ' escapes the space character
+
- '\\$' escapes the dollar character
+
- '\\\\' escapes the backslash character
+
- '\\*' escapes the star character
+
- '\\?' escapes the question mark character
+
- '\\~' escapes the tilde character
+
- '\\%' escapes the percent character
+
- '\\#' escapes the hash character
+
- '\\(' escapes the left parenthesis character
+
- '\\)' escapes the right parenthesis character
+
- '\\{' escapes the left curly bracket character
+
- '\\}' escapes the right curly bracket character
+
- '\\[' escapes the left bracket character
+
- '\\]' escapes the right bracket character
+
- '\\' escapes the less than character
+
- '\\\>' escapes the more than character
+
- '\\^' escapes the circumflex character
+
- '\\&' escapes the ampersand character
+
- '\\;' escapes the semicolon character
+
- '\\"' escapes the quote character
+
- '\\'' escapes the apostrophe character
+
- '\\xxx', where xx is a hexadecimal number, escapes the ascii character with the specified value. For example, `\x9` is the tab character.
-- '\\Xxx', where xx is a hexadecimal number, escapes a byte of data with the specified value. If you are using a mutibyte encoding, this can be used to enter invalid strings. Only use this if you know what you are doing.
+
+- '\\Xxx', where xx is a hexadecimal number, escapes a byte of data with the specified value. If you are using a mutibyte encoding, this can be used to enter
+invalid strings. Only use this if you know what you are doing.
+
- '\\ooo', where ooo is an octal number, escapes the ascii character with the specified value. For example, `\011` is the tab character.
+
- '\\uxxxx', where xxxx is a hexadecimal number, escapes the 16-bit Unicode character with the specified value. For example, `\u9` is the tab character.
+
- '\\Uxxxxxxxx', where xxxxxxxx is a hexadecimal number, escapes the 32-bit Unicode character with the specified value. For example, `\U9` is the tab character.
-- '\\cx', where x is a letter of the alphabet, escapes the control sequence generated by pressing the control key and the specified letter. For example, `\ci` is the tab character
+
+- '\\cx', where x is a letter of the alphabet, escapes the control sequence generated by pressing the control key and the specified letter. For example, `\ci` is
+the tab character
\subsection redirects Input/Output (IO) redirection
@@ -121,7 +163,9 @@ Some characters can not be written directly on the command line. For these chara
Most programs use three input/output (IO) streams, each represented by a number called a file descriptor (FD). These are:
- Standard input, FD 0, for reading, defaults to reading from the keyboard.
+
- Standard output, FD 1, for writing, defaults to writing to the screen.
+
- Standard error, FD 2, for writing errors and warnings, defaults to writing to the screen.
The reason for providing for two output file descriptors is to allow
@@ -132,15 +176,21 @@ Any file descriptor can be directed to a different output than its default throu
An example of a file redirection is `echo hello > output.txt`, which directs the output of the echo command to the file output.txt.
- To read standard input from a file, write `