mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-28 07:31:14 -03:00
editorconfig / doc_src: trim trailing whitespace
Commit 0893134543 (Added .editorconfig file (#3332) (#3313),
2016-08-25) trimmed trailing whitespace for Markdown file (which do
have significant trailing whitespace) but ReStructuredText does not,
and none of our Markdown files cares about this, so let's clean up
whitespace always.
This commit is contained in:
@@ -46,7 +46,7 @@ Combining these features, it is possible to create custom syntaxes, where a regu
|
||||
|
||||
> abbr >> ~/.config/fish/config.fish
|
||||
> abbr --erase (abbr --list)
|
||||
|
||||
|
||||
Alternatively you can keep them in a separate :ref:`configuration file <configuration>` by doing something like the following::
|
||||
|
||||
> abbr > ~/.config/fish/conf.d/myabbrs.fish
|
||||
|
||||
@@ -46,12 +46,12 @@ The following code will create ``rmi``, which runs ``rm`` with additional argume
|
||||
::
|
||||
|
||||
alias rmi="rm -i"
|
||||
|
||||
|
||||
# This is equivalent to entering the following function:
|
||||
function rmi --wraps rm --description 'alias rmi=rm -i'
|
||||
rm -i $argv
|
||||
end
|
||||
|
||||
|
||||
``alias`` sometimes requires escaping, as you can see here::
|
||||
|
||||
# This needs to have the spaces escaped or "Chrome.app..."
|
||||
|
||||
@@ -33,10 +33,10 @@ The following code sets a number of variables inside of a block scope. Since the
|
||||
|
||||
begin
|
||||
set -l PIRATE Yarrr
|
||||
|
||||
|
||||
...
|
||||
end
|
||||
|
||||
|
||||
echo $PIRATE
|
||||
# This will not output anything, since the PIRATE variable
|
||||
# went out of scope at the end of the block
|
||||
|
||||
@@ -41,7 +41,7 @@ Examples
|
||||
|
||||
cd
|
||||
# changes the working directory to your home directory.
|
||||
|
||||
|
||||
cd /usr/src/fish-shell
|
||||
# changes the working directory to /usr/src/fish-shell
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ Example
|
||||
|
||||
count $PATH
|
||||
# Returns the number of directories in the users PATH variable.
|
||||
|
||||
|
||||
count *.txt
|
||||
# Returns the number of files in the current working directory
|
||||
# ending with the suffix '.txt'.
|
||||
|
||||
@@ -27,7 +27,7 @@ The following code first defines an event handler for the generic event named 't
|
||||
function event_test --on-event test_event
|
||||
echo event test: $argv
|
||||
end
|
||||
|
||||
|
||||
emit test_event something
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ Synopsis
|
||||
.. synopsis::
|
||||
|
||||
begin
|
||||
[COMMANDS ...]
|
||||
[COMMANDS ...]
|
||||
end
|
||||
|
||||
.. synopsis::
|
||||
|
||||
@@ -13,7 +13,7 @@ Synopsis
|
||||
Description
|
||||
-----------
|
||||
|
||||
``export`` is a function included for compatibility with POSIX shells. In general, the :doc:`set <set>`
|
||||
``export`` is a function included for compatibility with POSIX shells. In general, the :doc:`set <set>`
|
||||
builtin should be used instead.
|
||||
|
||||
When called without arguments, ``export`` prints a list of currently-exported variables, like ``set
|
||||
|
||||
@@ -51,7 +51,7 @@ The following options are available:
|
||||
when :command:`fish` exits, output timing information on all executed commands to the specified file.
|
||||
This excludes time spent starting up and reading the configuration.
|
||||
|
||||
**--profile-startup=PROFILE_FILE**
|
||||
**--profile-startup=PROFILE_FILE**
|
||||
Will write timing for ``fish`` startup to specified file.
|
||||
|
||||
**-P** or **--private**
|
||||
|
||||
@@ -50,6 +50,6 @@ This refuses to store any immediate "vault", "mysql" or "ls" calls. Commands sta
|
||||
and string match -qr "^/home/me/my-secret-project/" -- (pwd -P)
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ Example
|
||||
::
|
||||
|
||||
for i in foo bar baz; echo $i; end
|
||||
|
||||
|
||||
# would output:
|
||||
foo
|
||||
bar
|
||||
|
||||
@@ -85,7 +85,7 @@ will run the ``ls`` command, using the ``-l`` option, while passing on any addit
|
||||
# prints: [DEBUG] foo: bar
|
||||
|
||||
# OR
|
||||
|
||||
|
||||
function debug2 -a var
|
||||
echo [DEBUG] $var: $$var >&2
|
||||
end
|
||||
@@ -106,7 +106,7 @@ will create a ``debug`` command to print chosen variables to `stderr`.
|
||||
if test $status = 0
|
||||
switch $argv[(count $argv)]
|
||||
case '-*'
|
||||
|
||||
|
||||
case '*'
|
||||
cd $argv[(count $argv)]
|
||||
return
|
||||
@@ -124,7 +124,7 @@ This will run the ``mkdir`` command, and if it is successful, change the current
|
||||
function notify
|
||||
set -l job (jobs -l -g)
|
||||
or begin; echo "There are no jobs" >&2; return 1; end
|
||||
|
||||
|
||||
function _notify_job_$job --on-job-exit $job --inherit-variable job
|
||||
echo -n \a # beep
|
||||
functions -e _notify_job_$job
|
||||
|
||||
@@ -82,10 +82,10 @@ Examples
|
||||
|
||||
functions -n
|
||||
# Displays a list of currently-defined functions
|
||||
|
||||
|
||||
functions -c foo bar
|
||||
# Copies the 'foo' function to a new function called 'bar'
|
||||
|
||||
|
||||
functions -e bar
|
||||
# Erases the function ``bar``
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ Examples
|
||||
# This is the same as above: "-f" is "--type=file", "-d" is "--type=dir",
|
||||
# "-x" is short for "--perm=exec" and "-w" short for "--perm=write"!
|
||||
/home/me
|
||||
|
||||
|
||||
>_ path filter -fx $PATH/*
|
||||
# Prints all possible commands - the first entry of each name is what fish would execute!
|
||||
|
||||
@@ -306,7 +306,7 @@ Examples
|
||||
>_ path normalize /bin//bash
|
||||
# The "//" is squashed, but /bin isn't resolved even if your system links it to /usr/bin.
|
||||
/bin/bash
|
||||
|
||||
|
||||
>_ path normalize ./my/subdirs/../sub2
|
||||
my/sub2
|
||||
|
||||
@@ -337,7 +337,7 @@ Examples
|
||||
# The "//" is squashed, and /bin is resolved if your system links it to /usr/bin.
|
||||
# sh here is bash (this is common on linux systems)
|
||||
/usr/bin/bash
|
||||
|
||||
|
||||
>_ path resolve /bin/foo///bar/../baz
|
||||
# Assuming /bin exists and is a symlink to /usr/bin, but /bin/foo doesn't.
|
||||
# This resolves the /bin/ and normalizes the nonexistent rest:
|
||||
@@ -381,7 +381,7 @@ Examples
|
||||
|
||||
>_ path change-extension '' ~/.config.
|
||||
/home/alfa/.config
|
||||
|
||||
|
||||
"sort" subcommand
|
||||
-----------------------------
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ The *FORMAT* argument is re-used as many times as necessary to convert all of th
|
||||
|
||||
Unlike :doc:`echo <echo>`, ``printf`` does not append a new line unless it is specified as part of the string.
|
||||
|
||||
It doesn't support any options, so there is no need for a ``--`` separator, which makes it easier to use for arbitrary input than ``echo``. [#]_
|
||||
It doesn't support any options, so there is no need for a ``--`` separator, which makes it easier to use for arbitrary input than ``echo``. [#]_
|
||||
|
||||
Format Specifiers
|
||||
-----------------
|
||||
|
||||
@@ -44,7 +44,7 @@ Example
|
||||
The following code will count down from a random even number between 10 and 20 to 1:
|
||||
|
||||
::
|
||||
|
||||
|
||||
for i in (seq (random 10 2 20) -1 1)
|
||||
echo $i
|
||||
end
|
||||
@@ -62,5 +62,5 @@ Or, to only get even numbers from 2 to 20::
|
||||
random 2 2 20
|
||||
|
||||
Or odd numbers from 1 to 3::
|
||||
|
||||
|
||||
random 1 2 3 # or 1 2 4
|
||||
|
||||
@@ -46,7 +46,7 @@ Examples
|
||||
# depending on $fish_emoji_width, this is either 4 or 8
|
||||
# in new terminals it should be
|
||||
8
|
||||
|
||||
|
||||
>_ string length --visible abcdef\r123
|
||||
# this displays as "123def", so the width is 6
|
||||
6
|
||||
|
||||
@@ -89,7 +89,7 @@ See Also
|
||||
.. BEGIN SEEALSO
|
||||
|
||||
- :doc:`string pad <string-pad>` does the inverse of this command, adding padding to a specific width instead.
|
||||
|
||||
|
||||
- The :doc:`printf <printf>` command can do simple padding, for example ``printf %10s\n`` works like ``string pad -w10``.
|
||||
|
||||
- :doc:`string length <string-length>` with the ``--visible`` option can be used to show what fish thinks the width is.
|
||||
|
||||
@@ -55,7 +55,7 @@ Example
|
||||
::
|
||||
|
||||
>_ time sleep 1s
|
||||
|
||||
|
||||
________________________________________________________
|
||||
Executed in 1,01 secs fish external
|
||||
usr time 2,32 millis 0,00 micros 2,32 millis
|
||||
|
||||
@@ -95,5 +95,5 @@ And here is the full list:
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
|
||||
cmds/*
|
||||
|
||||
@@ -263,7 +263,7 @@ and could be written in other shells as
|
||||
xterm
|
||||
rxvt-unicode
|
||||
EOF
|
||||
|
||||
|
||||
So heredocs really are minor syntactical sugar that introduces a lot of special rules, which is why fish doesn't have them. Pipes are a core concept, and are simpler and compose nicer.
|
||||
|
||||
.. [#] For example, the "EOF" is just a convention, the terminator can be an arbitrary string, something like "THISISTHEEND" also works. And using ``<<-`` trims leading *tab* characters (but not other whitespace), so you can indent the lines, but only with tabs. Substitutions (variables, commands) are done on the heredoc by default, but not if the terminator is quoted: ``cat << "EOF"``.
|
||||
@@ -341,7 +341,7 @@ Fish's blocking constructs look a little different. They all start with a word,
|
||||
done
|
||||
|
||||
# becomes
|
||||
|
||||
|
||||
for i in 1 2 3
|
||||
echo $i
|
||||
end
|
||||
@@ -361,7 +361,7 @@ Fish's blocking constructs look a little different. They all start with a word,
|
||||
}
|
||||
|
||||
# becomes
|
||||
|
||||
|
||||
begin
|
||||
echo Hello
|
||||
end
|
||||
|
||||
@@ -110,7 +110,7 @@ This will call ``env``, which then goes through :envvar:`PATH` to find a program
|
||||
The shebang line is only used when scripts are executed without specifying the interpreter. For functions inside fish or when executing a script with ``fish /path/to/script``, a shebang is not required (but it doesn't hurt!).
|
||||
|
||||
When executing files without an interpreter, fish, like other shells, tries your system shell, typically ``/bin/sh``. This is needed because some scripts are shipped without a shebang line.
|
||||
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
@@ -158,7 +158,7 @@ Other help pages
|
||||
================
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
|
||||
self
|
||||
faq
|
||||
interactive
|
||||
|
||||
@@ -446,7 +446,7 @@ The ``fish_vi_cursor`` function will be used to change the cursor's shape depend
|
||||
# Set the replace mode cursors to an underscore
|
||||
set fish_cursor_replace_one underscore
|
||||
set fish_cursor_replace underscore
|
||||
# Set the external cursor to a line. The external cursor appears when a command is started.
|
||||
# Set the external cursor to a line. The external cursor appears when a command is started.
|
||||
# The cursor shape takes the value of fish_cursor_default when fish_cursor_external is not specified.
|
||||
set fish_cursor_external line
|
||||
# The following variable can be used to configure cursor shape in
|
||||
@@ -592,7 +592,7 @@ To find out the name of a key, you can use :doc:`fish_key_reader <cmds/fish_key_
|
||||
> fish_key_reader # Press Alt + right-arrow
|
||||
Press a key:
|
||||
bind alt-right 'do something'
|
||||
|
||||
|
||||
Note that the historical way the terminal encodes keys and sends them to the application (fish, in this case) makes a lot of combinations indistinguishable or unbindable. In the usual encoding, :kbd:`ctrl-i` *is the same* as the tab key, and shift cannot be detected when ctrl is also pressed.
|
||||
|
||||
There are more powerful encoding schemes, and fish tries to tell the terminal to turn them on, but there are still many terminals that do not support them. When ``fish_key_reader`` prints the same sequence for two different keys, then that is because your terminal sends the same sequence for them, and there isn't anything fish can do about it. It is our hope that these schemes will become more widespread, making input more flexible.
|
||||
|
||||
@@ -1178,7 +1178,7 @@ All variables in fish have a scope. For example they can be global or local to a
|
||||
|
||||
echo $name, I am $place and my instrument is $instrument
|
||||
# Will print:
|
||||
# Patrick, I am at the Krusty Krab and my instrument is
|
||||
# Patrick, I am at the Krusty Krab and my instrument is
|
||||
|
||||
There are four kinds of variable scopes in fish: universal, global, function and local variables.
|
||||
|
||||
|
||||
@@ -113,9 +113,9 @@ It's useful to display this in your prompt, but showing it when it's 0 seems kin
|
||||
First of all, since every command (except for :doc:`set <cmds/set>`) changes the status, you need to store it for later use as the first thing in your prompt. Use a :ref:`local variable <variables-scope>` so it will be confined to your prompt function::
|
||||
|
||||
set -l last_status $status
|
||||
|
||||
|
||||
And after that, you can set a string if it is not zero::
|
||||
|
||||
|
||||
# Prompt status only if it's not 0
|
||||
set -l stat
|
||||
if test $last_status -ne 0
|
||||
@@ -125,7 +125,7 @@ And after that, you can set a string if it is not zero::
|
||||
And to print it, we add it to our ``string join``::
|
||||
|
||||
string join '' -- (set_color green) (prompt_pwd) (set_color normal) $stat '>'
|
||||
|
||||
|
||||
If ``$last_status`` was 0, ``$stat`` is empty, and so it will simply disappear.
|
||||
|
||||
So our entire prompt is now::
|
||||
|
||||
@@ -323,7 +323,7 @@ This also means that, if the list is empty, there will be no argument::
|
||||
|
||||
> set empty # no argument
|
||||
> echo $empty/this_is_gone # prints an empty line
|
||||
|
||||
|
||||
If you quote the list, it will be used as one string and so you'll get one argument even if it is empty.
|
||||
|
||||
For more, see :ref:`Lists <variables-lists>`.
|
||||
@@ -431,7 +431,7 @@ Like other shells, fish allows multiple commands either on separate lines or the
|
||||
To write them on the same line, use the semicolon (";"). That means the following two examples are equivalent::
|
||||
|
||||
echo fish; echo chips
|
||||
|
||||
|
||||
# or
|
||||
echo fish
|
||||
echo chips
|
||||
@@ -504,9 +504,9 @@ To compare strings or numbers or check file properties (whether a file exists or
|
||||
if test "$fish" = "flounder"
|
||||
echo FLOUNDER
|
||||
end
|
||||
|
||||
|
||||
# or
|
||||
|
||||
|
||||
if test "$number" -gt 5
|
||||
echo $number is greater than five
|
||||
else
|
||||
@@ -698,9 +698,9 @@ It is possible to directly create functions and variables in ``config.fish`` fil
|
||||
::
|
||||
|
||||
> cat ~/.config/fish/config.fish
|
||||
|
||||
|
||||
set -x PATH $PATH /sbin/
|
||||
|
||||
|
||||
function ll
|
||||
ls -lh $argv
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user