docs: standardise on "fish" as the name for the shell

This is a potential bikeshed project but if fish is being used as a
proper noun, it should either be capitalised all the time or none of the
time, and the latter looks better.
This commit is contained in:
David Adam
2026-06-02 14:13:18 +08:00
parent 7304fdfffb
commit 1abeae2f4b
25 changed files with 103 additions and 103 deletions

View File

@@ -1460,7 +1460,7 @@ Deprecations and removed features
Like ``stderr-nocaret``, they will eventually be made read-only.
- Most ``string`` subcommands no longer append a newline to their input if the input didn't have one (:issue:`8473`, :issue:`3847`)
- Fish's escape sequence removal (like for ``string length --visible`` or to figure out how wide the prompt is) no longer has special support for non-standard color sequences like from Data General terminals, e.g. the Data General Dasher D220 from 1984. This removes a bunch of work in the common case, allowing ``string length --visible`` to be much faster with unknown escape sequences. We don't expect anyone to have ever used fish with such a terminal (:issue:`8769`).
- fish's escape sequence removal (like for ``string length --visible`` or to figure out how wide the prompt is) no longer has special support for non-standard color sequences like from Data General terminals, e.g. the Data General Dasher D220 from 1984. This removes a bunch of work in the common case, allowing ``string length --visible`` to be much faster with unknown escape sequences. We don't expect anyone to have ever used fish with such a terminal (:issue:`8769`).
- Code to upgrade universal variables from fish before 3.0 has been removed. Users who upgrade directly from fish versions 2.7.1 or before will have to set their universal variables & abbreviations again. (:issue:`8781`)
- The meaning of an empty color variable has changed (:issue:`8793`). Previously, when a variable was set but empty, it would be interpreted as the "normal" color. Now, empty color variables cause the same effect as unset variables - the general highlighting variable for that type is used instead. For example::
@@ -1471,14 +1471,14 @@ Deprecations and removed features
This makes it easier to make self-contained color schemes that don't accidentally use color that was set before.
``fish_config`` has been adjusted to set known color variables that a theme doesn't explicitly set to empty.
- ``eval`` is now a reserved keyword, so it can't be used as a function name. This follows ``set`` and ``read``, and is necessary because it can't be cleanly shadowed by a function - at the very least ``eval set -l argv foo`` breaks. Fish will ignore autoload files for it, so left over ``eval.fish`` from previous fish versions won't be loaded.
- ``eval`` is now a reserved keyword, so it can't be used as a function name. This follows ``set`` and ``read``, and is necessary because it can't be cleanly shadowed by a function - at the very least ``eval set -l argv foo`` breaks. fish will ignore autoload files for it, so left over ``eval.fish`` from previous fish versions won't be loaded.
- The git prompt in informative mode now defaults to skipping counting untracked files, as this was extremely slow. To turn it on, set :envvar:`__fish_git_prompt_showuntrackedfiles` or set the git config value "bash.showuntrackedfiles" to ``true`` explicitly (which can be done for individual repositories). The "informative+vcs" sample prompt already skipped display of untracked files, but didn't do so in a way that skipped the computation, so it should be quite a bit faster in many cases (:issue:`8980`).
- The ``__terlar_git_prompt`` function, used by the "Terlar" sample prompt, has been rebuilt as a configuration of the normal ``fish_git_prompt`` to ease maintenance, improve performance and add features (like reading per-repo git configuration). Some slight changes remain; users who absolutely must have the same behavior are encouraged to copy the old function (:issue:`9011`, :issue:`7918`, :issue:`8979`).
Scripting improvements
----------------------
- Quoted command substitution that directly follow a variable expansion (like ``echo "$var$(echo x)"``) no longer affect the variable expansion (:issue:`8849`).
- Fish now correctly expands command substitutions that are preceded by an escaped dollar (like ``echo \$(echo)``). This regressed in version 3.4.0.
- fish now correctly expands command substitutions that are preceded by an escaped dollar (like ``echo \$(echo)``). This regressed in version 3.4.0.
- ``math`` can now handle underscores (``_``) as visual separators in numbers (:issue:`8611`, :issue:`8496`)::
math 5 + 2_123_252
@@ -1498,7 +1498,7 @@ Scripting improvements
Interactive improvements
------------------------
- Fish now reports a special error if a command wasn't found and there is a non-executable file by that name in :envvar:`PATH` (:issue:`8804`).
- fish now reports a special error if a command wasn't found and there is a non-executable file by that name in :envvar:`PATH` (:issue:`8804`).
- ``less`` and other interactive commands would occasionally be stopped when run in a pipeline with fish functions; this has been fixed (:issue:`8699`).
- Case-changing autosuggestions generated mid-token now correctly append only the suffix, instead of duplicating the token (:issue:`8820`).
- ``ulimit`` learned a number of new options for the resource limits available on Linux, FreeBSD ande NetBSD, and returns a specific warning if the limit specified is not available on the active operating system (:issue:`8823`, :issue:`8786`).
@@ -1508,9 +1508,9 @@ Interactive improvements
- Since fish 3.2.0, pressing :kbd:`ctrl-d` while a command is running would end up inserting a space into the next commandline, which has been fixed (:issue:`8871`).
- A bug that caused multi-line prompts to be moved down a line when pasting or switching modes has been fixed (:issue:`3481`).
- The Web-based configuration system no longer strips too many quotes in the abbreviation display (:issue:`8917`, :issue:`8918`).
- Fish started with ``--no-config`` will now use the default keybindings (:issue:`8493`)
- fish started with ``--no-config`` will now use the default keybindings (:issue:`8493`)
- When fish inherits a :envvar:`USER` environment variable value that doesn't correspond to the current effective user ID, it will now correct it in all cases (:issue:`8879`, :issue:`8583`).
- Fish sets a new :envvar:`EUID` variable containing the current effective user id (:issue:`8866`).
- fish sets a new :envvar:`EUID` variable containing the current effective user id (:issue:`8866`).
- ``history search`` no longer interprets the search term as an option (:issue:`8853`)
- The status message when a job terminates should no longer be erased by a multiline prompt (:issue:`8817`)
@@ -1771,7 +1771,7 @@ Improved terminal support
Other improvements
------------------
- Fish's test suite now uses ``ctest``, and has become much faster to run. It is now also possible to run only specific tests with targets named ``test_$filename`` - ``make test_set.fish`` only runs the set.fish test. (:issue:`7851`)
- fish's test suite now uses ``ctest``, and has become much faster to run. It is now also possible to run only specific tests with targets named ``test_$filename`` - ``make test_set.fish`` only runs the set.fish test. (:issue:`7851`)
- The HTML version of the documentation now includes copy buttons for code examples (:issue:`8218`).
- The HTML version of the documentation and the web-based configuration tool now pick more modern system fonts instead of falling back to Arial and something like Courier New most of the time (:issue:`8632`).
- The Debian & Ubuntu package linked from fishshell.com is now a single package, rather than split into ``fish`` and ``fish-common`` (:issue:`7845`).
@@ -3370,7 +3370,7 @@ Other fixes and improvements
variables (:issue:`4200`, :issue:`4341`), executing functions, globs (:issue:`4579`),
``string`` reading from standard input (:issue:`4610`), and slicing history
(in particular, ``$history[1]`` for the last executed command).
- Fishs internal wcwidth function has been updated to deal with newer
- fishs internal wcwidth function has been updated to deal with newer
Unicode, and the width of some characters can be configured via the
``fish_ambiguous_width`` (:issue:`5149`) and ``fish_emoji_width`` (:issue:`2652`)
variables. Alternatively, a new build-time option INTERNAL_WCWIDTH
@@ -4126,7 +4126,7 @@ Backward-incompatible changes
Other notable fixes and improvements
------------------------------------
- Fish no longer silences errors in config.fish (:issue:`2702`)
- fish no longer silences errors in config.fish (:issue:`2702`)
- Directory autosuggestions will now descend as far as possible if
there is only one child directory (:issue:`2531`)
- Add support for bright colors (:issue:`1464`)
@@ -4156,13 +4156,13 @@ Other notable fixes and improvements
systemd-analyze, localectl, timedatectl
- and more
- Fish no longer has a function called sgrep, freeing it for user
- fish no longer has a function called sgrep, freeing it for user
customization (:issue:`2245`)
- A rewrite of the completions for cd, fixing a few bugs (:issue:`2299`, :issue:`2300`,
:issue:`562`)
- Linux VTs now run in a simplified mode to avoid issues (:issue:`2311`)
- The vi-bindings now inherit from the emacs bindings
- Fish will also execute ``fish_user_key_bindings`` when in vi-mode
- fish will also execute ``fish_user_key_bindings`` when in vi-mode
- ``funced`` will now also check $VISUAL (:issue:`2268`)
- A new ``suspend`` function (:issue:`2269`)
- Subcommand completion now works better with split /usr (:issue:`2141`)
@@ -4231,7 +4231,7 @@ Other notable fixes and improvements
- New documentation design (:issue:`1662`), which requires a Doxygen version
1.8.7 or newer to build.
- Fish now defines a default directory for other packages to provide
- fish now defines a default directory for other packages to provide
completions. By default this is
``/usr/share/fish/vendor-completions.d``; on systems with
``pkgconfig`` installed this path is discoverable with

View File

@@ -1,10 +1,10 @@
####################
Contributing To Fish
Contributing To fish
####################
This document tells you how you can contribute to fish.
Fish is free and open source software, distributed under the terms of the GPLv2.
fish is free and open source software, distributed under the terms of the GPLv2.
Contributions are welcome, and there are many ways to contribute!
@@ -21,7 +21,7 @@ Archives are available at https://lists.sr.ht/~krobelus/fish-shell/.
GitHub
======
Fish is available on GitHub, at https://github.com/fish-shell/fish-shell.
fish is available on GitHub, at https://github.com/fish-shell/fish-shell.
First, you'll need an account there, and you'll need a git clone of fish.
Fork it on GitHub and then run::
@@ -140,7 +140,7 @@ To reformat files, there is an xtask
cargo xtask format --all
cargo xtask format somefile.rs some.fish
Fish Script Style Guide
fish Script Style Guide
-----------------------
1. All fish scripts, such as those in the *share/functions* and *tests*
@@ -154,7 +154,7 @@ Fish Script Style Guide
for public vars or ``_fish`` for private vars to minimize the
possibility of name clashes with user defined vars.
Configuring Your Editor for Fish Scripts
Configuring Your Editor for fish Scripts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you use Vim: Install `vim-fish <https://github.com/dag/vim-fish>`__,
@@ -253,7 +253,7 @@ To run all tests and linters, use::
Contributing Translations
=========================
Fish uses GNU gettext to translate messages from English to other languages.
fish uses GNU gettext to translate messages from English to other languages.
We use custom tools for extracting messages from source files and to localize at runtime.
This means that we do not have a runtime dependency on the gettext library.
It also means that some features are not supported, such as message context and plurals.

View File

@@ -62,7 +62,7 @@ Windows
for Linux with the instructions for the appropriate distribution
listed above under “Packages for Linux”, or from source with the
instructions below.
- Fish can also be installed on all versions of Windows using
- fish can also be installed on all versions of Windows using
`Cygwin <https://cygwin.com/>`__ or `MSYS2 <https://github.com/Berrysoft/fish-msys2>`__.
Building from source

View File

@@ -221,7 +221,7 @@ These variables are passed to the function as local exported variables.
The script should write any error messages to stdout, not stderr. It should return a status of zero if the flag value is valid otherwise a non-zero status to indicate it is invalid.
Fish ships with a ``_validate_int`` function that accepts a ``--min`` and ``--max`` flag. Let's say your command accepts a ``-m`` or ``--max`` flag and the minimum allowable value is zero and the maximum is 5. You would define the option like this: ``m/max=!_validate_int --min 0 --max 5``. The default if you call ``_validate_int`` without those flags is to check that the value is a valid integer with no limits on the min or max value allowed.
fish ships with a ``_validate_int`` function that accepts a ``--min`` and ``--max`` flag. Let's say your command accepts a ``-m`` or ``--max`` flag and the minimum allowable value is zero and the maximum is 5. You would define the option like this: ``m/max=!_validate_int --min 0 --max 5``. The default if you call ``_validate_int`` without those flags is to check that the value is a valid integer with no limits on the min or max value allowed.
Here are some examples of flag validations::

View File

@@ -34,9 +34,9 @@ supplied. This default behaviour can be enforced with the ``-L`` or ``--no-deref
The ``-P`` or ``--dereference`` option resolves all symbolic links first. This was the default in fish versions before 3.0.0.
Fish will also try to change directory if given a command that looks like a directory (starting with **.**, **/** or **~**, or ending with **/**), without explicitly requiring **cd**.
fish will also try to change directory if given a command that looks like a directory (starting with **.**, **/** or **~**, or ending with **/**), without explicitly requiring **cd**.
Fish also ships a wrapper function around the builtin **cd** that understands ``cd -`` as changing to the previous directory.
fish also ships a wrapper function around the builtin **cd** that understands ``cd -`` as changing to the previous directory.
See also :doc:`prevd <prevd>`.
This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables.
If you make those universal variables your **cd** history is shared among all fish instances.

View File

@@ -81,7 +81,7 @@ The following options are available:
**-h** or **--help**
Displays help about using this command.
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 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 getopt library. These styles are:
- Short options, like ``-a``. Short options are a single character long, are preceded by a single hyphen and can be grouped together (like ``-la``, which is equivalent to ``-l -a``). Option arguments may be specified by appending the option with the value (``-w32``), or, if ``--require-parameter`` is given, in the following parameter (``-w 32``).

View File

@@ -18,7 +18,7 @@ When fish tries to execute a command and can't find it, it invokes this function
It can print a message to tell you about it, and it often also checks for a missing package that would include the command.
Fish ships multiple handlers for various operating systems and chooses from them when this function is loaded,
fish ships multiple handlers for various operating systems and chooses from them when this function is loaded,
or you can define your own.
It receives the full commandline as one argument per token, so $argv[1] contains the missing command.

View File

@@ -27,7 +27,7 @@ Further information on how to use :ref:`vi mode <vi-mode>`.
Differences from Vim
--------------------
Fish's vi mode aims to be familiar to vim users, but there are some differences:
fish's vi mode aims to be familiar to vim users, but there are some differences:
**Word character handling**
In vim, underscore (``_``) is treated as a keyword character by default, so word motions like ``w``, ``b``, and ``e`` treat ``foo_bar`` as a single word. In fish, underscore is treated as punctuation, so word motions stop at underscores. For example, pressing ``w`` on ``foo_bar`` in fish stops at the ``_``, while in vim it would jump past the entire identifier.

View File

@@ -40,7 +40,7 @@ Run::
>_ funced fish_prompt
This will open up your editor, allowing you to modify the function. When you're done, save and quit. Fish will reload the function, so you should see the changes right away.
This will open up your editor, allowing you to modify the function. When you're done, save and quit. fish will reload the function, so you should see the changes right away.
When you're done, use::

View File

@@ -32,7 +32,7 @@ The following options are available:
If the wrapped command is the same as the function name, this will be ignored.
**-e** *EVENT_NAME* or **--on-event** *EVENT_NAME*
Run this function when the specified named event is emitted. Fish internally generates named events, for example, when showing the prompt. Custom events can be emitted using the :doc:`emit <emit>` command.
Run this function when the specified named event is emitted. fish internally generates named events, for example, when showing the prompt. Custom events can be emitted using the :doc:`emit <emit>` command.
**-v** *VARIABLE_NAME* or **--on-variable** *VARIABLE_NAME*
Run this function when the variable *VARIABLE_NAME* changes value. Note that :program:`fish` makes no guarantees on any particular timing or even that the function will be run for every single ``set``. Rather it will be run when the variable has been set at least once, possibly skipping some values or being run when the variable has been set to the same value (except for universal variables set in other shells - only changes in the value will be picked up for those).
@@ -56,7 +56,7 @@ The following options are available:
**-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.
The event handler switches (``on-event``, ``on-variable``, ``on-job-exit``, ``on-process-exit`` and ``on-signal``) cause a function to run automatically at specific events. New named events for ``--on-event`` can be fired using the :doc:`emit <emit>` builtin. Fish already generates a few events, see :ref:`event` for more.
The event handler switches (``on-event``, ``on-variable``, ``on-job-exit``, ``on-process-exit`` and ``on-signal``) cause a function to run automatically at specific events. New named events for ``--on-event`` can be fired using the :doc:`emit <emit>` builtin. fish already generates a few events, see :ref:`event` for more.
Functions names cannot be reserved words. These are elements of fish syntax or builtin commands which are essential for the operations of the shell. Current reserved words are ``[``, ``_``, ``and``, ``argparse``, ``begin``, ``break``, ``builtin``, ``case``, ``command``, ``continue``, ``else``, ``end``, ``eval``, ``exec``, ``for``, ``function``, ``if``, ``not``, ``or``, ``read``, ``return``, ``set``, ``status``, ``string``, ``switch``, ``test``, ``time``, and ``while``.

View File

@@ -109,7 +109,7 @@ You can set the ``fish_history`` variable to another name for the current shell
You can change ``fish_history`` at any time (by using ``set -x fish_history "session_name"``) and it will take effect right away. If you set it to ``"default"``, it will use the default session name (which is ``"fish"``).
Other shells such as bash and zsh use a variable named ``HISTFILE`` for a similar purpose. Fish uses a different name to avoid conflicts and signal that the behavior is different (session name instead of a file path). Also, if you set the var to anything other than ``fish`` or ``default`` it will inhibit importing the bash history. That's because the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation.
Other shells such as bash and zsh use a variable named ``HISTFILE`` for a similar purpose. fish uses a different name to avoid conflicts and signal that the behavior is different (session name instead of a file path). Also, if you set the var to anything other than ``fish`` or ``default`` it will inhibit importing the bash history. That's because the most common use case for this feature is to avoid leaking private or sensitive history when giving a presentation.
Notes
-----

View File

@@ -53,7 +53,7 @@ See also
``if`` is only as useful as the command used as the condition.
Fish ships a few:
fish ships a few:
- :doc:`test` can compare numbers, strings and check paths
- :doc:`string` can perform string operations including wildcard and regular expression matches

View File

@@ -218,6 +218,6 @@ Examples
Compatibility notes
-------------------
Fish 1.x and 2.x releases relied on the ``bc`` command for handling ``math`` expressions. Starting with fish 3.0.0 fish uses the tinyexpr library and evaluates the expression without the involvement of any external commands.
fish 1.x and 2.x releases relied on the ``bc`` command for handling ``math`` expressions. Starting with fish 3.0.0 fish uses the tinyexpr library and evaluates the expression without the involvement of any external commands.
You don't need to use ``--`` before the expression, even if it begins with a minus sign which might otherwise be interpreted as an invalid option. If you do insert ``--`` before the expression, it will cause option scanning to stop just like for every other command and it won't be part of the expression.

View File

@@ -220,4 +220,4 @@ This runs fish with a temporary home directory::
Notes
-----
- Fish versions prior to 3.0 supported the syntax ``set PATH[1] PATH[4] /bin /sbin``, which worked like ``set PATH[1 4] /bin /sbin``.
- fish versions prior to 3.0 supported the syntax ``set PATH[1] PATH[4] /bin /sbin``, which worked like ``set PATH[1 4] /bin /sbin``.

View File

@@ -31,7 +31,7 @@ Hexadecimal RGB values can be in lower or uppercase.
If :envvar:`fish_term24bit` is set to 0, fish will translate RGB values to the nearest color on the 256-color palette.
If :envvar:`fish_term256` is also set to 0, fish will translate them to the 16-color palette instead.
Fish launched as ``fish -d term_support`` will include diagnostic messages that indicate the color support mode in use.
fish launched as ``fish -d term_support`` will include diagnostic messages that indicate the color support mode in use.
If multiple colors are specified, fish prefers the first RGB one.
However if :envvar:`fish_term256` is set to 0, fish prefers the first named color specified.
@@ -93,7 +93,7 @@ Notes
1. Using ``set_color normal`` will reset all colors and modes to the terminal's default.
2. In contrast, ``set_color --foreground normal`` will only reset the foreground color and leave all the other colors and modes unchanged.
3. Because of the risk of confusion, ``set_color --reset`` is recommended over ``set_color normal``.
4. Setting the background color only affects subsequently written characters. Fish provides no way to set the background color for the entire terminal window. Configuring the window background color (and other attributes such as its opacity) has to be done using whatever mechanisms the terminal provides. Look for a config option.
4. Setting the background color only affects subsequently written characters. fish provides no way to set the background color for the entire terminal window. Configuring the window background color (and other attributes such as its opacity) has to be done using whatever mechanisms the terminal provides. Look for a config option.
5. Some terminals use the ``--bold`` escape sequence to switch to a brighter color set rather than increasing the weight of text.
6. If you use ``set_color`` in a command substitution or a pipe, these characters will also be captured.
This may or may not be desirable.

View File

@@ -38,7 +38,7 @@ just always use ``--`` to avoid unwelcome surprises.
``string join0`` adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``.
Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution <expand-command-substitution>`) won't actually work.
Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends.
fish will pass the correct bytes along, but the command won't be able to tell where the argument ends.
This is a limitation of Unix' argument passing.
.. END DESCRIPTION

View File

@@ -102,11 +102,11 @@ The following additional options are also understood by ``ulimit``:
The ``fish`` implementation of ``ulimit`` should behave identically to the implementation in bash, except for these differences:
- Fish ``ulimit`` supports GNU-style long options for all switches.
- fish ``ulimit`` supports GNU-style long options for all switches.
- Fish ``ulimit`` does not support the **-p** option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. Fish does not do this because this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.
- fish ``ulimit`` does not support the **-p** option for getting the pipe size. The bash implementation consists of a compile-time check that empirically guesses this number by writing to a pipe and waiting for SIGPIPE. fish does not do this because this method of determining pipe size is unreliable. Depending on bash version, there may also be further additional limits to set in bash that do not exist in fish.
- Fish ``ulimit`` does not support getting or setting multiple limits in one command, except reporting all values using the **-a** switch.
- fish ``ulimit`` does not support getting or setting multiple limits in one command, except reporting all values using the **-a** switch.
Example

View File

@@ -38,7 +38,7 @@ which offers yes/no in these cases::
> myprog -o <TAB>
> myprog --output <TAB>
Fish will also offer files by default, in addition to the arguments you specified. You would either inhibit file completion for a single option::
fish will also offer files by default, in addition to the arguments you specified. You would either inhibit file completion for a single option::
complete -c myprog -s o -l output --no-files -ra "yes no"
@@ -142,9 +142,9 @@ Functions beginning with the string ``__fish_print_`` print a newline separated
Where to put completions
------------------------
Completions can be defined on the commandline or in a configuration file, but they can also be automatically loaded. Fish automatically searches through any directories in the list variable ``$fish_complete_path``, and any completions defined are automatically loaded when needed. A completion file must have a filename consisting of the name of the command to complete and the suffix ``.fish``.
Completions can be defined on the commandline or in a configuration file, but they can also be automatically loaded. fish automatically searches through any directories in the list variable ``$fish_complete_path``, and any completions defined are automatically loaded when needed. A completion file must have a filename consisting of the name of the command to complete and the suffix ``.fish``.
By default, Fish searches the following for completions, using the first available file that it finds:
By default, fish searches the following for completions, using the first available file that it finds:
- A directory for end-users to keep their own completions, usually ``~/.config/fish/completions`` (controlled by the ``XDG_CONFIG_HOME`` environment variable);
- A directory for systems administrators to install completions for all users on the system, usually ``/etc/fish/completions``;

View File

@@ -5,7 +5,7 @@ This is a description of the design principles that have been used to design fis
1. 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.
2. 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.
2. 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.
3. Whenever possible without breaking the above goals, fish should follow POSIX.
@@ -55,9 +55,9 @@ Different configuration options are a nightmare to maintain, since the number of
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 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 number of history entries, different language substyles or any number of other common shell configuration options.
- fish does not allow you to set 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 supports that are disabled by default include tab-completion of strings containing wildcards, a sane completion pager and a history file.

View File

@@ -4,7 +4,7 @@ Frequently asked questions
What is the equivalent to this thing from bash (or other shells)?
-----------------------------------------------------------------
See :doc:`Fish for bash users <fish_for_bash_users>`
See :doc:`fish for bash users <fish_for_bash_users>`
How do I set or clear an environment variable?
----------------------------------------------
@@ -327,7 +327,7 @@ This is more important to fish than other shells because features like syntax hi
Sometimes, there is disagreement on the width. There are numerous causes and fixes for this:
- It is possible the character is too new for your system to know - in this case you need to refrain from using it.
- Fish or your terminal might not know about the character or handle it wrong - in this case fish or your terminal needs to be fixed, or you need to update to a fixed version.
- fish or your terminal might not know about the character or handle it wrong - in this case fish or your terminal needs to be fixed, or you need to update to a fixed version.
- The character has an "ambiguous" width and fish thinks that means a width of X while your terminal thinks it's Y. In this case you either need to change your terminal's configuration or set $fish_ambiguous_width to the correct value.
- The character is an emoji and your system only supports Unicode 8. In this case set $fish_emoji_width to 1.

View File

@@ -1,7 +1,7 @@
Fish for bash users
fish for Bash users
===================
This is to give you a quick overview if you come from bash (or to a lesser extent other shells like zsh or ksh) and want to know how fish differs. Fish is intentionally not POSIX-compatible and as such some of the things you are used to work differently.
This is to give you a quick overview if you come from bash (or to a lesser extent other shells like zsh or ksh) and want to know how fish differs. fish is intentionally not POSIX-compatible and as such some of the things you are used to work differently.
Many things are similar - they both fundamentally expand commandlines to execute commands, have pipes, redirections, variables, globs, use command output in various ways. This document is there to quickly show you the differences.
@@ -10,7 +10,7 @@ Many things are similar - they both fundamentally expand commandlines to execute
Command substitutions
---------------------
Fish spells command substitutions as ``$(command)`` or ``(command)``, but not ```command```.
fish spells command substitutions as ``$(command)`` or ``(command)``, but not ```command```.
In addition, it only splits them on newlines instead of $IFS. If you want to split on something else, use :doc:`string split <cmds/string-split>`, :doc:`string split0 <cmds/string-split>` or :doc:`string collect <cmds/string-collect>`. If those are used as the last command in a command substitution the splits they create are carried over. So::
@@ -21,7 +21,7 @@ will correctly handle all possible filenames.
Variables
---------
Fish sets and erases variables with :doc:`set <cmds/set>` instead of ``VAR=VAL`` and a variety of separate builtins like ``declare`` and ``unset`` and ``export``. ``set`` takes options to determine the scope and exportedness of a variable::
fish sets and erases variables with :doc:`set <cmds/set>` instead of ``VAR=VAL`` and a variety of separate builtins like ``declare`` and ``unset`` and ``export``. ``set`` takes options to determine the scope and exportedness of a variable::
# Define $PAGER *g*lobal and e*x*ported,
# so this is like ``export PAGER=less``
@@ -41,7 +41,7 @@ or to erase variables::
PAGER=cat git log
Fish does not perform word splitting. Once a variable has been set to a value, that value stays as it is, so double-quoting variable expansions isn't the necessity it is in bash. [#]_
fish does not perform word splitting. Once a variable has been set to a value, that value stays as it is, so double-quoting variable expansions isn't the necessity it is in bash. [#]_
For instance, here's bash
@@ -102,7 +102,7 @@ See :ref:`Shell variables <variables>` for more.
Variable defaults (``${my_variable:-"default value"}``)
-------------------------------------------------------
Fish doesn't have ``${my_variable:-fallback}`` for providing default values to unset variables. Instead, you can set default values by checking whether the variable has been set yet::
fish doesn't have ``${my_variable:-fallback}`` for providing default values to unset variables. Instead, you can set default values by checking whether the variable has been set yet::
# Ensure XDG_CONFIG_HOME is set or use a default value
set -q XDG_CONFIG_HOME || set XDG_CONFIG_HOME $HOME/.config
@@ -111,7 +111,7 @@ Fish doesn't have ``${my_variable:-fallback}`` for providing default values to u
Wildcards (globs)
-----------------
Fish only supports the ``*`` and ``**`` glob (and the deprecated ``?`` glob) as syntax. If a glob doesn't match it fails the command (like with bash's ``failglob``) unless the command is ``for``, ``set`` or ``count`` or the glob is used with an environment override (``VAR=* command``), in which case it expands to nothing (like with bash's ``nullglob`` option).
fish only supports the ``*`` and ``**`` glob (and the deprecated ``?`` glob) as syntax. If a glob doesn't match it fails the command (like with bash's ``failglob``) unless the command is ``for``, ``set`` or ``count`` or the glob is used with an environment override (``VAR=* command``), in which case it expands to nothing (like with bash's ``nullglob`` option).
Globbing doesn't happen on expanded variables, so::
@@ -131,7 +131,7 @@ See :ref:`Wildcards <expand-wildcard>` for more.
Quoting
-------
Fish has two quoting styles: ``""`` and ``''``. Variables are expanded in double-quotes, nothing is expanded in single-quotes.
fish has two quoting styles: ``""`` and ``''``. Variables are expanded in double-quotes, nothing is expanded in single-quotes.
There is no ``$''``, instead the sequences that would transform are transformed *when unquoted*::
@@ -144,7 +144,7 @@ See :ref:`Quotes <quotes>` for more.
String manipulation
-------------------
Fish does not have ``${foo%bar}``, ``${foo#bar}`` and ``${foo/bar/baz}``. Instead string manipulation is done by the :doc:`string <cmds/string>` builtin.
fish does not have ``${foo%bar}``, ``${foo#bar}`` and ``${foo/bar/baz}``. Instead string manipulation is done by the :doc:`string <cmds/string>` builtin.
For example, to replace "bar" with "baz"::
@@ -208,7 +208,7 @@ as fish's :doc:`source <cmds/source>` can read from stdin.
Heredocs
--------
Fish does not have ``<<EOF`` "heredocs". Instead of
fish does not have ``<<EOF`` "heredocs". Instead of
.. code-block:: sh
@@ -280,14 +280,14 @@ So heredocs really are minor syntactical sugar that introduces a lot of special
Test (``test``, ``[``, ``[[``)
------------------------------
Fish has a POSIX-compatible ``test`` or ``[`` builtin. There is no ``[[`` and ``test`` does not accept ``==`` as a synonym for ``=``. It can compare floating point numbers, however.
fish has a POSIX-compatible ``test`` or ``[`` builtin. There is no ``[[`` and ``test`` does not accept ``==`` as a synonym for ``=``. It can compare floating point numbers, however.
``set -q`` can be used to determine if a variable exists or has a certain number of elements (``set -q foo[2]``).
Arithmetic Expansion
--------------------
Fish does not have ``$((i+1))`` arithmetic expansion, computation is handled by :doc:`math <cmds/math>`::
fish does not have ``$((i+1))`` arithmetic expansion, computation is handled by :doc:`math <cmds/math>`::
math $i + 1
@@ -310,7 +310,7 @@ Both ``*`` and ``x`` are valid ways to spell multiplication, but ``*`` needs to
Prompts
-------
Fish does not use the ``$PS1``, ``$PS2`` and so on variables. Instead the prompt is the output of the :doc:`fish_prompt <cmds/fish_prompt>` function, plus the :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` function if :ref:`vi mode <vi-mode>` is enabled. The output of the :doc:`fish_right_prompt <cmds/fish_right_prompt>` function is used for the right-sided prompt.
fish does not use the ``$PS1``, ``$PS2`` and so on variables. Instead the prompt is the output of the :doc:`fish_prompt <cmds/fish_prompt>` function, plus the :doc:`fish_mode_prompt <cmds/fish_mode_prompt>` function if :ref:`vi mode <vi-mode>` is enabled. The output of the :doc:`fish_right_prompt <cmds/fish_right_prompt>` function is used for the right-sided prompt.
As an example, here's a relatively simple bash prompt:
@@ -332,18 +332,18 @@ and a rough fish equivalent::
This shows a few differences:
- Fish provides :doc:`set_color <cmds/set_color>` to color text. It can use the 16 named colors and also RGB sequences (so you could also use ``set_color 5555FF``)
- fish provides :doc:`set_color <cmds/set_color>` to color text. It can use the 16 named colors and also RGB sequences (so you could also use ``set_color 5555FF``)
- Instead of introducing specific escapes like ``\h`` for the hostname, the prompt is a function. To achieve the effect of ``\h``, fish provides helper functions like :doc:`prompt_hostname <cmds/prompt_hostname>`, which prints a shortened version of the hostname.
- Fish offers other helper functions for adding things to the prompt, like :doc:`fish_vcs_prompt <cmds/fish_vcs_prompt>` for adding a display for common version control systems (git, mercurial, svn), and :doc:`prompt_pwd <cmds/prompt_pwd>` for showing a shortened ``$PWD`` (the user's home directory becomes ``~`` and any path component is shortened).
- fish offers other helper functions for adding things to the prompt, like :doc:`fish_vcs_prompt <cmds/fish_vcs_prompt>` for adding a display for common version control systems (git, mercurial, svn), and :doc:`prompt_pwd <cmds/prompt_pwd>` for showing a shortened ``$PWD`` (the user's home directory becomes ``~`` and any path component is shortened).
The default prompt is reasonably full-featured and its code can be read via ``type fish_prompt``.
Fish does not have ``$PS2`` for continuation lines, instead it leaves the lines indented to show that the commandline isn't complete yet.
fish does not have ``$PS2`` for continuation lines, instead it leaves the lines indented to show that the commandline isn't complete yet.
Blocks and loops
----------------
Fish's blocking constructs look a little different. They all start with a word, end in ``end`` and don't have a second starting word::
fish's blocking constructs look a little different. They all start with a word, end in ``end`` and don't have a second starting word::
for i in 1 2 3; do
echo $i
@@ -402,7 +402,7 @@ Fish's blocking constructs look a little different. They all start with a word,
# (bash allows the word "function",
# but this is an extension)
Fish does not have an ``until``. Use ``while not`` or ``while !``.
fish does not have an ``until``. Use ``while not`` or ``while !``.
Subshells
---------
@@ -424,7 +424,7 @@ This includes things like:
baz &
done
Fish does not currently have subshells. You will have to find a different solution. The isolation can usually be achieved by scoping variables (with ``set -l``), but if you really do need to run your code in a new shell environment you can use ``fish -c 'your code here'`` to do so explicitly.
fish does not currently have subshells. You will have to find a different solution. The isolation can usually be achieved by scoping variables (with ``set -l``), but if you really do need to run your code in a new shell environment you can use ``fish -c 'your code here'`` to do so explicitly.
``()`` subshells are often confused with ``{}`` grouping, which does *not* use a subshell. When you just need to group, you can use ``begin; end`` in fish::

View File

@@ -1,16 +1,16 @@
Interactive use
===============
Fish prides itself on being really nice to use interactively. That's down to a few features we'll explain in the next few sections.
fish prides itself on being really nice to use interactively. That's down to a few features we'll explain in the next few sections.
Fish is used by giving commands in the fish language, see :doc:`The Fish Language <language>` for information on that.
fish is used by giving commands in the fish language, see :doc:`The fish Language <language>` for information on that.
Help
----
Fish has an extensive help system. Use the :doc:`help <cmds/help>` command to obtain help on a specific subject or command. For instance, writing ``help syntax`` displays the :ref:`syntax section <syntax>` of this documentation.
fish has an extensive help system. Use the :doc:`help <cmds/help>` command to obtain help on a specific subject or command. For instance, writing ``help syntax`` displays the :ref:`syntax section <syntax>` of this documentation.
Fish also has man pages for its commands, and translates the help pages to man pages. For example, ``man set`` will show the documentation for ``set`` as a man page.
fish also has man pages for its commands, and translates the help pages to man pages. For example, ``man set`` will show the documentation for ``set`` as a man page.
Help on a specific builtin can also be obtained with the ``-h`` parameter. For instance, to obtain help on the :doc:`fg <cmds/fg>` builtin, either type ``fg -h`` or ``help fg``.
@@ -40,7 +40,7 @@ Tab completion is a time saving feature of any modern shell. When you type :kbd:
The pager can be navigated with the arrow keys, :kbd:`pageup` / :kbd:`pagedown`, :kbd:`tab` or :kbd:`shift-tab`. Pressing :kbd:`ctrl-s` (the ``pager-toggle-search`` binding - :kbd:`/` in vi mode) opens up a search menu that you can use to filter the list.
Fish provides some general purpose completions, like for commands, variable names, usernames or files.
fish provides some general purpose completions, like for commands, variable names, usernames or files.
It also provides a large number of program specific scripted completions. Most of these completions are simple options like the ``-l`` option for ``ls``, but a lot are more advanced. For example:
@@ -61,7 +61,7 @@ Completion scripts are loaded on demand, like :ref:`functions are <syntax-functi
Syntax highlighting
-------------------
Fish interprets the command line as it is typed and uses syntax highlighting to provide feedback. The most important feedback is the detection of potential errors. By default, errors are marked red.
fish interprets the command line as it is typed and uses syntax highlighting to provide feedback. The most important feedback is the detection of potential errors. By default, errors are marked red.
Detected errors include:
@@ -72,7 +72,7 @@ Detected errors include:
To customize the syntax highlighting, you can set the environment variables listed in the :ref:`Variables for changing highlighting colors <variables-color>` section.
Fish also provides pre-made color themes you can pick with :doc:`fish_config <cmds/fish_config>`.
fish also provides pre-made color themes you can pick with :doc:`fish_config <cmds/fish_config>`.
Running just ``fish_config`` opens a browser interface, or you can use ``fish_config theme`` from fish::
# disable nearly all coloring
@@ -243,7 +243,7 @@ For :ref:`vi mode <vi-mode>`, the output of :doc:`fish_mode_prompt <cmds/fish_mo
If :envvar:`fish_transient_prompt` is set to 1, fish will redraw the prompt with a ``--final-rendering`` argument before running a commandline, allowing you to change it before pushing it to the scrollback.
Fish ships with a few prompts which you can see with :doc:`fish_config <cmds/fish_config>`. If you run just ``fish_config`` it will open a web interface [#]_ where you'll be shown the prompts and can pick which one you want. ``fish_config prompt show`` will show you the prompts right in your terminal.
fish ships with a few prompts which you can see with :doc:`fish_config <cmds/fish_config>`. If you run just ``fish_config`` it will open a web interface [#]_ where you'll be shown the prompts and can pick which one you want. ``fish_config prompt show`` will show you the prompts right in your terminal.
For example ``fish_config prompt choose disco`` will temporarily select the "disco" prompt. If you like it and decide to keep it, run ``fish_config prompt save``.
@@ -274,7 +274,7 @@ Programmable title
------------------
Most terminals allow setting the text displayed in the titlebar of the terminal window.
Fish does this by running the :doc:`fish_title <cmds/fish_title>` function.
fish does this by running the :doc:`fish_title <cmds/fish_title>` function.
It is executed before and after a command and the output is used as a titlebar message.
The :doc:`status current-command <cmds/status>` builtin will always return the name of the job to be put into the foreground (or ``fish`` if control is returning to the shell) when the :doc:`fish_title <cmds/fish_title>` function is called. The first argument will contain the most recently executed foreground command as a string.
@@ -474,7 +474,7 @@ The ``fish_vi_cursor`` function will be used to change the cursor's shape depend
Additionally, ``blink`` can be added after each of the cursor shape parameters to set a blinking cursor in the specified shape.
Fish knows the shapes "block", "line" and "underscore", other values will be ignored.
fish knows the shapes "block", "line" and "underscore", other values will be ignored.
If the cursor shape does not appear to be changing after setting the above variables, it's likely your terminal emulator does not support the capabilities necessary to do this.
@@ -593,7 +593,7 @@ If you change your mind on a binding and want to go back to fish's default, you
bind --erase ctrl-c
Fish remembers its preset bindings and so it will take effect again. This saves you from having to remember what it was before and add it again yourself.
fish remembers its preset bindings and so it will take effect again. This saves you from having to remember what it was before and add it again yourself.
If you use :ref:`vi bindings <vi-mode>`, note that ``bind`` will by default bind keys in :ref:`command mode <vi-mode-command>`. To bind something in :ref:`insert mode <vi-mode-insert>`::
@@ -638,7 +638,7 @@ Similarly, to disambiguate *other* keypresses where you've bound a subsequence a
Copy and paste (Kill Ring)
^^^^^^^^^^^^^^^^^^^^^^^^^^
Fish uses an Emacs-style kill ring for copy and paste functionality. For example, use :kbd:`ctrl-k` (`kill-line`) to cut from the current cursor position to the end of the line. The string that is cut (a.k.a. killed in emacs-ese) is inserted into a list of kills, called the kill ring. To paste the latest value from the kill ring (emacs calls this "yanking") use :kbd:`ctrl-y` (the ``yank`` input function). After pasting, use :kbd:`alt-y` (``yank-pop``) to rotate to the previous kill.
fish uses an Emacs-style kill ring for copy and paste functionality. For example, use :kbd:`ctrl-k` (`kill-line`) to cut from the current cursor position to the end of the line. The string that is cut (a.k.a. killed in emacs-ese) is inserted into a list of kills, called the kill ring. To paste the latest value from the kill ring (emacs calls this "yanking") use :kbd:`ctrl-y` (the ``yank`` input function). After pasting, use :kbd:`alt-y` (``yank-pop``) to rotate to the previous kill.
Copy and paste from outside are also supported, both via the :kbd:`ctrl-x` / :kbd:`ctrl-v` bindings (the ``fish_clipboard_copy`` and ``fish_clipboard_paste`` functions [#]_) and via the terminal's paste function, for which fish enables "Bracketed Paste Mode", so it can tell a paste from manually entered text.
In addition, when pasting inside single quotes, pasted single quotes and backslashes are automatically escaped so that the result can be used as a single token by closing the quote after.
@@ -700,7 +700,7 @@ If the commandline reads ``cd m``, place the cursor over the ``m`` character and
Private mode
-------------
Fish has a private mode, in which command history will not be written to the history file on disk. To enable it, either set ``$fish_private_mode`` to a non-empty value, or launch with ``fish --private`` (or ``fish -P`` for short).
fish has a private mode, in which command history will not be written to the history file on disk. To enable it, either set ``$fish_private_mode`` to a non-empty value, or launch with ``fish --private`` (or ``fish -P`` for short).
If you launch fish with ``-P``, it both hides old history and prevents writing history to disk. This is useful to avoid leaking personal information (e.g. for screencasts) or when dealing with sensitive information.
@@ -718,7 +718,7 @@ The current working directory can be displayed with the :doc:`pwd <cmds/pwd>` co
Directory history
^^^^^^^^^^^^^^^^^
Fish automatically keeps a trail of the recent visited directories with :doc:`cd <cmds/cd>` by storing this history in the ``dirprev`` and ``dirnext`` variables.
fish automatically keeps a trail of the recent visited directories with :doc:`cd <cmds/cd>` by storing this history in the ``dirprev`` and ``dirnext`` variables.
Several commands are provided to interact with this directory history:

View File

@@ -70,7 +70,7 @@ Sometimes you want to give a command an argument that contains characters specia
to remove a file called ``my file.txt`` instead of trying to remove two files, ``my`` and ``file.txt``.
Fish understands two kinds of quotes: Single (``'``) and double (``"``), and both work slightly differently.
fish understands two kinds of quotes: Single (``'``) and double (``"``), and both work slightly differently.
Between single quotes, fish performs no expansions. Between double quotes, fish only performs :ref:`variable expansion <expand-variable>` and :ref:`command substitution <expand-command-substitution>` in the ``$(command)``. No other kind of expansion (including :ref:`brace expansion <expand-brace>` or parameter expansion) is performed, and escape sequences (for example, ``\n``) are ignored. Within quotes, whitespace is not used to separate arguments, allowing quoted arguments to contain spaces.
@@ -315,7 +315,7 @@ Calling this as ``ll /tmp/`` will end up running ``ls -l /tmp/``, which will lis
This is a kind of function known as an :ref:`alias <syntax-aliases>`.
Fish's prompt is also defined in a function, called :doc:`fish_prompt <cmds/fish_prompt>`. It is run when the prompt is about to be displayed and its output forms the prompt::
fish's prompt is also defined in a function, called :doc:`fish_prompt <cmds/fish_prompt>`. It is run when the prompt is about to be displayed and its output forms the prompt::
function fish_prompt
# A simple prompt. Displays the current directory
@@ -413,7 +413,7 @@ Comments can also appear after a line like so::
Conditions
----------
Fish has some builtins that let you execute commands only if a specific criterion is met: :doc:`if <cmds/if>`, :doc:`switch <cmds/switch>`, :doc:`and <cmds/and>` and :doc:`or <cmds/or>`, and also the familiar :ref:`&&/|| <syntax-combiners>` syntax.
fish has some builtins that let you execute commands only if a specific criterion is met: :doc:`if <cmds/if>`, :doc:`switch <cmds/switch>`, :doc:`and <cmds/and>` and :doc:`or <cmds/or>`, and also the familiar :ref:`&&/|| <syntax-combiners>` syntax.
.. _syntax-if:
@@ -422,7 +422,7 @@ The ``if`` statement
The :doc:`if <cmds/if>` statement runs a block of commands if the condition was true.
Like other shells, but unlike typical programming languages you might know, the condition here is a *command*. Fish runs it, and if it returns a true :ref:`exit status <variables-status>` (that's 0), the if-block is run. For example::
Like other shells, but unlike typical programming languages you might know, the condition here is a *command*. fish runs it, and if it returns a true :ref:`exit status <variables-status>` (that's 0), the if-block is run. For example::
if test -e /etc/os-release
cat /etc/os-release
@@ -692,7 +692,7 @@ Quoting variables
Variable expansion also happens in double quoted strings. Inside double quotes (``"these"``), variables will always expand to exactly one argument. If they are empty or undefined, it will result in an empty string. If they have one element, they'll expand to that element. If they have more than that, the elements will be joined with spaces, unless the variable is a :ref:`path variable <variables-path>` - in that case it will use a colon (``:``) instead [#]_.
Fish variables are all :ref:`lists <variables-lists>`, and they are split into elements when they are *set* - that means it is important to decide whether to use quotes or not with :doc:`set <cmds/set>`::
fish variables are all :ref:`lists <variables-lists>`, and they are split into elements when they are *set* - that means it is important to decide whether to use quotes or not with :doc:`set <cmds/set>`::
set foo 1 2 3 # a variable with three elements
rm $foo # runs the equivalent of `rm 1 2 3` - trying to delete three files: 1, 2 and 3.
@@ -830,7 +830,7 @@ When using double quotes, the command output is not split up by lines, but trail
If the output is piped to :doc:`string split or string split0 <cmds/string-split>` as the last step, those splits are used as they appear instead of splitting lines.
Fish also allows spelling command substitutions without the dollar, like ``echo (pwd)``. This variant will not be expanded in double-quotes (``echo "(pwd)"`` will print ``(pwd)``).
fish also allows spelling command substitutions without the dollar, like ``echo (pwd)``. This variant will not be expanded in double-quotes (``echo "(pwd)"`` will print ``(pwd)``).
The exit status of the last run command substitution is available in the :ref:`status <variables-status>` variable if the substitution happens in the context of a :doc:`set <cmds/set>` command (so ``if set -l (something)`` checks if ``something`` returned true).
@@ -863,7 +863,7 @@ but if you need multiple or the command doesn't read from standard input, "proce
This creates a temporary file, stores the output of the command in that file and prints the filename, so it is given to the outer command.
Fish has a default limit of 1 GiB on the data it will read in a command substitution. If that limit is reached the command (all of it, not just the command substitution - the outer command won't be executed at all) fails and ``$status`` is set to 122. This is so command substitutions can't cause the system to go out of memory, because typically your operating system has a much lower limit, so reading more than that would be useless and harmful. This limit can be adjusted with the ``fish_read_limit`` variable (`0` meaning no limit). This limit also affects the :doc:`read <cmds/read>` command.
fish has a default limit of 1 GiB on the data it will read in a command substitution. If that limit is reached the command (all of it, not just the command substitution - the outer command won't be executed at all) fails and ``$status`` is set to 122. This is so command substitutions can't cause the system to go out of memory, because typically your operating system has a much lower limit, so reading more than that would be useless and harmful. This limit can be adjusted with the ``fish_read_limit`` variable (`0` meaning no limit). This limit also affects the :doc:`read <cmds/read>` command.
.. [#] One exception: Setting ``$IFS`` to empty will disable line splitting. This is deprecated, use :doc:`string split <cmds/string-split>` instead.
@@ -922,7 +922,7 @@ The very first character of a command token is never interpreted as expanding br
Combining lists
^^^^^^^^^^^^^^^
Fish expands lists like :ref:`brace expansions <expand-brace>`::
fish expands lists like :ref:`brace expansions <expand-brace>`::
>_ set -l foo x y z
>_ echo 1$foo
@@ -1348,7 +1348,7 @@ Note: Exporting is not a :ref:`scope <variables-scope>`, but an additional state
Lists
^^^^^
Fish can store a list (or an "array" if you wish) of multiple strings inside of a variable::
fish can store a list (or an "array" if you wish) of multiple strings inside of a variable::
> set mylist first second third
> printf '%s\n' $mylist # prints each element on its own line
@@ -1415,7 +1415,7 @@ When a list is exported as an environment variable, it is either space or colon
smurf=blue small
smurf_PATH=forest:mushroom
Fish automatically creates lists from all environment variables whose name ends in ``PATH`` (like :envvar:`PATH`, :envvar:`CDPATH` or :envvar:`MANPATH`), by splitting them on colons. Other variables are not automatically split.
fish automatically creates lists from all environment variables whose name ends in ``PATH`` (like :envvar:`PATH`, :envvar:`CDPATH` or :envvar:`MANPATH`), by splitting them on colons. Other variables are not automatically split.
Lists can be inspected with the :doc:`count <cmds/count>` or the :doc:`contains <cmds/contains>` commands::
@@ -1662,7 +1662,7 @@ You can change the settings of fish by changing the values of certain variables.
your preferred web browser. If this variable is set, fish will use the specified browser instead of the system default browser to display the fish documentation.
Fish also provides additional information through the values of certain environment variables. Most of these variables are read-only and their value can't be changed with ``set``.
fish also provides additional information through the values of certain environment variables. Most of these variables are read-only and their value can't be changed with ``set``.
.. envvar:: _
@@ -1739,7 +1739,7 @@ Fish also provides additional information through the values of certain environm
.. ENVVAR:: SHLVL
the level of nesting of shells. Fish increments this in interactive shells, otherwise it only passes it along.
the level of nesting of shells. fish increments this in interactive shells, otherwise it only passes it along.
.. envvar:: status
@@ -1763,7 +1763,7 @@ Fish also provides additional information through the values of certain environm
As a convention, an uppercase name is usually used for exported variables, while lowercase variables are not exported. (``CMD_DURATION`` is an exception for historical reasons). This rule is not enforced by fish, but it is good coding practice to use casing to distinguish between exported and unexported variables.
Fish also uses some variables internally, their name usually starting with ``__fish``. These are internal and should not typically be modified directly.
fish also uses some variables internally, their name usually starting with ``__fish``. These are internal and should not typically be modified directly.
.. _variables-status:
@@ -1772,7 +1772,7 @@ The status variable
Whenever a process exits, an exit status is returned to the program that started it (usually the shell). This exit status is an integer number, which tells the calling application how the execution of the command went. In general, a zero exit status means that the command executed without problem, but a non-zero exit status means there was some form of problem.
Fish stores the exit status of the last process in the last job to exit in the ``status`` variable.
fish stores the exit status of the last process in the last job to exit in the ``status`` variable.
If fish encounters a problem while executing a command, the status variable may also be set to a specific value:
@@ -1882,7 +1882,7 @@ In UNIX, these are made up of several categories. The categories used by fish ar
Builtin commands
----------------
Fish includes a number of commands in the shell directly. We call these "builtins". These include:
fish includes a number of commands in the shell directly. We call these "builtins". These include:
- Builtins that manipulate the shell state - :doc:`cd <cmds/cd>` changes directory, :doc:`set <cmds/set>` sets variables
- Builtins for dealing with data, like :doc:`string <cmds/string>` for strings and :doc:`math <cmds/math>` for numbers, :doc:`count <cmds/count>` for counting lines or arguments, :doc:`path <cmds/path>` for dealing with path
@@ -2101,7 +2101,7 @@ To specify a signal handler for the WINCH signal, write::
echo Got WINCH signal!
end
Fish already has the following named events for the ``--on-event`` switch:
fish already has the following named events for the ``--on-event`` switch:
- ``fish_prompt`` is emitted whenever a new fish prompt is about to be displayed.
@@ -2144,7 +2144,7 @@ For more information on how to define new event handlers, see the documentation
Debugging fish scripts
----------------------
Fish includes basic built-in debugging facilities that allow you to stop execution of a script at an arbitrary point. When this happens you are presented with an interactive prompt where you can execute any fish command to inspect or change state (there are no debug commands as such). For example, you can check or change the value of any variables using :doc:`printf <cmds/printf>` and :doc:`set <cmds/set>`. As another example, you can run :doc:`status print-stack-trace <cmds/status>` to see how the current breakpoint was reached. To resume normal execution of the script, type :doc:`exit <cmds/exit>` or :kbd:`ctrl-d`.
fish includes basic built-in debugging facilities that allow you to stop execution of a script at an arbitrary point. When this happens you are presented with an interactive prompt where you can execute any fish command to inspect or change state (there are no debug commands as such). For example, you can check or change the value of any variables using :doc:`printf <cmds/printf>` and :doc:`set <cmds/set>`. As another example, you can run :doc:`status print-stack-trace <cmds/status>` to see how the current breakpoint was reached. To resume normal execution of the script, type :doc:`exit <cmds/exit>` or :kbd:`ctrl-d`.
To start a debug session insert the :doc:`builtin command <cmds/breakpoint>` ``breakpoint`` at the point in a function or script where you wish to gain control, then run the function or script. Also, the default action of the ``TRAP`` signal is to call this builtin, meaning a running script can be actively debugged by sending it the ``TRAP`` signal (``kill -s TRAP <PID>``). There is limited support for interactively setting or modifying breakpoints from this debug prompt: it is possible to insert new breakpoints in (or remove old ones from) other functions by using the ``funced`` function to edit the definition of a function, but it is not possible to add or remove a breakpoint from the function/script currently loaded and being executed.

View File

@@ -7,7 +7,7 @@ Writing your own prompt
This document uses formatting to show what a prompt would look like. If you are viewing this in the man page,
you probably want to switch to looking at the html version instead. Run ``help custom-prompt`` to view it in a web browser.
Fish ships a number of prompts that you can view with the :doc:`fish_config <cmds/fish_config>` command, and many users have shared their prompts online.
fish ships a number of prompts that you can view with the :doc:`fish_config <cmds/fish_config>` command, and many users have shared their prompts online.
However, you can also write your own, or adjust an existing prompt. This is a good way to get used to fish's :doc:`scripting language <language>`.
@@ -207,7 +207,7 @@ Where to go from here?
We have now built a simple but working and usable prompt, but of course more can be done.
- Fish offers more helper functions:
- fish offers more helper functions:
- ``prompt_login`` to describe the user/hostname/container or ``prompt_hostname`` to describe just the host
- ``fish_is_root_user`` to help with changing the symbol for root.
- ``fish_vcs_prompt`` to show version control information (or ``fish_git_prompt`` / ``fish_hg_prompt`` / ``fish_svn_prompt`` to limit it to specific systems)

View File

@@ -6,7 +6,7 @@ Tutorial
Why fish?
---------
Fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. Fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.
fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.
If you want to make your command line more productive, more useful, and more fun, without learning a bunch of arcane syntax and configuration options, then fish might be just what you're looking for!
@@ -46,7 +46,7 @@ For a comprehensive description of fish's scripting language, see :doc:`The Fish
Running Commands
----------------
Fish runs commands like other shells: you type a command, followed by its arguments. Spaces are separators::
fish runs commands like other shells: you type a command, followed by its arguments. Spaces are separators::
> echo hello world
hello world
@@ -332,7 +332,7 @@ For more on combining lists with strings (or even other lists), see :ref:`cartes
Wildcards
---------
Fish supports the familiar wildcard ``*``. To list all JPEG files::
fish supports the familiar wildcard ``*``. To list all JPEG files::
> ls *.jpg
lena.jpg
@@ -655,7 +655,7 @@ $PATH
``$PATH`` is an environment variable containing the directories that fish searches for commands. Unlike other shells, $PATH is a :ref:`list <tut-lists>`, not a colon-delimited string.
Fish takes care to set ``$PATH`` to a default, but typically it is just inherited from fish's parent process and is set to a value that makes sense for the system - see :ref:`Exports <tut-exports>`.
fish takes care to set ``$PATH`` to a default, but typically it is just inherited from fish's parent process and is set to a value that makes sense for the system - see :ref:`Exports <tut-exports>`.
To prepend /usr/local/bin and /usr/sbin to ``$PATH``, you can write::
@@ -689,7 +689,7 @@ Or you can modify $fish_user_paths yourself, but you should be careful *not* to
Startup (Where's .bashrc?)
--------------------------
Fish starts by executing commands in ``~/.config/fish/config.fish``. You can create it if it does not exist.
fish starts by executing commands in ``~/.config/fish/config.fish``. You can create it if it does not exist.
It is possible to directly create functions and variables in ``config.fish`` file, using the commands shown above. For example: