Commit Graph

1617 Commits

Author SHA1 Message Date
Johannes Altmanninger
851512a7cc complete.rst: clarify in synopsis that -c/-p take an argument
Correct the grammar by moving the options after the command argument.
Also group the -c/--command and -p/--path pairs, to convey that the
short and long variants are equivalent.

While at it, consolidate the -C/--do-complete forms, like we usually
do.
2022-01-16 14:05:47 +01:00
Johannes Altmanninger
115615b831 psub.rst: add long option to synopsis 2022-01-16 14:05:47 +01:00
Johannes Altmanninger
d9287ec471 set.rst: fix synopsis glitch and make placeholder uppercase
One synopsis misrenders as

    set [options] VARIABLE*[*INDICES]… VALUES…

Add a missing backslash to fix that.  Also go back to uppercase
because I'm not sure why this was changed to lowercase.

Finally, remove the spurious ellipsis after VARIABLE[INDICES].
This element cannot be repeated. Multiple index values and ranges
can be specified but that's already implied by the plural INDICES.
2022-01-16 14:05:47 +01:00
Johannes Altmanninger
dd8351d1b4 history.rst: fix BNF syntax for orthogonal options
These can be used alone, or in combination, let's reflect that in
the synopsis.
2022-01-16 14:05:47 +01:00
Johannes Altmanninger
a7f45b05b7 history.rst: fix wrong subcommand name and unconventional braces
For alteration we usually use "(a | b)", not "{a | b}".

While at it, instead of writing 4/6 subcommands in one line, write them
on separate lines, so it's very obvious that all these are separate
subcommands. We mainly use the (a | b) syntax for long/short options.
2022-01-16 14:05:47 +01:00
Johannes Altmanninger
0d6bad9660 history.rst: don't mention the --show-time option for "history delete"
It's ignored.  We could support it in future (and maybe throw an
"unsupported" error until then).
2022-01-16 14:05:47 +01:00
Johannes Altmanninger
19aebebb95 math.rst: remove stray mention of -- separator from synopsis
The -- is not special here and we don't mention it in other synopses.

It was originally added for a good reason in 98449fec5 (fix `math`
regression, 2017-07-14), along this addition to math.rst:

> You should always place a `--` flag separator before the expression. [...]

However, since 56d913453 (Cache math expressions, 2017-08-24) that
line was changed to

> You don't need to use `--` before the expression even if it begins with a minus sign [...]
2022-01-16 14:05:47 +01:00
Johannes Altmanninger
6df86c6c23 math.rst: use 4 spaces instead of a tab for indentation
I personally prefer tabs but we always use spaces, so this is much
less surprising.
2022-01-16 14:05:47 +01:00
Fabian Homborg
0781473564 argparse: Jump to the next option after an unknown one
Previously, when we got an unknown option with --ignore-unknown, we
would increment woptind but still try to read the same contents.

This means in e.g.

```
argparse -i h -- -ooo -h
```

The `-h` would also be skipped as an option, because after the first
`-o` getopt reads the other two `-o` and skips that many options.

This could be handled more extensively in wgetopt, but the simpler fix
is to just skip to the next argv entry once we have an unknown option
- there's nothing more we can do with it anyway!

Additionally, document this and clearly explain that we currently
don't transform the option.

Fixes #8637
2022-01-15 12:17:43 +01:00
Fabian Homborg
8e60f1b4a3 docs: Set doc language
This sets the html lang= attribute, which should be useful for
accessibility (screenreaders).
2022-01-14 18:54:01 +01:00
Fabian Homborg
e27456df24 css: Use same font for headers
For some reason classic.css gives these a special font. Let's just
pick the body font again.
2022-01-13 19:25:44 +01:00
Fabian Homborg
7a3594d840 docs: Increase contrast in dark theme for header/footer
This was flagged by one of those WCAG checkers, and there's no real
reason to introduce another color here.
2022-01-13 17:07:04 +01:00
Fabian Homborg
9220b96531 Make inline code color a little bluer 2022-01-13 16:23:54 +01:00
Fabian Homborg
e2157d09df Add a background and some padding to inline-code
This allows it to be distinguished not just based on the font.

Not adding a border because that's a bit much.
2022-01-13 16:23:54 +01:00
Fabian Homborg
30dc91225e css: Pick nicer fonts
Unfortunately the normal font families like "sans-serif" and
"monospace" are basically broken because the browser defaults are
decades old.

TODO: Inline code is barely distinguishable.
2022-01-13 16:23:54 +01:00
Fabian Homborg
9eb1b7a9ae Revert "index.rst: don't mention current page under "Other help pages""
Unfortunately this removes the index also from the sidebar in other pages. This makes it basically inaccessible.

Maybe there is a way to not show it in the list at the bottom, but this isn't it. Maybe a manual list of pages instead of reusing the TOC?

This reverts commit b5a95317f0.
2022-01-12 21:42:16 +01:00
Fabian Homborg
c6fa2ec82f
Doc theme: Stop picking specific code fonts again
d54c8a42a9 reintroduced #7714 by picking Source Code Pro again, which is *broken* on MacOS.
2022-01-12 12:48:14 +01:00
David Adam
5ee389592c Bump copyright year 2022-01-09 23:47:58 +08:00
Kid
8aa2857c43 Clarify functions -Dv's output 2022-01-08 13:46:00 +01:00
David Adam
e86a84765f funcsave: add documentation for feature added in 3a402b19b 2022-01-03 23:03:38 +08:00
Johannes Altmanninger
5e67a299ae string-match.rst: fix wrong RST directive
This would show up in the rendered version.
2022-01-02 12:23:39 +01:00
Johannes Altmanninger
89b38e87bd ulimit.rst: remove spurious backtick 2022-01-02 12:23:39 +01:00
Johannes Altmanninger
b5a95317f0 index.rst: don't mention current page under "Other help pages"
This is the list of pages at the end of the introduction; no need to
link to the introduction, we're already there.
2022-01-02 12:23:39 +01:00
Johannes Altmanninger
41080c4f41 math.rst: fix typo 2022-01-02 10:14:46 +01:00
Aaron Gyes
4efb1b1644 math.rst: use definition lists.
Also, follow the one-line per sentence rule as that has semantic
meaning for man/groff.
2021-12-24 16:39:47 -08:00
Aaron Gyes
a16fd0baa4 Update synopsis of a few stragglers. 2021-12-24 16:15:40 -08:00
Aaron Gyes
6e426cefbd HTML docs theme: increase line spacing for synopsis section 2021-12-24 16:02:52 -08:00
Aaron Gyes
45b302839b status.rst: fixup 2021-12-21 18:52:45 -08:00
Aaron Gyes
14d60ccb32 More synopsis work.
A great leap forward
2021-12-21 17:24:47 -08:00
Aaron Gyes
461facb42e History: adjust description entries 2021-12-17 15:44:05 -08:00
Aaron Gyes
5ae7bc1443 help: adjust synopsis. history manpage: indent long synopsis lines 2021-12-17 15:38:49 -08:00
Aaron Gyes
50d65ace34 fixup 2021-12-17 15:23:02 -08:00
Aaron Gyes
4c6da2091d Harmonize some idiosyncrancies introduced
For now, we are going with ``command`` for builtins and fish scripts,
and **keyword** for parser keywords like if or and.
2021-12-17 15:20:46 -08:00
Aaron Gyes
af61ea1325 doc_src: Continue the slog through the letter F.
We are using only :: in a synopsis for fishscript examples given
of the command being documented.
2021-12-17 15:16:47 -08:00
Aaron Gyes
5e880bb1c3 Commit doc_src progress.
This is continuing the work I've been doing to remove the ::
formatting for the synopsis sections of our manual pages.
2021-12-17 13:59:39 -08:00
Johannes Altmanninger
b98f71c16f fish_config.rst: make the synopsis imply that "browse" is the default 2021-12-13 20:41:45 +01:00
Aaron Gyes
196b42e4eb pygments lexer: use the token type intended for CLI output
and squash an unused import
2021-12-12 12:00:23 -08:00
Aaron Gyes
57119fb84d conf.py: two unused imports, an unused local variable. 2021-12-12 10:45:50 -08:00
Aaron Gyes
5e96f817a6
Update command.rst 2021-12-12 00:17:16 -08:00
Andrey Mishchenko
45dbfda5cc Add documentation for nextd-or-forward-word and prevd-or-backward-word readline functions 2021-12-11 10:19:18 +01:00
Andrey Mishchenko
f88bb35204 Fix delete-or-exit doc wording for local consistency 2021-12-11 10:19:18 +01:00
Andrey Mishchenko
bb1955ccf9 Remove delete-or-exit function, which has a C++ implementation 2021-12-11 10:19:18 +01:00
Andrey Mishchenko
fb73a4b2e2 Implement nextd-or-forward-word and prevd-or-backward-word in C++ 2021-12-11 10:19:18 +01:00
Aaron Gyes
4746137a61 complete synopsis should just be a synopsis. 2021-12-11 00:41:09 -08:00
Aaron Gyes
124734cbaa cd, cdh, command, commandline
Documentation.
2021-12-09 04:45:10 -08:00
Aaron Gyes
3b629d29aa More documentation work 2021-12-09 03:53:13 -08:00
Aaron Gyes
79d1b3e085 slog through documentation
I did.. a and b today.
2021-12-09 03:34:28 -08:00
thibault
ceade1629d builtin commandline: add option to determine if pager is fully disclosed
Use the remaining_to_disclose count to determine if all completions
are shown (allows consistent behavior between short and long completion
lists).

Closes #8485
2021-12-04 22:43:39 +01:00
Andrey Mishchenko
e79617f4b7 Add documentation for prompt_hostname 2021-12-04 10:37:49 +01:00
Andrey Mishchenko
bea86f04c7 Lowercase command description for consistency 2021-12-04 10:37:49 +01:00
Andrey Mishchenko
7f4b71e533 Delete trailing whitespace 2021-12-04 10:37:49 +01:00
Andrey Mishchenko
a3bf41223e Reword documentation for filename in man status 2021-12-04 10:32:15 +01:00
Fabian Homborg
be43e95ac9 docs: Expand path variable section 2021-12-01 19:03:40 +01:00
Fabian Homborg
47e45704b1
Allow set --query to check for pathvarness (#8494)
Currently,

    set -q --unpath PATH

simply ignores the "--unpath" bit (and same for "--path").

This changes it, so just like exportedness you can check pathness.
2021-11-26 18:29:10 +01:00
Johannes Altmanninger
41be9fa9fd Clarify that optional option arguments must have no separating space
Unless we use "complete --require-parameter", we must say "-w32",
not "-w 32", because the second "32" is a positional argument.

Notably, old options do not have this behavior, which is a bit weird,
see #8465

Taken from a discussion in #8459
2021-11-26 18:05:29 +01:00
Fabian Homborg
0d309b0d9e docs/for-bash-users: Some cosmetic changes 2021-11-25 21:52:03 +01:00
Fabian Homborg
f2fd30df03
Make fish_key_reader's output simpler (#8467)
* fish_key_reader: Simplify default output

It now only prints the bind statement. Timing information and such is
relegated to a separate "verbose" mode.

* Adjust fish_key_reader docs

* Adjust tests
2021-11-22 17:22:22 +01:00
Johannes Altmanninger
4657ac0a7c builtin complete: document that old-style option args can be given after =
Fixes #8457
2021-11-19 05:59:17 +01:00
Johannes Altmanninger
0d3d84a39c Fix typos in documentation 2021-11-18 15:06:12 +01:00
Johannes Altmanninger
0acbbfe2ca Document that a for-loop passes through any exit status
Unlike in other shells, for-loops do not set $status if
1. the loop count is zero, or if
2. the loop body consists of only commands like "set" that don't
   set $status.

POSIX for-loops always set an exit status (they set 0 if no loop
iterations). Following that would be awkward because it would add a
lot of complexity in combination with the 2 special cases above.

Document that "for" behaves the same as "set": it will pass through
existing $status, and also the last child's $status.

See the discussion in #8409
2021-11-18 15:06:12 +01:00
Emily Seville
3c4969fc38 Change "while" command title to match "for" one
Closes #8409
2021-11-18 14:54:46 +01:00
ridiculousfish
88a89d0a52 docs: remove an errant space 2021-11-14 13:40:02 -08:00
Fabian Homborg
0f1bc5335a docs: :envvar: the rest of the variables
Just a quick mechanical translation
2021-11-12 19:43:00 +01:00
Fabian Homborg
6b7fe49858 docs: Restrict underlining links to the body
Adding the underline in the list of sections makes them bleed
together, making it hard to discern where one ends and the other
begins.

In the body of the text we don't have that issue - multiple links are
rarely next to each other.

Fixes #8439
2021-11-12 18:47:56 +01:00
Fabian Homborg
57eccb7e1e docs: Readd note about the command to realpath 2021-11-12 18:28:35 +01:00
Fabian Homborg
9a9cd5172d docs: Don't make envvar names so large and in a different font
They're still bold, so still quite noticeable.

But not *IN YOUR FACE*.
2021-11-12 18:21:38 +01:00
Fabian Homborg
02553d8fa6 Docs: Don't use seealso
This is too eye catching and almost unreadable in the dark theme.
2021-11-12 18:13:36 +01:00
Fabian Homborg
edc09c8419 Docs: Switch back to vanilla :ref: for commands that should be linked
Unfortunately, currently :program: doesn't link to the program's page.

So we use the old-school :ref: again where we should link, i.e. for
everything that's not the program the current page is about.

Fixes #8438
2021-11-12 18:02:56 +01:00
Fabian Homborg
2e9e94f17e Fix broken envvar link
Apparently you can't use spaces here.
2021-11-12 17:57:11 +01:00
Aaron Gyes
7a8fce6941 Thwart more dastardly schemes
thanks @faho
2021-11-12 04:52:38 -08:00
Aaron Gyes
e6eb049aeb Remove imperialist sabotage to previous commit
Juche!
2021-11-12 04:39:11 -08:00
Aaron Gyes
ac1df310c8 Long march towards more structured text 2021-11-12 04:22:35 -08:00
Aaron Gyes
97245fcd3f fix typo 2021-11-06 14:14:11 -07:00
Aaron Gyes
94890c28d3 Underline links. Use CSS to add $ to envvar links 2021-11-06 14:09:27 -07:00
Aaron Gyes
579d1e190c pygments.css: update colors
Try some nicer greens, and grey for comments in the code blocks.
2021-11-06 14:09:27 -07:00
ridiculousfish
797e3f1ce9 language.rst: clean up redirection docs and mention noclobber + append
Fixes #8380
2021-11-06 13:11:18 -07:00
ridiculousfish
13133f66be docs: remove an errant } from the css file
This was causing strange spacing in the language docs.
2021-11-06 12:30:51 -07:00
Aaron Gyes
b550b38859 index.rst: copy-edit
Try to improve the quality of this writing.

Evict a paragraph about running Bash from our documentation front
page.
2021-11-05 16:50:19 -07:00
Aaron Gyes
da896cfcd4 pydoctheme.css: bump up line spacing
make this less of an eye-chart.
2021-11-05 16:34:34 -07:00
Aaron Gyes
c5e02206d3 Fix up the _PATH ref.
So, it looks like even without -n `sphinx` will report on refs
are bad.

Closes #8407
2021-11-05 16:21:01 -07:00
Aaron Gyes
3078d0a252 fish documentation manpages: omit NAME for non-commands
Documents like fish-tutorial don't need the NAME portion below.

(they also shoudln't be in section 1! These should be section 7,
they aren't for programs.)

the manpage writer will skip NAME if given an empty sstring as
the description.

--

FISH-TUTORIAL(1)     fish-shell     FISH-TUTORIAL(1)

NAME
       fish-tutorial - fish-shell tutorial
2021-11-05 07:50:30 -07:00
Aaron Gyes
d54c8a42a9 Documentation WIP:
Start doing the envvar:: directives and cut some copy. These should
be linking up now.
2021-11-05 05:14:02 -07:00
Fabian Homborg
a4ae950312 Readd copyright section
Otherwise the html render will just show

"Copyright ."

Also this is typically added and it's non-intrusive
2021-11-04 22:00:56 +01:00
Aaron Gyes
0803a8fc3e Remove Copyright sectionf from doc pages, and a couple missing bits
... from fish.rst
2021-11-04 13:27:52 -07:00
Aaron Gyes
1c5a88ad21 pydoctheme.css: render #synopsis usage as monospace. 2021-11-04 13:23:22 -07:00
Aaron Gyes
42239d4dd8 fish.rst: do better
This fixes the indentation problem for the SYNOPSIS section by not
inserting the :: literal block. Format it the same way Sphinx does
their own manpages for commands.

Use more semantic markup, like :command:, so that commands are
highlighted in the man pages.

Split by sentence to give `man` a chance to ascertain lines.

Long-term, it should be possible to teach Sphinx to turn :command:s
into references and get us automatic links to articles for matching
cmds/*.
2021-11-04 13:16:13 -07:00
Fabian Homborg
ea40c1e9de docs: Add missing backticks
This turned `\n` into `n`.
2021-11-04 15:21:28 +01:00
Fabian Homborg
de79458be2 docs: Expand string-for-bash-users section
Show some cool stuff.
2021-11-03 17:29:51 +01:00
Fabian Homborg
a4adda5da8 docs: Expand math for bash users a bit
Also fix some awkward typos.
2021-11-03 17:23:36 +01:00
Fabian Homborg
cbf28dfa57 Document turning off suggestions/history
Also add more mentions of `fish_config` in general.
2021-11-02 21:40:56 +01:00
Fabian Homborg
4118bda21c docs: Go over the FAQ again
Mention more fish_config CLI, `$()`, do some rewording, ...
2021-10-29 17:14:53 +02:00
Fabian Homborg
a4983af94d docs: Fix section level
Using "=====" makes it an entry in the toc
2021-10-29 17:01:48 +02:00
Fabian Homborg
8428247f31 docs: Split up the variable docs some more
(also remove some broken or incorrect footnotes)
2021-10-28 16:48:08 +02:00
Fabian Homborg
387904928b docs: Add more on wordsplitting 2021-10-28 16:42:19 +02:00
Fabian Homborg
ae3d5af1ab docs: Correct an example 2021-10-28 16:35:21 +02:00
Fabian Homborg
bffb49b38a Explicitly mention function variables don't go out of scope
Fixes #8385.
2021-10-27 16:55:11 +02:00
Aaron Gyes
91a048596b sphinx: enable proper quotes with the smartquotes module
turn off the option for em-dashes.
2021-10-26 10:46:06 -07:00
Fabian Homborg
d03ec2cc6b docs/interactive: Some rewording. 2021-10-24 21:18:31 +02:00
Fabian Homborg
479c11bc80 FAQ: Remove rarely asked questions 2021-10-24 21:18:31 +02:00
Fabian Homborg
4b46717a91 docs: Move configuration section to language
Instead leave a simple "use config.fish" bit in-place.

Also some minor rewording.
2021-10-23 17:13:36 +02:00
Fabian Homborg
aef6cc1538 docs: Hand-write a list of short descriptions in commands
This is more readable than the full list, especially for the important
things.
2021-10-23 16:46:15 +02:00
Fabian Homborg
db5e7734a6 Some small changes to the docs
Reorder the variables, make more cd-related stuff subsections, a
slight rewording.
2021-10-20 21:28:14 +02:00
Fabian Homborg
711796ad13 Highlight options differently
This introduces a new variable, $fish_color_option, that can be used
to highlight options differently.

Options are tokens starting with `-`, but only up to (and including!)
the first `--`.

Fixes #8292.
2021-10-19 17:20:21 +02:00
Erik Serrander
049104e8df Adds sub-command clear-session to history command.
Issue #5791
This clears all history for the current session. Documentation and
autocompletion for the new subcommand is added.
2021-10-17 19:27:46 -07:00
Aaron Gyes
ec855c75c0 run fish.png through imageoptim
14KB -> 7KB
2021-10-16 14:33:12 -07:00
Adam Skoufis
d619d79117
Fix typo in set_colors command documentation (#8321)
* Fix typo in `set_colors` command documentation
* Replace `It` with `VALUE` to reduce ambiguity
2021-09-29 08:17:21 -07:00
Aaron Gyes
ed8c78c0ea Update docs, completions for funcsave
Remove long opt for -q, funcsave does not have so many options that
it's any help.
2021-09-29 03:08:10 -07:00
Fabian Homborg
f4c8dc72a7 docs: Some minor stuff in fish_for_bash_users 2021-09-24 20:32:29 +02:00
Fabian Homborg
615e8b2e8b docs: Expand section on heredocs
This should give a better rationale for why fish doesn't have them.
2021-09-24 20:29:57 +02:00
Fabian Homborg
45714eb29d Add function scope to read as well
Fixes #8295.
2021-09-23 17:12:37 +02:00
Adam Skoufis
1ff6160058 Fix typo in abbr docs 2021-09-09 15:13:17 +02:00
Johannes Altmanninger
7cdf624086 docs: mention the "all" feature group 2021-09-05 03:34:25 +02:00
Ariel Fermani
2e24aaa605 docs: Fix missing semicolon in Bash group command example 2021-09-04 16:30:28 +02:00
Fabian Homborg
8b4585d387 docs: Some mistakes in interactive
"This page" is no longer index, we don't match matching parentheses or
quotes and the `\n` didn't show up in the render as the backslash disappeared.
2021-09-01 19:48:33 +02:00
Evan Chen
878bfa94cb Typo funcions -> functions 2021-08-28 22:47:00 +02:00
Fabian Homborg
c055e3ae66 docs: Reword feature flags chapter 2021-08-17 17:32:41 +02:00
David Adam
8dd4c67db1 funcsave: edit the whole file containing a function
Many functions ship in files with helper functions, and it is useful to
edit those too.

Closes #391.
2021-08-16 21:45:22 +08:00
David Adam
a40e60b45b funced: minor grammar fixes to documentation 2021-08-16 21:44:43 +08:00
Fabian Homborg
7f34b8ab53 docs: Add copy buttons to all the codeblocks
This uses a bit of javascript to add copy buttons, so you can directly
copy all the code in a given block to the clipboard!

For codeblocks without prompts, it just copies all the code, for
blocks with prompts, it copies all the lines after prompts, under the
assumption that that's the code to be executed.

It would give you *all* the lines, so the output wouldn't be
interleaved like it is in the html, but good enough.

The buttons appear on hover, so they aren't usable on phones, but
since you won't really have a clipboard on phones and I have no idea
how to make them not always in front of the text otherwise: Eh.

I'm not in love with the javascript here, but it'll do.
2021-08-15 20:09:49 +02:00
Fabian Homborg
c4593828f4
commandline: Add --is-valid option (#8142)
* commandline: Add --is-valid option to query whether it's syntactically complete

This means querying when the commandline is in a state that it could
be executed. Because our `execute` bind function also inserts a
newline if it isn't.

One case that's not handled right now: `execute` also expands
abbreviations, those can technically make the commandline invalid
again.

Unfortunately we have no real way to *check* without doing the
replacement.

Also since abbreviations are only available in command position when
you _execute_ them the commandline will most likely be valid.

This is enough to make transient prompts work:

```fish
function reset-transient --on-event fish_postexec
    set -g TRANSIENT 0
end

function maybe_execute
    if commandline --is-valid
        set -g TRANSIENT 1
        commandline -f repaint
    else
        set -g TRANSIENT 0
    end
    commandline -f execute
end

bind \r maybe_execute
```

and then in `fish_prompt` react to $TRANSIENT being set to 1.
2021-08-14 11:29:22 +02:00
Fabian Homborg
eee38836cf set -q: Return 255 if no variable name was passed
Previously this strictly returned the number of unset variables. So if
no variable was given, it would return *true*, which is highly
suspect.
2021-08-14 10:55:21 +02:00
Fabian Homborg
35c53a94b5 docs: Remove stuff from globbing
That `find` example is a bit dated and awkward, and doesn't really fit
the section.

We also don't want to point people to `?` because we want to remove it.
2021-08-11 18:42:21 +02:00
Fabian Homborg
013f98a5b3 docs: Double-re-extra mention bash vs fish globbing
And in the section we now point people towards!
2021-08-11 18:41:37 +02:00
Johannes Altmanninger
cb3f3480b2 Fix punctuation in footnote 2021-08-10 21:01:39 +02:00
Fabian Homborg
b10d64e22e prompt_pwd: Update docs 2021-08-09 17:42:00 +02:00
Fabian Homborg
7a8feb4656 prompt_pwd: Allow keeping components full length
And allow passing the parameters as options.
2021-08-09 17:42:00 +02:00
Fabian Homborg
b2764ad4b1 docs 2021-08-04 21:09:47 +02:00
Fabian Homborg
733114fefb
Add set --function (#8145)
* Add `set --function`

This makes the function's scope available, even inside of blocks. Outside of blocks it's the toplevel local scope.

This removes the need to declare variables locally before use, and will probably end up being the main way variables get set.

E.g.:

```fish
set -l thing
if condition
    set thing one
else
    set thing two
end
```

could be written as

```fish
if condition
    set -f thing one
else
    set -f thing two
end
```

Note: Many scripts shipped with fish use workarounds like `and`/`or`
instead of `if`, so it isn't easy to find good examples.

Also, if there isn't an else-branch in that above, just with

```fish
if condition
    set -f thing one
end
```

that means something different from setting it before! Now, if
`condition` isn't true, it would use a global (or universal) variable of
te same name!

Some more interesting parts:

Because it *is* a local scope, setting a variable `-f` and
`-l` in the toplevel of a function ends up the same:

```fish
function foo2
    set -l foo bar
    set -f foo baz # modifies the *same* variable!
end
```

but setting it locally inside a block creates a new local variable
that shadows the function-scoped variable:

```fish
function foo3
    set -f foo bar
    begin
        set -l foo banana
        # $foo is banana
    end
    # $foo is bar again
end
```

This is how local variables already work. "Local" is actually "block-scoped".

Also `set --show` will only show the closest local scope, so it won't
show a shadowed function-level variable. Again, this is how local
variables already work, and could be done as a separate change.

As a fun tidbit, functions with --no-scope-shadowing can now use this to set variables in the calling function. That's probably okay given that it's already an escape hatch (but to be clear: if it turns out to problematic I reserve the right to remove it).

Fixes #565
2021-08-01 20:08:12 +02:00
Fabian Homborg
2c420ef728 docs: Document that commands with space will be kept until the next 2021-08-01 14:01:49 +02:00
Fabian Homborg
0d054f16c4 docs: Remove background from pygments
For some reason I've seen one version of firefox use this over the one
we set in pydoctheme.css. Since we set it there in both light and dark
mode, this one should not be used.
2021-07-30 18:36:12 +02:00
Branch Vincent
d8465e0a86 document --no-config 2021-07-27 23:00:23 +02:00
Fabian Homborg
04b9a8b3b5 docs: Fix a label 2021-07-27 18:49:34 +02:00
Fabian Homborg
6e7d497a52 docs: Add a note explaining test 2021-07-27 18:35:20 +02:00
Fabian Homborg
d67470c482 docs: Link to the rest of the docs in fish_for_bash_users 2021-07-27 16:54:24 +02:00
Fabian Homborg
25af0230ad docs: Clarify stderr-nocaret being on by default 2021-07-27 16:54:03 +02:00
Johannes Altmanninger
cc32b4f2a7 Make '&' only background if followed by a separating character
This is opt-in through a new feature flag "ampersand-nobg-in-token".

When this flag and "qmark-noglob" are enabled, this command no longer
needs quoting:

	curl https://example.com/thing?foo=bar&duran=duran

Compared to the previous approach e1570a4 ("Let '&' only separate as
the first char of a word"), this has some advantages:

1. "&&" and "&>" are no longer affected. They are still special, even
   if used between tokens without spaces, like "echo bar&>foo".
   Maybe this is not really *better*, but it avoids risking to annoy
   users by breaking the old variant.

2. "&" is still special if at the end of a token, like in "sleep 1&".

Word movement is not affected by the semantics change, so Alt-F and
friends still stop at every "&".
2021-07-23 22:58:51 +02:00
Fabian Homborg
3cc59a9a12 docs: Document how complete groups options
Fixes #8146.
2021-07-23 19:29:16 +02:00
Fabian Homborg
7a5587de75 docs: Reword cd a bit 2021-07-23 18:00:57 +02:00
Fabian Homborg
152097ca34 doc: Some more rewordings
I'm struggling to avoid this massive list of files and directories.

Maybe a second section for integrators?
2021-07-23 18:00:57 +02:00
Fabian Homborg
3359e5d2e9
Let "return" exit a script (#8148)
Currently, if a "return" is given outside of a function, we'd just
throw an error.

That always struck me as a bit weird, given that scripts can also
return a value.

So simply let "return" outside also exit the script, kinda like "exit"
does.

However, unlike "exit" it doesn't quit an interactive shell - it seems
weird to have "return" do that as well. It sets $status, so it can be
used to quickly set that, in case you want to test something.
2021-07-21 22:33:39 +02:00
Fabian Homborg
4be6021131 docs: Some de-alienizing of the configuration section
Still not happy with this, it's overwhelming!

Might have to split this into two - one with simple paths and rough
descriptions, and one with the full scoop for experts?
2021-07-20 21:03:55 +02:00
Fabian Homborg
f3f6e4a982 string: Add "--groups-only" to match
This adds a simple way of picking bits from a string that might be a
bit nicer than having to resort to a full `replace`.

Fixes #6056
2021-07-16 20:27:54 +02:00
Fabian Homborg
801d7e3e11 docs: Document that the man pages are for our builtins
For builtins that have the same name as common commands, it might not
be entirely obvious that there is another page.

So, for those builtins, we add a note, but only in the man pages.

(exception is true and false because the note would be longer than the
page, and it's fridging true and false)

Fixes #8077.
2021-07-16 18:21:41 +02:00
Fabian Homborg
ee8c5579f3 docs: Add some links
(and remove a stray sentence)
2021-07-16 18:08:55 +02:00
Fabian Homborg
a6699576ce docs: Some more $() changes 2021-07-16 18:08:36 +02:00
Fabian Homborg
8223e6f23e fish_config: Add CLI-based theme selector
`fish_config theme`:

- `list` to list all available themes (files in the two theme
directories - either the web_config/themes one or
~/.config/fish/themes!)
- `show` to show select (or all) themes right in the terminal - this
starts another fish that reads the theme file and prints the sample
text, manually colored
- `choose` to load a theme *now*, setting the variables globally
- `save` to load a theme and save the variables universally
- `dump` to write the current theme in .theme format (to stdout)
- `demo` to display the current theme
2021-07-14 18:56:19 +02:00
Fabian Homborg
01b0b04cbf docs: Remove lAtEx thing again
Now it's screaming in the man builder.

Honestly, some parts of sphinx aren't very well thought out.
2021-07-14 17:03:41 +02:00
Fabian Homborg
2b7f6e4b0c docs: Put a note on which binding function to call in each section
Fixes #8084.
2021-07-14 16:49:22 +02:00
Fabian Homborg
df6109b953 docs: Reword bit about aliases and autoloading
This was kinda misleading. Point people to funcsave and `alias --save`
instead.

Fixes #8137.
2021-07-14 16:46:26 +02:00
Fabian Homborg
6640f45913 docs: Use a separate top-level document for lAtEx
This screams about duplicate labels even *if this part isn't built!*

So we use another document that we ignore in other builders.

Blergh
2021-07-14 16:42:04 +02:00