diff --git a/sphinx_doc_src/cmds/block.rst b/sphinx_doc_src/cmds/block.rst index dc786dd9a..b0f055875 100644 --- a/sphinx_doc_src/cmds/block.rst +++ b/sphinx_doc_src/cmds/block.rst @@ -32,24 +32,21 @@ The following parameters are available: Example ------- - - :: # Create a function that listens for events function --on-event foo foo; echo 'foo fired'; end - + # Block the delivery of events block -g - + emit foo # No output will be produced - + block -e # 'foo fired' will now be printed - Notes ----- diff --git a/sphinx_doc_src/cmds/nextd.rst b/sphinx_doc_src/cmds/nextd.rst index 05173e846..0c2457af6 100644 --- a/sphinx_doc_src/cmds/nextd.rst +++ b/sphinx_doc_src/cmds/nextd.rst @@ -29,13 +29,13 @@ Example cd /usr/src # Working directory is now /usr/src - + cd /usr/src/fish-shell # Working directory is now /usr/src/fish-shell - + prevd # Working directory is now /usr/src - + nextd # Working directory is now /usr/src/fish-shell diff --git a/sphinx_doc_src/cmds/popd.rst b/sphinx_doc_src/cmds/popd.rst index 96cd28eb5..29467fd47 100644 --- a/sphinx_doc_src/cmds/popd.rst +++ b/sphinx_doc_src/cmds/popd.rst @@ -19,18 +19,16 @@ You may be interested in the :ref:`cdh ` command which provides a more Example ------- - - :: pushd /usr/src # Working directory is now /usr/src # Directory stack contains /usr/src - + pushd /usr/src/fish-shell # Working directory is now /usr/src/fish-shell # Directory stack contains /usr/src /usr/src/fish-shell - + popd # Working directory is now /usr/src # Directory stack contains /usr/src diff --git a/sphinx_doc_src/cmds/prevd.rst b/sphinx_doc_src/cmds/prevd.rst index e5b444220..0bbf57157 100644 --- a/sphinx_doc_src/cmds/prevd.rst +++ b/sphinx_doc_src/cmds/prevd.rst @@ -29,13 +29,13 @@ Example cd /usr/src # Working directory is now /usr/src - + cd /usr/src/fish-shell # Working directory is now /usr/src/fish-shell - + prevd # Working directory is now /usr/src - + nextd # Working directory is now /usr/src/fish-shell diff --git a/sphinx_doc_src/cmds/prompt_pwd.rst b/sphinx_doc_src/cmds/prompt_pwd.rst index fcd38f3f3..0ee7a0ea4 100644 --- a/sphinx_doc_src/cmds/prompt_pwd.rst +++ b/sphinx_doc_src/cmds/prompt_pwd.rst @@ -19,22 +19,19 @@ To change the number of characters per path component, set $fish_prompt_pwd_dir_ Examples -------- - - :: >_ cd ~/ >_ echo $PWD /home/alfa - + >_ prompt_pwd ~ - + >_ cd /tmp/banana/sausage/with/mustard >_ prompt_pwd /t/b/s/w/mustard - + >_ set -g fish_prompt_pwd_dir_length 3 >_ prompt_pwd /tmp/ban/sau/wit/mustard - diff --git a/sphinx_doc_src/cmds/psub.rst b/sphinx_doc_src/cmds/psub.rst index d63edb3d0..dea5f2187 100644 --- a/sphinx_doc_src/cmds/psub.rst +++ b/sphinx_doc_src/cmds/psub.rst @@ -25,13 +25,11 @@ The following options are available: Example ------- - - :: diff (sort a.txt | psub) (sort b.txt | psub) # 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. diff --git a/sphinx_doc_src/cmds/pushd.rst b/sphinx_doc_src/cmds/pushd.rst index a4e97544d..727b11cf6 100644 --- a/sphinx_doc_src/cmds/pushd.rst +++ b/sphinx_doc_src/cmds/pushd.rst @@ -27,27 +27,24 @@ You may be interested in the :ref:`cdh ` command which provides a more Example ------- - - :: pushd /usr/src # Working directory is now /usr/src # Directory stack contains /usr/src - + pushd /usr/src/fish-shell # Working directory is now /usr/src/fish-shell # Directory stack contains /usr/src /usr/src/fish-shell - + pushd /tmp/ # Working directory is now /tmp # Directory stack contains /tmp /usr/src /usr/src/fish-shell - + pushd +1 # Working directory is now /usr/src # Directory stack contains /usr/src /usr/src/fish-shell /tmp - + popd # Working directory is now /usr/src/fish-shell # Directory stack contains /usr/src/fish-shell /tmp - diff --git a/sphinx_doc_src/cmds/read.rst b/sphinx_doc_src/cmds/read.rst index 16568c0ae..1bed7993c 100644 --- a/sphinx_doc_src/cmds/read.rst +++ b/sphinx_doc_src/cmds/read.rst @@ -89,16 +89,14 @@ The following code stores the value 'hello' in the shell variable ``$foo``. :: echo hello|read foo - + # This is a neat way to handle command output by-line: printf '%s\n' line1 line2 line3 line4 | while read -l foo echo "This is another line: $foo" end - + # Delimiters given via "-d" are taken as one string echo a==b==c | read -d == -l a b c echo $a # a echo $b # b echo $c # c - - diff --git a/sphinx_doc_src/cmds/set.rst b/sphinx_doc_src/cmds/set.rst index fe5aab282..068642ab5 100644 --- a/sphinx_doc_src/cmds/set.rst +++ b/sphinx_doc_src/cmds/set.rst @@ -96,29 +96,28 @@ Examples # Prints all global, exported variables. set -xg - + # Sets the value of the variable $foo to be 'hi'. set foo hi - + # Appends the value "there" to the variable $foo. set -a foo there - + # Does the same thing as the previous two commands the way it would be done pre-fish 3.0. set foo hi set foo $foo there - + # Removes the variable $smurf set -e smurf - + # Changes the fourth element of the $PATH list to ~/bin set PATH[4] ~/bin - + # Outputs the path to Python if ``type -p`` returns true. if set python_path (type -p python) echo "Python is at $python_path" end - Notes ----- diff --git a/sphinx_doc_src/cmds/string.rst b/sphinx_doc_src/cmds/string.rst index 16478d5a8..83df2e2b3 100644 --- a/sphinx_doc_src/cmds/string.rst +++ b/sphinx_doc_src/cmds/string.rst @@ -129,7 +129,7 @@ Exit status: 0 if at least one match was found, or 1 otherwise. ------------------- ``string repeat [(-n | --count) COUNT] [(-m | --max) MAX] [(-N | --no-newline)] [(-q | --quiet)] [STRING...]`` - + ``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 @@ -162,7 +162,7 @@ See also ``read --delimiter``. ------------------- ``string split0 [(-m | --max) MAX] [(-n | --no-empty)] [(-q | --quiet)] [(-r | --right)] [STRING...]`` - + ``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. @@ -171,14 +171,14 @@ See also ``read --delimiter``. ---------------- ``string sub [(-s | --start) START] [(-l | --length) LENGTH] [(-q | --quiet)] [STRING...]`` - + ``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 [(-l | --left)] [(-r | --right)] [(-c | --chars CHARS)] [(-q | --quiet)] [STRING...]`` - + ``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 @@ -261,89 +261,66 @@ Like ``sed``\ s `s/` command, ``string replace`` still prints strings that don't Examples -------- - - :: >_ string length 'hello, world' 12 - + >_ set str foo >_ string length -q $str; echo $status 0 # Equivalent to test -n $str - - - :: >_ string sub --length 2 abcde ab - + >_ string sub -s 2 -l 2 abcde bc - + >_ string sub --start=-2 abcde de - - - :: >_ string split . example.com example com - + >_ string split -r -m1 / /usr/local/bin/fish /usr/local/bin fish - + >_ string split '' abc a b c - - - :: >_ seq 3 | string join ... 1...2...3 - - - :: >_ string trim ' abc ' abc - + >_ string trim --right --chars=yz xyzzy zany x zan - - - :: >_ echo \\x07 | string escape cg - - - :: >_ string escape --style=var 'a1 b2'\\u6161 a1_20b2__c_E6_85_A1 - - - :: >_ echo \"(echo one\ntwo\nthree | string collect)\" @@ -351,7 +328,7 @@ Examples two three " - + >_ echo \"(echo one\ntwo\nthree | string collect -N)\" "one two @@ -361,49 +338,42 @@ Examples Match Glob Examples ------------------- - - :: >_ string match '?' a a - + >_ string match 'a*b' axxb axxb - + >_ string match -i 'a??B' Axxb Axxb - + >_ echo 'ok?' | string match '*\\?' ok? - + # Note that only the second STRING will match here. >_ string match 'foo' 'foo1' 'foo' 'foo2' foo - + >_ string match -e 'foo' 'foo1' 'foo' 'foo2' foo1 foo foo2 - - + >_ string match 'foo?' 'foo1' 'foo' 'foo2' foo1 foo foo2 - - Match Regex Examples -------------------- - - :: >_ string match -r 'cat|dog|fish' 'nice dog' dog - + >_ string match -r -v "c.*[12]" {cat,dog}(seq 1 4) dog1 dog2 @@ -411,99 +381,86 @@ Match Regex Examples dog3 cat4 dog4 - + >_ string match -r '(\\d\\d?):(\\d\\d):(\\d\\d)' 2:34:56 2:34:56 2 34 56 - + >_ string match -r '^(\\w{{2,4}})\\g1$' papa mud murmur papa pa murmur mur - + >_ string match -r -a -n at ratatat 2 2 4 2 6 2 - + >_ string match -r -i '0x[0-9a-f]{{1,8}}' 'int magic = 0xBadC0de;' 0xBadC0de - NUL Delimited Examples ---------------------- - - :: >_ # Count files in a directory, without being confused by newlines. >_ count (find . -print0 | string split0) 42 - + >_ # Sort a list of elements which may contain newlines >_ set foo beta alpha\\ngamma >_ set foo (string join0 $foo | sort -z | string split0) >_ string escape $foo[1] alpha\\ngamma - Replace Literal Examples ------------------------ - - :: >_ string replace is was 'blue is my favorite' blue was my favorite - + >_ string replace 3rd last 1st 2nd 3rd 1st 2nd last - + >_ string replace -a ' ' _ 'spaces to underscores' spaces_to_underscores - Replace Regex Examples ---------------------- - - :: >_ string replace -r -a '[^\\d.]+' ' ' '0 one two 3.14 four 5x' 0 3.14 5 - + >_ string replace -r '(\\w+)\\s+(\\w+)' '$2 $1 $$' 'left right' right left $ - + >_ string replace -r '\\s*newline\\s*' '\\n' 'put a newline here' put a here - Repeat Examples --------------- - - :: >_ string repeat -n 2 'foo ' foo foo - + >_ echo foo | string repeat -n 2 foofoo - + >_ string repeat -n 2 -m 5 'foo' foofo - + >_ string repeat -m 5 'foo' foofo -