mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 15:14:44 +00:00
Switch backticks to double backticks for rst compatibility
This commit is contained in:
parent
2a002a4ba1
commit
0e936198db
84 changed files with 825 additions and 825 deletions
|
@ -13,29 +13,29 @@ abbr --list
|
|||
Description
|
||||
------------
|
||||
|
||||
`abbr` manages abbreviations - user-defined words that are replaced with longer phrases after they are entered.
|
||||
``abbr`` manages abbreviations - user-defined words that are replaced with longer phrases after they are entered.
|
||||
|
||||
For example, a frequently-run command like `git checkout` can be abbreviated to `gco`. After entering `gco` and pressing @key{Space} or @key{Enter}, the full text `git checkout` will appear in the command line.
|
||||
For example, a frequently-run command like ``git checkout`` can be abbreviated to ``gco``. After entering ``gco`` and pressing @key{Space} or @key{Enter}, the full text ``git checkout`` will appear in the command line.
|
||||
|
||||
Options
|
||||
------------
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a WORD EXPANSION` or `--add WORD EXPANSION` Adds a new abbreviation, causing WORD to be expanded to PHRASE.
|
||||
- ``-a WORD EXPANSION`` or ``--add WORD EXPANSION`` Adds a new abbreviation, causing WORD to be expanded to PHRASE.
|
||||
|
||||
- `-r OLD_WORD NEW_WORD` or `--rename OLD_WORD NEW_WORD` Renames an abbreviation, from OLD_WORD to NEW_WORD.
|
||||
- ``-r OLD_WORD NEW_WORD`` or ``--rename OLD_WORD NEW_WORD`` Renames an abbreviation, from OLD_WORD to NEW_WORD.
|
||||
|
||||
- `-s` or `--show` Show all abbreviations in a manner suitable for export and import.
|
||||
- ``-s`` or ``--show`` Show all abbreviations in a manner suitable for export and import.
|
||||
|
||||
- `-l` or `--list` Lists all abbreviated words.
|
||||
- ``-l`` or ``--list`` Lists all abbreviated words.
|
||||
|
||||
- `-e WORD` or `--erase WORD` Erase the abbreviation WORD.
|
||||
- ``-e WORD`` or ``--erase WORD`` Erase the abbreviation WORD.
|
||||
|
||||
In addition, when adding abbreviations:
|
||||
|
||||
- `-g` or `--global` to use a global variable.
|
||||
- `-U` or `--universal` to use a universal variable (default).
|
||||
- ``-g`` or ``--global`` to use a global variable.
|
||||
- ``-U`` or ``--universal`` to use a universal variable (default).
|
||||
|
||||
See the "Internals" section for more on them.
|
||||
|
||||
|
@ -48,7 +48,7 @@ Examples
|
|||
|
||||
abbr -a -g gco git checkout
|
||||
|
||||
Add a new abbreviation where `gco` will be replaced with `git checkout` global to the current shell. This abbreviation will not be automatically visible to other shells unless the same command is run in those shells (such as when executing the commands in config.fish).
|
||||
Add a new abbreviation where ``gco`` will be replaced with ``git checkout`` global to the current shell. This abbreviation will not be automatically visible to other shells unless the same command is run in those shells (such as when executing the commands in config.fish).
|
||||
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ Add a new abbreviation where `gco` will be replaced with `git checkout` global t
|
|||
|
||||
abbr -a -U l less
|
||||
|
||||
Add a new abbreviation where `l` will be replaced with `less` universal so all shells. Note that you omit the `-U` since it is the default.
|
||||
Add a new abbreviation where ``l`` will be replaced with ``less`` universal so all shells. Note that you omit the ``-U`` since it is the default.
|
||||
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ Add a new abbreviation where `l` will be replaced with `less` universal so all s
|
|||
|
||||
abbr -r gco gch
|
||||
|
||||
Renames an existing abbreviation from `gco` to `gch`.
|
||||
Renames an existing abbreviation from ``gco`` to ``gch``.
|
||||
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ Renames an existing abbreviation from `gco` to `gch`.
|
|||
|
||||
abbr -e gco
|
||||
|
||||
Erase the `gco` abbreviation.
|
||||
Erase the ``gco`` abbreviation.
|
||||
|
||||
|
||||
|
||||
|
@ -84,9 +84,9 @@ Import the abbreviations defined on another_host over SSH.
|
|||
|
||||
Internals
|
||||
------------
|
||||
Each abbreviation is stored in its own global or universal variable. The name consists of the prefix `_fish_abbr_` followed by the WORD after being transformed by `string escape style=var`. The WORD cannot contain a space but all other characters are legal.
|
||||
Each abbreviation is stored in its own global or universal variable. The name consists of the prefix ``_fish_abbr_`` followed by the WORD after being transformed by ``string escape style=var``. The WORD cannot contain a space but all other characters are legal.
|
||||
|
||||
Defining an abbreviation with global scope is slightly faster than universal scope (which is the default). But in general you'll only want to use the global scope when defining abbreviations in a startup script like `~/.config/fish/config.fish` like this:
|
||||
Defining an abbreviation with global scope is slightly faster than universal scope (which is the default). But in general you'll only want to use the global scope when defining abbreviations in a startup script like ``~/.config/fish/config.fish`` like this:
|
||||
|
||||
|
||||
|
||||
|
@ -100,4 +100,4 @@ Defining an abbreviation with global scope is slightly faster than universal sco
|
|||
end
|
||||
|
||||
|
||||
You can create abbreviations interactively and they will be visible to other fish sessions if you use the `-U` or `--universal` flag or don't explicitly specify the scope and the abbreviation isn't already defined with global scope. If you want it to be visible only to the current shell use the `-g` or `--global` flag.
|
||||
You can create abbreviations interactively and they will be visible to other fish sessions if you use the ``-U`` or ``--universal`` flag or don't explicitly specify the scope and the abbreviation isn't already defined with global scope. If you want it to be visible only to the current shell use the ``-g`` or ``--global`` flag.
|
||||
|
|
|
@ -12,25 +12,25 @@ alias [OPTIONS] NAME=DEFINITION
|
|||
Description
|
||||
------------
|
||||
|
||||
`alias` is a simple wrapper for the `function` builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell `alias`. For other uses, it is recommended to define a <a href='#function'>function</a>.
|
||||
``alias`` is a simple wrapper for the ``function`` builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell ``alias``. For other uses, it is recommended to define a <a href='#function'>function</a>.
|
||||
|
||||
`fish` marks functions that have been created by `alias` by including the command used to create them in the function description. You can list `alias`-created functions by running `alias` without arguments. They must be erased using `functions -e`.
|
||||
``fish`` marks functions that have been created by ``alias`` by including the command used to create them in the function description. You can list ``alias``-created functions by running ``alias`` without arguments. They must be erased using ``functions -e``.
|
||||
|
||||
- `NAME` is the name of the alias
|
||||
- `DEFINITION` is the actual command to execute. The string `$argv` will be appended.
|
||||
- ``NAME`` is the name of the alias
|
||||
- ``DEFINITION`` is the actual command to execute. The string ``$argv`` will be appended.
|
||||
|
||||
You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to `alias` just like at the command line, _even inside quoted parts_.
|
||||
You cannot create an alias to a function with the same name. Note that spaces need to be escaped in the call to ``alias`` just like at the command line, _even inside quoted parts_.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-h` or `--help` displays help about using this command.
|
||||
- ``-h`` or ``--help`` displays help about using this command.
|
||||
|
||||
- `-s` or `--save` Automatically save the function created by the alias into your fish configuration directory using <a href='#funcsave'>funcsave</a>.
|
||||
- ``-s`` or ``--save`` Automatically save the function created by the alias into your fish configuration directory using <a href='#funcsave'>funcsave</a>.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code will create `rmi`, which runs `rm` with additional arguments on every invocation.
|
||||
The following code will create ``rmi``, which runs ``rm`` with additional arguments on every invocation.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,16 +10,16 @@ COMMAND1; and COMMAND2
|
|||
Description
|
||||
------------
|
||||
|
||||
`and` is used to execute a command if the previous command was successful (returned a status of 0).
|
||||
``and`` is used to execute a command if the previous command was successful (returned a status of 0).
|
||||
|
||||
`and` statements may be used as part of the condition in an <a href="#if">`if`</a> or <a href="#while">`while`</a> block. See the documentation for <a href="#if">`if`</a> and <a href="#while">`while`</a> for examples.
|
||||
``and`` statements may be used as part of the condition in an <a href="#if">``if``</a> or <a href="#while">``while``</a> block. See the documentation for <a href="#if">``if``</a> and <a href="#while">``while``</a> for examples.
|
||||
|
||||
`and` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
``and`` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code runs the `make` command to build a program. If the build succeeds, `make`'s exit status is 0, and the program is installed. If either step fails, the exit status is 1, and `make clean` is run, which removes the files created by the build process.
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,35 +10,35 @@ argparse [OPTIONS] OPTION_SPEC... -- [ARG...]
|
|||
Description
|
||||
------------
|
||||
|
||||
This command makes it easy for fish scripts and functions to handle arguments in a manner 100% identical to how fish builtin commands handle their arguments. You pass a sequence of arguments that define the options recognized, followed by a literal `--`, then the arguments to be parsed (which might also include a literal `--`). More on this in the <a href="#argparse-usage">usage</a> section below.
|
||||
This command makes it easy for fish scripts and functions to handle arguments in a manner 100% identical to how fish builtin commands handle their arguments. You pass a sequence of arguments that define the options recognized, followed by a literal ``--``, then the arguments to be parsed (which might also include a literal ``--``). More on this in the <a href="#argparse-usage">usage</a> section below.
|
||||
|
||||
Each OPTION_SPEC can be written in the domain specific language <a href="#argparse-option-specs">described below</a> or created using the companion <a href="#fish-opt">`fish_opt`</a> command. All OPTION_SPECs must appear after any argparse flags and before the `--` that separates them from the arguments to be parsed.
|
||||
Each OPTION_SPEC can be written in the domain specific language <a href="#argparse-option-specs">described below</a> or created using the companion <a href="#fish-opt">``fish_opt``</a> command. All OPTION_SPECs must appear after any argparse flags and before the ``--`` that separates them from the arguments to be parsed.
|
||||
|
||||
Each option that is seen in the ARG list will result in a var name of the form `_flag_X`, where `X` is the short flag letter and the long flag name. The OPTION_SPEC always requires a short flag even if it can't be used. So there will always be `_flag_X` var set using the short flag letter if the corresponding short or long flag is seen. The long flag name var (e.g., `_flag_help`) will only be defined, obviously, if the OPTION_SPEC includes a long flag name.
|
||||
Each option that is seen in the ARG list will result in a var name of the form ``_flag_X``, where ``X`` is the short flag letter and the long flag name. The OPTION_SPEC always requires a short flag even if it can't be used. So there will always be ``_flag_X`` var set using the short flag letter if the corresponding short or long flag is seen. The long flag name var (e.g., ``_flag_help``) will only be defined, obviously, if the OPTION_SPEC includes a long flag name.
|
||||
|
||||
For example `_flag_h` and `_flag_help` if `-h` or `--help` is seen. The var will be set with local scope (i.e., as if the script had done `set -l _flag_X`). If the flag is a boolean (that is, does not have an associated value) the values are the short and long flags seen. If the option is not a boolean flag the values will be zero or more values corresponding to the values collected when the ARG list is processed. If the flag was not seen the flag var will not be set.
|
||||
For example ``_flag_h`` and ``_flag_help`` if ``-h`` or ``--help`` is seen. The var will be set with local scope (i.e., as if the script had done ``set -l _flag_X``). If the flag is a boolean (that is, does not have an associated value) the values are the short and long flags seen. If the option is not a boolean flag the values will be zero or more values corresponding to the values collected when the ARG list is processed. If the flag was not seen the flag var will not be set.
|
||||
|
||||
Options
|
||||
------------
|
||||
|
||||
The following `argparse` options are available. They must appear before all OPTION_SPECs:
|
||||
The following ``argparse`` options are available. They must appear before all OPTION_SPECs:
|
||||
|
||||
- `-n` or `--name` is the command name to insert into any error messages. If you don't provide this value `argparse` will be used.
|
||||
- ``-n`` or ``--name`` is the command name to insert into any error messages. If you don't provide this value ``argparse`` will be used.
|
||||
|
||||
- `-x` or `--exclusive` should be followed by a comma separated list of short of long options that are mutually exclusive. You can use this option more than once to define multiple sets of mutually exclusive options.
|
||||
- ``-x`` or ``--exclusive`` should be followed by a comma separated list of short of long options that are mutually exclusive. You can use this option more than once to define multiple sets of mutually exclusive options.
|
||||
|
||||
- `-N` or `--min-args` is followed by an integer that defines the minimum number of acceptable non-option arguments. The default is zero.
|
||||
- ``-N`` or ``--min-args`` is followed by an integer that defines the minimum number of acceptable non-option arguments. The default is zero.
|
||||
|
||||
- `-X` or `--max-args` is followed by an integer that defines the maximum number of acceptable non-option arguments. The default is infinity.
|
||||
- ``-X`` or ``--max-args`` is followed by an integer that defines the maximum number of acceptable non-option arguments. The default is infinity.
|
||||
|
||||
- `-s` or `--stop-nonopt` causes scanning the arguments to stop as soon as the first non-option argument is seen. Using this arg is equivalent to calling the C function `getopt_long()` with the short options starting with a `+` symbol. This is sometimes known as "POSIXLY CORRECT". If this flag is not used then arguments are reordered (i.e., permuted) so that all non-option arguments are moved after option arguments. This mode has several uses but the main one is to implement a command that has subcommands.
|
||||
- ``-s`` or ``--stop-nonopt`` causes scanning the arguments to stop as soon as the first non-option argument is seen. Using this arg is equivalent to calling the C function ``getopt_long()`` with the short options starting with a ``+`` symbol. This is sometimes known as "POSIXLY CORRECT". If this flag is not used then arguments are reordered (i.e., permuted) so that all non-option arguments are moved after option arguments. This mode has several uses but the main one is to implement a command that has subcommands.
|
||||
|
||||
- `-h` or `--help` displays help about using this command.
|
||||
- ``-h`` or ``--help`` displays help about using this command.
|
||||
|
||||
Usage
|
||||
------------
|
||||
|
||||
Using this command involves passing two sets of arguments separated by `--`. The first set consists of one or more option specifications (`OPTION_SPEC` above) and options that modify the behavior of `argparse`. These must be listed before the `--` argument. The second set are the arguments to be parsed in accordance with the option specifications. They occur after the `--` argument and can be empty. More about this below but here is a simple example that might be used in a function named `my_function`:
|
||||
Using this command involves passing two sets of arguments separated by ``--``. The first set consists of one or more option specifications (``OPTION_SPEC`` above) and options that modify the behavior of ``argparse``. These must be listed before the ``--`` argument. The second set are the arguments to be parsed in accordance with the option specifications. They occur after the ``--`` argument and can be empty. More about this below but here is a simple example that might be used in a function named ``my_function``:
|
||||
|
||||
|
||||
|
||||
|
@ -48,9 +48,9 @@ Using this command involves passing two sets of arguments separated by `--`. The
|
|||
or return
|
||||
|
||||
|
||||
If `$argv` is empty then there is nothing to parse and `argparse` returns zero to indicate success. If `$argv` is not empty then it is checked for flags `-h`, `--help`, `-n` and `--name`. If they are found they are removed from the arguments and local variables (more on this <a href="argparse-local-variables">below</a>) are set so the script can determine which options were seen. Assuming `$argv` doesn't have any errors, such as a missing mandatory value for an option, then `argparse` exits with status zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one.
|
||||
If ``$argv`` is empty then there is nothing to parse and ``argparse`` returns zero to indicate success. If ``$argv`` is not empty then it is checked for flags ``-h``, ``--help``, ``-n`` and ``--name``. If they are found they are removed from the arguments and local variables (more on this <a href="argparse-local-variables">below</a>) are set so the script can determine which options were seen. Assuming ``$argv`` doesn't have any errors, such as a missing mandatory value for an option, then ``argparse`` exits with status zero. Otherwise it writes appropriate error messages to stderr and exits with a status of one.
|
||||
|
||||
The `--` argument is required. You do not have to include any arguments after the `--` but you must include the `--`. For example, this is acceptable:
|
||||
The ``--`` argument is required. You do not have to include any arguments after the ``--`` but you must include the ``--``. For example, this is acceptable:
|
||||
|
||||
|
||||
|
||||
|
@ -70,80 +70,80 @@ But this is not:
|
|||
argparse 'h/help' 'n/name' $argv
|
||||
|
||||
|
||||
The first `--` seen is what allows the `argparse` command to reliably separate the option specifications from the command arguments.
|
||||
The first ``--`` seen is what allows the ``argparse`` command to reliably separate the option specifications from the command arguments.
|
||||
|
||||
Option Specifications
|
||||
------------
|
||||
|
||||
Each option specification is a string composed of
|
||||
|
||||
- A short flag letter (which is mandatory). It must be an alphanumeric or "#". The "#" character is special and means that a flag of the form `-123` is valid. The short flag "#" must be followed by "-" (since the short name isn't otherwise valid since `_flag_#` is not a valid var name) and must be followed by a long flag name with no modifiers.
|
||||
- A short flag letter (which is mandatory). It must be an alphanumeric or "#". The "#" character is special and means that a flag of the form ``-123`` is valid. The short flag "#" must be followed by "-" (since the short name isn't otherwise valid since ``_flag_#`` is not a valid var name) and must be followed by a long flag name with no modifiers.
|
||||
|
||||
- A `/` if the short flag can be used by someone invoking your command else `-` if it should not be exposed as a valid short flag. If there is no long flag name these characters should be omitted. You can also specify a '#' to indicate the short and long flag names can be used and the value can be specified as an implicit int; i.e., a flag of the form `-NNN`.
|
||||
- A ``/`` if the short flag can be used by someone invoking your command else ``-`` if it should not be exposed as a valid short flag. If there is no long flag name these characters should be omitted. You can also specify a '#' to indicate the short and long flag names can be used and the value can be specified as an implicit int; i.e., a flag of the form ``-NNN``.
|
||||
|
||||
- A long flag name which is optional. If not present then only the short flag letter can be used.
|
||||
|
||||
- Nothing if the flag is a boolean that takes no argument or is an implicit int flag, else
|
||||
|
||||
- `=` if it requires a value and only the last instance of the flag is saved, else
|
||||
- ``=`` if it requires a value and only the last instance of the flag is saved, else
|
||||
|
||||
- `=?` it takes an optional value and only the last instance of the flag is saved, else
|
||||
- ``=?`` it takes an optional value and only the last instance of the flag is saved, else
|
||||
|
||||
- `=+` if it requires a value and each instance of the flag is saved.
|
||||
- ``=+`` if it requires a value and each instance of the flag is saved.
|
||||
|
||||
- Optionally a `!` followed by fish script to validate the value. Typically this will be a function to run. If the return status is zero the value for the flag is valid. If non-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on <a href="#arparse-validation">Flag Value Validation</a> for more information.
|
||||
- Optionally a ``!`` followed by fish script to validate the value. Typically this will be a function to run. If the return status is zero the value for the flag is valid. If non-zero the value is invalid. Any error messages should be written to stdout (not stderr). See the section on <a href="#arparse-validation">Flag Value Validation</a> for more information.
|
||||
|
||||
See the <a href="#fish-opt">`fish_opt`</a> command for a friendlier but more verbose way to create option specifications.
|
||||
See the <a href="#fish-opt">``fish_opt``</a> command for a friendlier but more verbose way to create option specifications.
|
||||
|
||||
In the following examples if a flag is not seen when parsing the arguments then the corresponding _flag_X var(s) will not be set.
|
||||
|
||||
Flag Value Validation
|
||||
------------
|
||||
|
||||
It is common to want to validate the the value provided for an option satisfies some criteria. For example, that it is a valid integer within a specific range. You can always do this after `argparse` returns but you can also request that `argparse` perform the validation by executing arbitrary fish script. To do so simply append an `!` (exclamation-mark) then the fish script to be run. When that code is executed three vars will be defined:
|
||||
It is common to want to validate the the value provided for an option satisfies some criteria. For example, that it is a valid integer within a specific range. You can always do this after ``argparse`` returns but you can also request that ``argparse`` perform the validation by executing arbitrary fish script. To do so simply append an ``!`` (exclamation-mark) then the fish script to be run. When that code is executed three vars will be defined:
|
||||
|
||||
- `_argparse_cmd` will be set to the value of the value of the `argparse --name` value.
|
||||
- ``_argparse_cmd`` will be set to the value of the value of the ``argparse --name`` value.
|
||||
|
||||
- `_flag_name` will be set to the short or long flag that being processed.
|
||||
- ``_flag_name`` will be set to the short or long flag that being processed.
|
||||
|
||||
- `_flag_value` will be set to the value associated with the flag being processed.
|
||||
- ``_flag_value`` will be set to the value associated with the flag being processed.
|
||||
|
||||
If you do this via a function it should be defined with the `--no-scope-shadowing` flag. Otherwise it won't have access to those variables.
|
||||
If you do this via a function it should be defined with the ``--no-scope-shadowing`` flag. Otherwise it won't have access to those 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 just call `_validate_int` without those flags is to simply 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 just call ``_validate_int`` without those flags is to simply check that the value is a valid integer with no limits on the min or max value allowed.
|
||||
|
||||
Example OPTION_SPECs
|
||||
------------
|
||||
|
||||
Some OPTION_SPEC examples:
|
||||
|
||||
- `h/help` means that both `-h` and `--help` are valid. The flag is a boolean and can be used more than once. If either flag is used then `_flag_h` and `_flag_help` will be set to the count of how many times either flag was seen.
|
||||
- ``h/help`` means that both ``-h`` and ``--help`` are valid. The flag is a boolean and can be used more than once. If either flag is used then ``_flag_h`` and ``_flag_help`` will be set to the count of how many times either flag was seen.
|
||||
|
||||
- `h-help` means that only `--help` is valid. The flag is a boolean and can be used more than once. If the long flag is used then `_flag_h` and `_flag_help` will be set to the count of how many times the long flag was seen.
|
||||
- ``h-help`` means that only ``--help`` is valid. The flag is a boolean and can be used more than once. If the long flag is used then ``_flag_h`` and ``_flag_help`` will be set to the count of how many times the long flag was seen.
|
||||
|
||||
- `n/name=` means that both `-n` and `--name` are valid. It requires a value and can be used at most once. If the flag is seen then `_flag_n` and `_flag_name` will be set with the single mandatory value associated with the flag.
|
||||
- ``n/name=`` means that both ``-n`` and ``--name`` are valid. It requires a value and can be used at most once. If the flag is seen then ``_flag_n`` and ``_flag_name`` will be set with the single mandatory value associated with the flag.
|
||||
|
||||
- `n/name=?` means that both `-n` and `--name` are valid. It accepts an optional value and can be used at most once. If the flag is seen then `_flag_n` and `_flag_name` will be set with the value associated with the flag if one was provided else it will be set with no values.
|
||||
- ``n/name=?`` means that both ``-n`` and ``--name`` are valid. It accepts an optional value and can be used at most once. If the flag is seen then ``_flag_n`` and ``_flag_name`` will be set with the value associated with the flag if one was provided else it will be set with no values.
|
||||
|
||||
- `n-name=+` means that only `--name` is valid. It requires a value and can be used more than once. If the flag is seen then `_flag_n` and `_flag_name` will be set with the values associated with each occurrence of the flag.
|
||||
- ``n-name=+`` means that only ``--name`` is valid. It requires a value and can be used more than once. If the flag is seen then ``_flag_n`` and ``_flag_name`` will be set with the values associated with each occurrence of the flag.
|
||||
|
||||
- `x` means that only `-x` is valid. It is a boolean can can be used more than once. If it is seen then `_flag_x` will be set to the count of how many times the flag was seen.
|
||||
- ``x`` means that only ``-x`` is valid. It is a boolean can can be used more than once. If it is seen then ``_flag_x`` will be set to the count of how many times the flag was seen.
|
||||
|
||||
- `x=`, `x=?`, and `x=+` are similar to the n/name examples above but there is no long flag alternative to the short flag `-x`.
|
||||
- ``x=``, ``x=?``, and ``x=+`` are similar to the n/name examples above but there is no long flag alternative to the short flag ``-x``.
|
||||
|
||||
- `x-` is not valid since there is no long flag name and therefore the short flag, `-x`, has to be usable.
|
||||
- ``x-`` is not valid since there is no long flag name and therefore the short flag, ``-x``, has to be usable.
|
||||
|
||||
- `#-max` means that flags matching the regex "^--?\d+$" are valid. When seen they are assigned to the variable `_flag_max`. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example `head -3 /a/file` to emit only the first three lines of /a/file.
|
||||
- ``#-max`` means that flags matching the regex "^--?\d+$" are valid. When seen they are assigned to the variable ``_flag_max``. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example ``head -3 /a/file`` to emit only the first three lines of /a/file.
|
||||
|
||||
- `n#max` means that flags matching the regex "^--?\d+$" are valid. When seen they are assigned to the variables `_flag_n` and `_flag_max`. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example `head -3 /a/file` to emit only the first three lines of /a/file. You can also specify the value using either flag: `-n NNN` or `--max NNN` in this example.
|
||||
- ``n#max`` means that flags matching the regex "^--?\d+$" are valid. When seen they are assigned to the variables ``_flag_n`` and ``_flag_max``. This allows any valid positive or negative integer to be specified by prefixing it with a single "-". Many commands support this idiom. For example ``head -3 /a/file`` to emit only the first three lines of /a/file. You can also specify the value using either flag: ``-n NNN`` or ``--max NNN`` in this example.
|
||||
|
||||
After parsing the arguments the `argv` var is set with local scope to any values not already consumed during flag processing. If there are not unbound values the var is set but `count $argv` will be zero.
|
||||
After parsing the arguments the ``argv`` var is set with local scope to any values not already consumed during flag processing. If there are not unbound values the var is set but ``count $argv`` will be zero.
|
||||
|
||||
If an error occurs during argparse processing it will exit with a non-zero status and print error messages to stderr.
|
||||
|
||||
Notes
|
||||
------------
|
||||
|
||||
Prior to the addition of this builtin command in the 2.7.0 release there were two main ways to parse the arguments passed to a fish script or function. One way was to use the OS provided `getopt` command. The problem with that is that the GNU and BSD implementations are not compatible. Which makes using that external command difficult other than in trivial situations. The other way is to iterate over `$argv` and use the fish `switch` statement to decide how to handle the argument. That, however, involves a huge amount of boilerplate code. It is also borderline impossible to implement the same behavior as builtin commands.
|
||||
Prior to the addition of this builtin command in the 2.7.0 release there were two main ways to parse the arguments passed to a fish script or function. One way was to use the OS provided ``getopt`` command. The problem with that is that the GNU and BSD implementations are not compatible. Which makes using that external command difficult other than in trivial situations. The other way is to iterate over ``$argv`` and use the fish ``switch`` statement to decide how to handle the argument. That, however, involves a huge amount of boilerplate code. It is also borderline impossible to implement the same behavior as builtin commands.
|
||||
|
|
|
@ -10,13 +10,13 @@ begin; [COMMANDS...;] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`begin` is used to create a new block of code.
|
||||
``begin`` is used to create a new block of code.
|
||||
|
||||
A block 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`.
|
||||
A block 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``.
|
||||
|
||||
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` does not change the current exit status itself. After the block has completed, `$status` will be set to the status returned by the most recent command.
|
||||
``begin`` does not change the current exit status itself. After the block has completed, ``$status`` will be set to the status returned by the most recent command.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,20 +10,20 @@ bg [PID...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`bg` sends <a href="index.html#syntax-job-control">jobs</a> to the background, resuming them if they are stopped.
|
||||
``bg`` sends <a href="index.html#syntax-job-control">jobs</a> 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.
|
||||
|
||||
When at least one of the arguments isn't a valid job specifier (i.e. PID),
|
||||
`bg` will print an error without backgrounding anything.
|
||||
``bg`` will print an error without backgrounding anything.
|
||||
|
||||
When all arguments are valid job specifiers, bg will background all matching jobs that exist.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`bg 123 456 789` will background 123, 456 and 789.
|
||||
``bg 123 456 789`` will background 123, 456 and 789.
|
||||
|
||||
If only 123 and 789 exist, it will still background them and print an error about 456.
|
||||
|
||||
`bg 123 banana` or `bg banana 123` will complain that "banana" is not a valid job specifier.
|
||||
``bg 123 banana`` or ``bg banana 123`` will complain that "banana" is not a valid job specifier.
|
||||
|
|
|
@ -19,131 +19,131 @@ bind (-e | --erase) [(-M | --mode) MODE]
|
|||
Description
|
||||
------------
|
||||
|
||||
`bind` adds a binding for the specified key sequence to the specified 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 <a href="index.html#escapes">fish escape sequences</a>. 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 <a href="index.html#escapes">fish escape sequences</a>. 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 used in conjunction with the `-s` switch, `bind` will silently ignore bindings to named keys that are not found in termcap for the current `$TERMINAL`, otherwise a warning is emitted.
|
||||
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 used in conjunction with the ``-s`` switch, ``bind`` will silently ignore bindings to named keys that are not found in termcap for the current ``$TERMINAL``, otherwise a warning is emitted.
|
||||
|
||||
`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 <a href="#function">function</a> 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 <a href="#function">function</a> 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 a script produces output, it should finish by calling `commandline -f repaint` to tell fish that a repaint is in order.
|
||||
If a script produces output, it should finish by calling ``commandline -f repaint`` to tell fish that a repaint is in order.
|
||||
|
||||
When multiple `COMMAND`s are provided, they are all run in the specified order when the key is pressed. Note that special input functions cannot be combined with ordinary shell script commands. The commands must be entirely a sequence of special input functions (from `bind -f`) or all shell script commands (i.e., valid fish script).
|
||||
When multiple ``COMMAND``s are provided, they are all run in the specified order when the key is pressed. Note that special input functions cannot be combined with ordinary shell script commands. The commands must be entirely a sequence of special input functions (from ``bind -f``) or all shell script commands (i.e., valid fish script).
|
||||
|
||||
If no `SEQUENCE` is provided, all bindings (or just the bindings in the specified `MODE`) are printed. If `SEQUENCE` is provided without `COMMAND`, just the binding matching that sequence is printed.
|
||||
If no ``SEQUENCE`` is provided, all bindings (or just the bindings in the specified ``MODE``) are printed. If ``SEQUENCE`` is provided without ``COMMAND``, just the binding matching that sequence is printed.
|
||||
|
||||
To save custom keybindings, put the `bind` statements into <a href="index.html#initialization">config.fish</a>. Alternatively, fish also automatically executes a function called `fish_user_key_bindings` if it exists.
|
||||
To save custom keybindings, put the ``bind`` statements into <a href="index.html#initialization">config.fish</a>. Alternatively, fish also automatically executes a function called ``fish_user_key_bindings`` if it exists.
|
||||
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default", and every bind applies to a single mode. The mode can be viewed/changed with the `$fish_bind_mode` variable.
|
||||
Key bindings may use "modes", which mimics Vi's modal input behavior. The default mode is "default", and every bind applies to a single mode. The mode can be viewed/changed with the ``$fish_bind_mode`` variable.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `-k` or `--key` Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
- ``-k`` or ``--key`` Specify a key name, such as 'left' or 'backspace' instead of a character sequence
|
||||
|
||||
- `-K` or `--key-names` Display a list of available key names. Specifying `-a` or `--all` includes keys that don't have a known mapping
|
||||
- ``-K`` or ``--key-names`` Display a list of available key names. Specifying ``-a`` or ``--all`` includes keys that don't have a known mapping
|
||||
|
||||
- `-f` or `--function-names` Display a list of available input functions
|
||||
- ``-f`` or ``--function-names`` Display a list of available input functions
|
||||
|
||||
- `-L` or `--list-modes` Display a list of defined bind modes
|
||||
- ``-L`` or ``--list-modes`` Display a list of defined bind modes
|
||||
|
||||
- `-M MODE` or `--mode MODE` Specify a bind mode that the bind is used in. Defaults to "default"
|
||||
- ``-M MODE`` or ``--mode MODE`` Specify a bind mode that the bind is used in. Defaults to "default"
|
||||
|
||||
- `-m NEW_MODE` or `--sets-mode NEW_MODE` Change the current mode to `NEW_MODE` after this binding is executed
|
||||
- ``-m NEW_MODE`` or ``--sets-mode NEW_MODE`` Change the current mode to ``NEW_MODE`` after this binding is executed
|
||||
|
||||
- `-e` or `--erase` Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying `-a` or `--all` with `-M` or `--mode` erases all binds in the given mode regardless of sequence. Specifying `-a` or `--all` without `-M` or `--mode` erases all binds in all modes regardless of sequence.
|
||||
- ``-e`` or ``--erase`` Erase the binding with the given sequence and mode instead of defining a new one. Multiple sequences can be specified with this flag. Specifying ``-a`` or ``--all`` with ``-M`` or ``--mode`` erases all binds in the given mode regardless of sequence. Specifying ``-a`` or ``--all`` without ``-M`` or ``--mode`` erases all binds in all modes regardless of sequence.
|
||||
|
||||
- `-a` or `--all` See `--erase` and `--key-names`
|
||||
- ``-a`` or ``--all`` See ``--erase`` and ``--key-names``
|
||||
|
||||
- `--preset` and `--user` specify if bind should operate on user or preset bindings. User bindings take precedence over preset bindings when fish looks up mappings. By default, all `bind` invocations work on the "user" level except for listing, which will show both levels. All invocations except for inserting new bindings can operate on both levels at the same time. `--preset` should only be used in full binding sets (like when working on `fish_vi_key_bindings`).
|
||||
- ``--preset`` and ``--user`` specify if bind should operate on user or preset bindings. User bindings take precedence over preset bindings when fish looks up mappings. By default, all ``bind`` invocations work on the "user" level except for listing, which will show both levels. All invocations except for inserting new bindings can operate on both levels at the same time. ``--preset`` should only be used in full binding sets (like when working on ``fish_vi_key_bindings``).
|
||||
|
||||
Special input functions
|
||||
------------
|
||||
The following special input functions are available:
|
||||
|
||||
- `accept-autosuggestion`, accept the current autosuggestion completely
|
||||
- ``accept-autosuggestion``, accept the current autosuggestion completely
|
||||
|
||||
- `backward-char`, moves one character to the left
|
||||
- ``backward-char``, moves one character to the left
|
||||
|
||||
- `backward-bigword`, move one whitespace-delimited word to the left
|
||||
- ``backward-bigword``, move one whitespace-delimited word to the left
|
||||
|
||||
- `backward-delete-char`, deletes one character of input to the left of the cursor
|
||||
- ``backward-delete-char``, deletes one character of input to the left of the cursor
|
||||
|
||||
- `backward-kill-bigword`, move the whitespace-delimited word to the left of the cursor to the killring
|
||||
- ``backward-kill-bigword``, move the whitespace-delimited word to the left of the cursor to the killring
|
||||
|
||||
- `backward-kill-line`, move everything from the beginning of the line to the cursor to the killring
|
||||
- ``backward-kill-line``, move everything from the beginning of the line to the cursor to the killring
|
||||
|
||||
- `backward-kill-path-component`, move one path component to the left of the cursor (everything from the last "/" or whitespace exclusive) to the killring
|
||||
- ``backward-kill-path-component``, move one path component to the left of the cursor (everything from the last "/" or whitespace exclusive) to the killring
|
||||
|
||||
- `backward-kill-word`, move the word to the left of the cursor to the killring
|
||||
- ``backward-kill-word``, move the word to the left of the cursor to the killring
|
||||
|
||||
- `backward-word`, move one word to the left
|
||||
- ``backward-word``, move one word to the left
|
||||
|
||||
- `beginning-of-buffer`, moves to the beginning of the buffer, i.e. the start of the first line
|
||||
- ``beginning-of-buffer``, moves to the beginning of the buffer, i.e. the start of the first line
|
||||
|
||||
- `beginning-of-history`, move to the beginning of the history
|
||||
- ``beginning-of-history``, move to the beginning of the history
|
||||
|
||||
- `beginning-of-line`, move to the beginning of the line
|
||||
- ``beginning-of-line``, move to the beginning of the line
|
||||
|
||||
- `begin-selection`, start selecting text
|
||||
- ``begin-selection``, start selecting text
|
||||
|
||||
- `capitalize-word`, make the current word begin with a capital letter
|
||||
- ``capitalize-word``, make the current word begin with a capital letter
|
||||
|
||||
- `complete`, guess the remainder of the current token
|
||||
- ``complete``, guess the remainder of the current token
|
||||
|
||||
- `complete-and-search`, invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager)
|
||||
- ``complete-and-search``, invoke the searchable pager on completion options (for convenience, this also moves backwards in the completion pager)
|
||||
|
||||
- `delete-char`, delete one character to the right of the cursor
|
||||
- ``delete-char``, delete one character to the right of the cursor
|
||||
|
||||
- `downcase-word`, make the current word lowercase
|
||||
- ``downcase-word``, make the current word lowercase
|
||||
|
||||
- `end-of-buffer`, moves to the end of the buffer, i.e. the end of the first line
|
||||
- ``end-of-buffer``, moves to the end of the buffer, i.e. the end of the first line
|
||||
|
||||
- `end-of-history`, move to the end of the history
|
||||
- ``end-of-history``, move to the end of the history
|
||||
|
||||
- `end-of-line`, move to the end of the line
|
||||
- ``end-of-line``, move to the end of the line
|
||||
|
||||
- `end-selection`, end selecting text
|
||||
- ``end-selection``, end selecting text
|
||||
|
||||
- `forward-bigword`, move one whitespace-delimited word to the right
|
||||
- ``forward-bigword``, move one whitespace-delimited word to the right
|
||||
|
||||
- `forward-char`, move one character to the right
|
||||
- ``forward-char``, move one character to the right
|
||||
|
||||
- `forward-word`, move one word to the right
|
||||
- ``forward-word``, move one word to the right
|
||||
|
||||
- `history-search-backward`, search the history for the previous match
|
||||
- ``history-search-backward``, search the history for the previous match
|
||||
|
||||
- `history-search-forward`, search the history for the next match
|
||||
- ``history-search-forward``, search the history for the next match
|
||||
|
||||
- `kill-bigword`, move the next whitespace-delimited word to the killring
|
||||
- ``kill-bigword``, move the next whitespace-delimited word to the killring
|
||||
|
||||
- `kill-line`, move everything from the cursor to the end of the line to the killring
|
||||
- ``kill-line``, move everything from the cursor to the end of the line to the killring
|
||||
|
||||
- `kill-selection`, move the selected text to the killring
|
||||
- ``kill-selection``, move the selected text to the killring
|
||||
|
||||
- `kill-whole-line`, move the line to the killring
|
||||
- ``kill-whole-line``, move the line to the killring
|
||||
|
||||
- `kill-word`, move the next word to the killring
|
||||
- ``kill-word``, move the next word to the killring
|
||||
|
||||
- `pager-toggle-search`, toggles the search field if the completions pager is visible.
|
||||
- ``pager-toggle-search``, toggles the search field if the completions pager is visible.
|
||||
|
||||
- `suppress-autosuggestion`, remove the current autosuggestion
|
||||
- ``suppress-autosuggestion``, remove the current autosuggestion
|
||||
|
||||
- `swap-selection-start-stop`, go to the other end of the highlighted text without changing the selection
|
||||
- ``swap-selection-start-stop``, go to the other end of the highlighted text without changing the selection
|
||||
|
||||
- `transpose-chars`, transpose two characters to the left of the cursor
|
||||
- ``transpose-chars``, transpose two characters to the left of the cursor
|
||||
|
||||
- `transpose-words`, transpose two words to the left of the cursor
|
||||
- ``transpose-words``, transpose two words to the left of the cursor
|
||||
|
||||
- `upcase-word`, make the current word uppercase
|
||||
- ``upcase-word``, make the current word uppercase
|
||||
|
||||
- `yank`, insert the latest entry of the killring into the buffer
|
||||
- ``yank``, insert the latest entry of the killring into the buffer
|
||||
|
||||
- `yank-pop`, rotate to the previous entry of the killring
|
||||
- ``yank-pop``, rotate to the previous entry of the killring
|
||||
|
||||
|
||||
Examples
|
||||
|
@ -155,7 +155,7 @@ Examples
|
|||
|
||||
bind <asis>\\cd</asis> 'exit'
|
||||
|
||||
Causes `fish` to exit when @key{Control,D} is pressed.
|
||||
Causes ``fish`` to exit when @key{Control,D} is pressed.
|
||||
|
||||
|
||||
|
||||
|
@ -180,6 +180,6 @@ Special Case: The escape Character
|
|||
|
||||
The escape key can be used standalone, for example, to switch from insertion mode to normal mode when using Vi keybindings. Escape may also be used as a "meta" key, to indicate the start of an escape sequence, such as function or arrow keys. Custom bindings can also be defined that begin with an escape character.
|
||||
|
||||
fish waits for a period after receiving the escape character, to determine whether it is standalone or part of an escape sequence. While waiting, additional key presses make the escape key behave as a meta key. If no other key presses come in, it is handled as a standalone escape. The waiting period is set to 300 milliseconds (0.3 seconds) in the default key bindings and 10 milliseconds in the vi key bindings. It can be configured by setting the `fish_escape_delay_ms` variable to a value between 10 and 5000 ms. It is recommended that this be a universal variable that you set once from an interactive session.
|
||||
fish waits for a period after receiving the escape character, to determine whether it is standalone or part of an escape sequence. While waiting, additional key presses make the escape key behave as a meta key. If no other key presses come in, it is handled as a standalone escape. The waiting period is set to 300 milliseconds (0.3 seconds) in the default key bindings and 10 milliseconds in the vi key bindings. It can be configured by setting the ``fish_escape_delay_ms`` variable to a value between 10 and 5000 ms. It is recommended that this be a universal variable that you set once from an interactive session.
|
||||
|
||||
Note: fish 2.2.0 and earlier used a default of 10 milliseconds, and provided no way to configure it. That effectively made it impossible to use escape as a meta key.
|
||||
|
|
|
@ -10,21 +10,21 @@ block [OPTIONS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`block` prevents events triggered by `fish` or the <a href="commands.html#emit">`emit`</a> command from being delivered and acted upon while the block is in place.
|
||||
``block`` prevents events triggered by ``fish`` or the <a href="commands.html#emit">``emit``</a> 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.
|
||||
|
||||
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
|
||||
- ``-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
|
||||
- ``-g`` or ``--global`` Never automatically release the lock
|
||||
|
||||
- `-e` or `--erase` Release global block
|
||||
- ``-e`` or ``--erase`` Release global block
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,9 +10,9 @@ LOOP_CONSTRUCT; [COMMANDS...] break; [COMMANDS...] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`break` halts a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
``break`` halts a currently running loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
|
||||
There are no parameters for `break`.
|
||||
There are no parameters for ``break``.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,8 +10,8 @@ breakpoint
|
|||
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 <a href="index.html#debugging">Debugging fish scripts</a> in the `fish` manual.
|
||||
For more details, see <a href="index.html#debugging">Debugging fish scripts</a> in the ``fish`` manual.
|
||||
|
||||
There are no parameters for `breakpoint`.
|
||||
There are no parameters for ``breakpoint``.
|
||||
|
|
|
@ -10,11 +10,11 @@ builtin BUILTINNAME [OPTIONS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`builtin` forces the shell to use a builtin command, rather than a function or program.
|
||||
``builtin`` forces the shell to use a builtin command, rather than a function or program.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `-n` or `--names` List the names of all defined builtins
|
||||
- ``-n`` or ``--names`` List the names of all defined builtins
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,9 +10,9 @@ switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`switch` executes one of several blocks of commands, depending on whether a specified value matches one of several values. `case` is used together with the `switch` statement in order to determine which block should be executed.
|
||||
``switch`` executes one of several blocks of commands, depending on whether a specified value matches one of several 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.
|
||||
|
||||
|
@ -43,7 +43,7 @@ Say \$animal contains the name of an animal. Then this code would classify it:
|
|||
end
|
||||
|
||||
|
||||
If the above code was run with `$animal` set to `whale`, the output
|
||||
would be `mammal`.
|
||||
If the above code was run with ``$animal`` set to ``whale``, the output
|
||||
would be ``mammal``.
|
||||
|
||||
If `$animal` was set to "banana", it would print "I have no idea what a banana is".
|
||||
If ``$animal`` was set to "banana", it would print "I have no idea what a banana is".
|
||||
|
|
|
@ -9,17 +9,17 @@ cd [DIRECTORY]
|
|||
|
||||
Description
|
||||
------------
|
||||
`cd` changes the current working directory.
|
||||
``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 ``/``).
|
||||
|
||||
Fish also ships a wrapper function around the builtin `cd` that understands `cd -` as changing to the previous directory. See also <a href="commands.html#prevd">`prevd`</a>. 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.
|
||||
Fish also ships a wrapper function around the builtin ``cd`` that understands ``cd -`` as changing to the previous directory. See also <a href="commands.html#prevd">``prevd``</a>. 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.
|
||||
|
||||
As a special case, `cd .` is equivalent to `cd $PWD`, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated.
|
||||
As a special case, ``cd .`` is equivalent to ``cd $PWD``, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated.
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
@ -38,4 +38,4 @@ Examples
|
|||
See Also
|
||||
------------
|
||||
|
||||
See also the <a href="commands.html#cdh">`cdh`</a> command for changing to a recently visited directory.
|
||||
See also the <a href="commands.html#cdh">``cdh``</a> command for changing to a recently visited directory.
|
||||
|
|
|
@ -11,11 +11,11 @@ cdh [ directory ]
|
|||
Description
|
||||
------------
|
||||
|
||||
`cdh` with no arguments presents a list of recently visited directories. You can then select one of the entries by letter or number. You can also press @key{tab} to use the completion pager to select an item from the list. If you give it a single argument it is equivalent to `cd directory`.
|
||||
``cdh`` with no arguments presents a list of recently visited directories. You can then select one of the entries by letter or number. You can also press @key{tab} to use the completion pager to select an item from the list. If you give it a single argument it is equivalent to ``cd directory``.
|
||||
|
||||
Note that the `cd` command limits directory history to the 25 most recently visited directories. The history is stored in the `$dirprev` and `$dirnext` variables which this command manipulates. If you make those universal variables your `cd` history is shared among all fish instances.
|
||||
Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates. If you make those universal variables your ``cd`` history is shared among all fish instances.
|
||||
|
||||
See Also
|
||||
------------
|
||||
|
||||
See also the <a href="commands.html#prevd">`prevd`</a> and <a href="commands.html#pushd">`pushd`</a> commands which also work with the recent `cd` history and are provided for compatibility with other shells.
|
||||
See also the <a href="commands.html#prevd">``prevd``</a> and <a href="commands.html#pushd">``pushd``</a> commands which also work with the recent ``cd`` history and are provided for compatibility with other shells.
|
||||
|
|
|
@ -10,25 +10,25 @@ command [OPTIONS] COMMANDNAME [ARGS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`command` forces the shell to execute the program `COMMANDNAME` and ignore any functions or builtins with the same name.
|
||||
``command`` forces the shell to execute the program ``COMMANDNAME`` and ignore any functions or builtins with the same name.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a` or `--all` returns all the external commands that are found in `$PATH` in the order they are found.
|
||||
- ``-a`` or ``--all`` returns all the external commands that are found in ``$PATH`` in the order they are found.
|
||||
|
||||
- `-q` or `--quiet`, in conjunction with `-s`, silences the output and prints nothing, setting only the exit code.
|
||||
- ``-q`` or ``--quiet``, in conjunction with ``-s``, silences the output and prints nothing, setting only the exit code.
|
||||
|
||||
- `-s` or `--search` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the `$PATH`.
|
||||
- ``-s`` or ``--search`` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the ``$PATH``.
|
||||
|
||||
With the `-s` option, `command` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a `-q` or `--quiet` option prevents any paths from being printed, like `type -q`, for testing only the exit status.
|
||||
With the ``-s`` option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a ``-q`` or ``--quiet`` option prevents any paths from being printed, like ``type -q``, for testing only the exit status.
|
||||
|
||||
For basic compatibility with POSIX `command`, the `-v` flag is recognized as an alias for `-s`.
|
||||
For basic compatibility with POSIX ``command``, the ``-v`` flag is recognized as an alias for ``-s``.
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
||||
`command ls` causes fish to execute the `ls` program, even if an `ls` function exists.
|
||||
``command ls`` causes fish to execute the ``ls`` program, even if an ``ls`` function exists.
|
||||
|
||||
`command -s ls` returns the path to the `ls` program.
|
||||
``command -s ls`` returns the path to the ``ls`` program.
|
||||
|
||||
`command -sq git; and command git log` runs `git log` only if `git` exists.
|
||||
``command -sq git; and command git log`` runs ``git log`` only if ``git`` exists.
|
||||
|
|
|
@ -10,59 +10,59 @@ commandline [OPTIONS] [CMD]
|
|||
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.
|
||||
- ``-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.
|
||||
- ``-f`` or ``--function`` inject readline functions into the reader. This option cannot be combined with any other option. It will cause any additional arguments to be interpreted as readline functions, and these functions will be injected into the reader, so that they will be returned to the reader before any additional actual key presses are read.
|
||||
|
||||
The following options change the way `commandline` updates the command line buffer:
|
||||
The following options change the way ``commandline`` updates the command line buffer:
|
||||
|
||||
- `-a` or `--append` do not remove the current commandline, append the specified string at the end of it
|
||||
- ``-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
|
||||
- ``-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)
|
||||
- ``-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, including any displayed autosuggestion (default)
|
||||
- ``-b`` or ``--current-buffer`` select the entire buffer, including any displayed autosuggestion (default)
|
||||
|
||||
- `-j` or `--current-job` select the current job
|
||||
- ``-j`` or ``--current-job`` select the current job
|
||||
|
||||
- `-p` or `--current-process` select the current process
|
||||
- ``-p`` or ``--current-process`` select the current process
|
||||
|
||||
- `-s` or `--current-selection` selects the current selection
|
||||
- ``-s`` or ``--current-selection`` selects the current selection
|
||||
|
||||
- `-t` or `--current-token` select the current token
|
||||
- ``-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
|
||||
- ``-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
|
||||
- ``-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
|
||||
- ``-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
|
||||
- ``-P`` or ``--paging-mode`` evaluates to true if the commandline is showing pager contents, such as tab completions
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`commandline -j $history[3]` replaces the job under the cursor with the third item from the command line history.
|
||||
``commandline -j $history[3]`` replaces the job under the cursor with the third item from the command line history.
|
||||
|
||||
If the commandline contains
|
||||
|
||||
|
|
|
@ -27,77 +27,77 @@ For an introduction to specifying completions, see <a
|
|||
href='index.html#completion-own'>Writing your own completions</a> in
|
||||
the fish manual.
|
||||
|
||||
- `COMMAND` is the name of the command for which to add a completion.
|
||||
- ``COMMAND`` is the name of the command for which to add a completion.
|
||||
|
||||
- `SHORT_OPTION` is a one character option for the command.
|
||||
- ``SHORT_OPTION`` is a one character option for the command.
|
||||
|
||||
- `LONG_OPTION` is a multi character option for the command.
|
||||
- ``LONG_OPTION`` is a multi character option for the command.
|
||||
|
||||
- `OPTION_ARGUMENTS` is parameter containing a space-separated list of possible option-arguments, which may contain command substitutions.
|
||||
- ``OPTION_ARGUMENTS`` is parameter containing a space-separated list of possible option-arguments, which may contain command substitutions.
|
||||
|
||||
- `DESCRIPTION` is a description of what the option and/or option arguments do.
|
||||
- ``DESCRIPTION`` is a description of what the option and/or option arguments do.
|
||||
|
||||
- `-c COMMAND` or `--command COMMAND` specifies that `COMMAND` is the name of the command.
|
||||
- ``-c COMMAND`` or ``--command COMMAND`` specifies that ``COMMAND`` is the name of the command.
|
||||
|
||||
- `-p COMMAND` or `--path COMMAND` specifies that `COMMAND` is the absolute path of the program (optionally containing wildcards).
|
||||
- ``-p COMMAND`` or ``--path COMMAND`` specifies that ``COMMAND`` is the absolute path of the program (optionally containing wildcards).
|
||||
|
||||
- `-e` or `--erase` deletes the specified completion.
|
||||
- ``-e`` or ``--erase`` deletes the specified completion.
|
||||
|
||||
- `-s SHORT_OPTION` or `--short-option=SHORT_OPTION` adds a short option to the completions list.
|
||||
- ``-s SHORT_OPTION`` or ``--short-option=SHORT_OPTION`` adds a short option to the completions list.
|
||||
|
||||
- `-l LONG_OPTION` or `--long-option=LONG_OPTION` adds a GNU style long option to the completions list.
|
||||
- ``-l LONG_OPTION`` or ``--long-option=LONG_OPTION`` adds a GNU style long option to the completions list.
|
||||
|
||||
- `-o LONG_OPTION` or `--old-option=LONG_OPTION` adds an old style long option to the completions list (See below for details).
|
||||
- ``-o LONG_OPTION`` or ``--old-option=LONG_OPTION`` adds an old style long option to the completions list (See below for details).
|
||||
|
||||
- `-a OPTION_ARGUMENTS` or `--arguments=OPTION_ARGUMENTS` adds the specified option arguments to the completions list.
|
||||
- ``-a OPTION_ARGUMENTS`` or ``--arguments=OPTION_ARGUMENTS`` adds the specified option arguments to the completions list.
|
||||
|
||||
- `-k` or `--keep-order` preserves the order of the `OPTION_ARGUMENTS` specified via `-a` or `--arguments` instead of sorting alphabetically.
|
||||
- ``-k`` or ``--keep-order`` preserves the order of the ``OPTION_ARGUMENTS`` specified via ``-a`` or ``--arguments`` instead of sorting alphabetically.
|
||||
|
||||
- `-f` or `--no-files` specifies that the options specified by this completion may not be followed by a filename.
|
||||
- ``-f`` or ``--no-files`` specifies that the options specified by this completion may not be followed by a filename.
|
||||
|
||||
- `-r` or `--require-parameter` specifies that the options specified by this completion always must have an option argument, i.e. may not be followed by another option.
|
||||
- ``-r`` or ``--require-parameter`` specifies that the options specified by this completion always must have an option argument, i.e. may not be followed by another option.
|
||||
|
||||
- `-x` or `--exclusive` implies both `-r` and `-f`.
|
||||
- ``-x`` or ``--exclusive`` implies both ``-r`` and ``-f``.
|
||||
|
||||
- `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the specified command to inherit completions from the wrapped command (See below for details).
|
||||
- ``-w WRAPPED_COMMAND`` or ``--wraps=WRAPPED_COMMAND`` causes the specified command to inherit completions from the wrapped command (See below for details).
|
||||
|
||||
- `-n` or `--condition` specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
|
||||
- ``-n`` or ``--condition`` specifies a shell command that must return 0 if the completion is to be used. This makes it possible to specify completions that should only be used in some cases.
|
||||
|
||||
- `-CSTRING` or `--do-complete=STRING` makes complete try to find all possible completions for the specified string.
|
||||
- ``-CSTRING`` or ``--do-complete=STRING`` makes complete try to find all possible completions for the specified string.
|
||||
|
||||
- `-C` or `--do-complete` with no argument makes complete try to find all possible completions for the current command line buffer. If the shell is not in interactive mode, an error is returned.
|
||||
- ``-C`` or ``--do-complete`` with no argument makes complete try to find all possible completions for the current command line buffer. If the shell is not in interactive mode, an error is returned.
|
||||
|
||||
- `-A` and `--authoritative` no longer do anything and are silently ignored.
|
||||
- ``-A`` and ``--authoritative`` no longer do anything and are silently ignored.
|
||||
|
||||
- `-u` and `--unauthoritative` no longer do anything and are silently ignored.
|
||||
- ``-u`` and ``--unauthoritative`` no longer do anything and are silently ignored.
|
||||
|
||||
Command specific tab-completions in `fish` are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as '`-h`', '`-help`' or '`--help`'. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU version of the getopt library. These styles are:
|
||||
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`').
|
||||
- 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`').
|
||||
- Old style long options, like '``-Wall``'. Old style long options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified in the following parameter ('``-ao null``').
|
||||
|
||||
- GNU style long options, like '`--colors`'. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('`--quoting-style shell`') or by appending the option with a '`=`' and the value ('`--quoting-style=shell`'). GNU style long options may be abbreviated so long as the abbreviation is unique ('`--h`') is equivalent to '`--help`' if help is the only long option beginning with an 'h').
|
||||
- GNU style long options, like '``--colors``'. GNU style long options can be more than one character long, are preceded by two hyphens, and may not be grouped together. Option arguments may be specified in the following parameter ('``--quoting-style shell``') or by appending the option with a '``=``' and the value ('``--quoting-style=shell``'). GNU style long options may be abbreviated so long as the abbreviation is unique ('``--h``') is equivalent to '``--help``' if help is the only long option beginning with an 'h').
|
||||
|
||||
The options for specifying command name and command path may be used multiple times to define the same completions for multiple commands.
|
||||
|
||||
The options for specifying command switches and wrapped commands may be used multiple times to define multiple completions for the command(s) in a single call.
|
||||
|
||||
Invoking `complete` multiple times for the same command adds the new definitions on top of any existing completions defined for the command.
|
||||
Invoking ``complete`` multiple times for the same command adds the new definitions on top of any existing completions defined for the command.
|
||||
|
||||
When `-a` or `--arguments` is specified in conjunction with long, short, or old style options, the specified arguments are only used as completions when attempting to complete an argument for any of the specified options. If `-a` or `--arguments` is specified without any long, short, or old style options, the specified arguments are used when completing any argument to the command (except when completing an option argument that was specified with `-r` or `--require-parameter`).
|
||||
When ``-a`` or ``--arguments`` is specified in conjunction with long, short, or old style options, the specified arguments are only used as completions when attempting to complete an argument for any of the specified options. If ``-a`` or ``--arguments`` is specified without any long, short, or old style options, the specified arguments are used when completing any argument to the command (except when completing an option argument that was specified with ``-r`` or ``--require-parameter``).
|
||||
|
||||
Command substitutions found in `OPTION_ARGUMENTS` are not expected to return a space-separated list of arguments. Instead they must return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Any description provided in this way overrides a description given with `-d` or `--description`.
|
||||
Command substitutions found in ``OPTION_ARGUMENTS`` are not expected to return a space-separated list of arguments. Instead they must return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Any description provided in this way overrides a description given with ``-d`` or ``--description``.
|
||||
|
||||
The `-w` or `--wraps` options causes the specified command to inherit completions from another command. The inheriting command is said to "wrap" the inherited command. The wrapping command may have its own completions in addition to inherited ones. A command may wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the `-e` or `--erase` options. Note that wrapping only works for completions specified with `-c` or `--command` and are ignored when specifying completions with `-p` or `--path`.
|
||||
The ``-w`` or ``--wraps`` options causes the specified command to inherit completions from another command. The inheriting command is said to "wrap" the inherited command. The wrapping command may have its own completions in addition to inherited ones. A command may wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C's completions. Wrapping can be removed using the ``-e`` or ``--erase`` options. Note that wrapping only works for completions specified with ``-c`` or ``--command`` and are ignored when specifying completions with ``-p`` or ``--path``.
|
||||
|
||||
When erasing completions, it is possible to either erase all completions for a specific command by specifying `complete -c COMMAND -e`, or by specifying a specific completion option to delete by specifying either a long, short or old style option.
|
||||
When erasing completions, it is possible to either erase all completions for a specific command by specifying ``complete -c COMMAND -e``, or by specifying a specific completion option to delete by specifying either a long, short or old style option.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The short style option `-o` for the `gcc` command requires that a file follows it. This can be done using writing:
|
||||
The short style option ``-o`` for the ``gcc`` command requires that a file follows it. This can be done using writing:
|
||||
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ The short style option `-o` for the `gcc` command requires that a file follows i
|
|||
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:
|
||||
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ The short style option `-d` for the `grep` command requires that one of the stri
|
|||
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:
|
||||
|
||||
|
||||
|
||||
|
@ -124,7 +124,7 @@ The `su` command takes any username as an argument. Usernames are given as the f
|
|||
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:
|
||||
|
||||
|
@ -135,9 +135,9 @@ This can be written as:
|
|||
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 command line buffer for the presence of a specified set of options.
|
||||
where ``__fish_contains_opt`` is a function that checks the command line buffer for the presence of a specified set of options.
|
||||
|
||||
To implement an alias, use the `-w` or `--wraps` option:
|
||||
To implement an alias, use the ``-w`` or ``--wraps`` option:
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ contains [OPTIONS] KEY [VALUES...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`contains` tests whether the set `VALUES` contains the string `KEY`. If so, `contains` exits with status 0; if not, it exits with status 1.
|
||||
``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
|
||||
- ``-i`` or ``--index`` print the word index
|
||||
|
||||
Note that, like GNU tools and most of fish's builtins, `contains` interprets all arguments starting with a `-` as options to contains, until it reaches an argument that is `--` (two dashes). See the examples below.
|
||||
Note that, like GNU tools and most of fish's builtins, ``contains`` interprets all arguments starting with a ``-`` as options to contains, until it reaches an argument that is ``--`` (two dashes). See the examples below.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -45,7 +45,7 @@ This code will add some directories to $PATH if they aren't yet included:
|
|||
end
|
||||
|
||||
|
||||
While this will check if `hasargs` was run with the `-q` option:
|
||||
While this will check if ``hasargs`` was run with the ``-q`` option:
|
||||
|
||||
|
||||
|
||||
|
@ -58,4 +58,4 @@ While this will check if `hasargs` was run with the `-q` option:
|
|||
end
|
||||
|
||||
|
||||
The `--` here stops `contains` from treating `-q` to an option to itself. Instead it treats it as a normal string to check.
|
||||
The ``--`` here stops ``contains`` from treating ``-q`` to an option to itself. Instead it treats it as a normal string to check.
|
||||
|
|
|
@ -10,7 +10,7 @@ LOOP_CONSTRUCT; [COMMANDS...;] continue; [COMMANDS...;] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`continue` skips the remainder of the current iteration of the current inner loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
``continue`` skips the remainder of the current iteration of the current inner loop, such as a <a href="#for">for</a> loop or a <a href="#while">while</a> loop. It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,11 +10,11 @@ count $VARIABLE
|
|||
Description
|
||||
------------
|
||||
|
||||
`count` prints the number of arguments that were passed to it. This is usually used to find out how many elements an environment variable array contains.
|
||||
``count`` 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, not even `-h` or `--help`.
|
||||
``count`` does not accept any options, not even ``-h`` or ``--help``.
|
||||
|
||||
`count` exits with a non-zero exit status if no arguments were passed to it, and with zero if at least one argument was passed.
|
||||
``count`` exits with a non-zero exit status if no arguments were passed to it, and with zero if at least one argument was passed.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,8 +10,8 @@ dirh
|
|||
Description
|
||||
------------
|
||||
|
||||
`dirh` prints the current directory history. The current position in the history is highlighted using the color defined in the `fish_color_history_current` environment variable.
|
||||
``dirh`` 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.
|
||||
``dirh`` does not accept any parameters.
|
||||
|
||||
Note that the `cd` command limits directory history to the 25 most recently visited directories. The history is stored in the `$dirprev` and `$dirnext` variables.
|
||||
Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables.
|
||||
|
|
|
@ -11,8 +11,8 @@ dirs -c
|
|||
Description
|
||||
------------
|
||||
|
||||
`dirs` prints the current directory stack, as created by the <a href="#pushd">`pushd`</a> command.
|
||||
``dirs`` prints the current directory stack, as created by the <a href="#pushd">``pushd``</a> command.
|
||||
|
||||
With "-c", it clears the directory stack instead.
|
||||
|
||||
`dirs` does not accept any parameters.
|
||||
``dirs`` does not accept any parameters.
|
||||
|
|
|
@ -10,19 +10,19 @@ disown [ PID ... ]
|
|||
Description
|
||||
------------
|
||||
|
||||
`disown` removes the specified <a href="index.html#syntax-job-control">job</a> from the list of jobs. The job itself continues to exist, but fish does not keep track of it any longer.
|
||||
``disown`` removes the specified <a href="index.html#syntax-job-control">job</a> from the list of jobs. The job itself continues to exist, but fish does not keep track of it any longer.
|
||||
|
||||
Jobs in the list of jobs are sent a hang-up signal when fish terminates, which usually causes the job to terminate; `disown` allows these processes to continue regardless.
|
||||
Jobs in the list of jobs are sent a hang-up signal when fish terminates, which usually causes the job to terminate; ``disown`` allows these processes to continue regardless.
|
||||
|
||||
If no process is specified, the most recently-used job is removed (like `bg` and `fg`). If one or more `PID`s are specified, jobs with the specified process IDs are removed from the job list. Invalid jobs are ignored and a warning is printed.
|
||||
If no process is specified, the most recently-used job is removed (like ``bg`` and ``fg``). If one or more ``PID``s are specified, jobs with the specified process IDs are removed from the job list. Invalid jobs are ignored and a warning is printed.
|
||||
|
||||
If a job is stopped, it is sent a signal to continue running, and a warning is printed. It is not possible to use the `bg` builtin to continue a job once it has been disowned.
|
||||
If a job is stopped, it is sent a signal to continue running, and a warning is printed. It is not possible to use the ``bg`` builtin to continue a job once it has been disowned.
|
||||
|
||||
`disown` returns 0 if all specified jobs were disowned successfully, and 1 if any problems were encountered.
|
||||
``disown`` returns 0 if all specified jobs were disowned successfully, and 1 if any problems were encountered.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`firefox &; disown` will start the Firefox web browser in the background and remove it from the job list, meaning it will not be closed when the fish process is closed.
|
||||
``firefox &; disown`` will start the Firefox web browser in the background and remove it from the job list, meaning it will not be closed when the fish process is closed.
|
||||
|
||||
`disown (jobs -p)` removes all jobs from the job list without terminating them.
|
||||
``disown (jobs -p)`` removes all jobs from the job list without terminating them.
|
||||
|
|
|
@ -10,46 +10,46 @@ echo [OPTIONS] [STRING]
|
|||
Description
|
||||
------------
|
||||
|
||||
`echo` displays a string of text.
|
||||
``echo`` displays a string of text.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-n`, Do not output a newline
|
||||
- ``-n``, Do not output a newline
|
||||
|
||||
- `-s`, Do not separate arguments with spaces
|
||||
- ``-s``, Do not separate arguments with spaces
|
||||
|
||||
- `-E`, Disable interpretation of backslash escapes (default)
|
||||
- ``-E``, Disable interpretation of backslash escapes (default)
|
||||
|
||||
- `-e`, Enable interpretation of backslash escapes
|
||||
- ``-e``, Enable interpretation of backslash escapes
|
||||
|
||||
Escape Sequences
|
||||
------------
|
||||
|
||||
If `-e` is used, the following sequences are recognized:
|
||||
If ``-e`` is used, the following sequences are recognized:
|
||||
|
||||
- `\` backslash
|
||||
- ``\`` backslash
|
||||
|
||||
- `\a` alert (BEL)
|
||||
- ``\a`` alert (BEL)
|
||||
|
||||
- `\b` backspace
|
||||
- ``\b`` backspace
|
||||
|
||||
- `\c` produce no further output
|
||||
- ``\c`` produce no further output
|
||||
|
||||
- `\e` escape
|
||||
- ``\e`` escape
|
||||
|
||||
- `\f` form feed
|
||||
- ``\f`` form feed
|
||||
|
||||
- `\n` new line
|
||||
- ``\n`` new line
|
||||
|
||||
- `\r` carriage return
|
||||
- ``\r`` carriage return
|
||||
|
||||
- `\t` horizontal tab
|
||||
- ``\t`` horizontal tab
|
||||
|
||||
- `\v` vertical tab
|
||||
- ``\v`` vertical tab
|
||||
|
||||
- `\0NNN` byte with octal value NNN (1 to 3 digits)
|
||||
- ``\0NNN`` byte with octal value NNN (1 to 3 digits)
|
||||
|
||||
- `\xHH` byte with hexadecimal value HH (1 to 2 digits)
|
||||
- ``\xHH`` byte with hexadecimal value HH (1 to 2 digits)
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,13 +10,13 @@ if CONDITION; COMMANDS_TRUE...; [else; COMMANDS_FALSE...;] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`if` will execute the command `CONDITION`. If the condition's exit status is 0, the commands `COMMANDS_TRUE` will execute. If it is not 0 and `else` is given, `COMMANDS_FALSE` will be executed.
|
||||
``if`` will execute the command ``CONDITION``. If the condition's exit status is 0, the commands ``COMMANDS_TRUE`` will execute. If it is not 0 and ``else`` is given, ``COMMANDS_FALSE`` will be executed.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code tests whether a file `foo.txt` exists as a regular file.
|
||||
The following code tests whether a file ``foo.txt`` exists as a regular file.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ emit EVENT_NAME [ARGUMENTS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`emit` emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
|
||||
``emit`` emits, or fires, an event. Events are delivered to, or caught by, special functions called event handlers. The arguments are passed to the event handlers as function arguments.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -14,9 +14,9 @@ switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`end` ends a block of commands.
|
||||
``end`` ends a block of commands.
|
||||
|
||||
For more information, read the
|
||||
documentation for the block constructs, such as `if`, `for` and `while`.
|
||||
documentation for the block constructs, such as ``if``, ``for`` and ``while``.
|
||||
|
||||
The `end` command does not change the current exit status. Instead, the status after it will be the status returned by the most recent command.
|
||||
The ``end`` command does not change the current exit status. Instead, the status after it will be the status returned by the most recent command.
|
||||
|
|
|
@ -9,14 +9,14 @@ eval [COMMANDS...]
|
|||
|
||||
Description
|
||||
------------
|
||||
`eval` evaluates the specified parameters as a command. If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
||||
``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.
|
||||
|
||||
If your command does not need access to stdin, consider using `source` instead.
|
||||
If your command does not need access to stdin, consider using ``source`` instead.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code will call the ls command. Note that `fish` does not support the use of shell variables as direct commands; `eval` can be used to work around this.
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ exec COMMAND [OPTIONS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`exec` replaces the currently running shell with a new command. On successful completion, `exec` never returns. `exec` cannot be used inside a pipeline.
|
||||
``exec`` replaces the currently running shell with a new command. On successful completion, ``exec`` never returns. ``exec`` cannot be used inside a pipeline.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`exec emacs` starts up the emacs text editor, and exits `fish`. When emacs exits, the session will terminate.
|
||||
``exec emacs`` starts up the emacs text editor, and exits ``fish``. When emacs exits, the session will terminate.
|
||||
|
|
|
@ -10,6 +10,6 @@ exit [STATUS]
|
|||
Description
|
||||
------------
|
||||
|
||||
`exit` causes fish to exit. If `STATUS` is supplied, it will be converted to an integer and used as the exit code. Otherwise, the exit code will be that of the last command executed.
|
||||
``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 <a href="#source">source</a> builtin) the rest of the file will be skipped, but the shell itself will not exit.
|
||||
|
|
|
@ -10,4 +10,4 @@ false
|
|||
Description
|
||||
------------
|
||||
|
||||
`false` sets the exit status to 1.
|
||||
``false`` sets the exit status to 1.
|
||||
|
|
|
@ -10,10 +10,10 @@ fg [PID]
|
|||
Description
|
||||
------------
|
||||
|
||||
`fg` brings the specified <a href="index.html#syntax-job-control">job</a> to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group ID is put in the foreground.
|
||||
``fg`` brings the specified <a href="index.html#syntax-job-control">job</a> to the foreground, resuming it if it is stopped. While a foreground job is executed, fish is suspended. If no job is specified, the last job to be used is put in the foreground. If PID is specified, the job with the specified group ID is put in the foreground.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`fg` will put the last job in the foreground.
|
||||
``fg`` will put the last job in the foreground.
|
||||
|
|
|
@ -10,28 +10,28 @@ fish [OPTIONS] [-c command] [FILE [ARGUMENTS...]]
|
|||
Description
|
||||
------------
|
||||
|
||||
`fish` is a command-line shell written mainly with interactive use in mind. The full manual is available <a href='index.html'>in HTML</a> by using the <a href='#help'>help</a> command from inside fish.
|
||||
``fish`` is a command-line shell written mainly with interactive use in mind. The full manual is available <a href='index.html'>in HTML</a> by using the <a href='#help'>help</a> command from inside fish.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-c` or `--command=COMMANDS` evaluate the specified commands instead of reading from the commandline
|
||||
- ``-c`` or ``--command=COMMANDS`` evaluate the specified commands instead of reading from the commandline
|
||||
|
||||
- `-C` or `--init-command=COMMANDS` evaluate the specified commands after reading the configuration, before running the command specified by `-c` or reading interactive input
|
||||
- ``-C`` or ``--init-command=COMMANDS`` evaluate the specified commands after reading the configuration, before running the command specified by ``-c`` or reading interactive input
|
||||
|
||||
- `-d` or `--debug-level=DEBUG_LEVEL` specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
|
||||
- ``-d`` or ``--debug-level=DEBUG_LEVEL`` specify the verbosity level of fish. A higher number means higher verbosity. The default level is 1.
|
||||
|
||||
- `-i` or `--interactive` specify that fish is to run in interactive mode
|
||||
- ``-i`` or ``--interactive`` specify that fish is to run in interactive mode
|
||||
|
||||
- `-l` or `--login` specify that fish is to run as a login shell
|
||||
- ``-l`` or ``--login`` specify that fish is to run as a login shell
|
||||
|
||||
- `-n` or `--no-execute` do not execute any commands, only perform syntax checking
|
||||
- ``-n`` or ``--no-execute`` do not execute any commands, only perform syntax checking
|
||||
|
||||
- `-p` or `--profile=PROFILE_FILE` when fish exits, output timing information on all executed commands to the specified file
|
||||
- ``-p`` or ``--profile=PROFILE_FILE`` when fish exits, output timing information on all executed commands to the specified file
|
||||
|
||||
- `-v` or `--version` display version and exit
|
||||
- ``-v`` or ``--version`` display version and exit
|
||||
|
||||
- `-D` or `--debug-stack-frames=DEBUG_LEVEL` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
- ``-D`` or ``--debug-stack-frames=DEBUG_LEVEL`` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
|
||||
- `-f` or `--features=FEATURES` enables one or more feature flags (separated by a comma). These are how fish stages changes that might break scripts.
|
||||
- ``-f`` or ``--features=FEATURES`` enables one or more feature flags (separated by a comma). These are how fish stages changes that might break scripts.
|
||||
|
||||
The fish exit status is generally the exit status of the last foreground command. If fish is exiting because of a parse error, the exit status is 127.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fish_breakpoint_prompt - define the appearance of the command line prompt when in the context of a `breakpoint` command
|
||||
fish_breakpoint_prompt - define the appearance of the command line prompt when in the context of a ``breakpoint`` command
|
||||
==========================================
|
||||
|
||||
Synopsis
|
||||
|
@ -12,11 +12,11 @@ end
|
|||
Description
|
||||
------------
|
||||
|
||||
By defining the `fish_breakpoint_prompt` function, the user can choose a custom prompt when asking for input in response to a `breakpoint` command. The `fish_breakpoint_prompt` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
By defining the ``fish_breakpoint_prompt`` function, the user can choose a custom prompt when asking for input in response to a ``breakpoint`` command. The ``fish_breakpoint_prompt`` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
|
||||
The exit status of commands within `fish_breakpoint_prompt` will not modify the value of <a href="index.html#variables-status">$status</a> outside of the `fish_breakpoint_prompt` function.
|
||||
The exit status of commands within ``fish_breakpoint_prompt`` will not modify the value of <a href="index.html#variables-status">$status</a> outside of the ``fish_breakpoint_prompt`` function.
|
||||
|
||||
`fish` ships with a default version of this function that displays the function name and line number of the current execution context.
|
||||
``fish`` ships with a default version of this function that displays the function name and line number of the current execution context.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -5,18 +5,18 @@ fish_config - start the web-based configuration interface
|
|||
Description
|
||||
------------
|
||||
|
||||
`fish_config` starts the web-based configuration interface.
|
||||
``fish_config`` starts the web-based configuration interface.
|
||||
|
||||
The web interface allows you to view your functions, variables and history, and to make changes to your prompt and color configuration.
|
||||
|
||||
`fish_config` starts a local web server and then opens a web browser window; when you have finished, close the browser window and then press the Enter key to terminate the configuration session.
|
||||
``fish_config`` starts a local web server and then opens a web browser window; when you have finished, close the browser window and then press the Enter key to terminate the configuration session.
|
||||
|
||||
`fish_config` optionally accepts name of the initial configuration tab. For e.g. `fish_config history` will start configuration interface with history tab.
|
||||
``fish_config`` optionally accepts name of the initial configuration tab. For e.g. ``fish_config history`` will start configuration interface with history tab.
|
||||
|
||||
If the `BROWSER` environment variable is set, it will be used as the name of the web browser to open instead of the system default.
|
||||
If the ``BROWSER`` environment variable is set, it will be used as the name of the web browser to open instead of the system default.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`fish_config` opens a new web browser window and allows you to configure certain fish settings.
|
||||
``fish_config`` opens a new web browser window and allows you to configure certain fish settings.
|
||||
|
|
|
@ -10,22 +10,22 @@ fish_indent [OPTIONS]
|
|||
Description
|
||||
------------
|
||||
|
||||
`fish_indent` is used to indent a piece of fish code. `fish_indent` reads commands from standard input and outputs them to standard output or a specified file.
|
||||
``fish_indent`` is used to indent a piece of fish code. ``fish_indent`` reads commands from standard input and outputs them to standard output or a specified file.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-w` or `--write` indents a specified file and immediately writes to that file.
|
||||
- ``-w`` or ``--write`` indents a specified file and immediately writes to that file.
|
||||
|
||||
- `-i` or `--no-indent` do not indent commands; only reformat to one job per line.
|
||||
- ``-i`` or ``--no-indent`` do not indent commands; only reformat to one job per line.
|
||||
|
||||
- `-v` or `--version` displays the current fish version and then exits.
|
||||
- ``-v`` or ``--version`` displays the current fish version and then exits.
|
||||
|
||||
- `--ansi` colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as `$fish_color_command`).
|
||||
- ``--ansi`` colorizes the output using ANSI escape sequences, appropriate for the current $TERM, using the colors defined in the environment (such as ``$fish_color_command``).
|
||||
|
||||
- `--html` outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as `fish_color_command`.
|
||||
- ``--html`` outputs HTML, which supports syntax highlighting if the appropriate CSS is defined. The CSS class names are the same as the variable names, such as ``fish_color_command``.
|
||||
|
||||
- `-d` or `--debug-level=DEBUG_LEVEL` enables debug output and specifies a verbosity level (like `fish -d`). Defaults to 0.
|
||||
- ``-d`` or ``--debug-level=DEBUG_LEVEL`` enables debug output and specifies a verbosity level (like ``fish -d``). Defaults to 0.
|
||||
|
||||
- `-D` or `--debug-stack-frames=DEBUG_LEVEL` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
- ``-D`` or ``--debug-stack-frames=DEBUG_LEVEL`` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
|
||||
- `--dump-parse-tree` dumps information about the parsed statements to stderr. This is likely to be of interest only to people working on the fish source code.
|
||||
- ``--dump-parse-tree`` dumps information about the parsed statements to stderr. This is likely to be of interest only to people working on the fish source code.
|
||||
|
|
|
@ -10,30 +10,30 @@ fish_key_reader [OPTIONS]
|
|||
Description
|
||||
------------
|
||||
|
||||
`fish_key_reader` is used to study input received from the terminal and can help with key binds. The program is interactive and works on standard input. Individual characters themselves and their hexadecimal values are displayed.
|
||||
``fish_key_reader`` is used to study input received from the terminal and can help with key binds. The program is interactive and works on standard input. Individual characters themselves and their hexadecimal values are displayed.
|
||||
|
||||
The tool will write an example `bind` command matching the character sequence captured to stdout. If the character sequence matches a special key name (see `bind --key-names`), both `bind CHARS ...` and `bind -k KEYNAME ...` usage will be shown. Additional details about the characters received, such as the delay between chars, are written to stderr.
|
||||
The tool will write an example ``bind`` command matching the character sequence captured to stdout. If the character sequence matches a special key name (see ``bind --key-names``), both ``bind CHARS ...`` and ``bind -k KEYNAME ...`` usage will be shown. Additional details about the characters received, such as the delay between chars, are written to stderr.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-c` or `--continuous` begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence.
|
||||
- ``-c`` or ``--continuous`` begins a session where multiple key sequences can be inspected. By default the program exits after capturing a single key sequence.
|
||||
|
||||
- `-d` or `--debug-level=DEBUG_LEVEL` enables debug output and specifies a verbosity level (like `fish -d`). Defaults to 0.
|
||||
- ``-d`` or ``--debug-level=DEBUG_LEVEL`` enables debug output and specifies a verbosity level (like ``fish -d``). Defaults to 0.
|
||||
|
||||
- `-D` or `--debug-stack-frames=DEBUG_LEVEL` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
- ``-D`` or ``--debug-stack-frames=DEBUG_LEVEL`` specify how many stack frames to display when debug messages are written. The default is zero. A value of 3 or 4 is usually sufficient to gain insight into how a given debug call was reached but you can specify a value up to 128.
|
||||
|
||||
- `-h` or `--help` prints usage information.
|
||||
- ``-h`` or ``--help`` prints usage information.
|
||||
|
||||
- `-v` or `--version` prints fish_key_reader's version and exits.
|
||||
- ``-v`` or ``--version`` prints fish_key_reader's version and exits.
|
||||
|
||||
Usage Notes
|
||||
------------
|
||||
|
||||
The delay in milliseconds since the previous character was received is included in the diagnostic information written to stderr. This information may be useful to determine the optimal `fish_escape_delay_ms` setting or learn the amount of lag introduced by tools like `ssh`, `mosh` or `tmux`.
|
||||
The delay in milliseconds since the previous character was received is included in the diagnostic information written to stderr. This information may be useful to determine the optimal ``fish_escape_delay_ms`` setting or learn the amount of lag introduced by tools like ``ssh``, ``mosh`` or ``tmux``.
|
||||
|
||||
`fish_key_reader` intentionally disables handling of many signals. To terminate `fish_key_reader` in `--continuous` mode do:
|
||||
``fish_key_reader`` intentionally disables handling of many signals. To terminate ``fish_key_reader`` in ``--continuous`` mode do:
|
||||
|
||||
- press `Ctrl-C` twice, or
|
||||
- press `Ctrl-D` twice, or
|
||||
- type `exit`, or
|
||||
- type `quit`
|
||||
- press ``Ctrl-C`` twice, or
|
||||
- press ``Ctrl-D`` twice, or
|
||||
- type ``exit``, or
|
||||
- type ``quit``
|
||||
|
|
|
@ -8,8 +8,8 @@ The fish_mode_prompt function will output the mode indicator for use in vi-mode.
|
|||
Description
|
||||
------------
|
||||
|
||||
The default `fish_mode_prompt` function will output indicators about the current Vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. You can also define an empty `fish_mode_prompt` function to remove the Vi mode indicators. The `$fish_bind_mode variable` can be used to determine the current mode. It
|
||||
will be one of `default`, `insert`, `replace_one`, or `visual`.
|
||||
The default ``fish_mode_prompt`` function will output indicators about the current Vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. You can also define an empty ``fish_mode_prompt`` function to remove the Vi mode indicators. The ``$fish_bind_mode variable`` can be used to determine the current mode. It
|
||||
will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -40,4 +40,4 @@ Example
|
|||
end
|
||||
|
||||
|
||||
Outputting multiple lines is not supported in `fish_mode_prompt`.
|
||||
Outputting multiple lines is not supported in ``fish_mode_prompt``.
|
||||
|
|
|
@ -12,23 +12,23 @@ fish_opt ( -s X | --short=X ) [ -l LONG | --long=LONG ] [ --long-only ] \
|
|||
Description
|
||||
------------
|
||||
|
||||
This command provides a way to produce option specifications suitable for use with the <a href="#argparse">`argparse`</a> command. You can, of course, write the option specs by hand without using this command. But you might prefer to use this for the clarity it provides.
|
||||
This command provides a way to produce option specifications suitable for use with the <a href="#argparse">``argparse``</a> command. You can, of course, write the option specs by hand without using this command. But you might prefer to use this for the clarity it provides.
|
||||
|
||||
The following `argparse` options are available:
|
||||
The following ``argparse`` options are available:
|
||||
|
||||
- `-s` or `--short` takes a single letter that is used as the short flag in the option being defined. This option is mandatory.
|
||||
- ``-s`` or ``--short`` takes a single letter that is used as the short flag in the option being defined. This option is mandatory.
|
||||
|
||||
- `-l` or `--long` takes a string that is used as the long flag in the option being defined. This option is optional and has no default. If no long flag is defined then only the short flag will be allowed when parsing arguments using the option spec.
|
||||
- ``-l`` or ``--long`` takes a string that is used as the long flag in the option being defined. This option is optional and has no default. If no long flag is defined then only the short flag will be allowed when parsing arguments using the option spec.
|
||||
|
||||
- `--long-only` means the option spec being defined will only allow the long flag name to be used. The short flag name must still be defined (i.e., `--short` must be specified) but it cannot be used when parsing args using this option spec.
|
||||
- ``--long-only`` means the option spec being defined will only allow the long flag name to be used. The short flag name must still be defined (i.e., ``--short`` must be specified) but it cannot be used when parsing args using this option spec.
|
||||
|
||||
- `-o` or `--optional` means the option being defined can take a value but it is optional rather than required. If the option is seen more than once when parsing arguments only the last value seen is saved. This means the resulting flag variable created by `argparse` will zero elements if no value was given with the option else it will have exactly one element.
|
||||
- ``-o`` or ``--optional`` means the option being defined can take a value but it is optional rather than required. If the option is seen more than once when parsing arguments only the last value seen is saved. This means the resulting flag variable created by ``argparse`` will zero elements if no value was given with the option else it will have exactly one element.
|
||||
|
||||
- `-r` or `--required` means the option being defined requires a value. If the option is seen more than once when parsing arguments only the last value seen is saved. This means the resulting flag variable created by `argparse` will have exactly one element.
|
||||
- ``-r`` or ``--required`` means the option being defined requires a value. If the option is seen more than once when parsing arguments only the last value seen is saved. This means the resulting flag variable created by ``argparse`` will have exactly one element.
|
||||
|
||||
- `--multiple-vals` means the option being defined requires a value each time it is seen. Each instance is stored. This means the resulting flag variable created by `argparse` will have one element for each instance of this option in the args.
|
||||
- ``--multiple-vals`` means the option being defined requires a value each time it is seen. Each instance is stored. This means the resulting flag variable created by ``argparse`` will have one element for each instance of this option in the args.
|
||||
|
||||
- `-h` or `--help` displays help about using this command.
|
||||
- ``-h`` or ``--help`` displays help about using this command.
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
@ -54,7 +54,7 @@ Same as above but with a second flag that requires a value:
|
|||
argparse $options -- $argv
|
||||
|
||||
|
||||
Same as above but with a third flag that can be given multiple times saving the value of each instance seen and only the long flag name (`--token`) can be used:
|
||||
Same as above but with a third flag that can be given multiple times saving the value of each instance seen and only the long flag name (``--token``) can be used:
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ end
|
|||
Description
|
||||
------------
|
||||
|
||||
By defining the `fish_prompt` function, the user can choose a custom prompt. The `fish_prompt` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
By defining the ``fish_prompt`` function, the user can choose a custom prompt. The ``fish_prompt`` function is executed when the prompt is to be shown, and the output is used as a prompt.
|
||||
|
||||
The exit status of commands within `fish_prompt` will not modify the value of <a href="index.html#variables-status">$status</a> outside of the `fish_prompt` function.
|
||||
The exit status of commands within ``fish_prompt`` will not modify the value of <a href="index.html#variables-status">$status</a> outside of the ``fish_prompt`` function.
|
||||
|
||||
`fish` ships with a number of example prompts that can be chosen with the `fish_config` command.
|
||||
``fish`` ships with a number of example prompts that can be chosen with the ``fish_config`` command.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -12,9 +12,9 @@ end
|
|||
Description
|
||||
------------
|
||||
|
||||
`fish_right_prompt` is similar to `fish_prompt`, except that it appears on the right side of the terminal window.
|
||||
``fish_right_prompt`` is similar to ``fish_prompt``, except that it appears on the right side of the terminal window.
|
||||
|
||||
Multiple lines are not supported in `fish_right_prompt`.
|
||||
Multiple lines are not supported in ``fish_right_prompt``.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -5,8 +5,8 @@ fish_update_completions - Update completions using manual pages
|
|||
Description
|
||||
------------
|
||||
|
||||
`fish_update_completions` parses manual pages installed on the system, and attempts to create completion files in the `fish` configuration directory.
|
||||
``fish_update_completions`` parses manual pages installed on the system, and attempts to create completion files in the ``fish`` configuration directory.
|
||||
|
||||
This does not overwrite custom completions.
|
||||
|
||||
There are no parameters for `fish_update_completions`.
|
||||
There are no parameters for ``fish_update_completions``.
|
||||
|
|
|
@ -10,6 +10,6 @@ fish_vi_mode
|
|||
Description
|
||||
------------
|
||||
|
||||
This function is deprecated. Please call `fish_vi_key_bindings directly`
|
||||
This function is deprecated. Please call ``fish_vi_key_bindings directly``
|
||||
|
||||
`fish_vi_mode` enters a vi-like command editing mode. To always start in vi mode, add `fish_vi_mode` to your `config.fish` file.
|
||||
``fish_vi_mode`` enters a vi-like command editing mode. To always start in vi mode, add ``fish_vi_mode`` to your ``config.fish`` file.
|
||||
|
|
|
@ -10,7 +10,7 @@ for VARNAME in [VALUES...]; COMMANDS...; end
|
|||
Description
|
||||
------------
|
||||
|
||||
`for` is a loop construct. It will perform the commands specified by `COMMANDS` multiple times. On each iteration, the local variable specified by `VARNAME` is assigned a new value from `VALUES`. If `VALUES` is empty, `COMMANDS` will not be executed at all. The `VARNAME` is visible when the loop terminates and will contain the last value assigned to it. If `VARNAME` does not already exist it will be set in the local scope. For our purposes if the `for` block is inside a function there must be a local variable with the same name. If the `for` block is not nested inside a function then global and universal variables of the same name will be used if they exist.
|
||||
``for`` is a loop construct. It will perform the commands specified by ``COMMANDS`` multiple times. On each iteration, the local variable specified by ``VARNAME`` is assigned a new value from ``VALUES``. If ``VALUES`` is empty, ``COMMANDS`` will not be executed at all. The ``VARNAME`` is visible when the loop terminates and will contain the last value assigned to it. If ``VARNAME`` does not already exist it will be set in the local scope. For our purposes if the ``for`` block is inside a function there must be a local variable with the same name. If the ``for`` block is not nested inside a function then global and universal variables of the same name will be used if they exist.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -30,7 +30,7 @@ Example
|
|||
Notes
|
||||
------------
|
||||
|
||||
The `VARNAME` was local to the for block in releases prior to 3.0.0. This means that if you did something like this:
|
||||
The ``VARNAME`` was local to the for block in releases prior to 3.0.0. This means that if you did something like this:
|
||||
|
||||
|
||||
|
||||
|
@ -44,4 +44,4 @@ The `VARNAME` was local to the for block in releases prior to 3.0.0. This means
|
|||
echo $var
|
||||
|
||||
|
||||
The last value assigned to `var` when the loop terminated would not be available outside the loop. What `echo $var` would write depended on what it was set to before the loop was run. Likely nothing.
|
||||
The last value assigned to ``var`` when the loop terminated would not be available outside the loop. What ``echo $var`` would write depended on what it was set to before the loop was run. Likely nothing.
|
||||
|
|
|
@ -10,14 +10,14 @@ funced [OPTIONS] NAME
|
|||
Description
|
||||
------------
|
||||
|
||||
`funced` provides an interface to edit the definition of the function `NAME`.
|
||||
``funced`` provides an interface to edit the definition of the function ``NAME``.
|
||||
|
||||
If the `$VISUAL` environment variable is set, it will be used as the program to edit the function. If `$VISUAL` is unset but `$EDITOR` is set, that will be used. Otherwise, a built-in editor will be used. Note that to enter a literal newline using the built-in editor you should press @key{Alt,Enter}. Pressing @key{Enter} signals that you are done editing the function. This does not apply to an external editor like emacs or vim.
|
||||
If the ``$VISUAL`` environment variable is set, it will be used as the program to edit the function. If ``$VISUAL`` is unset but ``$EDITOR`` is set, that will be used. Otherwise, a built-in editor will be used. Note that to enter a literal newline using the built-in editor you should press @key{Alt,Enter}. Pressing @key{Enter} signals that you are done editing the function. This does not apply to an external editor like emacs or vim.
|
||||
|
||||
If there is no function called `NAME` a new function will be created with the specified name
|
||||
If there is no function called ``NAME`` a new function will be created with the specified name
|
||||
|
||||
- `-e command` or `--editor command` Open the function body inside the text editor given by the command (for example, `-e vi`). The special command `fish` will use the built-in editor (same as specifying `-i`).
|
||||
- ``-e command`` or ``--editor command`` Open the function body inside the text editor given by the command (for example, ``-e vi``). The special command ``fish`` will use the built-in editor (same as specifying ``-i``).
|
||||
|
||||
- `-i` or `--interactive` Force opening the function body in the built-in editor even if `$VISUAL` or `$EDITOR` is defined.
|
||||
- ``-i`` or ``--interactive`` Force opening the function body in the built-in editor even if ``$VISUAL`` or ``$EDITOR`` is defined.
|
||||
|
||||
- `-s` or `--save` Automatically save the function after successfully editing it.
|
||||
- ``-s`` or ``--save`` Automatically save the function after successfully editing it.
|
||||
|
|
|
@ -10,6 +10,6 @@ funcsave FUNCTION_NAME
|
|||
Description
|
||||
------------
|
||||
|
||||
`funcsave` saves the current definition of a function to a file in the fish configuration directory. This function will be automatically loaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.
|
||||
``funcsave`` saves the current definition of a function to a file in the fish configuration directory. This function will be automatically loaded by current and future fish sessions. This can be useful if you have interactively created a new function and wish to save it for later use.
|
||||
|
||||
Note that because fish loads functions on-demand, saved functions will not function as <a href="index.html#event">event handlers</a> until they are run or sourced otherwise. To activate an event handler for every new shell, add the function to your <a href="index.html#initialization">shell initialization file</a> instead of using `funcsave`.
|
||||
Note that because fish loads functions on-demand, saved functions will not function as <a href="index.html#event">event handlers</a> until they are run or sourced otherwise. To activate an event handler for every new shell, add the function to your <a href="index.html#initialization">shell initialization file</a> instead of using ``funcsave``.
|
||||
|
|
|
@ -10,52 +10,52 @@ function NAME [OPTIONS]; BODY; end
|
|||
Description
|
||||
------------
|
||||
|
||||
`function` creates a new function `NAME` with the body `BODY`.
|
||||
``function`` creates a new function ``NAME`` with the body ``BODY``.
|
||||
|
||||
A function is a list of commands that will be executed when the name of the function is given as a command.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a NAMES` or `--argument-names NAMES` assigns the value of successive command-line arguments to the names given in NAMES.
|
||||
- ``-a NAMES`` or ``--argument-names NAMES`` assigns the value of successive command-line arguments to the names given in NAMES.
|
||||
|
||||
- `-d DESCRIPTION` or `--description=DESCRIPTION` is a description of what the function does, suitable as a completion description.
|
||||
- ``-d DESCRIPTION`` or ``--description=DESCRIPTION`` is a description of what the function does, suitable as a completion description.
|
||||
|
||||
- `-w WRAPPED_COMMAND` or `--wraps=WRAPPED_COMMAND` causes the function to inherit completions from the given wrapped command. See the documentation for <a href="#complete">`complete`</a> for more information.
|
||||
- ``-w WRAPPED_COMMAND`` or ``--wraps=WRAPPED_COMMAND`` causes the function to inherit completions from the given wrapped command. See the documentation for <a href="#complete">``complete``</a> for more information.
|
||||
|
||||
- `-e` or `--on-event EVENT_NAME` tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
|
||||
- ``-e`` or ``--on-event EVENT_NAME`` tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt.
|
||||
|
||||
- `-v` or `--on-variable VARIABLE_NAME` tells fish to run this function when the variable VARIABLE_NAME changes value.
|
||||
- ``-v`` or ``--on-variable VARIABLE_NAME`` tells fish to run this function when the variable VARIABLE_NAME changes value.
|
||||
|
||||
- `-j PGID` or `--on-job-exit PGID` tells fish to run this function when the job with group ID PGID exits. Instead of PGID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
|
||||
- ``-j PGID`` or ``--on-job-exit PGID`` tells fish to run this function when the job with group ID PGID exits. Instead of PGID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution.
|
||||
|
||||
- `-p PID` or `--on-process-exit PID` tells fish to run this function when the fish child process
|
||||
- ``-p PID`` or ``--on-process-exit PID`` tells fish to run this function when the fish child process
|
||||
with process ID PID exits. Instead of a PID, for backward compatibility,
|
||||
"`%self`" can be specified as an alias for `$fish_pid`, and the function will be run when the
|
||||
"``%self``" can be specified as an alias for ``$fish_pid``, and the function will be run when the
|
||||
current fish instance exits.
|
||||
|
||||
- `-s` or `--on-signal SIGSPEC` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
|
||||
- ``-s`` or ``--on-signal SIGSPEC`` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
|
||||
|
||||
- `-S` or `--no-scope-shadowing` allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents is independent of the calling function.
|
||||
- ``-S`` or ``--no-scope-shadowing`` allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents is independent of the calling function.
|
||||
|
||||
- `-V` or `--inherit-variable NAME` snapshots the value of the variable `NAME` and defines a local variable with that same name and value when the function is defined. This is similar to a closure in other languages like Python but a bit different. Note the word "snapshot" in the first sentence. If you change the value of the variable after defining the function, even if you do so in the same scope (typically another function) the new value will not be used by the function you just created using this option. See the `function notify` example below for how this might be used.
|
||||
- ``-V`` or ``--inherit-variable NAME`` snapshots the value of the variable ``NAME`` and defines a local variable with that same name and value when the function is defined. This is similar to a closure in other languages like Python but a bit different. Note the word "snapshot" in the first sentence. If you change the value of the variable after defining the function, even if you do so in the same scope (typically another function) the new value will not be used by the function you just created using this option. See the ``function notify`` example below for how this might be used.
|
||||
|
||||
If the user enters any additional arguments after the function, they are inserted into the environment <a href="index.html#variables-arrays">variable array</a> `$argv`. If the `--argument-names` option is provided, the arguments are also assigned to names specified in that option.
|
||||
If the user enters any additional arguments after the function, they are inserted into the environment <a href="index.html#variables-arrays">variable array</a> ``$argv``. If the ``--argument-names`` option is provided, the arguments are also assigned to names specified in that option.
|
||||
|
||||
By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the <a href="#emit">emit</a> builtin. Fish generates the following named events:
|
||||
|
||||
- `fish_prompt`, which is emitted whenever a new fish prompt is about to be displayed.
|
||||
- ``fish_prompt``, which is emitted whenever a new fish prompt is about to be displayed.
|
||||
|
||||
- `fish_command_not_found`, which is emitted whenever a command lookup failed.
|
||||
- ``fish_command_not_found``, which is emitted whenever a command lookup failed.
|
||||
|
||||
- `fish_preexec`, which is emitted right before executing an interactive command. The commandline is passed as the first parameter.
|
||||
- ``fish_preexec``, which is emitted right before executing an interactive command. The commandline is passed as the first parameter.
|
||||
|
||||
Note: This event will be emitted even if the command is invalid. The commandline parameter includes the entire commandline verbatim, and may potentially include newlines.
|
||||
|
||||
- `fish_postexec`, which is emitted right after executing an interactive command. The commandline is passed as the first parameter.
|
||||
- ``fish_postexec``, which is emitted right after executing an interactive command. The commandline is passed as the first parameter.
|
||||
|
||||
Note: This event will be emitted even if the command is invalid. The commandline parameter includes the entire commandline verbatim, and may potentially include newlines.
|
||||
|
||||
- `fish_exit` is emitted right before fish exits.
|
||||
- ``fish_exit`` is emitted right before fish exits.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -69,7 +69,7 @@ Example
|
|||
end
|
||||
|
||||
|
||||
will run the `ls` command, using the `-l` option, while passing on any additional files and switches to `ls`.
|
||||
will run the ``ls`` command, using the ``-l`` option, while passing on any additional files and switches to ``ls``.
|
||||
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ will run the `ls` command, using the `-l` option, while passing on any additiona
|
|||
end
|
||||
|
||||
|
||||
This will run the `mkdir` command, and if it is successful, change the current working directory to the one just created.
|
||||
This will run the ``mkdir`` command, and if it is successful, change the current working directory to the one just created.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -14,49 +14,49 @@ functions [ -e | -q ] FUNCTIONS...
|
|||
Description
|
||||
------------
|
||||
|
||||
`functions` prints or erases functions.
|
||||
``functions`` prints or erases functions.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a` or `--all` lists all functions, even those whose name starts with an underscore.
|
||||
- ``-a`` or ``--all`` lists all functions, even those whose name starts with an underscore.
|
||||
|
||||
- `-c OLDNAME NEWNAME` or `--copy OLDNAME NEWNAME` creates a new function named NEWNAME, using the definition of the OLDNAME function.
|
||||
- ``-c OLDNAME NEWNAME`` or ``--copy OLDNAME NEWNAME`` creates a new function named NEWNAME, using the definition of the OLDNAME function.
|
||||
|
||||
- `-d DESCRIPTION` or `--description=DESCRIPTION` changes the description of this function.
|
||||
- ``-d DESCRIPTION`` or ``--description=DESCRIPTION`` changes the description of this function.
|
||||
|
||||
- `-e` or `--erase` causes the specified functions to be erased.
|
||||
- ``-e`` or ``--erase`` causes the specified functions to be erased.
|
||||
|
||||
- `-D` or `--details` reports the path name where each function is defined or could be autoloaded, `stdin` if the function was defined interactively or on the command line or by reading stdin, and `n/a` if the function isn't available. If the `--verbose` option is also specified then five lines are written:
|
||||
- ``-D`` or ``--details`` reports the path name where each function is defined or could be autoloaded, ``stdin`` if the function was defined interactively or on the command line or by reading stdin, and ``n/a`` if the function isn't available. If the ``--verbose`` option is also specified then five lines are written:
|
||||
|
||||
-# the pathname as already described,
|
||||
-# `autoloaded`, `not-autoloaded` or `n/a`,
|
||||
-# ``autoloaded``, ``not-autoloaded`` or ``n/a``,
|
||||
-# the line number within the file or zero if not applicable,
|
||||
-# `scope-shadowing` if the function shadows the vars in the calling function (the normal case if it wasn't defined with `--no-scope-shadowing`), else `no-scope-shadowing`, or `n/a` if the function isn't defined,
|
||||
-# the function description minimally escaped so it is a single line or `n/a` if the function isn't defined.
|
||||
-# ``scope-shadowing`` if the function shadows the vars in the calling function (the normal case if it wasn't defined with ``--no-scope-shadowing``), else ``no-scope-shadowing``, or ``n/a`` if the function isn't defined,
|
||||
-# the function description minimally escaped so it is a single line or ``n/a`` if the function isn't defined.
|
||||
|
||||
You should not assume that only five lines will be written since we may add additional information to the output in the future.
|
||||
|
||||
- `-n` or `--names` lists the names of all defined functions.
|
||||
- ``-n`` or ``--names`` lists the names of all defined functions.
|
||||
|
||||
- `-q` or `--query` tests if the specified functions exist.
|
||||
- ``-q`` or ``--query`` tests if the specified functions exist.
|
||||
|
||||
- `-v` or `--verbose` will make some output more verbose.
|
||||
- ``-v`` or ``--verbose`` will make some output more verbose.
|
||||
|
||||
- `-H` or `--handlers` will show all event handlers.
|
||||
- ``-H`` or ``--handlers`` will show all event handlers.
|
||||
|
||||
- `-t` or `--handlers-type TYPE` will show all event handlers matching the given type
|
||||
- ``-t`` or ``--handlers-type TYPE`` will show all event handlers matching the given type
|
||||
|
||||
The default behavior of `functions`, when called with no arguments, is to print the names of all defined functions. Unless the `-a` option is given, no functions starting with underscores are not included in the output.
|
||||
The default behavior of ``functions``, when called with no arguments, is to print the names of all defined functions. Unless the ``-a`` option is given, no functions starting with underscores are not included in the output.
|
||||
|
||||
If any non-option parameters are given, the definition of the specified functions are printed.
|
||||
|
||||
Automatically loaded functions cannot be removed using `functions -e`. Either remove the definition file or change the $fish_function_path variable to remove autoloaded functions.
|
||||
Automatically loaded functions cannot be removed using ``functions -e``. Either remove the definition file or change the $fish_function_path variable to remove autoloaded functions.
|
||||
|
||||
Copying a function using `-c` copies only the body of the function, and does not attach any event notifications from the original function.
|
||||
Copying a function using ``-c`` copies only the body of the function, and does not attach any event notifications from the original function.
|
||||
|
||||
Only one function's description can be changed in a single invocation of `functions -d`.
|
||||
Only one function's description can be changed in a single invocation of ``functions -d``.
|
||||
|
||||
The exit status of `functions` is the number of functions specified in the argument list that do not exist, which can be used in concert with the `-q` option.
|
||||
The exit status of ``functions`` is the number of functions specified in the argument list that do not exist, which can be used in concert with the ``-q`` option.
|
||||
|
||||
|
||||
Examples
|
||||
|
@ -72,5 +72,5 @@ Examples
|
|||
# Copies the 'foo' function to a new function called 'bar'
|
||||
|
||||
functions -e bar
|
||||
# Erases the function `bar`
|
||||
# Erases the function ``bar``
|
||||
|
||||
|
|
|
@ -10,18 +10,18 @@ help [SECTION]
|
|||
Description
|
||||
------------
|
||||
|
||||
`help` displays the fish help documentation.
|
||||
``help`` displays the fish help documentation.
|
||||
|
||||
If a `SECTION` is specified, the help for that command is shown.
|
||||
If a ``SECTION`` is specified, the help for that command is shown.
|
||||
|
||||
If the BROWSER environment variable is set, it will be used to display the documentation. Otherwise, fish will search for a suitable browser.
|
||||
|
||||
If you prefer to use a different browser (other than as described above) for fish help, you can set the fish_help_browser variable. This variable may be set as an array, where the first element is the browser command and the rest are browser options.
|
||||
|
||||
Note that most builtin commands display their help in the terminal when given the `--help` option.
|
||||
Note that most builtin commands display their help in the terminal when given the ``--help`` option.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`help fg` shows the documentation for the `fg` builtin.
|
||||
``help fg`` shows the documentation for the ``fg`` builtin.
|
||||
|
|
|
@ -15,41 +15,41 @@ history ( -h | --help )
|
|||
Description
|
||||
------------
|
||||
|
||||
`history` is used to search, delete, and otherwise manipulate the history of interactive commands.
|
||||
``history`` is used to search, delete, and otherwise manipulate the history of interactive commands.
|
||||
|
||||
The following operations (sub-commands) are available:
|
||||
|
||||
- `search` returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say `history search` if you wish to search for one of the subcommands. The `--contains` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest unless you use the `--reverse` flag. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin simply writes the results to stdout.
|
||||
- ``search`` returns history items matching the search string. If no search string is provided it returns all history items. This is the default operation if no other operation is specified. You only have to explicitly say ``history search`` if you wish to search for one of the subcommands. The ``--contains`` search option will be used if you don't specify a different search option. Entries are ordered newest to oldest unless you use the ``--reverse`` flag. If stdout is attached to a tty the output will be piped through your pager by the history function. The history builtin simply writes the results to stdout.
|
||||
|
||||
- `delete` deletes history items. Without the `--prefix` or `--contains` options, the exact match of the specified text will be deleted. If you don't specify `--exact` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID separated by a space to delete multiple entries. Just press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports `--exact --case-sensitive` deletion.
|
||||
- ``delete`` deletes history items. Without the ``--prefix`` or ``--contains`` options, the exact match of the specified text will be deleted. If you don't specify ``--exact`` a prompt will be displayed before any items are deleted asking you which entries are to be deleted. You can enter the word "all" to delete all matching entries. You can enter a single ID (the number in square brackets) to delete just that single entry. You can enter more than one ID separated by a space to delete multiple entries. Just press [enter] to not delete anything. Note that the interactive delete behavior is a feature of the history function. The history builtin only supports ``--exact --case-sensitive`` deletion.
|
||||
|
||||
- `merge` immediately incorporates history changes from other sessions. Ordinarily `fish` ignores history changes from sessions started after the current one. This command applies those changes immediately.
|
||||
- ``merge`` immediately incorporates history changes from other sessions. Ordinarily ``fish`` ignores history changes from sessions started after the current one. This command applies those changes immediately.
|
||||
|
||||
- `save` immediately writes all changes to the history file. The shell automatically saves the history file; this option is provided for internal use and should not normally need to be used by the user.
|
||||
- ``save`` immediately writes all changes to the history file. The shell automatically saves the history file; this option is provided for internal use and should not normally need to be used by the user.
|
||||
|
||||
- `clear` clears the history file. A prompt is displayed before the history is erased asking you to confirm you really want to clear all history unless `builtin history` is used.
|
||||
- ``clear`` clears the history file. A prompt is displayed before the history is erased asking you to confirm you really want to clear all history unless ``builtin history`` is used.
|
||||
|
||||
The following options are available:
|
||||
|
||||
These flags can appear before or immediately after one of the sub-commands listed above.
|
||||
|
||||
- `-C` or `--case-sensitive` does a case-sensitive search. The default is case-insensitive. Note that prior to fish 2.4.0 the default was case-sensitive.
|
||||
- ``-C`` or ``--case-sensitive`` does a case-sensitive search. The default is case-insensitive. Note that prior to fish 2.4.0 the default was case-sensitive.
|
||||
|
||||
- `-c` or `--contains` searches or deletes items in the history that contain the specified text string. This is the default for the `--search` flag. This is not currently supported by the `delete` subcommand.
|
||||
- ``-c`` or ``--contains`` searches or deletes items in the history that contain the specified text string. This is the default for the ``--search`` flag. This is not currently supported by the ``delete`` subcommand.
|
||||
|
||||
- `-e` or `--exact` searches or deletes items in the history that exactly match the specified text string. This is the default for the `delete` subcommand. Note that the match is case-insensitive by default. If you really want an exact match, including letter case, you must use the `-C` or `--case-sensitive` flag.
|
||||
- ``-e`` or ``--exact`` searches or deletes items in the history that exactly match the specified text string. This is the default for the ``delete`` subcommand. Note that the match is case-insensitive by default. If you really want an exact match, including letter case, you must use the ``-C`` or ``--case-sensitive`` flag.
|
||||
|
||||
- `-p` or `--prefix` searches or deletes items in the history that begin with the specified text string. This is not currently supported by the `--delete` flag.
|
||||
- ``-p`` or ``--prefix`` searches or deletes items in the history that begin with the specified text string. This is not currently supported by the ``--delete`` flag.
|
||||
|
||||
- `-t` or `--show-time` prepends each history entry with the date and time the entry was recorded. By default it uses the strftime format `# %c%n`. You can specify another format; e.g., `--show-time="%Y-%m-%d %H:%M:%S "` or `--show-time="%a%I%p"`. The short option, `-t`, doesn't accept a strftime format string; it only uses the default format. Any strftime format is allowed, including `%s` to get the raw UNIX seconds since the epoch.
|
||||
- ``-t`` or ``--show-time`` prepends each history entry with the date and time the entry was recorded. By default it uses the strftime format ``# %c%n``. You can specify another format; e.g., ``--show-time="%Y-%m-%d %H:%M:%S "`` or ``--show-time="%a%I%p"``. The short option, ``-t``, doesn't accept a strftime format string; it only uses the default format. Any strftime format is allowed, including ``%s`` to get the raw UNIX seconds since the epoch.
|
||||
|
||||
- `-z` or `--null` causes history entries written by the search operations to be terminated by a NUL character rather than a newline. This allows the output to be processed by `read -z` to correctly handle multiline history entries.
|
||||
- ``-z`` or ``--null`` causes history entries written by the search operations to be terminated by a NUL character rather than a newline. This allows the output to be processed by ``read -z`` to correctly handle multiline history entries.
|
||||
|
||||
- `-<number>` `-n <number>` or `--max=<number>` limits the matched history items to the first "n" matching entries. This is only valid for `history search`.
|
||||
- ``-<number>`` ``-n <number>`` or ``--max=<number>`` limits the matched history items to the first "n" matching entries. This is only valid for ``history search``.
|
||||
|
||||
- `-R` or `--reverse` causes the history search results to be ordered oldest to newest. Which is the order used by most shells. The default is newest to oldest.
|
||||
- ``-R`` or ``--reverse`` causes the history search results to be ordered oldest to newest. Which is the order used by most shells. The default is newest to oldest.
|
||||
|
||||
- `-h` or `--help` display help for this command.
|
||||
- ``-h`` or ``--help`` display help for this command.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -72,17 +72,17 @@ Example
|
|||
Customizing the name of the history file
|
||||
------------
|
||||
|
||||
By default interactive commands are logged to `$XDG_DATA_HOME/fish/fish_history` (typically `~/.local/share/fish/fish_history`).
|
||||
By default interactive commands are logged to ``$XDG_DATA_HOME/fish/fish_history`` (typically ``~/.local/share/fish/fish_history``).
|
||||
|
||||
You can set the `fish_history` variable to another name for the current shell session. The default value (when the variable is unset) is `fish` which corresponds to `$XDG_DATA_HOME/fish/fish_history`. If you set it to e.g. `fun`, the history would be written to `$XDG_DATA_HOME/fish/fun_history`. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
|
||||
You can set the ``fish_history`` variable to another name for the current shell session. The default value (when the variable is unset) is ``fish`` which corresponds to ``$XDG_DATA_HOME/fish/fish_history``. If you set it to e.g. ``fun``, the history would be written to ``$XDG_DATA_HOME/fish/fun_history``. An empty string means history will not be stored at all. This is similar to the private session features in web browsers.
|
||||
|
||||
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"`).
|
||||
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
|
||||
------------
|
||||
|
||||
If you specify both `--prefix` and `--contains` the last flag seen is used.
|
||||
If you specify both ``--prefix`` and ``--contains`` the last flag seen is used.
|
||||
|
||||
Note that for backwards compatibility each subcommand can also be specified as a long option. For example, rather than `history search` you can type `history --search`. Those long options are deprecated and will be removed in a future release.
|
||||
Note that for backwards compatibility each subcommand can also be specified as a long option. For example, rather than ``history search`` you can type ``history --search``. Those long options are deprecated and will be removed in a future release.
|
||||
|
|
|
@ -13,16 +13,16 @@ end
|
|||
Description
|
||||
------------
|
||||
|
||||
`if` will execute the command `CONDITION`. If the condition's exit status is 0, the commands `COMMANDS_TRUE` will execute. If the exit status 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 the exit status is not 0 and ``else`` is given, ``COMMANDS_FALSE`` will be executed.
|
||||
|
||||
You can use <a href="#and">`and`</a> or <a href="#or">`or`</a> in the condition. See the second example below.
|
||||
You can use <a href="#and">``and``</a> or <a href="#or">``or``</a> in the condition. See the second example below.
|
||||
|
||||
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code will print `foo.txt exists` if the file foo.txt exists and is a regular file, otherwise it will print `bar.txt exists` if the file bar.txt exists and is a regular file, otherwise it will print `foo.txt and bar.txt do not exist`.
|
||||
The following code will print ``foo.txt exists`` if the file foo.txt exists and is a regular file, otherwise it will print ``bar.txt exists`` if the file bar.txt exists and is a regular file, otherwise it will print ``foo.txt and bar.txt do not exist``.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ isatty [FILE DESCRIPTOR]
|
|||
Description
|
||||
------------
|
||||
|
||||
`isatty` tests if a file descriptor is a tty.
|
||||
``isatty`` tests if a file descriptor is a tty.
|
||||
|
||||
`FILE DESCRIPTOR` may be either the number of a file descriptor, or one of the strings `stdin`, `stdout`, or `stderr`.
|
||||
``FILE DESCRIPTOR`` may be either the number of a file descriptor, or one of the strings ``stdin``, ``stdout``, or ``stderr``.
|
||||
|
||||
If the specified file descriptor is a tty, the exit status of the command is zero. Otherwise, the exit status is non-zero. No messages are printed to standard error.
|
||||
|
||||
|
|
|
@ -10,23 +10,23 @@ jobs [OPTIONS] [PID]
|
|||
Description
|
||||
------------
|
||||
|
||||
`jobs` prints a list of the currently running <a href="index.html#syntax-job-control">jobs</a> and their status.
|
||||
``jobs`` prints a list of the currently running <a href="index.html#syntax-job-control">jobs</a> and their status.
|
||||
|
||||
jobs accepts the following switches:
|
||||
|
||||
- `-c` or `--command` prints the command name for each process in jobs.
|
||||
- ``-c`` or ``--command`` prints the command name for each process in jobs.
|
||||
|
||||
- `-g` or `--group` only prints the group ID of each job.
|
||||
- ``-g`` or ``--group`` only prints the group ID of each job.
|
||||
|
||||
- `-l` or `--last` prints only the last job to be started.
|
||||
- ``-l`` or ``--last`` prints only the last job to be started.
|
||||
|
||||
- `-p` or `--pid` prints the process ID for each process in all jobs.
|
||||
- ``-p`` or ``--pid`` prints the process ID for each process in all jobs.
|
||||
|
||||
- `-q` or `--quiet` prints no output for evaluation of jobs by exit code only.
|
||||
- ``-q`` or ``--quiet`` prints no output for evaluation of jobs by exit code only.
|
||||
|
||||
On systems that supports this feature, jobs will print the CPU usage of each job since the last command was executed. The CPU usage is expressed as a percentage of full CPU activity. Note that on multiprocessor systems, the total activity may be more than 100\%.
|
||||
|
||||
The exit code of the `jobs` builtin is `0` if there are running background jobs and `1` otherwise.
|
||||
The exit code of the ``jobs`` builtin is ``0`` if there are running background jobs and ``1`` otherwise.
|
||||
|
||||
no output.
|
||||
------------
|
||||
|
@ -35,4 +35,4 @@ no output.
|
|||
Example
|
||||
------------
|
||||
|
||||
`jobs` outputs a summary of the current jobs.
|
||||
``jobs`` outputs a summary of the current jobs.
|
||||
|
|
|
@ -10,105 +10,105 @@ math [-sN | --scale=N] [--] EXPRESSION
|
|||
Description
|
||||
------------
|
||||
|
||||
`math` is used to perform mathematical calculations. It supports all the usual operations such as addition, subtraction, etc. As well as functions like `abs()`, `sqrt()` and `log2()`.
|
||||
``math`` is used to perform mathematical calculations. It supports all the usual operations such as addition, subtraction, etc. As well as functions like ``abs()``, ``sqrt()`` and ``log2()``.
|
||||
|
||||
By default, the output is as a float with trailing zeroes trimmed. To get a fixed representation, the `--scale` option can be used, including `--scale=0` for integer output.
|
||||
By default, the output is as a float with trailing zeroes trimmed. To get a fixed representation, the ``--scale`` option can be used, including ``--scale=0`` for integer output.
|
||||
|
||||
Keep in mind that parameter expansion takes before expressions are evaluated. This can be very useful in order to perform calculations involving shell variables or the output of command substitutions, but it also means that parenthesis and the asterisk glob character have to be escaped or quoted.
|
||||
|
||||
`math` ignores whitespace between arguments and takes its input as multiple arguments (internally joined with a space), so `math 2 +2` and `math "2 + 2"` work the same. `math 2 2` is an error.
|
||||
``math`` ignores whitespace between arguments and takes its input as multiple arguments (internally joined with a space), so ``math 2 +2`` and ``math "2 + 2"`` work the same. ``math 2 2`` is an error.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-sN` or `--scale=N` sets the scale of the result. `N` must be an integer. A scale of zero causes results to be rounded down to the nearest integer. So `3/2` returns `1` rather than `2` which `1.5` would normally round to. This is for compatibility with `bc` which was the basis for this command prior to fish 3.0.0. Scale values greater than zero causes the result to be rounded using the usual rules to the specified number of decimal places.
|
||||
- ``-sN`` or ``--scale=N`` sets the scale of the result. ``N`` must be an integer. A scale of zero causes results to be rounded down to the nearest integer. So ``3/2`` returns ``1`` rather than ``2`` which ``1.5`` would normally round to. This is for compatibility with ``bc`` which was the basis for this command prior to fish 3.0.0. Scale values greater than zero causes the result to be rounded using the usual rules to the specified number of decimal places.
|
||||
|
||||
Return Values
|
||||
------------
|
||||
|
||||
If the expression is successfully evaluated and doesn't over/underflow or return NaN the return `status` is zero (success) else one.
|
||||
If the expression is successfully evaluated and doesn't over/underflow or return NaN the return ``status`` is zero (success) else one.
|
||||
|
||||
Syntax
|
||||
------------
|
||||
|
||||
`math` knows some operators, constants, functions and can (obviously) read numbers.
|
||||
``math`` knows some operators, constants, functions and can (obviously) read numbers.
|
||||
|
||||
For numbers, `.` is always the radix character regardless of locale - `2.5`, not `2,5`. Scientific notation (`10e5`) is also available.
|
||||
For numbers, ``.`` is always the radix character regardless of locale - ``2.5``, not ``2,5``. Scientific notation (``10e5``) is also available.
|
||||
|
||||
Operators
|
||||
------------
|
||||
|
||||
`math` knows the following operators:
|
||||
``math`` knows the following operators:
|
||||
|
||||
- `+` for addition and `-` for subtraction.
|
||||
- ``+`` for addition and ``-`` for subtraction.
|
||||
|
||||
- `*` for multiplication, `/` for division.
|
||||
- ``*`` for multiplication, ``/`` for division.
|
||||
|
||||
- `^` for exponentiation.
|
||||
- ``^`` for exponentiation.
|
||||
|
||||
- `%` for modulo.
|
||||
- ``%`` for modulo.
|
||||
|
||||
- `(` and `)` for grouping.
|
||||
- ``(`` and ``)`` for grouping.
|
||||
|
||||
They are all used in an infix manner - `5 + 2`, not `+ 5 2`.
|
||||
They are all used in an infix manner - ``5 + 2``, not ``+ 5 2``.
|
||||
|
||||
Constants
|
||||
------------
|
||||
|
||||
`math` knows the following constants:
|
||||
``math`` knows the following constants:
|
||||
|
||||
- `e` - Euler's number.
|
||||
- `pi` - You know that one. Half of Tau. (Tau is not implemented)
|
||||
- ``e`` - Euler's number.
|
||||
- ``pi`` - You know that one. Half of Tau. (Tau is not implemented)
|
||||
|
||||
Use them without a leading `$` - `pi - 3` should be about 0.
|
||||
Use them without a leading ``$`` - ``pi - 3`` should be about 0.
|
||||
|
||||
Functions
|
||||
------------
|
||||
|
||||
`math` supports the following functions:
|
||||
``math`` supports the following functions:
|
||||
|
||||
- `abs`
|
||||
- `acos`
|
||||
- `asin`
|
||||
- `atan`
|
||||
- `atan2`
|
||||
- `ceil`
|
||||
- `cos`
|
||||
- `cosh`
|
||||
- `exp` - the base-e exponential function
|
||||
- `fac` - factorial
|
||||
- `floor`
|
||||
- `ln`
|
||||
- `log` or `log10` - the base-10 logarithm
|
||||
- `ncr`
|
||||
- `npr`
|
||||
- `pow(x,y)` returns x to the y (and can be written as `x ^ y`)
|
||||
- `round` - rounds to the nearest integer, away from 0
|
||||
- `sin`
|
||||
- `sinh`
|
||||
- `sqrt`
|
||||
- `tan`
|
||||
- `tanh`
|
||||
- ``abs``
|
||||
- ``acos``
|
||||
- ``asin``
|
||||
- ``atan``
|
||||
- ``atan2``
|
||||
- ``ceil``
|
||||
- ``cos``
|
||||
- ``cosh``
|
||||
- ``exp`` - the base-e exponential function
|
||||
- ``fac`` - factorial
|
||||
- ``floor``
|
||||
- ``ln``
|
||||
- ``log`` or ``log10`` - the base-10 logarithm
|
||||
- ``ncr``
|
||||
- ``npr``
|
||||
- ``pow(x,y)`` returns x to the y (and can be written as ``x ^ y``)
|
||||
- ``round`` - rounds to the nearest integer, away from 0
|
||||
- ``sin``
|
||||
- ``sinh``
|
||||
- ``sqrt``
|
||||
- ``tan``
|
||||
- ``tanh``
|
||||
|
||||
All of the trigonometric functions use radians.
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
||||
`math 1+1` outputs 2.
|
||||
``math 1+1`` outputs 2.
|
||||
|
||||
`math $status - 128` outputs the numerical exit status of the last command minus 128.
|
||||
``math $status - 128`` outputs the numerical exit status of the last command minus 128.
|
||||
|
||||
`math 10 / 6` outputs `1.666667`.
|
||||
``math 10 / 6`` outputs ``1.666667``.
|
||||
|
||||
`math -s0 10.0 / 6.0` outputs `1`.
|
||||
``math -s0 10.0 / 6.0`` outputs ``1``.
|
||||
|
||||
`math -s3 10 / 6` outputs `1.666`.
|
||||
``math -s3 10 / 6`` outputs ``1.666``.
|
||||
|
||||
`math "sin(pi)"` outputs `0`.
|
||||
``math "sin(pi)"`` outputs ``0``.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
|
|
@ -10,13 +10,13 @@ nextd [ -l | --list ] [POS]
|
|||
Description
|
||||
------------
|
||||
|
||||
`nextd` moves forwards `POS` positions in the history of visited directories; if the end of the history has been hit, a warning is printed.
|
||||
``nextd`` moves forwards ``POS`` positions in the history of visited directories; if the end of the history has been hit, a warning is printed.
|
||||
|
||||
If the `-l` or `--list` flag is specified, the current directory history is also displayed.
|
||||
If the ``-l`` or ``--list`` flag is specified, the current directory history is also displayed.
|
||||
|
||||
Note that the `cd` command limits directory history to the 25 most recently visited directories. The history is stored in the `$dirprev` and `$dirnext` variables which this command manipulates.
|
||||
Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates.
|
||||
|
||||
You may be interested in the <a href="commands.html#cdh">`cdh`</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
You may be interested in the <a href="commands.html#cdh">``cdh``</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,7 +10,7 @@ not COMMAND [OPTIONS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`not` negates the exit status of another command. If the exit status is zero, `not` returns 1. Otherwise, `not` returns 0.
|
||||
``not`` negates the exit status of another command. If the exit status is zero, ``not`` returns 1. Otherwise, ``not`` returns 0.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,7 +10,7 @@ open FILES...
|
|||
Description
|
||||
------------
|
||||
|
||||
`open` opens a file in its default application, using the appropriate tool for the operating system. On GNU/Linux, this requires the common but optional `xdg-open` utility, from the `xdg-utils` package.
|
||||
``open`` opens a file in its default application, using the appropriate tool for the operating system. On GNU/Linux, this requires the common but optional ``xdg-open`` utility, from the ``xdg-utils`` package.
|
||||
|
||||
Note that this function will not be used if a command by this name exists (which is the case on macOS or Haiku).
|
||||
|
||||
|
@ -18,4 +18,4 @@ Note that this function will not be used if a command by this name exists (which
|
|||
Example
|
||||
------------
|
||||
|
||||
`open *.txt` opens all the text files in the current directory using your system's default text editor.
|
||||
``open *.txt`` opens all the text files in the current directory using your system's default text editor.
|
||||
|
|
|
@ -10,17 +10,17 @@ COMMAND1; or COMMAND2
|
|||
Description
|
||||
------------
|
||||
|
||||
`or` is used to execute a command if the previous command was not successful (returned a status of something other than 0).
|
||||
``or`` is used to execute a command if the previous command was not successful (returned a status of something other than 0).
|
||||
|
||||
`or` statements may be used as part of the condition in an <a href="#if">`and`</a> or <a href="#while">`while`</a> block. See the documentation
|
||||
for <a href="#if">`if`</a> and <a href="#while">`while`</a> for examples.
|
||||
``or`` statements may be used as part of the condition in an <a href="#if">``and``</a> or <a href="#while">``while``</a> block. See the documentation
|
||||
for <a href="#if">``if``</a> and <a href="#while">``while``</a> for examples.
|
||||
|
||||
`or` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
``or`` does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> variable.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code runs the `make` command to build a program. If the build succeeds, the program is installed. If either step fails, `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, the program is installed. If either step fails, ``make clean`` is run, which removes the files created by the build process.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ popd
|
|||
Description
|
||||
------------
|
||||
|
||||
`popd` removes the top directory from the directory stack and changes the working directory to the new top directory. Use <a href="#pushd">`pushd`</a> to add directories to the stack.
|
||||
``popd`` removes the top directory from the directory stack and changes the working directory to the new top directory. Use <a href="#pushd">``pushd``</a> to add directories to the stack.
|
||||
|
||||
You may be interested in the <a href="commands.html#cdh">`cdh`</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
You may be interested in the <a href="commands.html#cdh">``cdh``</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,13 +10,13 @@ prevd [ -l | --list ] [POS]
|
|||
Description
|
||||
------------
|
||||
|
||||
`prevd` moves backwards `POS` positions in the history of visited directories; if the beginning of the history has been hit, a warning is printed.
|
||||
``prevd`` moves backwards ``POS`` positions in the history of visited directories; if the beginning of the history has been hit, a warning is printed.
|
||||
|
||||
If the `-l` or `--list` flag is specified, the current history is also displayed.
|
||||
If the ``-l`` or ``--list`` flag is specified, the current history is also displayed.
|
||||
|
||||
Note that the `cd` command limits directory history to the 25 most recently visited directories. The history is stored in the `$dirprev` and `$dirnext` variables which this command manipulates.
|
||||
Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates.
|
||||
|
||||
You may be interested in the <a href="commands.html#cdh">`cdh`</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
You may be interested in the <a href="commands.html#cdh">``cdh``</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -11,54 +11,54 @@ Description
|
|||
------------
|
||||
printf formats the string FORMAT with ARGUMENT, and displays the result.
|
||||
|
||||
The string FORMAT should contain format specifiers, each of which are replaced with successive arguments according to the specifier. Specifiers are detailed below, and are taken from the C library function `printf(3)`.
|
||||
The string FORMAT should contain format specifiers, each of which are replaced with successive arguments according to the specifier. Specifiers are detailed below, and are taken from the C library function ``printf(3)``.
|
||||
|
||||
Unlike `echo`, `printf` does not append a new line unless it is specified as part of the string.
|
||||
Unlike ``echo``, ``printf`` does not append a new line unless it is specified as part of the string.
|
||||
|
||||
Valid format specifiers are:
|
||||
|
||||
- `%%d`: Argument will be used as decimal integer (signed or unsigned)
|
||||
- ``%%d``: Argument will be used as decimal integer (signed or unsigned)
|
||||
|
||||
- `%%i`: Argument will be used as a signed integer
|
||||
- ``%%i``: Argument will be used as a signed integer
|
||||
|
||||
- `%%o`: An octal unsigned integer
|
||||
- ``%%o``: An octal unsigned integer
|
||||
|
||||
- `%%u`: An unsigned decimal integer
|
||||
- ``%%u``: An unsigned decimal integer
|
||||
|
||||
- `%%x` or `%%X`: An unsigned hexadecimal integer
|
||||
- ``%%x`` or ``%%X``: An unsigned hexadecimal integer
|
||||
|
||||
- `%%f`, `%%g` or `%%G`: A floating-point number
|
||||
- ``%%f``, ``%%g`` or ``%%G``: A floating-point number
|
||||
|
||||
- `%%e` or `%%E`: A floating-point number in scientific (XXXeYY) notation
|
||||
- ``%%e`` or ``%%E``: A floating-point number in scientific (XXXeYY) notation
|
||||
|
||||
- `%%s`: A string
|
||||
- ``%%s``: A string
|
||||
|
||||
- `%%b`: As a string, interpreting backslash escapes, except that octal escapes are of the form \0 or \0ooo.
|
||||
- ``%%b``: As a string, interpreting backslash escapes, except that octal escapes are of the form \0 or \0ooo.
|
||||
|
||||
`%%` signifies a literal "%".
|
||||
``%%`` signifies a literal "%".
|
||||
|
||||
Note that conversion may fail, e.g. "102.234" will not losslessly convert to an integer, causing printf to print an error.
|
||||
|
||||
printf also knows a number of backslash escapes:
|
||||
- `\"` double quote
|
||||
- `\\` backslash
|
||||
- `\a` alert (bell)
|
||||
- `\b` backspace
|
||||
- `\c` produce no further output
|
||||
- `\e` escape
|
||||
- `\f` form feed
|
||||
- `\n` new line
|
||||
- `\r` carriage return
|
||||
- `\t` horizontal tab
|
||||
- `\v` vertical tab
|
||||
- `\ooo` octal number (ooo is 1 to 3 digits)
|
||||
- `\xhh` hexadecimal number (hhh is 1 to 2 digits)
|
||||
- `\uhhhh` 16-bit Unicode character (hhhh is 4 digits)
|
||||
- `\Uhhhhhhhh` 32-bit Unicode character (hhhhhhhh is 8 digits)
|
||||
- ``\"`` double quote
|
||||
- ``\\`` backslash
|
||||
- ``\a`` alert (bell)
|
||||
- ``\b`` backspace
|
||||
- ``\c`` produce no further output
|
||||
- ``\e`` escape
|
||||
- ``\f`` form feed
|
||||
- ``\n`` new line
|
||||
- ``\r`` carriage return
|
||||
- ``\t`` horizontal tab
|
||||
- ``\v`` vertical tab
|
||||
- ``\ooo`` octal number (ooo is 1 to 3 digits)
|
||||
- ``\xhh`` hexadecimal number (hhh is 1 to 2 digits)
|
||||
- ``\uhhhh`` 16-bit Unicode character (hhhh is 4 digits)
|
||||
- ``\Uhhhhhhhh`` 32-bit Unicode character (hhhhhhhh is 8 digits)
|
||||
|
||||
The `format` argument is re-used as many times as necessary to convert all of the given arguments. If a format specifier is not appropriate for the given argument, an error is printed. For example, `printf '%d' "102.234"` produces an error, as "102.234" cannot be formatted as an integer.
|
||||
The ``format`` argument is re-used as many times as necessary to convert all of the given arguments. If a format specifier is not appropriate for the given argument, an error is printed. For example, ``printf '%d' "102.234"`` produces an error, as "102.234" cannot be formatted as an integer.
|
||||
|
||||
This file has been imported from the printf in GNU Coreutils version 6.9. If you would like to use a newer version of printf, for example the one shipped with your OS, try `command printf`.
|
||||
This file has been imported from the printf in GNU Coreutils version 6.9. If you would like to use a newer version of printf, for example the one shipped with your OS, try ``command printf``.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,15 +10,15 @@ COMMAND1 ( COMMAND2 | psub [-F | --fifo] [-f | --file] [-s SUFFIX])
|
|||
Description
|
||||
------------
|
||||
|
||||
Some shells (e.g., ksh, bash) feature a syntax that is a mix between command substitution and piping, called process substitution. It is used to send the output of a command into the calling command, much like command substitution, but with the difference that the output is not sent through commandline arguments but through a named pipe, with the filename of the named pipe sent as an argument to the calling program. `psub` combined with a regular command substitution provides the same functionality.
|
||||
Some shells (e.g., ksh, bash) feature a syntax that is a mix between command substitution and piping, called process substitution. It is used to send the output of a command into the calling command, much like command substitution, but with the difference that the output is not sent through commandline arguments but through a named pipe, with the filename of the named pipe sent as an argument to the calling program. ``psub`` combined with a regular command substitution provides the same functionality.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-f` or `--file` will cause psub to use a regular file instead of a named pipe to communicate with the calling process. This will cause `psub` to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream. This is the default.
|
||||
- ``-f`` or ``--file`` will cause psub to use a regular file instead of a named pipe to communicate with the calling process. This will cause ``psub`` to be significantly slower when large amounts of data are involved, but has the advantage that the reading process can seek in the stream. This is the default.
|
||||
|
||||
- `-F` or `--fifo` will cause psub to use a named pipe rather than a file. You should only use this if the command produces no more than 8 KiB of output. The limit on the amount of data a FIFO can buffer varies with the OS but is typically 8 KiB, 16 KiB or 64 KiB. If you use this option and the command on the left of the psub pipeline produces more output a deadlock is likely to occur.
|
||||
- ``-F`` or ``--fifo`` will cause psub to use a named pipe rather than a file. You should only use this if the command produces no more than 8 KiB of output. The limit on the amount of data a FIFO can buffer varies with the OS but is typically 8 KiB, 16 KiB or 64 KiB. If you use this option and the command on the left of the psub pipeline produces more output a deadlock is likely to occur.
|
||||
|
||||
- `-s` or `--suffix` will append SUFFIX to the filename.
|
||||
- ``-s`` or ``--suffix`` will append SUFFIX to the filename.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -28,8 +28,8 @@ Example
|
|||
::
|
||||
|
||||
diff (sort a.txt | psub) (sort b.txt | psub)
|
||||
# shows the difference between the sorted versions of files `a.txt` and `b.txt`.
|
||||
# shows the difference between the sorted versions of files ``a.txt`` and ``b.txt``.
|
||||
|
||||
source-highlight -f esc (cpp main.c | psub -f -s .c)
|
||||
# highlights `main.c` after preprocessing as a C source.
|
||||
# highlights ``main.c`` after preprocessing as a C source.
|
||||
|
||||
|
|
|
@ -10,17 +10,17 @@ pushd [DIRECTORY]
|
|||
Description
|
||||
------------
|
||||
|
||||
The `pushd` function adds `DIRECTORY` to the top of the directory stack and makes it the current working directory. <a href="#popd">`popd`</a> will pop it off and return to the original directory.
|
||||
The ``pushd`` function adds ``DIRECTORY`` to the top of the directory stack and makes it the current working directory. <a href="#popd">``popd``</a> will pop it off and return to the original directory.
|
||||
|
||||
Without arguments, it exchanges the top two directories in the stack.
|
||||
|
||||
`pushd +NUMBER` rotates the stack counter-clockwise i.e. from bottom to top
|
||||
``pushd +NUMBER`` rotates the stack counter-clockwise i.e. from bottom to top
|
||||
|
||||
`pushd -NUMBER` rotates clockwise i.e. top to bottom.
|
||||
``pushd -NUMBER`` rotates clockwise i.e. top to bottom.
|
||||
|
||||
See also `dirs` and `dirs -c`.
|
||||
See also ``dirs`` and ``dirs -c``.
|
||||
|
||||
You may be interested in the <a href="commands.html#cdh">`cdh`</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
You may be interested in the <a href="commands.html#cdh">``cdh``</a> command which provides a more intuitive way to navigate to recently visited directories.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,10 +10,10 @@ pwd
|
|||
Description
|
||||
------------
|
||||
|
||||
`pwd` outputs (prints) the current working directory.
|
||||
``pwd`` outputs (prints) the current working directory.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-L`, Output the logical working directory, without resolving symlinks (default behavior).
|
||||
- ``-L``, Output the logical working directory, without resolving symlinks (default behavior).
|
||||
|
||||
- `-P`, Output the physical working directory, with symlinks resolved.
|
||||
- ``-P``, Output the physical working directory, with symlinks resolved.
|
||||
|
|
|
@ -14,20 +14,20 @@ random choice [ITEMS...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`RANDOM` generates a pseudo-random integer from a uniform distribution. The
|
||||
``RANDOM`` generates a pseudo-random integer from a uniform distribution. The
|
||||
range (inclusive) is dependent on the arguments passed.
|
||||
No arguments indicate a range of [0; 32767].
|
||||
If one argument is specified, the internal engine will be seeded with the
|
||||
argument for future invocations of `RANDOM` and no output will be produced.
|
||||
argument for future invocations of ``RANDOM`` and no output will be produced.
|
||||
Two arguments indicate a range of [START; END].
|
||||
Three arguments indicate a range of [START; END] with a spacing of STEP
|
||||
between possible outputs.
|
||||
`RANDOM choice` will select one random item from the succeeding arguments.
|
||||
``RANDOM choice`` will select one random item from the succeeding arguments.
|
||||
|
||||
Note that seeding the engine will NOT give the same result across different
|
||||
systems.
|
||||
|
||||
You should not consider `RANDOM` cryptographically secure, or even
|
||||
You should not consider ``RANDOM`` cryptographically secure, or even
|
||||
statistically accurate.
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,77 +10,77 @@ read [OPTIONS] [VARIABLE ...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`read` reads from standard input and either writes the result back to standard output (for use in command substitution), or stores the result in one or more shell variables. By default, `read` reads a single line and splits it into variables on spaces or tabs. Alternatively, a null character or a maximum number of characters can be used to terminate the input, and other delimiters can be given. Unlike other shells, there is no default variable (such as `REPLY`) for storing the result - instead, it is printed on standard output.
|
||||
``read`` reads from standard input and either writes the result back to standard output (for use in command substitution), or stores the result in one or more shell variables. By default, ``read`` reads a single line and splits it into variables on spaces or tabs. Alternatively, a null character or a maximum number of characters can be used to terminate the input, and other delimiters can be given. Unlike other shells, there is no default variable (such as ``REPLY``) for storing the result - instead, it is printed on standard output.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-c CMD` or `--command=CMD` sets the initial string in the interactive mode command buffer to `CMD`.
|
||||
- ``-c CMD`` or ``--command=CMD`` sets the initial string in the interactive mode command buffer to ``CMD``.
|
||||
|
||||
- `-d DELIMITER` or `--delimiter=DELIMITER` splits on DELIMITER. DELIMITER will be used as an entire string to split on, not a set of characters.
|
||||
- ``-d DELIMITER`` or ``--delimiter=DELIMITER`` splits on DELIMITER. DELIMITER will be used as an entire string to split on, not a set of characters.
|
||||
|
||||
- `-g` or `--global` makes the variables global.
|
||||
- ``-g`` or ``--global`` makes the variables global.
|
||||
|
||||
- `-s` or `--silent` masks characters written to the terminal, replacing them with asterisks. This is useful for reading things like passwords or other sensitive information.
|
||||
- ``-s`` or ``--silent`` masks characters written to the terminal, replacing them with asterisks. This is useful for reading things like passwords or other sensitive information.
|
||||
|
||||
- `-l` or `--local` makes the variables local.
|
||||
- ``-l`` or ``--local`` makes the variables local.
|
||||
|
||||
- `-n NCHARS` or `--nchars=NCHARS` makes `read` return after reading NCHARS characters or the end of
|
||||
- ``-n NCHARS`` or ``--nchars=NCHARS`` makes ``read`` return after reading NCHARS characters or the end of
|
||||
the line, whichever comes first.
|
||||
|
||||
- `-p PROMPT_CMD` or `--prompt=PROMPT_CMD` uses the output of the shell command `PROMPT_CMD` as the prompt for the interactive mode. The default prompt command is <code>set_color green; echo read; set_color normal; echo "> "</code>.
|
||||
- ``-p PROMPT_CMD`` or ``--prompt=PROMPT_CMD`` uses the output of the shell command ``PROMPT_CMD`` as the prompt for the interactive mode. The default prompt command is <code>set_color green; echo read; set_color normal; echo "> "</code>.
|
||||
|
||||
- `-P PROMPT_STR` or `--prompt-str=PROMPT_STR` uses the string as the prompt for the interactive mode. It is equivalent to <code>echo PROMPT_STR</code> and is provided solely to avoid the need to frame the prompt as a command. All special characters in the string are automatically escaped before being passed to the <code>echo</code> command.
|
||||
- ``-P PROMPT_STR`` or ``--prompt-str=PROMPT_STR`` uses the string as the prompt for the interactive mode. It is equivalent to <code>echo PROMPT_STR</code> and is provided solely to avoid the need to frame the prompt as a command. All special characters in the string are automatically escaped before being passed to the <code>echo</code> command.
|
||||
|
||||
- `-R RIGHT_PROMPT_CMD` or `--right-prompt=RIGHT_PROMPT_CMD` uses the output of the shell command `RIGHT_PROMPT_CMD` as the right prompt for the interactive mode. There is no default right prompt command.
|
||||
- ``-R RIGHT_PROMPT_CMD`` or ``--right-prompt=RIGHT_PROMPT_CMD`` uses the output of the shell command ``RIGHT_PROMPT_CMD`` as the right prompt for the interactive mode. There is no default right prompt command.
|
||||
|
||||
- `-S` or `--shell` enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode. NOTE: Prior to fish 3.0, the short opt for `--shell` was `-s`, but it has been changed for compatibility with bash's `-s` short opt for `--silent`.
|
||||
- ``-S`` or ``--shell`` enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode. NOTE: Prior to fish 3.0, the short opt for ``--shell`` was ``-s``, but it has been changed for compatibility with bash's ``-s`` short opt for ``--silent``.
|
||||
|
||||
- `-u` or `--unexport` prevents the variables from being exported to child processes (default behaviour).
|
||||
- ``-u`` or ``--unexport`` prevents the variables from being exported to child processes (default behaviour).
|
||||
|
||||
- `-U` or `--universal` causes the specified shell variable to be made universal.
|
||||
- ``-U`` or ``--universal`` causes the specified shell variable to be made universal.
|
||||
|
||||
- `-x` or `--export` exports the variables to child processes.
|
||||
- ``-x`` or ``--export`` exports the variables to child processes.
|
||||
|
||||
- `-a` or `--array` stores the result as an array in a single variable.
|
||||
- ``-a`` or ``--array`` stores the result as an array in a single variable.
|
||||
|
||||
- `-z` or `--null` marks the end of the line with the NUL character, instead of newline. This also
|
||||
- ``-z`` or ``--null`` marks the end of the line with the NUL character, instead of newline. This also
|
||||
disables interactive mode.
|
||||
|
||||
- `-L` or `--line` reads each line into successive variables, and stops after each variable has been filled. This cannot be combined with the `--delimiter` option.
|
||||
- ``-L`` or ``--line`` reads each line into successive variables, and stops after each variable has been filled. This cannot be combined with the ``--delimiter`` option.
|
||||
|
||||
Without the `--line` option, `read` reads a single line of input from standard input, breaks it into tokens, and then assigns one token to each variable specified in `VARIABLES`. If there are more tokens than variables, the complete remainder is assigned to the last variable.
|
||||
Without the ``--line`` option, ``read`` reads a single line of input from standard input, breaks it into tokens, and then assigns one token to each variable specified in ``VARIABLES``. If there are more tokens than variables, the complete remainder is assigned to the last variable.
|
||||
|
||||
If the `--delimiter` argument is not given, the variable `IFS` is used as a list of characters to split on. Relying on the use of `IFS` is deprecated and this behaviour will be removed in future versions. The default value of `IFS` contains space, tab and newline characters. As a special case, if `IFS` is set to the empty string, each character of the input is considered a separate token.
|
||||
If the ``--delimiter`` argument is not given, the variable ``IFS`` is used as a list of characters to split on. Relying on the use of ``IFS`` is deprecated and this behaviour will be removed in future versions. The default value of ``IFS`` contains space, tab and newline characters. As a special case, if ``IFS`` is set to the empty string, each character of the input is considered a separate token.
|
||||
|
||||
With the `--line` option, `read` reads a line of input from standard input into each provided variable, stopping when each variable has been filled. The line is not tokenized.
|
||||
With the ``--line`` option, ``read`` reads a line of input from standard input into each provided variable, stopping when each variable has been filled. The line is not tokenized.
|
||||
|
||||
If no variable names are provided, `read` enters a special case that simply provides redirection from standard input to standard output, useful for command substitution. For instance, the fish shell command below can be used to read data that should be provided via a command line argument from the console instead of hardcoding it in the command itself, allowing the command to both be reused as-is in various contexts with different input values and preventing possibly sensitive text from being included in the shell history:
|
||||
If no variable names are provided, ``read`` enters a special case that simply provides redirection from standard input to standard output, useful for command substitution. For instance, the fish shell command below can be used to read data that should be provided via a command line argument from the console instead of hardcoding it in the command itself, allowing the command to both be reused as-is in various contexts with different input values and preventing possibly sensitive text from being included in the shell history:
|
||||
|
||||
`mysql -uuser -p(read)`
|
||||
``mysql -uuser -p(read)``
|
||||
|
||||
When running in this mode, `read` does not split the input in any way and text is redirected to standard output without any further processing or manipulation.
|
||||
When running in this mode, ``read`` does not split the input in any way and text is redirected to standard output without any further processing or manipulation.
|
||||
|
||||
If `-a` or `--array` is provided, only one variable name is allowed and the tokens are stored as an array in this variable.
|
||||
If ``-a`` or ``--array`` is provided, only one variable name is allowed and the tokens are stored as an array in this variable.
|
||||
|
||||
See the documentation for `set` for more details on the scoping rules for variables.
|
||||
See the documentation for ``set`` for more details on the scoping rules for variables.
|
||||
|
||||
When `read` reaches the end-of-file (EOF) instead of the terminator, the exit status is set to 1.
|
||||
When ``read`` reaches the end-of-file (EOF) instead of the terminator, the exit status is set to 1.
|
||||
Otherwise, it is set to 0.
|
||||
|
||||
In order to protect the shell from consuming too many system resources, `read` will only consume a
|
||||
In order to protect the shell from consuming too many system resources, ``read`` will only consume a
|
||||
maximum of 10 MiB (1048576 bytes); if the terminator is not reached before this limit then VARIABLE
|
||||
is set to empty and the exit status is set to 122. This limit can be altered with the
|
||||
`fish_read_limit` variable. If set to 0 (zero), the limit is removed.
|
||||
``fish_read_limit`` variable. If set to 0 (zero), the limit is removed.
|
||||
|
||||
Using another read history file
|
||||
------------
|
||||
|
||||
The `read` command supported the `-m` and `--mode-name` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the `fish_history` variable to specify a history session ID. That will affect both the `read` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
||||
The ``read`` command supported the ``-m`` and ``--mode-name`` flags in fish versions prior to 2.7.0 to specify an alternative read history file. Those flags are now deprecated and ignored. Instead, set the ``fish_history`` variable to specify a history session ID. That will affect both the ``read`` history file and the fish command history file. You can set it to an empty string to specify that no history should be read or written. This is useful for presentations where you do not want possibly private or sensitive history to be exposed to the audience but do want history relevant to the presentation to be available.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
The following code stores the value 'hello' in the shell variable `$foo`.
|
||||
The following code stores the value 'hello' in the shell variable ``$foo``.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ realpath path
|
|||
Description
|
||||
------------
|
||||
|
||||
This is implemented as a function and a builtin. The function will attempt to use an external realpath command if one can be found. Otherwise it falls back to the builtin. The builtin does not support any options. It's meant to be used only by scripts which need to be portable. The builtin implementation behaves like GNU realpath when invoked without any options (which is the most common use case). In general scripts should not invoke the builtin directly. They should just use `realpath`.
|
||||
This is implemented as a function and a builtin. The function will attempt to use an external realpath command if one can be found. Otherwise it falls back to the builtin. The builtin does not support any options. It's meant to be used only by scripts which need to be portable. The builtin implementation behaves like GNU realpath when invoked without any options (which is the most common use case). In general scripts should not invoke the builtin directly. They should just use ``realpath``.
|
||||
|
||||
If the path is invalid no translated path will be written to stdout and an error will be reported.
|
||||
|
|
|
@ -10,7 +10,7 @@ function NAME; [COMMANDS...;] return [STATUS]; [COMMANDS...;] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`return` halts a currently running function. The exit status is set to `STATUS` if it is given.
|
||||
``return`` halts a currently running function. The exit status is set to ``STATUS`` if it is given.
|
||||
|
||||
It is usually added inside of a conditional block such as an <a href="#if">if</a> statement or a <a href="#switch">switch</a> statement to conditionally stop the executing function and return to the caller, but it can also be used to specify the exit status of a function.
|
||||
|
||||
|
|
|
@ -16,45 +16,45 @@ set ( -S | --show ) [SCOPE_OPTIONS] [VARIABLE_NAME]...
|
|||
Description
|
||||
------------
|
||||
|
||||
`set` manipulates <a href="index.html#variables">shell variables</a>.
|
||||
``set`` manipulates <a href="index.html#variables">shell variables</a>.
|
||||
|
||||
If set is called with no arguments, the names and values of all shell variables are printed in sorted order. If some of the scope or export flags have been given, only the variables matching the specified scope are printed.
|
||||
|
||||
With both variable names and values provided, `set` assigns the variable `VARIABLE_NAME` the values `VALUES...`.
|
||||
With both variable names and values provided, ``set`` assigns the variable ``VARIABLE_NAME`` the values ``VALUES...``.
|
||||
|
||||
The following options control variable scope:
|
||||
|
||||
- `-a` or `--append` causes the values to be appended to the current set of values for the variable. This can be used with `--prepend` to both append and prepend at the same time. This cannot be used when assigning to a variable slice.
|
||||
- ``-a`` or ``--append`` causes the values to be appended to the current set of values for the variable. This can be used with ``--prepend`` to both append and prepend at the same time. This cannot be used when assigning to a variable slice.
|
||||
|
||||
- `-p` or `--prepend` causes the values to be prepended to the current set of values for the variable. This can be used with `--append` to both append and prepend at the same time. This cannot be used when assigning to a variable slice.
|
||||
- ``-p`` or ``--prepend`` causes the values to be prepended to the current set of values for the variable. This can be used with ``--append`` to both append and prepend at the same time. This cannot be used when assigning to a variable slice.
|
||||
|
||||
- `-l` or `--local` forces the specified shell variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
|
||||
- ``-l`` or ``--local`` forces the specified shell variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
|
||||
|
||||
- `-g` or `--global` causes the specified shell variable to be given a global scope. Non-global variables disappear when the block they belong to ends
|
||||
- ``-g`` or ``--global`` causes the specified shell variable to be given a global scope. Non-global variables disappear when the block they belong to ends
|
||||
|
||||
- `-U` or `--universal` causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell.
|
||||
- ``-U`` or ``--universal`` causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell.
|
||||
|
||||
- `-x` or `--export` causes the specified shell variable to be exported to child processes (making it an "environment variable")
|
||||
- ``-x`` or ``--export`` causes the specified shell variable to be exported to child processes (making it an "environment variable")
|
||||
|
||||
- `-u` or `--unexport` causes the specified shell variable to NOT be exported to child processes
|
||||
- ``-u`` or ``--unexport`` causes the specified shell variable to NOT be exported to child processes
|
||||
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-e` or `--erase` causes the specified shell variable to be erased
|
||||
- ``-e`` or ``--erase`` causes the specified shell variable to be erased
|
||||
|
||||
- `-q` or `--query` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
|
||||
- ``-q`` or ``--query`` test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
|
||||
|
||||
- `-n` or `--names` List only the names of all defined variables, not their value. The names are guaranteed to be sorted.
|
||||
- ``-n`` or ``--names`` List only the names of all defined variables, not their value. The names are guaranteed to be sorted.
|
||||
|
||||
- `-S` or `--show` Shows information about the given variables. If no variable names are given then all variables are shown in sorted order. No other flags can be used with this option. The information shown includes whether or not it is set in each of the local, global, and universal scopes. If it is set in one of those scopes whether or not it is exported is reported. The individual elements are also shown along with the length of each element.
|
||||
- ``-S`` or ``--show`` Shows information about the given variables. If no variable names are given then all variables are shown in sorted order. No other flags can be used with this option. The information shown includes whether or not it is set in each of the local, global, and universal scopes. If it is set in one of those scopes whether or not it is exported is reported. The individual elements are also shown along with the length of each element.
|
||||
|
||||
- `-L` or `--long` do not abbreviate long values when printing set variables
|
||||
- ``-L`` or ``--long`` do not abbreviate long values when printing set variables
|
||||
|
||||
|
||||
If a variable is set to more than one value, the variable will be an array with the specified elements. If a variable is set to zero elements, it will become an array with zero elements.
|
||||
|
||||
If the variable name is one or more array elements, such as `PATH[1 3 7]`, only those array elements specified will be changed. If you specify a negative index when expanding or assigning to an array variable, the index will be calculated from the end of the array. For example, the index -1 means the last index of an array.
|
||||
If the variable name is one or more array elements, such as ``PATH[1 3 7]``, only those array elements specified will be changed. If you specify a negative index when expanding or assigning to an array variable, the index will be calculated from the end of the array. For example, the index -1 means the last index of an array.
|
||||
|
||||
The scoping rules when creating or updating a variable are:
|
||||
|
||||
|
@ -62,7 +62,7 @@ The scoping rules when creating or updating a variable are:
|
|||
|
||||
-# If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previous variable scope is used.
|
||||
|
||||
-# If a variable is not explicitly set to be either universal, global or local and has never before been defined, the variable will be local to the currently executing function. Note that this is different from using the `-l` or `--local` flag. If one of those flags is used, the variable will be local to the most inner currently executing block, while without these the variable will be local to the function. If no function is executing, the variable will be global.
|
||||
-# If a variable is not explicitly set to be either universal, global or local and has never before been defined, the variable will be local to the currently executing function. Note that this is different from using the ``-l`` or ``--local`` flag. If one of those flags is used, the variable will be local to the most inner currently executing block, while without these the variable will be local to the function. If no function is executing, the variable will be global.
|
||||
|
||||
|
||||
The exporting rules when creating or updating a variable are identical to the scoping rules for variables:
|
||||
|
@ -78,9 +78,9 @@ In query mode, the scope to be examined can be specified.
|
|||
|
||||
In erase mode, if variable indices are specified, only the specified slices of the array variable will be erased.
|
||||
|
||||
`set` requires all options to come before any other arguments. For example, `set flags -l` will have the effect of setting the value of the variable `flags` to '-l', not making the variable local.
|
||||
``set`` requires all options to come before any other arguments. For example, ``set flags -l`` will have the effect of setting the value of the variable ``flags`` to '-l', not making the variable local.
|
||||
|
||||
In assignment mode, `set` does not modify the exit status. This allows simultaneous capture of the output and exit status of a subcommand, e.g. `if set output (command)`. In query mode, the exit status is the number of variables that were not found. In erase mode, `set` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.
|
||||
In assignment mode, ``set`` does not modify the exit status. This allows simultaneous capture of the output and exit status of a subcommand, e.g. ``if set output (command)``. In query mode, the exit status is the number of variables that were not found. In erase mode, ``set`` exits with a zero exit status in case of success, with a non-zero exit status if the commandline was invalid, if the variable was write-protected or if the variable did not exist.
|
||||
|
||||
|
||||
Examples
|
||||
|
@ -108,7 +108,7 @@ Examples
|
|||
# Changes the fourth element of the $PATH array to ~/bin
|
||||
set PATH[4] ~/bin
|
||||
|
||||
# Outputs the path to Python if `type -p` returns true.
|
||||
# Outputs the path to Python if ``type -p`` returns true.
|
||||
if set python_path (type -p python)
|
||||
echo "Python is at $python_path"
|
||||
end
|
||||
|
@ -117,5 +117,5 @@ Examples
|
|||
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`. This syntax was not widely used, and was ambiguous and inconsistent.
|
||||
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``. This syntax was not widely used, and was ambiguous and inconsistent.
|
||||
|
|
|
@ -10,24 +10,24 @@ set_color [OPTIONS] VALUE
|
|||
Description
|
||||
------------
|
||||
|
||||
`set_color` is used to control the color and styling of text in the terminal. `VALUE` corresponds to a reserved color name such as *red* or a RGB color value given as 3 or 6 hexadecimal digits. The *br*-, as in 'bright', forms are full-brightness variants of the 8 standard-brightness colors on many terminals. *brblack* has higher brightness than *black* - towards gray. A special keyword *normal* resets text formatting to terminal defaults.
|
||||
``set_color`` is used to control the color and styling of text in the terminal. ``VALUE`` corresponds to a reserved color name such as *red* or a RGB color value given as 3 or 6 hexadecimal digits. The *br*-, as in 'bright', forms are full-brightness variants of the 8 standard-brightness colors on many terminals. *brblack* has higher brightness than *black* - towards gray. A special keyword *normal* resets text formatting to terminal defaults.
|
||||
|
||||
Valid colors include:
|
||||
|
||||
- *black*, *red*, *green*, *yellow*, *blue*, *magenta*, *cyan*, *white*
|
||||
- *brblack*, *brred*, *brgreen*, *bryellow*, *brblue*, *brmagenta*, *brcyan*, *brwhite*
|
||||
|
||||
An RGB value with three or six hex digits, such as A0FF33 or f2f can be used. `fish` will choose the closest supported color. A three digit value is equivalent to specifying each digit twice; e.g., `set_color 2BC` is the same as `set_color 22BBCC`. Hexadecimal RGB values can be in lower or uppercase. Depending on the capabilities of your terminal (and the level of support `set_color` has for it) the actual color may be approximated by a nearby matching reserved color name or `set_color` may not have an effect on color. A second color may be given as a desired fallback color. e.g. `set_color 124212` *brblue* will instruct set_color to use *brblue* if a terminal is not capable of the exact shade of grey desired. This is very useful when an 8 or 16 color terminal might otherwise not use a color.
|
||||
An RGB value with three or six hex digits, such as A0FF33 or f2f can be used. ``fish`` will choose the closest supported color. A three digit value is equivalent to specifying each digit twice; e.g., ``set_color 2BC`` is the same as ``set_color 22BBCC``. Hexadecimal RGB values can be in lower or uppercase. Depending on the capabilities of your terminal (and the level of support ``set_color`` has for it) the actual color may be approximated by a nearby matching reserved color name or ``set_color`` may not have an effect on color. A second color may be given as a desired fallback color. e.g. ``set_color 124212`` *brblue* will instruct set_color to use *brblue* if a terminal is not capable of the exact shade of grey desired. This is very useful when an 8 or 16 color terminal might otherwise not use a color.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-b`, `--background` *COLOR* sets the background color.
|
||||
- `-c`, `--print-colors` prints a list of the 16 named colors.
|
||||
- `-o`, `--bold` sets bold mode.
|
||||
- `-d`, `--dim` sets dim mode.
|
||||
- `-i`, `--italics` sets italics mode.
|
||||
- `-r`, `--reverse` sets reverse mode.
|
||||
- `-u`, `--underline` sets underlined mode.
|
||||
- ``-b``, ``--background`` *COLOR* sets the background color.
|
||||
- ``-c``, ``--print-colors`` prints a list of the 16 named colors.
|
||||
- ``-o``, ``--bold`` sets bold mode.
|
||||
- ``-d``, ``--dim`` sets dim mode.
|
||||
- ``-i``, ``--italics`` sets italics mode.
|
||||
- ``-r``, ``--reverse`` sets reverse mode.
|
||||
- ``-u``, ``--underline`` sets underlined mode.
|
||||
|
||||
Using the *normal* keyword will reset foreground, background, and all formatting back to default.
|
||||
|
||||
|
@ -36,8 +36,8 @@ Notes
|
|||
|
||||
1. Using the *normal* keyword will reset both background and foreground colors to whatever is the default for the terminal.
|
||||
2. 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.
|
||||
3. Some terminals use the `--bold` escape sequence to switch to a brighter color set rather than increasing the weight of text.
|
||||
4. `set_color` works by printing sequences of characters to *stdout*. If used in command substitution or a pipe, these characters will also be captured. This may or may not be desirable. Checking the exit code of `isatty stdout` before using `set_color` can be useful to decide not to colorize output in a script.
|
||||
3. Some terminals use the ``--bold`` escape sequence to switch to a brighter color set rather than increasing the weight of text.
|
||||
4. ``set_color`` works by printing sequences of characters to *stdout*. If used in command substitution or a pipe, these characters will also be captured. This may or may not be desirable. Checking the exit code of ``isatty stdout`` before using ``set_color`` can be useful to decide not to colorize output in a script.
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
@ -55,12 +55,12 @@ Examples
|
|||
Terminal Capability Detection
|
||||
------------
|
||||
|
||||
Fish uses a heuristic to decide if a terminal supports the 256-color palette as opposed to the more limited 16 color palette of older terminals. Support can be forced on by setting `fish_term256` to *1*. If `$TERM` contains "256color" (e.g., *xterm-256color*), 256-color support is enabled. If `$TERM` contains *xterm*, 256 color support is enabled (except for MacOS: `$TERM_PROGRAM` and `$TERM_PROGRAM_VERSION` are used to detect Terminal.app from MacOS 10.6; support is disabled here it because it is known that it reports `xterm` and only supports 16 colors.
|
||||
Fish uses a heuristic to decide if a terminal supports the 256-color palette as opposed to the more limited 16 color palette of older terminals. Support can be forced on by setting ``fish_term256`` to *1*. If ``$TERM`` contains "256color" (e.g., *xterm-256color*), 256-color support is enabled. If ``$TERM`` contains *xterm*, 256 color support is enabled (except for MacOS: ``$TERM_PROGRAM`` and ``$TERM_PROGRAM_VERSION`` are used to detect Terminal.app from MacOS 10.6; support is disabled here it because it is known that it reports ``xterm`` and only supports 16 colors.
|
||||
|
||||
If terminfo reports 256 color support for a terminal, support will always be enabled. To debug color palette problems, `tput colors` may be useful to see the number of colors in terminfo for a terminal. Fish launched as `fish -d2` will include diagnostic messages that indicate the color support mode in use.
|
||||
If terminfo reports 256 color support for a terminal, support will always be enabled. To debug color palette problems, ``tput colors`` may be useful to see the number of colors in terminfo for a terminal. Fish launched as ``fish -d2`` will include diagnostic messages that indicate the color support mode in use.
|
||||
|
||||
Many terminals support 24-bit (i.e., true-color) color escape sequences. This includes modern xterm, Gnome Terminal, Konsole, and iTerm2. Fish attempts to detect such terminals through various means in `config.fish` You can explicitly force that support via `set fish_term24bit 1`.
|
||||
Many terminals support 24-bit (i.e., true-color) color escape sequences. This includes modern xterm, Gnome Terminal, Konsole, and iTerm2. Fish attempts to detect such terminals through various means in ``config.fish`` You can explicitly force that support via ``set fish_term24bit 1``.
|
||||
|
||||
The `set_color` command uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Fish will assume that all terminals can use the [ANSI X3.64](https://en.wikipedia.org/wiki/ANSI_escape_code) escape sequences if the terminfo definition indicates a color below 16 is not supported.
|
||||
The ``set_color`` command uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Fish will assume that all terminals can use the [ANSI X3.64](https://en.wikipedia.org/wiki/ANSI_escape_code) escape sequences if the terminfo definition indicates a color below 16 is not supported.
|
||||
|
||||
Support for italics, dim, reverse, and other modes is not guaranteed in all terminal emulators. Fish attempts to determine if the terminal supports these modes even if the terminfo database may not be up-to-date.
|
||||
|
|
|
@ -11,13 +11,13 @@ somecommand | source
|
|||
Description
|
||||
------------
|
||||
|
||||
`source` evaluates the commands of the specified file in the current shell. This is different from starting a new process to perform the commands (i.e. `fish < FILENAME`) since the commands will be evaluated by the current shell, which means that changes in shell variables will affect the current shell. If additional arguments are specified after the file name, they will be inserted into the `$argv` variable. The `$argv` variable will not include the name of the sourced file.
|
||||
``source`` evaluates the commands of the specified file in the current shell. This is different from starting a new process to perform the commands (i.e. ``fish < FILENAME``) since the commands will be evaluated by the current shell, which means that changes in shell variables will affect the current shell. If additional arguments are specified after the file name, they will be inserted into the ``$argv`` variable. The ``$argv`` variable will not include the name of the sourced file.
|
||||
|
||||
If no file is specified and stdin is not the terminal, or if the file name '`-`' is used, stdin will be read.
|
||||
If no file is specified and stdin is not the terminal, or if the file name '``-``' is used, stdin will be read.
|
||||
|
||||
The return status of `source` is the return status of the last job to execute. If something goes wrong while opening or reading the file, `source` exits with a non-zero status.
|
||||
The return status of ``source`` is the return status of the last job to execute. If something goes wrong while opening or reading the file, ``source`` exits with a non-zero status.
|
||||
|
||||
`.` (a single period) is an alias for the `source` command. The use of `.` is deprecated in favour of `source`, and `.` will be removed in a future version of fish.
|
||||
``.`` (a single period) is an alias for the ``source`` command. The use of ``.`` is deprecated in favour of ``source``, and ``.`` will be removed in a future version of fish.
|
||||
|
||||
|
||||
Example
|
||||
|
@ -33,4 +33,4 @@ Example
|
|||
|
||||
\subsection Caveats
|
||||
|
||||
In fish versions prior to 2.3.0 the `$argv` variable would have a single element (the name of the sourced file) if no arguments are present. Otherwise it would contain arguments without the name of the sourced file. That behavior was very confusing and unlike other shells such as bash and zsh.
|
||||
In fish versions prior to 2.3.0 the ``$argv`` variable would have a single element (the name of the sourced file) if no arguments are present. Otherwise it would contain arguments without the name of the sourced file. That behavior was very confusing and unlike other shells such as bash and zsh.
|
||||
|
|
|
@ -26,46 +26,46 @@ status test-feature FEATURE
|
|||
Description
|
||||
------------
|
||||
|
||||
With no arguments, `status` displays a summary of the current login and job control status of the shell.
|
||||
With no arguments, ``status`` displays a summary of the current login and job control status of the shell.
|
||||
|
||||
The following operations (sub-commands) are available:
|
||||
|
||||
- `is-command-sub` returns 0 if fish is currently executing a command substitution. Also `-c` or `--is-command-substitution`.
|
||||
- ``is-command-sub`` returns 0 if fish is currently executing a command substitution. Also ``-c`` or ``--is-command-substitution``.
|
||||
|
||||
- `is-block` returns 0 if fish is currently executing a block of code. Also `-b` or `--is-block`.
|
||||
- ``is-block`` returns 0 if fish is currently executing a block of code. Also ``-b`` or ``--is-block``.
|
||||
|
||||
- `is-breakpoint` returns 0 if fish is currently showing a prompt in the context of a `breakpoint` command. See also the `fish_breakpoint_prompt` function.
|
||||
- ``is-breakpoint`` returns 0 if fish is currently showing a prompt in the context of a ``breakpoint`` command. See also the ``fish_breakpoint_prompt`` function.
|
||||
|
||||
- `is-interactive` returns 0 if fish is interactive - that is, connected to a keyboard. Also `-i` or `--is-interactive`.
|
||||
- ``is-interactive`` returns 0 if fish is interactive - that is, connected to a keyboard. Also ``-i`` or ``--is-interactive``.
|
||||
|
||||
- `is-login` returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up the PATH. Also `-l` or `--is-login`.
|
||||
- ``is-login`` returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up the PATH. Also ``-l`` or ``--is-login``.
|
||||
|
||||
- `is-full-job-control` returns 0 if full job control is enabled. Also `--is-full-job-control` (no short flag).
|
||||
- ``is-full-job-control`` returns 0 if full job control is enabled. Also ``--is-full-job-control`` (no short flag).
|
||||
|
||||
- `is-interactive-job-control` returns 0 if interactive job control is enabled. Also, `--is-interactive-job-control` (no short flag).
|
||||
- ``is-interactive-job-control`` returns 0 if interactive job control is enabled. Also, ``--is-interactive-job-control`` (no short flag).
|
||||
|
||||
- `is-no-job-control` returns 0 if no job control is enabled. Also `--is-no-job-control` (no short flag).
|
||||
- ``is-no-job-control`` returns 0 if no job control is enabled. Also ``--is-no-job-control`` (no short flag).
|
||||
|
||||
- `filename` prints the filename of the currently running script. Also `current-filename`, `-f` or `--current-filename`.
|
||||
- ``filename`` prints the filename of the currently running script. Also ``current-filename``, ``-f`` or ``--current-filename``.
|
||||
|
||||
- `fish-path` prints the absolute path to the currently executing instance of fish.
|
||||
- ``fish-path`` prints the absolute path to the currently executing instance of fish.
|
||||
|
||||
- `function` prints the name of the currently called function if able, when missing displays "Not a
|
||||
function" (or equivalent translated string). Also `current-function`, `-u` or `--current-function`.
|
||||
- ``function`` prints the name of the currently called function if able, when missing displays "Not a
|
||||
function" (or equivalent translated string). Also ``current-function``, ``-u`` or ``--current-function``.
|
||||
|
||||
- `line-number` prints the line number of the currently running script. Also `current-line-number`, `-n` or `--current-line-number`.
|
||||
- ``line-number`` prints the line number of the currently running script. Also ``current-line-number``, ``-n`` or ``--current-line-number``.
|
||||
|
||||
- `stack-trace` prints a stack trace of all function calls on the call stack. Also `print-stack-trace`, `-t` or `--print-stack-trace`.
|
||||
- ``stack-trace`` prints a stack trace of all function calls on the call stack. Also ``print-stack-trace``, ``-t`` or ``--print-stack-trace``.
|
||||
|
||||
- `job-control CONTROL-TYPE` sets the job control type, which can be `none`, `full`, or `interactive`. Also `-j CONTROL-TYPE` or `--job-control=CONTROL-TYPE`.
|
||||
- ``job-control CONTROL-TYPE`` sets the job control type, which can be ``none``, ``full``, or ``interactive``. Also ``-j CONTROL-TYPE`` or ``--job-control=CONTROL-TYPE``.
|
||||
|
||||
- `features` lists all available feature flags.
|
||||
- ``features`` lists all available feature flags.
|
||||
|
||||
- `test-feature FEATURE` returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized.
|
||||
- ``test-feature FEATURE`` returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized.
|
||||
|
||||
Notes
|
||||
------------
|
||||
|
||||
For backwards compatibility each subcommand can also be specified as a long or short option. For example, rather than `status is-login` you can type `status --is-login`. The flag forms are deprecated and may be removed in a future release (but not before fish 3.0).
|
||||
For backwards compatibility each subcommand can also be specified as a long or short option. For example, rather than ``status is-login`` you can type ``status --is-login``. The flag forms are deprecated and may be removed in a future release (but not before fish 3.0).
|
||||
|
||||
You can only specify one subcommand per invocation even if you use the flag form of the subcommand.
|
||||
|
|
|
@ -31,159 +31,159 @@ string upper [(-q | --quiet)] [STRING...]
|
|||
Description
|
||||
------------
|
||||
|
||||
`string` performs operations on strings.
|
||||
``string`` performs operations on strings.
|
||||
|
||||
STRING arguments are taken from the command line unless standard input is connected to a pipe or a file, in which case they are read from standard input, one STRING per line. It is an error to supply STRING arguments on the command line and on standard input.
|
||||
|
||||
Arguments beginning with `-` are normally interpreted as switches; `--` causes the following arguments not to be treated as switches even if they begin with `-`. Switches and required arguments are recognized only on the command line.
|
||||
Arguments beginning with ``-`` are normally interpreted as switches; ``--`` causes the following arguments not to be treated as switches even if they begin with ``-``. Switches and required arguments are recognized only on the command line.
|
||||
|
||||
Most subcommands accept a `-q` or `--quiet` switch, which suppresses the usual output but exits with the documented status.
|
||||
Most subcommands accept a ``-q`` or ``--quiet`` switch, which suppresses the usual output but exits with the documented status.
|
||||
|
||||
The following subcommands are available.
|
||||
|
||||
"escape" subcommand
|
||||
------------
|
||||
|
||||
`string escape` escapes each STRING in one of three ways. The first is `--style=script`. This is the default. It alters the string such that it can be passed back to `eval` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If `-n` or `--no-quoted` is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise.
|
||||
``string escape`` escapes each STRING in one of three ways. The first is ``--style=script``. This is the default. It alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If ``-n`` or ``--no-quoted`` is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise.
|
||||
|
||||
`--style=var` ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded.
|
||||
``--style=var`` ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded.
|
||||
|
||||
`--style=url` ensures the string can be used as a URL by hex encoding any character which is not legal in a URL. The string is first converted to UTF-8 before being encoded.
|
||||
``--style=url`` ensures the string can be used as a URL by hex encoding any character which is not legal in a URL. The string is first converted to UTF-8 before being encoded.
|
||||
|
||||
`--style=regex` escapes an input string for literal matching within a regex expression. The string is first converted to UTF-8 before being encoded.
|
||||
``--style=regex`` escapes an input string for literal matching within a regex expression. The string is first converted to UTF-8 before being encoded.
|
||||
|
||||
`string unescape` performs the inverse of the `string escape` command. If the string to be unescaped is not properly formatted it is ignored. For example, doing `string unescape --style=var (string escape --style=var $str)` will return the original string. There is no support for unescaping pcre2.
|
||||
``string unescape`` performs the inverse of the ``string escape`` command. If the string to be unescaped is not properly formatted it is ignored. For example, doing ``string unescape --style=var (string escape --style=var $str)`` will return the original string. There is no support for unescaping pcre2.
|
||||
|
||||
"join" subcommand
|
||||
------------
|
||||
|
||||
`string join` joins its STRING arguments into a single string separated by SEP, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise.
|
||||
``string join`` joins its STRING arguments into a single string separated by SEP, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise.
|
||||
|
||||
\subsection string-join0 "join0" subcommand
|
||||
|
||||
`string join` joins its STRING arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as `sort -z`. Exit status: 0 if at least one join was performed, or 1 otherwise.
|
||||
``string join`` joins its STRING arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``. Exit status: 0 if at least one join was performed, or 1 otherwise.
|
||||
|
||||
"length" subcommand
|
||||
------------
|
||||
|
||||
`string length` reports the length of each string argument in characters. Exit status: 0 if at least one non-empty STRING was given, or 1 otherwise.
|
||||
``string length`` reports the length of each string argument in characters. Exit status: 0 if at least one non-empty STRING was given, or 1 otherwise.
|
||||
|
||||
"lower" subcommand
|
||||
------------
|
||||
|
||||
`string lower` converts each string argument to lowercase. Exit status: 0 if at least one string was converted to lowercase, else 1. This means that in conjunction with the `-q` flag you can readily test whether a string is already lowercase.
|
||||
``string lower`` converts each string argument to lowercase. Exit status: 0 if at least one string was converted to lowercase, else 1. This means that in conjunction with the ``-q`` flag you can readily test whether a string is already lowercase.
|
||||
|
||||
"match" subcommand
|
||||
------------
|
||||
|
||||
`string match` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless `-a` or `--all` is given, in which case all matches are reported.
|
||||
``string match`` tests each STRING against PATTERN and prints matching substrings. Only the first match for each STRING is reported unless ``-a`` or ``--all`` is given, in which case all matches are reported.
|
||||
|
||||
If you specify the `-e` or `--entire` then each matching string is printed including any prefix or suffix not matched by the pattern (equivalent to `grep` without the `-o` flag). You can, obviously, achieve the same result by prepending and appending `*` or `.*` depending on whether or not you have specified the `--regex` flag. The `--entire` flag is simply a way to avoid having to complicate the pattern in that fashion and make the intent of the `string match` clearer. Without `--entire` and `--regex`, a PATTERN will need to match the entire STRING before it will be reported.
|
||||
If you specify the ``-e`` or ``--entire`` then each matching string is printed including any prefix or suffix not matched by the pattern (equivalent to ``grep`` without the ``-o`` flag). You can, obviously, achieve the same result by prepending and appending ``*`` or ``.*`` depending on whether or not you have specified the ``--regex`` flag. The ``--entire`` flag is simply a way to avoid having to complicate the pattern in that fashion and make the intent of the ``string match`` clearer. Without ``--entire`` and ``--regex``, a PATTERN will need to match the entire STRING before it will be reported.
|
||||
|
||||
Matching can be made case-insensitive with `--ignore-case` or `-i`.
|
||||
Matching can be made case-insensitive with ``--ignore-case`` or ``-i``.
|
||||
|
||||
If `--index` or `-n` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. A glob pattern is only considered a valid match if it matches the entire STRING.
|
||||
If ``--index`` or ``-n`` is given, each match is reported as a 1-based start position and a length. By default, PATTERN is interpreted as a glob pattern matched against each entire STRING argument. A glob pattern is only considered a valid match if it matches the entire STRING.
|
||||
|
||||
If `--regex` or `-r` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. With this, only the matching part of the STRING will be reported, unless `--entire` is given.
|
||||
If ``--regex`` or ``-r`` is given, PATTERN is interpreted as a Perl-compatible regular expression, which does not have to match the entire STRING. For a regular expression containing capturing groups, multiple items will be reported for each match, one for the entire match and one for each capturing group. With this, only the matching part of the STRING will be reported, unless ``--entire`` is given.
|
||||
|
||||
If `--invert` or `-v` is used the selected lines will be only those which do not match the given glob pattern or regular expression.
|
||||
If ``--invert`` or ``-v`` is used the selected lines will be only those which do not match the given glob pattern or regular expression.
|
||||
|
||||
Exit status: 0 if at least one match was found, or 1 otherwise.
|
||||
|
||||
"repeat" subcommand
|
||||
------------
|
||||
|
||||
`string repeat` repeats the STRING `-n` or `--count` times. The `-m` or `--max` option will limit the number of outputted char (excluding the newline). This option can be used by itself or in conjunction with `--count`. If both `--count` and `--max` are present, max char will be outputed unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both `--count` and `--max` will accept a number greater than or equal to zero, in the case of zero, nothing will be outputed. If `-N` or `--no-newline` is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise.
|
||||
``string repeat`` repeats the STRING ``-n`` or ``--count`` times. The ``-m`` or ``--max`` option will limit the number of outputted char (excluding the newline). This option can be used by itself or in conjunction with ``--count``. If both ``--count`` and ``--max`` are present, max char will be outputed unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both ``--count`` and ``--max`` will accept a number greater than or equal to zero, in the case of zero, nothing will be outputed. If ``-N`` or ``--no-newline`` is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise.
|
||||
|
||||
"replace" subcommand
|
||||
------------
|
||||
|
||||
`string replace` is similar to `string match` but replaces non-overlapping matching substrings with a replacement string and prints the result. By default, PATTERN is treated as a literal substring to be matched.
|
||||
``string replace`` is similar to ``string match`` but replaces non-overlapping matching substrings with a replacement string and prints the result. By default, PATTERN is treated as a literal substring to be matched.
|
||||
|
||||
If `-r` or `--regex` is given, PATTERN is interpreted as a Perl-compatible regular expression, and REPLACEMENT can contain C-style escape sequences like `\t` as well as references to capturing groups by number or name as `$n` or `${n}`.
|
||||
If ``-r`` or ``--regex`` is given, PATTERN is interpreted as a Perl-compatible regular expression, and REPLACEMENT can contain C-style escape sequences like ``\t`` as well as references to capturing groups by number or name as ``$n`` or ``${n}``.
|
||||
|
||||
If you specify the `-f` or `--filter` flag then each input string is printed only if a replacement was done. This is useful where you would otherwise use this idiom: `a_cmd | string match pattern | string replace pattern new_pattern`. You can instead just write `a_cmd | string replace --filter pattern new_pattern`.
|
||||
If you specify the ``-f`` or ``--filter`` flag then each input string is printed only if a replacement was done. This is useful where you would otherwise use this idiom: ``a_cmd | string match pattern | string replace pattern new_pattern``. You can instead just write ``a_cmd | string replace --filter pattern new_pattern``.
|
||||
|
||||
Exit status: 0 if at least one replacement was performed, or 1 otherwise.
|
||||
|
||||
"split" subcommand
|
||||
------------
|
||||
|
||||
`string split` splits each STRING on the separator SEP, which can be an empty string. If `-m` or `--max` is specified, at most MAX splits are done on each STRING. If `-r` or `--right` is given, splitting is performed right-to-left. This is useful in combination with `-m` or `--max`. With `-n` or `--no-empty`, empty results are excluded from consideration (e.g. `hello\n\nworld` would expand to two strings and not three). Exit status: 0 if at least one split was performed, or 1 otherwise.
|
||||
``string split`` splits each STRING on the separator SEP, which can be an empty string. If ``-m`` or ``--max`` is specified, at most MAX splits are done on each STRING. If ``-r`` or ``--right`` is given, splitting is performed right-to-left. This is useful in combination with ``-m`` or ``--max``. With ``-n`` or ``--no-empty``, empty results are excluded from consideration (e.g. ``hello\n\nworld`` would expand to two strings and not three). Exit status: 0 if at least one split was performed, or 1 otherwise.
|
||||
|
||||
See also `read --delimiter`.
|
||||
See also ``read --delimiter``.
|
||||
|
||||
\subsection string-split0 "split0" subcommand
|
||||
|
||||
`string split0` splits each STRING on the zero byte (NUL). Options are the same as `string split` except that no separator is given.
|
||||
``string split0`` splits each STRING on the zero byte (NUL). Options are the same as ``string split`` except that no separator is given.
|
||||
|
||||
`split0` has the important property that its output is not further split when used in a command substitution, allowing for the command substitution to produce elements containing newlines. This is most useful when used with Unix tools that produce zero bytes, such as `find -print0` or `sort -z`. See split0 examples below.
|
||||
``split0`` has the important property that its output is not further split when used in a command substitution, allowing for the command substitution to produce elements containing newlines. This is most useful when used with Unix tools that produce zero bytes, such as ``find -print0`` or ``sort -z``. See split0 examples below.
|
||||
|
||||
"sub" subcommand
|
||||
------------
|
||||
|
||||
`string sub` prints a substring of each string argument. The start of the substring can be specified with `-s` or `--start` followed by a 1-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with `-l` or `--length`. If the length is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise.
|
||||
``string sub`` prints a substring of each string argument. The start of the substring can be specified with ``-s`` or ``--start`` followed by a 1-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with ``-l`` or ``--length``. If the length is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise.
|
||||
|
||||
"trim" subcommand
|
||||
------------
|
||||
|
||||
`string trim` removes leading and trailing whitespace from each STRING. If `-l` or `--left` is given, only leading whitespace is removed. If `-r` or `--right` is given, only trailing whitespace is trimmed. The `-c` or `--chars` switch causes the characters in CHARS to be removed instead of whitespace. Exit status: 0 if at least one character was trimmed, or 1 otherwise.
|
||||
``string trim`` removes leading and trailing whitespace from each STRING. If ``-l`` or ``--left`` is given, only leading whitespace is removed. If ``-r`` or ``--right`` is given, only trailing whitespace is trimmed. The ``-c`` or ``--chars`` switch causes the characters in CHARS to be removed instead of whitespace. Exit status: 0 if at least one character was trimmed, or 1 otherwise.
|
||||
|
||||
"upper" subcommand
|
||||
------------
|
||||
|
||||
`string upper` converts each string argument to uppercase. Exit status: 0 if at least one string was converted to uppercase, else 1. This means that in conjunction with the `-q` flag you can readily test whether a string is already uppercase.
|
||||
``string upper`` converts each string argument to uppercase. Exit status: 0 if at least one string was converted to uppercase, else 1. This means that in conjunction with the ``-q`` flag you can readily test whether a string is already uppercase.
|
||||
|
||||
Regular Expressions
|
||||
------------
|
||||
|
||||
Both the `match` and `replace` subcommand support regular expressions when used with the `-r` or `--regex` option. The dialect is that of PCRE2.
|
||||
Both the ``match`` and ``replace`` subcommand support regular expressions when used with the ``-r`` or ``--regex`` option. The dialect is that of PCRE2.
|
||||
|
||||
In general, special characters are special by default, so `a+` matches one or more "a"s, while `a\+` matches an "a" and then a "+". `(a+)` matches one or more "a"s in a capturing group (`(?:XXXX)` denotes a non-capturing group). For the replacement parameter of `replace`, `$n` refers to the n-th group of the match. In the match parameter, `\n` (e.g. `\1`) refers back to groups.
|
||||
In general, special characters are special by default, so ``a+`` matches one or more "a"s, while ``a\+`` matches an "a" and then a "+". ``(a+)`` matches one or more "a"s in a capturing group (``(?:XXXX)`` denotes a non-capturing group). For the replacement parameter of ``replace``, ``$n`` refers to the n-th group of the match. In the match parameter, ``\n`` (e.g. ``\1``) refers back to groups.
|
||||
|
||||
Some features include repetitions:
|
||||
- `*` refers to 0 or more repetitions of the previous expression
|
||||
- `+` 1 or more
|
||||
- `?` 0 or 1.
|
||||
- `{n}` to exactly n (where n is a number)
|
||||
- `{n,m}` at least n, no more than m.
|
||||
- `{n,}` n or more
|
||||
- ``*`` refers to 0 or more repetitions of the previous expression
|
||||
- ``+`` 1 or more
|
||||
- ``?`` 0 or 1.
|
||||
- ``{n}`` to exactly n (where n is a number)
|
||||
- ``{n,m}`` at least n, no more than m.
|
||||
- ``{n,}`` n or more
|
||||
|
||||
Character classes, some of the more important:
|
||||
- `.` any character except newline
|
||||
- `\d` a decimal digit and `\D`, not a decimal digit
|
||||
- `\s` whitespace and `\S`, not whitespace
|
||||
- `\w` a "word" character and `\W`, a "non-word" character
|
||||
- `[...]` (where "..." is some characters) is a character set
|
||||
- `[^...]` is the inverse of the given character set
|
||||
- `[x-y]` is the range of characters from x-y
|
||||
- `[[:xxx:]]` is a named character set
|
||||
- `[[:^xxx:]]` is the inverse of a named character set
|
||||
- `[[:alnum:]]` : "alphanumeric"
|
||||
- `[[:alpha:]]` : "alphabetic"
|
||||
- `[[:ascii:]]` : "0-127"
|
||||
- `[[:blank:]]` : "space or tab"
|
||||
- `[[:cntrl:]]` : "control character"
|
||||
- `[[:digit:]]` : "decimal digit"
|
||||
- `[[:graph:]]` : "printing, excluding space"
|
||||
- `[[:lower:]]` : "lower case letter"
|
||||
- `[[:print:]]` : "printing, including space"
|
||||
- `[[:punct:]]` : "printing, excluding alphanumeric"
|
||||
- `[[:space:]]` : "white space"
|
||||
- `[[:upper:]]` : "upper case letter"
|
||||
- `[[:word:]]` : "same as \w"
|
||||
- `[[:xdigit:]]` : "hexadecimal digit"
|
||||
- ``.`` any character except newline
|
||||
- ``\d`` a decimal digit and ``\D``, not a decimal digit
|
||||
- ``\s`` whitespace and ``\S``, not whitespace
|
||||
- ``\w`` a "word" character and ``\W``, a "non-word" character
|
||||
- ``[...]`` (where "..." is some characters) is a character set
|
||||
- ``[^...]`` is the inverse of the given character set
|
||||
- ``[x-y]`` is the range of characters from x-y
|
||||
- ``[[:xxx:]]`` is a named character set
|
||||
- ``[[:^xxx:]]`` is the inverse of a named character set
|
||||
- ``[[:alnum:]]`` : "alphanumeric"
|
||||
- ``[[:alpha:]]`` : "alphabetic"
|
||||
- ``[[:ascii:]]`` : "0-127"
|
||||
- ``[[:blank:]]`` : "space or tab"
|
||||
- ``[[:cntrl:]]`` : "control character"
|
||||
- ``[[:digit:]]`` : "decimal digit"
|
||||
- ``[[:graph:]]`` : "printing, excluding space"
|
||||
- ``[[:lower:]]`` : "lower case letter"
|
||||
- ``[[:print:]]`` : "printing, including space"
|
||||
- ``[[:punct:]]`` : "printing, excluding alphanumeric"
|
||||
- ``[[:space:]]`` : "white space"
|
||||
- ``[[:upper:]]`` : "upper case letter"
|
||||
- ``[[:word:]]`` : "same as \w"
|
||||
- ``[[:xdigit:]]`` : "hexadecimal digit"
|
||||
|
||||
Groups:
|
||||
- `(...)` is a capturing group
|
||||
- `(?:...)` is a non-capturing group
|
||||
- `\n` is a backreference (where n is the number of the group, starting with 1)
|
||||
- `$n` is a reference from the replacement expression to a group in the match expression.
|
||||
- ``(...)`` is a capturing group
|
||||
- ``(?:...)`` is a non-capturing group
|
||||
- ``\n`` is a backreference (where n is the number of the group, starting with 1)
|
||||
- ``$n`` is a reference from the replacement expression to a group in the match expression.
|
||||
|
||||
And some other things:
|
||||
- `\b` denotes a word boundary, `\B` is not a word boundary.
|
||||
- `^` is the start of the string or line, `$` the end.
|
||||
- `|` is "alternation", i.e. the "or".
|
||||
- ``\b`` denotes a word boundary, ``\B`` is not a word boundary.
|
||||
- ``^`` is the start of the string or line, ``$`` the end.
|
||||
- ``|`` is "alternation", i.e. the "or".
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
|
|
@ -10,9 +10,9 @@ suspend [--force]
|
|||
Description
|
||||
------------
|
||||
|
||||
`suspend` suspends execution of the current shell by sending it a
|
||||
``suspend`` suspends execution of the current shell by sending it a
|
||||
SIGTSTP signal, returning to the controlling process. It can be
|
||||
resumed later by sending it a SIGCONT. In order to prevent suspending
|
||||
a shell that doesn't have a controlling process, it will not suspend
|
||||
the shell if it is a login shell. This requirement is bypassed
|
||||
if the `--force` option is given or the shell is not interactive.
|
||||
if the ``--force`` option is given or the shell is not interactive.
|
|
@ -10,9 +10,9 @@ switch VALUE; [case [WILDCARD...]; [COMMANDS...]; ...] end
|
|||
Description
|
||||
------------
|
||||
|
||||
`switch` performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values. `case` is used together with the `switch` statement in order to determine which block should be executed.
|
||||
``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.
|
||||
|
||||
|
@ -42,5 +42,5 @@ If the variable \$animal contains the name of an animal, the following code woul
|
|||
end
|
||||
|
||||
|
||||
If the above code was run with `$animal` set to `whale`, the output
|
||||
would be `mammal`.
|
||||
If the above code was run with ``$animal`` set to ``whale``, the output
|
||||
would be ``mammal``.
|
||||
|
|
|
@ -13,101 +13,101 @@ Description
|
|||
|
||||
Tests the expression given and sets the exit status to 0 if true, and 1 if false. An expression is made up of one or more operators and their arguments.
|
||||
|
||||
The first form (`test`) is preferred. For compatibility with other shells, the second form is available: a matching pair of square brackets (`[ [EXPRESSION ] ]`).
|
||||
The first form (``test``) is preferred. For compatibility with other shells, the second form is available: a matching pair of square brackets (``[ [EXPRESSION ] ]``).
|
||||
|
||||
This test is mostly POSIX-compatible.
|
||||
|
||||
When using a variable as an argument for a test operator you should almost always enclose it in double-quotes. There are only two situations it is safe to omit the quote marks. The first is when the argument is a literal string with no whitespace or other characters special to the shell (e.g., semicolon). For example, `test -b /my/file`. The second is using a variable that expands to exactly one element including if that element is the empty string (e.g., `set x ''`). If the variable is not set, set but with no value, or set to more than one value you must enclose it in double-quotes. For example, `test "$x" = "$y"`. Since it is always safe to enclose variables in double-quotes when used as `test` arguments that is the recommended practice.
|
||||
When using a variable as an argument for a test operator you should almost always enclose it in double-quotes. There are only two situations it is safe to omit the quote marks. The first is when the argument is a literal string with no whitespace or other characters special to the shell (e.g., semicolon). For example, ``test -b /my/file``. The second is using a variable that expands to exactly one element including if that element is the empty string (e.g., ``set x ''``). If the variable is not set, set but with no value, or set to more than one value you must enclose it in double-quotes. For example, ``test "$x" = "$y"``. Since it is always safe to enclose variables in double-quotes when used as ``test`` arguments that is the recommended practice.
|
||||
|
||||
Operators for files and directories
|
||||
------------
|
||||
|
||||
- `-b FILE` returns true if `FILE` is a block device.
|
||||
- ``-b FILE`` returns true if ``FILE`` is a block device.
|
||||
|
||||
- `-c FILE` returns true if `FILE` is a character device.
|
||||
- ``-c FILE`` returns true if ``FILE`` is a character device.
|
||||
|
||||
- `-d FILE` returns true if `FILE` is a directory.
|
||||
- ``-d FILE`` returns true if ``FILE`` is a directory.
|
||||
|
||||
- `-e FILE` returns true if `FILE` exists.
|
||||
- ``-e FILE`` returns true if ``FILE`` exists.
|
||||
|
||||
- `-f FILE` returns true if `FILE` is a regular file.
|
||||
- ``-f FILE`` returns true if ``FILE`` is a regular file.
|
||||
|
||||
- `-g FILE` returns true if `FILE` has the set-group-ID bit set.
|
||||
- ``-g FILE`` returns true if ``FILE`` has the set-group-ID bit set.
|
||||
|
||||
- `-G FILE` returns true if `FILE` exists and has the same group ID as the current user.
|
||||
- ``-G FILE`` returns true if ``FILE`` exists and has the same group ID as the current user.
|
||||
|
||||
- `-k FILE` returns true if `FILE` has the sticky bit set. If the OS does not support the concept it returns false. See https://en.wikipedia.org/wiki/Sticky_bit.
|
||||
- ``-k FILE`` returns true if ``FILE`` has the sticky bit set. If the OS does not support the concept it returns false. See https://en.wikipedia.org/wiki/Sticky_bit.
|
||||
|
||||
- `-L FILE` returns true if `FILE` is a symbolic link.
|
||||
- ``-L FILE`` returns true if ``FILE`` is a symbolic link.
|
||||
|
||||
- `-O FILE` returns true if `FILE` exists and is owned by the current user.
|
||||
- ``-O FILE`` returns true if ``FILE`` exists and is owned by the current user.
|
||||
|
||||
- `-p FILE` returns true if `FILE` is a named pipe.
|
||||
- ``-p FILE`` returns true if ``FILE`` is a named pipe.
|
||||
|
||||
- `-r FILE` returns true if `FILE` is marked as readable.
|
||||
- ``-r FILE`` returns true if ``FILE`` is marked as readable.
|
||||
|
||||
- `-s FILE` returns true if the size of `FILE` is greater than zero.
|
||||
- ``-s FILE`` returns true if the size of ``FILE`` is greater than zero.
|
||||
|
||||
- `-S FILE` returns true if `FILE` is a socket.
|
||||
- ``-S FILE`` returns true if ``FILE`` is a socket.
|
||||
|
||||
- `-t FD` returns true if the file descriptor `FD` is a terminal (TTY).
|
||||
- ``-t FD`` returns true if the file descriptor ``FD`` is a terminal (TTY).
|
||||
|
||||
- `-u FILE` returns true if `FILE` has the set-user-ID bit set.
|
||||
- ``-u FILE`` returns true if ``FILE`` has the set-user-ID bit set.
|
||||
|
||||
- `-w FILE` returns true if `FILE` is marked as writable; note that this does not check if the filesystem is read-only.
|
||||
- ``-w FILE`` returns true if ``FILE`` is marked as writable; note that this does not check if the filesystem is read-only.
|
||||
|
||||
- `-x FILE` returns true if `FILE` is marked as executable.
|
||||
- ``-x FILE`` returns true if ``FILE`` is marked as executable.
|
||||
|
||||
Operators for text strings
|
||||
------------
|
||||
|
||||
- `STRING1 = STRING2` returns true if the strings `STRING1` and `STRING2` are identical.
|
||||
- ``STRING1 = STRING2`` returns true if the strings ``STRING1`` and ``STRING2`` are identical.
|
||||
|
||||
- `STRING1 != STRING2` returns true if the strings `STRING1` and `STRING2` are not identical.
|
||||
- ``STRING1 != STRING2`` returns true if the strings ``STRING1`` and ``STRING2`` are not identical.
|
||||
|
||||
- `-n STRING` returns true if the length of `STRING` is non-zero.
|
||||
- ``-n STRING`` returns true if the length of ``STRING`` is non-zero.
|
||||
|
||||
- `-z STRING` returns true if the length of `STRING` is zero.
|
||||
- ``-z STRING`` returns true if the length of ``STRING`` is zero.
|
||||
|
||||
Operators to compare and examine numbers
|
||||
------------
|
||||
|
||||
- `NUM1 -eq NUM2` returns true if `NUM1` and `NUM2` are numerically equal.
|
||||
- ``NUM1 -eq NUM2`` returns true if ``NUM1`` and ``NUM2`` are numerically equal.
|
||||
|
||||
- `NUM1 -ne NUM2` returns true if `NUM1` and `NUM2` are not numerically equal.
|
||||
- ``NUM1 -ne NUM2`` returns true if ``NUM1`` and ``NUM2`` are not numerically equal.
|
||||
|
||||
- `NUM1 -gt NUM2` returns true if `NUM1` is greater than `NUM2`.
|
||||
- ``NUM1 -gt NUM2`` returns true if ``NUM1`` is greater than ``NUM2``.
|
||||
|
||||
- `NUM1 -ge NUM2` returns true if `NUM1` is greater than or equal to `NUM2`.
|
||||
- ``NUM1 -ge NUM2`` returns true if ``NUM1`` is greater than or equal to ``NUM2``.
|
||||
|
||||
- `NUM1 -lt NUM2` returns true if `NUM1` is less than `NUM2`.
|
||||
- ``NUM1 -lt NUM2`` returns true if ``NUM1`` is less than ``NUM2``.
|
||||
|
||||
- `NUM1 -le NUM2` returns true if `NUM1` is less than or equal to `NUM2`.
|
||||
- ``NUM1 -le NUM2`` returns true if ``NUM1`` is less than or equal to ``NUM2``.
|
||||
|
||||
Both integers and floating point numbers are supported.
|
||||
|
||||
Operators to combine expressions
|
||||
------------
|
||||
|
||||
- `COND1 -a COND2` returns true if both `COND1` and `COND2` are true.
|
||||
- ``COND1 -a COND2`` returns true if both ``COND1`` and ``COND2`` are true.
|
||||
|
||||
- `COND1 -o COND2` returns true if either `COND1` or `COND2` are true.
|
||||
- ``COND1 -o COND2`` returns true if either ``COND1`` or ``COND2`` are true.
|
||||
|
||||
Expressions can be inverted using the `!` operator:
|
||||
Expressions can be inverted using the ``!`` operator:
|
||||
|
||||
- `! EXPRESSION` returns true if `EXPRESSION` is false, and false if `EXPRESSION` is true.
|
||||
- ``! EXPRESSION`` returns true if ``EXPRESSION`` is false, and false if ``EXPRESSION`` is true.
|
||||
|
||||
Expressions can be grouped using parentheses.
|
||||
|
||||
- `( EXPRESSION )` returns the value of `EXPRESSION`.
|
||||
- ``( EXPRESSION )`` returns the value of ``EXPRESSION``.
|
||||
|
||||
Note that parentheses will usually require escaping with `\(` to avoid being interpreted as a command substitution.
|
||||
Note that parentheses will usually require escaping with ``\(`` to avoid being interpreted as a command substitution.
|
||||
|
||||
|
||||
Examples
|
||||
------------
|
||||
|
||||
If the `/tmp` directory exists, copy the `/etc/motd` file to it:
|
||||
If the ``/tmp`` directory exists, copy the ``/etc/motd`` file to it:
|
||||
|
||||
|
||||
|
||||
|
@ -118,7 +118,7 @@ If the `/tmp` directory exists, copy the `/etc/motd` file to it:
|
|||
end
|
||||
|
||||
|
||||
If the variable `MANPATH` is defined and not empty, print the contents. (If `MANPATH` is not defined, then it will expand to zero arguments, unless quoted.)
|
||||
If the variable ``MANPATH`` is defined and not empty, print the contents. (If ``MANPATH`` is not defined, then it will expand to zero arguments, unless quoted.)
|
||||
|
||||
|
||||
|
||||
|
@ -129,7 +129,7 @@ If the variable `MANPATH` is defined and not empty, print the contents. (If `MAN
|
|||
end
|
||||
|
||||
|
||||
Parentheses and the `-o` and `-a` operators can be combined to produce more complicated expressions. In this example, success is printed if there is a `/foo` or `/bar` file as well as a `/baz` or `/bat` file.
|
||||
Parentheses and the ``-o`` and ``-a`` operators can be combined to produce more complicated expressions. In this example, success is printed if there is a ``/foo`` or ``/bar`` file as well as a ``/baz`` or ``/bat`` file.
|
||||
|
||||
|
||||
|
||||
|
@ -187,10 +187,10 @@ which is logically equivalent to the following:
|
|||
Standards
|
||||
------------
|
||||
|
||||
`test` implements a subset of the <a href="http://www.unix.com/man-page/POSIX/1/test/">IEEE Std 1003.1-2008 (POSIX.1) standard</a>. The following exceptions apply:
|
||||
``test`` implements a subset of the <a href="http://www.unix.com/man-page/POSIX/1/test/">IEEE Std 1003.1-2008 (POSIX.1) standard</a>. The following exceptions apply:
|
||||
|
||||
- The `<` and `>` operators for comparing strings are not implemented.
|
||||
- The ``<`` and ``>`` operators for comparing strings are not implemented.
|
||||
|
||||
- Because this test is a shell builtin and not a standalone utility, using the -c flag on a special file descriptors like standard input and output may not return the same result when invoked from within a pipe as one would expect when invoking the `test` utility in another shell.
|
||||
- Because this test is a shell builtin and not a standalone utility, using the -c flag on a special file descriptors like standard input and output may not return the same result when invoked from within a pipe as one would expect when invoking the ``test`` utility in another shell.
|
||||
|
||||
In cases such as this, one can use `command` `test` to explicitly use the system's standalone `test` rather than this `builtin` `test`.
|
||||
In cases such as this, one can use ``command`` ``test`` to explicitly use the system's standalone ``test`` rather than this ``builtin`` ``test``.
|
||||
|
|
|
@ -10,27 +10,27 @@ trap [OPTIONS] [[ARG] REASON ... ]
|
|||
Description
|
||||
------------
|
||||
|
||||
`trap` is a wrapper around the fish event delivery framework. It exists for backwards compatibility with POSIX shells. For other uses, it is recommended to define an <a href='index.html#event'>event handler</a>.
|
||||
``trap`` is a wrapper around the fish event delivery framework. It exists for backwards compatibility with POSIX shells. For other uses, it is recommended to define an <a href='index.html#event'>event handler</a>.
|
||||
|
||||
The following parameters are available:
|
||||
|
||||
- `ARG` is the command to be executed on signal delivery.
|
||||
- ``ARG`` is the command to be executed on signal delivery.
|
||||
|
||||
- `REASON` is the name of the event to trap. For example, a signal like `INT` or `SIGINT`, or the special symbol `EXIT`.
|
||||
- ``REASON`` is the name of the event to trap. For example, a signal like ``INT`` or ``SIGINT``, or the special symbol ``EXIT``.
|
||||
|
||||
- `-l` or `--list-signals` prints a list of signal names.
|
||||
- ``-l`` or ``--list-signals`` prints a list of signal names.
|
||||
|
||||
- `-p` or `--print` prints all defined signal handlers.
|
||||
- ``-p`` or ``--print`` prints all defined signal handlers.
|
||||
|
||||
If `ARG` and `REASON` are both specified, `ARG` is the command to be executed when the event specified by `REASON` occurs (e.g., the signal is delivered).
|
||||
If ``ARG`` and ``REASON`` are both specified, ``ARG`` is the command to be executed when the event specified by ``REASON`` occurs (e.g., the signal is delivered).
|
||||
|
||||
If `ARG` is absent (and there is a single REASON) or -, each specified signal is reset to its original disposition (the value it had upon entrance to the shell). If `ARG` is the null string the signal specified by each `REASON` is ignored by the shell and by the commands it invokes.
|
||||
If ``ARG`` is absent (and there is a single REASON) or -, each specified signal is reset to its original disposition (the value it had upon entrance to the shell). If ``ARG`` is the null string the signal specified by each ``REASON`` is ignored by the shell and by the commands it invokes.
|
||||
|
||||
If `ARG` is not present and `-p` has been supplied, then the trap commands associated with each `REASON` are displayed. If no arguments are supplied or if only `-p` is given, `trap` prints the list of commands associated with each signal.
|
||||
If ``ARG`` is not present and ``-p`` has been supplied, then the trap commands associated with each ``REASON`` are displayed. If no arguments are supplied or if only ``-p`` is given, ``trap`` prints the list of commands associated with each signal.
|
||||
|
||||
Signal names are case insensitive and the `SIG` prefix is optional.
|
||||
Signal names are case insensitive and the ``SIG`` prefix is optional.
|
||||
|
||||
The return status is 1 if any `REASON` is invalid; otherwise trap returns 0.
|
||||
The return status is 1 if any ``REASON`` is invalid; otherwise trap returns 0.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
|
@ -10,4 +10,4 @@ true
|
|||
Description
|
||||
------------
|
||||
|
||||
`true` sets the exit status to 0.
|
||||
``true`` sets the exit status to 0.
|
||||
|
|
|
@ -10,23 +10,23 @@ type [OPTIONS] NAME [NAME ...]
|
|||
Description
|
||||
------------
|
||||
|
||||
With no options, `type` indicates how each `NAME` would be interpreted if used as a command name.
|
||||
With no options, ``type`` indicates how each ``NAME`` would be interpreted if used as a command name.
|
||||
|
||||
The following options are available:
|
||||
|
||||
- `-a` or `--all` prints all of possible definitions of the specified names.
|
||||
- ``-a`` or ``--all`` prints all of possible definitions of the specified names.
|
||||
|
||||
- `-f` or `--no-functions` suppresses function and builtin lookup.
|
||||
- ``-f`` or ``--no-functions`` suppresses function and builtin lookup.
|
||||
|
||||
- `-t` or `--type` prints `function`, `builtin`, or `file` if `NAME` is a shell function, builtin, or disk file, respectively.
|
||||
- ``-t`` or ``--type`` prints ``function``, ``builtin``, or ``file`` if ``NAME`` is a shell function, builtin, or disk file, respectively.
|
||||
|
||||
- `-p` or `--path` returns the name of the disk file that would be executed, or nothing if `type -t name` would not return `file`.
|
||||
- ``-p`` or ``--path`` returns the name of the disk file that would be executed, or nothing if ``type -t name`` would not return ``file``.
|
||||
|
||||
- `-P` or `--force-path` returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
|
||||
- ``-P`` or ``--force-path`` returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
|
||||
|
||||
- `-q` or `--quiet` suppresses all output; this is useful when testing the exit status.
|
||||
- ``-q`` or ``--quiet`` suppresses all output; this is useful when testing the exit status.
|
||||
|
||||
The `-q`, `-p`, `-t` and `-P` flags (and their long flag aliases) are mutually exclusive. Only one can be specified at a time.
|
||||
The ``-q``, ``-p``, ``-t`` and ``-P`` flags (and their long flag aliases) are mutually exclusive. Only one can be specified at a time.
|
||||
|
||||
|
||||
Example
|
||||
|
|
|
@ -10,59 +10,59 @@ ulimit [OPTIONS] [LIMIT]
|
|||
Description
|
||||
------------
|
||||
|
||||
`ulimit` builtin sets or outputs the resource usage limits of the shell and any processes spawned by it. If a new limit value is omitted, the current value of the limit of the resource is printed; otherwise, the specified limit is set to the new value.
|
||||
``ulimit`` builtin sets or outputs the resource usage limits of the shell and any processes spawned by it. If a new limit value is omitted, the current value of the limit of the resource is printed; otherwise, the specified limit is set to the new value.
|
||||
|
||||
Use one of the following switches to specify which resource limit to set or report:
|
||||
|
||||
- `-c` or `--core-size`: the maximum size of core files created. By setting this limit to zero, core dumps can be disabled.
|
||||
- ``-c`` or ``--core-size``: the maximum size of core files created. By setting this limit to zero, core dumps can be disabled.
|
||||
|
||||
- `-d` or `--data-size`: the maximum size of a process' data segment.
|
||||
- ``-d`` or ``--data-size``: the maximum size of a process' data segment.
|
||||
|
||||
- `-f` or `--file-size`: the maximum size of files created by the shell.
|
||||
- ``-f`` or ``--file-size``: the maximum size of files created by the shell.
|
||||
|
||||
- `-l` or `--lock-size`: the maximum size that may be locked into memory.
|
||||
- ``-l`` or ``--lock-size``: the maximum size that may be locked into memory.
|
||||
|
||||
- `-m` or `--resident-set-size`: the maximum resident set size.
|
||||
- ``-m`` or ``--resident-set-size``: the maximum resident set size.
|
||||
|
||||
- `-n` or `--file-descriptor-count`: the maximum number of open file descriptors (most systems do not allow this value to be set).
|
||||
- ``-n`` or ``--file-descriptor-count``: the maximum number of open file descriptors (most systems do not allow this value to be set).
|
||||
|
||||
- `-s` or `--stack-size`: the maximum stack size.
|
||||
- ``-s`` or ``--stack-size``: the maximum stack size.
|
||||
|
||||
- `-t` or `--cpu-time`: the maximum amount of CPU time in seconds.
|
||||
- ``-t`` or ``--cpu-time``: the maximum amount of CPU time in seconds.
|
||||
|
||||
- `-u` or `--process-count`: the maximum number of processes available to a single user.
|
||||
- ``-u`` or ``--process-count``: the maximum number of processes available to a single user.
|
||||
|
||||
- `-v` or `--virtual-memory-size` The maximum amount of virtual memory available to the shell.
|
||||
- ``-v`` or ``--virtual-memory-size`` The maximum amount of virtual memory available to the shell.
|
||||
|
||||
Note that not all these limits are available in all operating systems.
|
||||
|
||||
The value of limit can be a number in the unit specified for the resource or one of the special values `hard`, `soft`, or `unlimited`, which stand for the current hard limit, the current soft limit, and no limit, respectively.
|
||||
The value of limit can be a number in the unit specified for the resource or one of the special values ``hard``, ``soft``, or ``unlimited``, which stand for the current hard limit, the current soft limit, and no limit, respectively.
|
||||
|
||||
If limit is given, it is the new value of the specified resource. If no option is given, then `-f` is assumed. Values are in kilobytes, except for `-t`, which is in seconds and `-n` and `-u`, which are unscaled values. The return status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit.
|
||||
If limit is given, it is the new value of the specified resource. If no option is given, then ``-f`` is assumed. Values are in kilobytes, except for ``-t``, which is in seconds and ``-n`` and ``-u``, which are unscaled values. The return status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit.
|
||||
|
||||
`ulimit` also accepts the following switches that determine what type of limit to set:
|
||||
``ulimit`` also accepts the following switches that determine what type of limit to set:
|
||||
|
||||
- `-H` or `--hard` sets hard resource limit
|
||||
- ``-H`` or ``--hard`` sets hard resource limit
|
||||
|
||||
- `-S` or `--soft` sets soft resource limit
|
||||
- ``-S`` or ``--soft`` sets soft resource limit
|
||||
|
||||
A hard limit can only be decreased. Once it is set it cannot be increased; a soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are updated when assigning a new limit value, and the soft limit is used when reporting the current value.
|
||||
|
||||
The following additional options are also understood by `ulimit`:
|
||||
The following additional options are also understood by ``ulimit``:
|
||||
|
||||
- `-a` or `--all` prints all current limits
|
||||
- ``-a`` or ``--all`` prints all current limits
|
||||
|
||||
The `fish` implementation of `ulimit` should behave identically to the implementation in bash, except for these differences:
|
||||
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 it 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 it 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
|
||||
------------
|
||||
|
||||
`ulimit -Hs 64` sets the hard stack size limit to 64 kB.
|
||||
``ulimit -Hs 64`` sets the hard stack size limit to 64 kB.
|
||||
|
||||
|
|
|
@ -10,31 +10,31 @@ umask [OPTIONS] [MASK]
|
|||
Description
|
||||
------------
|
||||
|
||||
`umask` displays and manipulates the "umask", or file creation mode mask, which is used to restrict the default access to files.
|
||||
``umask`` displays and manipulates the "umask", or file creation mode mask, which is used to restrict the default access to files.
|
||||
|
||||
The umask may be expressed either as an octal number, which represents the rights that will be removed by default, or symbolically, which represents the only rights that will be granted by default.
|
||||
|
||||
Access rights are explained in the manual page for the `chmod`(1) program.
|
||||
Access rights are explained in the manual page for the ``chmod``(1) program.
|
||||
|
||||
With no parameters, the current file creation mode mask is printed as an octal number.
|
||||
|
||||
- `-h` or `--help` prints this message.
|
||||
- ``-h`` or ``--help`` prints this message.
|
||||
|
||||
- `-S` or `--symbolic` prints the umask in symbolic form instead of octal form.
|
||||
- ``-S`` or ``--symbolic`` prints the umask in symbolic form instead of octal form.
|
||||
|
||||
- `-p` or `--as-command` outputs the umask in a form that may be reused as input
|
||||
- ``-p`` or ``--as-command`` outputs the umask in a form that may be reused as input
|
||||
|
||||
If a numeric mask is specified as a parameter, the current shell's umask will be set to that value, and the rights specified by that mask will be removed from new files and directories by default.
|
||||
|
||||
If a symbolic mask is specified, the desired permission bits, and not the inverse, should be specified. A symbolic mask is a comma separated list of rights. Each right consists of three parts:
|
||||
|
||||
- The first part specifies to whom this set of right applies, and can be one of `u`, `g`, `o` or `a`, where `u` specifies the user who owns the file, `g` specifies the group owner of the file, `o` specific other users rights and `a` specifies all three should be changed.
|
||||
- The first part specifies to whom this set of right applies, and can be one of ``u``, ``g``, ``o`` or ``a``, where ``u`` specifies the user who owns the file, ``g`` specifies the group owner of the file, ``o`` specific other users rights and ``a`` specifies all three should be changed.
|
||||
|
||||
- The second part of a right specifies the mode, and can be one of `=`, `+` or `-`, where `=` specifies that the rights should be set to the new value, `+` specifies that the specified right should be added to those previously specified and `-` specifies that the specified rights should be removed from those previously specified.
|
||||
- The second part of a right specifies the mode, and can be one of ``=``, ``+`` or ``-``, where ``=`` specifies that the rights should be set to the new value, ``+`` specifies that the specified right should be added to those previously specified and ``-`` specifies that the specified rights should be removed from those previously specified.
|
||||
|
||||
- The third part of a right specifies what rights should be changed and can be any combination of `r`, `w` and `x`, representing read, write and execute rights.
|
||||
- The third part of a right specifies what rights should be changed and can be any combination of ``r``, ``w`` and ``x``, representing read, write and execute rights.
|
||||
|
||||
If the first and second parts are skipped, they are assumed to be `a` and `=`, respectively. As an example, `r,u+w` means all users should have read access and the file owner should also have write access.
|
||||
If the first and second parts are skipped, they are assumed to be ``a`` and ``=``, respectively. As an example, ``r,u+w`` means all users should have read access and the file owner should also have write access.
|
||||
|
||||
Note that symbolic masks currently do not work as intended.
|
||||
|
||||
|
@ -42,4 +42,4 @@ Note that symbolic masks currently do not work as intended.
|
|||
Example
|
||||
------------
|
||||
|
||||
`umask 177` or `umask u=rw` sets the file creation mask to read and write for the owner and no permissions at all for any other users.
|
||||
``umask 177`` or ``umask u=rw`` sets the file creation mask to read and write for the owner and no permissions at all for any other users.
|
||||
|
|
|
@ -10,10 +10,10 @@ vared VARIABLE_NAME
|
|||
Description
|
||||
------------
|
||||
|
||||
`vared` is used to interactively edit the value of an environment variable. Array variables as a whole can not be edited using `vared`, but individual array elements can.
|
||||
``vared`` is used to interactively edit the value of an environment variable. Array variables as a whole can not be edited using ``vared``, but individual array elements can.
|
||||
|
||||
|
||||
Example
|
||||
------------
|
||||
|
||||
`vared PATH[3]` edits the third element of the PATH array
|
||||
``vared PATH[3]`` edits the third element of the PATH array
|
||||
|
|
|
@ -10,12 +10,12 @@ wait [-n | --any] [PID | PROCESS_NAME] ...
|
|||
Description
|
||||
------------
|
||||
|
||||
`wait` waits for child jobs to complete.
|
||||
``wait`` waits for child jobs to complete.
|
||||
|
||||
- If a pid is specified, the command waits for the job that the process with the pid belongs to.
|
||||
- If a process name is specified, the command waits for the jobs that the matched processes belong to.
|
||||
- If neither a pid nor a process name is specified, the command waits for all background jobs.
|
||||
- If the `-n` / `--any` flag is provided, the command returns as soon as the first job completes. If it is not provided, it returns after all jobs complete.
|
||||
- If the ``-n`` / ``--any`` flag is provided, the command returns as soon as the first job completes. If it is not provided, it returns after all jobs complete.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
@ -27,7 +27,7 @@ Example
|
|||
sleep 10 &
|
||||
wait $last_pid
|
||||
|
||||
spawns `sleep` in the background, and then waits until it finishes.
|
||||
spawns ``sleep`` in the background, and then waits until it finishes.
|
||||
|
||||
|
||||
::
|
||||
|
@ -44,4 +44,4 @@ spawns five jobs in the background, and then waits until all of them finishes.
|
|||
hoge &
|
||||
wait sleep
|
||||
|
||||
spawns five jobs and `hoge` in the background, and then waits until all `sleep`s finishes, and doesn't wait for `hoge` finishing.
|
||||
spawns five jobs and ``hoge`` in the background, and then waits until all ``sleep``s finishes, and doesn't wait for ``hoge`` finishing.
|
||||
|
|
|
@ -10,14 +10,14 @@ while CONDITION; COMMANDS...; end
|
|||
Description
|
||||
------------
|
||||
|
||||
`while` repeatedly executes `CONDITION`, and if the exit status is 0, then executes `COMMANDS`.
|
||||
``while`` repeatedly executes ``CONDITION``, and if the exit status is 0, then executes ``COMMANDS``.
|
||||
|
||||
If the exit status of `CONDITION` is non-zero on the first iteration, `COMMANDS` will not be
|
||||
executed at all, and the exit status of the loop set to the exit status of `CONDITION`.
|
||||
If the exit status of ``CONDITION`` is non-zero on the first iteration, ``COMMANDS`` will not be
|
||||
executed at all, and the exit status of the loop set to the exit status of ``CONDITION``.
|
||||
|
||||
The exit status of the loop is 0 otherwise.
|
||||
|
||||
You can use <a href="#and">`and`</a> or <a href="#or">`or`</a> for complex conditions. Even more complex control can be achieved with `while true` containing a <a href="#break">break</a>.
|
||||
You can use <a href="#and">``and``</a> or <a href="#or">``or``</a> for complex conditions. Even more complex control can be achieved with ``while true`` containing a <a href="#break">break</a>.
|
||||
|
||||
Example
|
||||
------------
|
||||
|
|
Loading…
Reference in a new issue