Commit Graph

374 Commits

Author SHA1 Message Date
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
a3bf41223e Reword documentation for filename in man status 2021-12-04 10:32:15 +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
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
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
57eccb7e1e docs: Readd note about the command to realpath 2021-11-12 18:28:35 +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
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
94890c28d3 Underline links. Use CSS to add $ to envvar links 2021-11-06 14:09:27 -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
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
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
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
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
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
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
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
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
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
Branch Vincent
d8465e0a86 document --no-config 2021-07-27 23:00:23 +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
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
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
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
Johannes Altmanninger
5999d660c0 Docs for "$(cmd)" and $(cmd) 2021-07-13 21:33:42 +02:00
David Adam
70eca5e204 function: note limits on signal triggers in documentation
See #5160.
2021-07-11 23:03:39 +08:00
Fabian Homborg
0e1f5108ae
string: Allow collect --allow-empty to avoid empty ellision (#8054)
* string: Allow `collect --no-empty` to avoid empty ellision

Currently we still have that issue where

    test -n (thing | string collect)

can return true if `thing` doesn't print anything, because the
collected argument will still be removed.

So, what we do is allow `--no-empty` to be used, in which case we
print one empty argument.

This means

    test -n (thing | string collect -n)

can now be safely used.

"no-empty" isn't the best name for this flag, but string's design
really incentivizes reusing names, and it's not *terrible*.

* Switch to `--allow-empty`

`--no-empty` does the exact opposite for `string split` and split0.

Since `-a`/`--allow-empty` already exists, use it.
2021-07-09 21:20:58 +02:00
Johannes Altmanninger
7c2dd694e0 Provide functions to toggle commandline prefix/suffix
This introduces two functions to
- toggle a process prefix, used for adding "sudo"
- add a job suffix, used for adding "&| less"

Not sure if they are very useful; we'll see.

Closes #7905
2021-06-23 20:51:20 +02:00
Johannes Altmanninger
be0b451207 commandline: allow to get/set cursor position relative to token/process/job
With a command line like

	a | b <cursor> | c

 "commandline -C 0 --current-process" will place the cursor just left of "b".
2021-06-23 20:51:20 +02:00
Fabian Homborg
21f5032a55 docs: Don't speak of "initialization files"
The file is called "config.fish", not "init.fish". We'll call it
"configuration" now.

"Initialization" might be slightly more precise, but in an irritating
way.

Also some wording improvements to the section. In particular we now
mention config.fish *early*, before the whole shebang.
2021-05-28 20:49:57 +02:00
ridiculousfish
73998b81b4 Correct the docs for commandline --current-buffer
commandline current-buffer was incorrectly documented as returning the
autosuggestion. Clarify that it does not.
2021-05-25 17:15:42 -07:00
ridiculousfish
33f3c03dae Allow on-job-exit handlers to be added for any pid in the job
Prior to this change, a function with an on-job-exit event handler must be
added with the pgid of the job. But sometimes the pgid of the job is fish
itself (if job control is disabled) and the previous commit made last_pid
an actual pid from the job, instead of its pgroup.

Switch on-job-exit to accept any pid from the job (except fish itself).
This allows it to be used directly with $last_pid, except that it now
works if job control is off. This is implemented by "resolving" the pid to
the internal job id at the point the event handler is added.

Also switch to passing the last pid of the job, rather than its pgroup.
This aligns better with $last_pid.
2021-05-25 15:28:53 -07:00
Fabian Homborg
406bc6a5d6 docs: Remove obsolete part from functions
This was forgotten in #5951, which allowed `functions --erase` to
prevent functions from being autoloaded.

Fixes #8014
2021-05-19 19:09:46 +02:00
Fabian Homborg
b63b511b0a docs: Clarify when on-variable handlers will be run
Fixes #8010.
2021-05-17 17:20:36 +02:00
Fabian Homborg
af84c35282 docs: A bit more on autoloading 2021-05-16 21:27:00 +02:00
Johannes Altmanninger
e10cab8104 Tweak documentation wording to include non-option arguments 2021-05-16 20:48:53 +02:00
Fabian Homborg
9fd69acd1a docs: Clean up set a bit
More links! Links good! Link link linky link!
2021-05-12 18:52:24 +02:00
Fabian Homborg
aa84a4ba30 docs: Links for the function-related commands 2021-05-08 12:12:56 +02:00
ridiculousfish
d338c45205 Fix a Sphinx warning
Add a newline to fix "Literal block ends without a blank line."
2021-05-04 13:50:09 -07:00
ridiculousfish
f0f10618df Improve the documentation for pushd
Correct the examples so that the directory stack is correct.
Fixes #7940
2021-05-04 13:21:46 -07:00
Fabian Homborg
d00576c9ea docs: More on join0 2021-05-04 14:14:27 +02:00
Fabian Homborg
4728d1772f Fix doc reference 2021-05-01 19:44:15 +02:00
Fabian Homborg
2b74affaf0 Add prompt selector
It's a bit weird to *have* to fire up a browser to get fish_config to
choose a prompt.

So this adds a `prompt` subcommand to `fish_config`:

- `fish_config prompt list` shows all the available prompt names
- `fish_config prompt show` demos the available sample prompts
- `fish_config prompt choose` sources a prompt
- `fish_config prompt save` makes the choice permanent

A bare `fish_config` or `fish_config browse` opens the web UI.

Part of #3625.

TODO: This shows the right prompt on a new line. Showing it in-line is awkward
to do because we'd have to move it to the right.
2021-05-01 18:50:05 +02:00
Fabian Homborg
2cea5b8eb1 Add a "prompt_login" helper function
This prints a description of the "host". Currently that's

`(chroot:debianchroot) $USER@$hostname`

with the chroot part when needed.

This also switches the default and terlar prompts to use it, the other
prompts have slightly different coloring or logic here.
2021-04-30 17:07:54 +02:00
Fabian Homborg
9850f8d18a docs: Update status docs
`status --current-function` is not a thing.
2021-04-14 21:46:51 +02:00
David Adam
9db846a5a7 docs: some improvements to the notes on key bindings
Includes acknowledgement that these are not full editors. Closes #4023.
2021-04-14 21:43:14 +08:00
David Adam
b05275cedc docs: remove undo-group functions from documentation
As discussed in
85ffa77b4e
these functions are not intended for long term use.

Also fix a typo introduced in 85ffa77.
2021-04-06 21:18:21 +08:00
Fabian Homborg
b5a5d98f80 docs: Add missing "`"
Fixes a sphinx warning.
2021-03-31 17:21:46 +02:00
David Adam
85ffa77b4e docs: note undocumented input functions
Noted in #7828.
2021-03-31 10:41:21 +08:00
Fabian Homborg
ed9268f99c
math: Make function parentheses optional (#7877)
* math: Make function parentheses optional

It's a bit annoying to use parentheses here because that requires
quoting or escaping.

This allows the parens to be omitted, so

math sin pi

is the same as

math 'sin(pi)'

Function calls have the lowest precedence, so

math sin 2 + 6

is the same as

math 'sin(2 + 6)'

* Add more tests

* Add a note to the docs

* even moar docs

Moar docca

* moar tests

Call me Nikola Testla
2021-03-30 17:21:28 +02:00
Fabian Homborg
18e332772d functions: Add "--no-details" flag and use it in funced
This inhibits the function path comment which is annoying in `funced`.

Fixes #7879.
2021-03-30 16:54:26 +02:00
Ilan Cosman
c762c62464 Add max and min math functions 2021-03-28 13:22:44 -07:00
Fabian Homborg
58177ba091 docs: Replace all internal links with :ref:s
Unlike links, these are checked by sphinx and it complains if they
don't match.

Also they have a better chance of doing something useful in outputs
other than html.
2021-03-26 19:32:14 +01:00
Fabian Homborg
cbd8f5f63e math: Add log2
This was already in the documentation as an example, now it is
actually working.

Fixes #7734
2021-03-26 19:30:38 +01:00
Fabian Homborg
018f1f7e20 docs: Document the math functions better 2021-03-11 19:46:52 +01:00
David Adam
c402ce0152 docs: note that function --on-variable is not fired for every change
As discussed in #7735.
2021-02-28 21:24:22 +08:00
David Adam
3e8e864c7c docs: note job expansion in bg/fg/jobs arguments
Discussed in #5019.
2021-02-28 20:56:23 +08:00
David Adam
e9ec95f875 docs: minor updates to math documentation
Closes #7734.
2021-02-21 21:34:15 +08:00
Ethel Morgan
5a0aa7824f Saturate exit codes to 255 for all builtins
After commit 6dd6a57c60, 3 remaining
builtins were affected by uint8_t overflow: `exit`, `return`, and
`functions --query`.

This commit:
- Moves the overflow check from `builtin_set_query` to `builtin_run`.
- Removes a conflicting int -> uint8_t conversion in `builtin_return`.
- Adds tests for the 3 remaining affected builtins.
- Simplifies the wording for the documentation for `set --query`.
- Does not change documentation for `functions --query`, because it does
  not state the exit code in its API.
- Updates the CHANGELOG to reflect the change to all builtins.
2021-02-13 08:41:51 +01:00
Ethel Morgan
6dd6a57c60 Saturate return value in builtin_set_query
builtin_set_query returns the number of missing variables. Because the
return value passed to the shell is an 8-bit unsigned integer, if the
number of missing variables is a multiple of 256, it would overflow to 0.

This commit saturates the return value at 255 if there are more than 255
missing variables.
2021-02-08 20:38:56 +01:00
Fabian Homborg
c8a91cb067 docs: Fix link in bind
Found while replacing links with :ref: roles, which are checked.
2021-02-05 20:19:28 +01:00
Fabian Homborg
b70600e070 docs: Remove errant space 2021-02-05 17:11:29 +01:00
Michael Jarvis
496d7c44a1 Fix sphinx doc warning
~/src/fish-shell/doc_src/cmds/argparse.rst:103: WARNING: Literal block ends without a blank line; unexpected unindent.
~/src/fish-shell/doc_src/cmds/argparse.rst:103: WARNING: Literal block ends without a blank line; unexpected unindent.
2021-02-05 11:07:58 +01:00
Fabian Homborg
3eef295990 docs/argparse: Remove more of the vestigial shortopt mentions
It should only be mentioned as a backwards-compatibility measure,
because it is useless - not even the short flag variable is set.
2021-02-03 19:13:53 +01:00
Fabian Homborg
d2d18e2a6a docs: Remove references to read history
This hasn't been kept since #5904 in 3.1.0.
2021-02-02 09:42:57 +01:00
Fabian Homborg
bb1aa5e72f docs: Make more code lines shorter 2021-02-02 08:35:38 +01:00
Fabian Homborg
8bb3d1198f docs: Make code lines shorter 2021-02-02 08:29:31 +01:00
Fabian Homborg
594d51e7eb Add a separate --profile-startup option to profile startup
This goes to a separate file because that makes option parsing easier
and allows profiling both at the same time.

The "normal" profile now contains only the profile data of the actual
run, which is much more useful - you can now profile a function by
running

   fish -C 'source /path/to/thing' --profile /tmp/thefunction.prof -c 'thefunction'

and won't need to filter out extraneous information.
2021-01-29 20:46:34 +01:00
Fabian Homborg
b489137fa9 docs: Link to fish_key_reader 2021-01-09 13:13:48 +01:00
David Adam
21f46181d9 string match: reword the named capture group documentation 2021-01-08 21:16:07 +08:00
Fabian Homborg
6eeb8861e7 Add exit bind function
Currently binding `exit` to a key checks too late that it's exitted,
so it leaves the shell hanging around until the user does an execute
or similar.

As I understand it, the `exit` builtin is supposed to only exit the
current "thread" (once that actually becomes a thing), and the
bindings would probably run in a dedicated one, so the simplest
solution here is to just add an `exit` bind function.

Fixes #7604.
2021-01-04 09:45:34 +01:00
Ilan Cosman
18940ea086
Remove dunderscores from __fish_status_to_signal (#7597)
* Remove dunderscores from __fish_status_to_signal

* Document fish_status_to_signal

* CHANGELOG: Add fish_status_to_signal

* Add string join to fish_status_to_signal documentation example
2021-01-03 15:15:57 +01:00
Fabian Homborg
b43a8688fe docs: Correct argparse on short- options
These aren't exposed as variables at all, so it's just entirely
vestigial now and only kept for backwards compatibility.
2021-01-01 14:22:22 +01:00
Fabian Homborg
57d23c390b docs: Reword argparse a bit
In particular use "variable" instead of "var".
2021-01-01 14:03:00 +01:00
Fabian Homborg
7ea8e20623
argparse: Make short flag names optional (#7585)
It was always a bit ridiculous that argparse required `X-longflag` if
that "X" short flag was never actually used anywhere.

Since the short letter is for getopt's benefit, we can hack around
this with our old friend: Unicode Private Use Areas.

We have a counter, starting at 0xE000 and going to 0xF8FF, that counts
up for all options that don't have a short flag and provides one. This
gives us up to 6400 long-only options.

6.4K should be enough for everybody.
2021-01-01 11:37:25 +01:00
elpres
aaeb7d107c Fixed sentence in fish_hg_prompt docs 2020-12-28 19:39:27 +01:00
ridiculousfish
f61f45748e Document insert-line-under and insert-line-over bindings 2020-12-19 14:32:17 -08:00
Fabian Homborg
6e9364ab50 fish_indent: Change --debug-level to --debug with flog categories
The "debug-level" flag makes little sense since we have no more
debug *levels* left.
2020-12-14 19:36:18 +01:00
Fabian Homborg
6bbb709c5d docs: Simplify regex importing
[ci skip]
2020-12-06 11:32:01 +01:00
Michael Jarvis
eb22a9c4db Reword text, based on suggestion by @zanchey 2020-12-05 15:00:11 -08:00
Michael Jarvis
350714775a Use "*n*\ th" instead
Escaping the space seems to be a better solution.
2020-12-05 15:00:11 -08:00
Michael Jarvis
74915489e3 Fix sphinx-docs warning
When building from source, there is a warning:

     ../doc_src/cmds/string-match.rst:13: WARNING: Inline emphasis
     start-string without end-string.

One fix appears to be putting a space after the epmhasized 'n' character,
e.g., `*n* th` instead of `*n*th`.
2020-12-05 15:00:11 -08:00
Fabian Homborg
720982a3cb string: Quit early if --quiet is satisfied
E.g. if we do `string match -q`, and we find a match, nothing about
the input can change anything, so we quit early.

This is mainly useful for performance, but it also allows `string`
with `-q` to be used with infinite input (e.g. `yes`).

Alternative to #7495.
2020-12-01 18:55:01 +01:00
Fabian Homborg
27039ed46f docs: Double-up "`"
Otherwise sphinx complains "WARNING: Inline emphasis start-string without end-string"

[ci skip]
2020-11-27 19:46:18 +01:00
Fabian Homborg
5872f4522d math: Add --base option
Currently a bit limited, unfortunately printf's `%a` specifier is
absolutely unreadable.

So we add `hex` and `octal` with `0x` and `0` prefixes respectively,
and also take a number but currently only allow 16 and 8.

The output is truncated to integer, so scale values other than 0 are
invalid and 0 is implied.

The docs mention this may change.
2020-11-27 19:33:27 +01:00
Mahmoud Al-Qudsi
f172b215cf Add documentation for regex import 2020-11-26 14:41:31 -06:00
Fabian Homborg
4ef6490a26 docs: Some fixes to the erase section of set's exit status
[ci skip]
2020-11-20 16:09:24 +01:00
Fabian Homborg
ad138ecef8 docs: Document sets $status peculiarities harder
[ci skip]
2020-11-20 16:07:22 +01:00
Fabian Homborg
9c2d22e452 Remove debug_stack_frames
This was unused with FLOG. We leave the option stubbed out for now, so
we don't error out for well-meaning calls.
2020-11-15 11:32:52 +01:00
Marcus Atilius Regulus
7b9c1a6076 escape a backslash (in 2 places) in argparse docs 2020-11-13 14:27:12 +01:00
Fabian Homborg
5ae7be1603 docs: Add fish_title and fish_greeting 2020-10-28 17:44:45 +01:00
Johannes Altmanninger
4081d58577 docs: use monospace for inline code snippets more consistently 2020-10-26 19:25:41 +01:00
Johannes Altmanninger
5ff2d38d4c builtin time: print help on invalid syntax
I always mix up the order with variable assignments.
2020-10-26 19:25:41 +01:00
Charles Gould
f73ee30111 docs: Fix markup for code blocks 2020-10-10 21:49:33 +02:00
Johannes Altmanninger
eca2a8ba55 complete: print completions without the implied -c switch
This switch is no longer necessary when only one command is given.
Internally completions are stored separately for each command,
so we only every print one command name per "complete" line anyway.
2020-10-10 11:54:52 +02:00
Fabian Homborg
0eeaa796fd docs: Fix argparse chapter
Missing a label.

Oops.

[ci skip]
2020-10-08 17:35:29 +02:00
Fabian Homborg
392b61014b docs: Some more argparse rewordings
[ci skip]
2020-10-07 21:52:35 +02:00
Fabian Homborg
194f4f3734 Update docs for multi-erase in abbr and set
[ci skip]
2020-10-04 12:39:32 +02:00
Ilan Cosman
067ec6ca97 Synopses examples for vcs services now function as intended 2020-10-02 23:45:38 +02:00
Fabian Homborg
17157b3516 docs: Update example prompt in fish_prompt docs
This used `whoami` and `hostname` and lacked spaces.

[ci skip]
2020-10-02 19:02:10 +02:00
Aurelio Jargas
8d2e4bbef5 Fix string match example
The `?` requires a char, so `foo` cannot match.
2020-09-28 18:49:55 +02:00
Johannes Altmanninger
286ad97cbd Improve string pad examples and add a cross-reference
The old examples were not really showcasing that it's nice for aligning text.
2020-09-28 18:42:02 +02:00
Fabian Homborg
d6d3abf59a Introduce $FISH_DEBUG and $FISH_DEBUG_OUTPUT variables
Same as the `--debug` and `--debug-output` options, can be enabled
when the option can't be passed, e.g. in linux shebangs.

Fixes #7359.
2020-09-28 17:46:37 +02:00
Johannes Altmanninger
f758d39535 string pad: handle padding characters of width > 1
If the padding is not divisible by the char's width without remainder,
we pad the remainder with spaces, so the total width of the output is correct.

Also add completions, changelog entry, adjust documentation, add examples
with emoji and some tests.  Apply some minor style nitpicks and avoid extra
allocations of the input strings.
2020-09-27 21:59:15 +02:00
Johannes Altmanninger
30f821c8f4 Fix example in string length docs
Technically the equivalence would be something like

	string length -q $str
	test -n (string join \n -- $str | string collect)

To handle when str has multiple empty strings;
but quoting is easier to remember and enough for most practical purposes.
2020-09-27 21:59:15 +02:00
Andrew Prokhorenkov
92511b09c4 New command "string pad" to pad text to a given width (#7340)
Pads text to a given width, or the maximum width of all inputs.
2020-09-27 21:59:15 +02:00
Fabian Homborg
fa0c9f90f8 Read arguments with fish -c
This reads any additional positional arguments given to `fish -c` into
$argv.

We don't handle the first argument specially (as `$0`) as that's confusing and
doesn't seem very useful.

Fixes #2314.
2020-09-26 14:47:20 +02:00
Fabian Homborg
06f6436943 reader: Return true if suppress-autosuggestion suppressed
This allows

bind -k backspace suppress-autosuggestion or backward-delete-char

To remove the suggestion on the first press and then delete
chars.

Note: This requires that we then don't reenable suggestions
immediately afterwards. Currently we don't after deletion.

Fixes #1419.
2020-09-26 10:09:55 +02:00
ridiculousfish
5c3571d626 Revert accidental merge of #7340
This reverts back to commit d8e2cac83e.
I accidentally did a 'git push' during code review.
2020-09-19 19:31:44 -07:00
Andrew Prokhorenkov
32f8b0c531 docs: update "string pad" to "width" argument 2020-09-19 19:25:57 -07:00
Andrew Prokhorenkov
bfa699c556 docs: update string doc 2020-09-19 19:25:57 -07:00
Andrew Prokhorenkov
e8d9572b3e docs: remove quiet for "string pad" 2020-09-19 19:25:57 -07:00
Andrew Prokhorenkov
ac8482113c docs: string pad doc update 2020-09-19 19:25:57 -07:00
Andrew Prokhorenkov
2b9158ddab builtin_string: add "--max" for "string pad" 2020-09-19 19:25:57 -07:00
Andrew Prokhorenkov
b11d4c16b8 docs: fix rst formatting for "string pad" 2020-09-19 19:25:57 -07:00
Andrew Prokhorenkov
c8e1894c72 builtin_string: add pad command 2020-09-19 19:25:57 -07:00
Fabian Homborg
dca6eee55f docs: Less "the user", more "you"
The person reading this is "you". It's completely okay and sounds
better to address them directly.

When we're talking about OS users or users of fish script the reader
writes, "the user" is still okay.

[ci skip]
2020-09-18 16:53:59 +02:00
Fabian Homborg
c932c03069 docs: Explain more variables for fish_git_prompt
Also some wording enhancements
2020-09-18 16:32:28 +02:00
Fabian Homborg
0072367512 fish_add_path: Don't resolve symlinks
The case for symlinked directories being duplicated a lot isn't there,
but there *is* a usecase for adding the symlink rather than the
target, and that's homebrew.

E.g. homebrew installs ruby into /usr/local/Cellar/ruby/2.7.1_2/bin,
and links to it from /usr/local/opt/ruby/bin. If we add the target, we
would miss updates.

Having path entries that point to the same location isn't a big
problem - it's a path lookup, so it takes a teensy bit longer. The
canonicalization is mainly so paths don't end up duplicated via weird
spelling and so relative paths can be used.
2020-09-12 19:28:01 +02:00
Fabian Homborg
568f9031aa builtin realpath: Add --no-symlinks option
Taken from GNU realpath, this one makes realpath not resolve symlinks.

It still makes paths absolute and handles duplicate and trailing
slashes.

(useful in fish_add_path)
2020-09-12 19:26:04 +02:00
Fabian Homborg
d688093f7a docs: Update repaint docs
force-repaint now does exactly the same thing as repaint and repaints
are no longer coalesced.
2020-09-11 19:38:55 +02:00
Fabian Homborg
c6cdc06a5b docs: Reword random
Don't SCREAMCAPS random, the command is `random`.

Also some stuffy verbiage.

[ci skip]
2020-09-10 20:48:13 +02:00
Fabian Homborg
7dae2b1e07 docs: Improve complete docs
A bit stuffy, some weird bits (I don't think GNU-style long options
can typically be abbreviated, ``true --v`` and ``bash --hel`` don't work).
2020-09-09 20:23:15 +02:00
Fabian Homborg
900a3c4049 complete: Remove removed options from the docs
These have been removed for ages, the complete docs are too verbose as
it is.
2020-09-09 20:23:15 +02:00
Fabian Homborg
903b7888d3 complete: Make -c optional
Currently, completions have to be specified like

```fish
complete -c foo -l opt
```

while

```fish
complete foo -l opt
```

just complains about there being too many arguments.

That's kinda useless, so we just assume if there is one left-over
argument that it's meant to be the command.

Theoretically we could also use *all* the arguments as commands to
complete, but that seems unlikely to be what the user wants.

(I don't think multi-command completions really happen)
2020-09-09 20:23:08 +02:00
Fabian Homborg
a8e237f0f9 Let complete show completions for one command if just given -c
Currently only `complete` will list completions, and it will list all
of them.

That's a bit ridiculous, especially since `complete -c foo` just does nothing.

So just make `complete -c foo` list all the completions for `foo`.
2020-09-09 18:37:39 +02:00
oui-ui
0f674435a3 correct description of -a param regarding _(\w*)
removed the word "not" to resolve an (unintended) negation of negation.
2020-09-08 18:02:50 +02:00
Fabian Homborg
340de73172 Call "fish_command_not_found" if a command wasn't found
Previously, when a command wasn't found, fish would emit the
"fish_command_not_found" *event*.

This was annoying as it was hard to override (the code ended up
checking for a function called `__fish_command_not_found_handler`
anyway!), the setup was ugly,
and it's useless - there is no use case for multiple command-not-found handlers.

Instead, let's just call a function `fish_command_not_found` if it
exists, or print the default message otherwise.

The event is completely removed, but because a missing event is not an error
(MEISNAE in C++-speak) this isn't an issue.

Note that, for backwards-compatibility, we still keep the default
handler function around even tho the new one is hard-coded in C++.

Also, if we detect a previous handler, the new handler just calls it.

This way, the backwards-compatible way to install a custom handler is:

```fish
function __fish_command_not_found_handler --on-event fish_command_not_found
    # do a little dance, make a little love, get down tonight
end
```

and the new hotness is

```fish
function fish_command_not_found
    # do the thing
end
```

Fixes #7293.
2020-09-06 11:15:54 +02:00
Aurelio Jargas
d4fe110f23 docs/isatty: Mention default value for FILE DESCRIPTOR
As seen in share/functions/isatty.fish (note the empty string):

    switch "$argv"
        case stdin ''
            set fd 0
2020-09-05 15:54:48 +02:00
Fabian Homborg
bfb5b28d0f Let command, jobs and type take --query instead of --quiet
Now command, jobs, type, abbr, builtin, functions and set take `-q` to
query for existence, but the long option is inconsistent.

The first three use `--quiet`, the latter use `--query`. Add `--query`
to the first three, but keep `--quiet` around.

Fixes #7276.
2020-09-04 16:55:09 +02:00
Aurelio Jargas
0304135d2b
docs: Use \ instead of \\ in examples (#7286)
Instead of informing the bell character (hex 07), the example was using
an escaped \ followed by x07.

    $ echo \\x07
    \x07
    $ echo \x07

    $ echo \x07 | od -a
    0000000 bel  nl
    0000002
    $

* docs: Use \u instead of \\u

Instead of informing the Unicode character 慡, this example was using an
escaped \ followed by u6161.

    $ echo \\u6161
    \u6161
    $ echo \u6161
    慡

Before:

    $ string escape --style=var 'a1 b2'\\u6161 | string unescape --style=var
    a1 b2\u6161

Now:

    $ string escape --style=var 'a1 b2'\u6161 | string unescape --style=var
    a1 b2慡
2020-08-26 18:29:03 +02:00
Fabian Homborg
5eb4de4285 math: Implement tau 2020-08-26 17:48:58 +02:00
Fabian Homborg
f14a1d3a27 math: Document hex numbers 2020-08-26 17:48:58 +02:00
Fabian Homborg
5b1c000a2e math: Add bitwise and/or functions
Just as `math "bitand(5,3)"` and `math "bitor(6,2)"`.

These cast to long long before doing their thing,
so they truncate to an integer, producing weird results with floats.

That's to be expected because float representation is *very*
different, and performing bitwise operations on floats feels quite useless.

Fixes #7281.
2020-08-26 17:48:58 +02:00
Aurelio Jargas
6ec6076c16 docs/string: Fix duplicated {} in match example
Follow-up fix from c5f06cd.

[ci skip]
2020-08-25 15:56:18 +02:00
Fabian Homborg
c9d2c99a98 Document that echo takes --
[ci skip]
2020-08-21 21:32:56 +02:00
jonbakke
02d0e50b61 Fix typo (verb clarification) in math.rst
Was: "parameter expansion takes before expressions are evaluated."
Now: "parameter expansion happens before expressions are evaluated."

I suspect the original intent was to use "takes place," but I see "happens" as less idiomatic and therefore may benefit non-English-native users.
2020-08-19 12:18:52 -07:00
Fabian Homborg
7254dfecb2 fish_indent: Print the failed files with --check
Also return the number of failed files.

I decided to *just* print the filenames (newline-separated because
NULLs are annoying here) to make it easier to deal with.

See #7251.
2020-08-10 22:03:51 +02:00
Fabian Homborg
2cdd6df257 fish_indent: Add a "--check" option to only test indentation
Fixes #7251.
2020-08-08 20:23:14 +02:00
Fabian Homborg
616cd38d8e docs: Don't use force-repaint
It's not needed here and misleading. force-repaint isn't all that
useful and especially not something for a simple example.
2020-08-07 21:06:16 +02:00
Johannes Altmanninger
242b60fdef history.rst: clarify that "history search" is the default command 2020-08-04 21:44:26 +02:00
Olivier FAURE
e7f0b5801d Add forward-single-char input command
This allows users to add custom keybindings to autocomplete only one
character at a time.

Resolves https://github.com/fish-shell/fish-shell/issues/4984
2020-08-01 12:09:31 +02:00
Olivier FAURE
6778d04aa5 Add or keybind input function 2020-08-01 12:09:31 +02:00
David Adam
4a35248465 docs/bind: make list formatting consistent 2020-07-06 20:50:19 +08:00
David Adam
1b121bd9a6 docs/jobs: add example output and remove spurious header 2020-07-06 20:48:13 +08:00
Gokul Soumya
6212a584a7 docs/jobs: Header is stripped in command substitution 2020-07-04 13:25:17 +02:00
Fabian Homborg
eb35975c0f Make cancel-commandline actual bind function
This was always awkward as fish script, and had problems with
interrupting the autoloading.

Note that we still leave the old function intact to facilitate easier
upgrading for now.

Fixes #7145.
2020-07-01 20:56:56 +02:00
Jeff Cook
b27440d536 Fix paste-o that duplicated documentation header. 2020-06-30 23:45:41 +02:00
Daniel Bengtsson
e2f03fa8a7 Add a function to check if the user is root.
Add a helper function to check if the user is root. This function can be
useful for the prompts for example. Modify the prompts made root checked
to use the function instead. Add also the support of Administrator like
a root user.

Fixes: #7031
2020-06-26 21:25:13 +02:00
Daniel Bengtsson
b8d0de1b88 Typo.
Replace the tabulation by space.
2020-06-20 18:17:11 +02:00
Fabian Homborg
c5f06cde82 docs/string: Fix match examples
One was just cosmetic (too many \\), one was actually broken because
it had duplicated `{{`, possibly resulting from the doxygen conversion?

[ci skip]
2020-06-19 21:23:51 +02:00
Fabian Homborg
547f649797 docs: Slight reword of argparse's optional argument section
[ci skip]
2020-06-17 15:36:50 +02:00
Fabian Homborg
7791457bbb docs: Add string-collect link 2020-06-07 20:04:31 +02:00
Mikel Ward
96425d2231 Fix string collect examples
collect -N leaves the trailing newline, not the other way around.
2020-06-07 19:33:27 +02:00
Awal Garg
cb5eb72c6b Skip pre/post exec events for empty commands (#4829) 2020-06-06 16:31:33 -07:00
David Adam
c5e535e794 docs: link and explicit instructions on creating a blank fish_mode_prompt
Work on #5783.

[ci skip]
2020-06-06 22:52:13 +08:00
Fabian Homborg
44184f68e4 Add status dirname and status basename convenience commands
There's a terrible number of fishscripts that start with

    set path (dirname (status filename))

And that's really just a bit boring.

So let's let it be

    set path (status dirname)
2020-06-04 18:23:32 +02:00
Fabian Homborg
5efe1a09ce docs/argparse: Add note on optional arguments
Yeah I had to answer this one again.

[ci skip]
2020-06-04 17:28:02 +02:00
Fabian Homborg
4785440f65
Add an "_" builtin to call into gettext (#7036)
* Add an "_" builtin to call into gettext

We already have gettext in C++ (if available), so it seems weird to
fork off a command to start it from script.

This is only for fish's own translations. There's no way to call into
other catalogs, it just translates all arguments separately.

This is faster by a factor of ~1000, which allows us to call
translations much more, especially from scripts.

E.g. making fish_greeting global by default would hurt cost-wise,
given that my fish starts up in 8ms and just calling the current `_`
function takes 2ms, and that would have two calls.

Incidentally, this also makes us rely on a weirdly defined function
less, so it:
Fixes #6804.

* docs: Add `_` docs

Let's see if that filename works out.

* Reword _ docs
2020-05-29 20:53:44 +02:00
Fabian Homborg
9354dd6971 Add fish_add_path, a simple way to add to $PATH
This is a function you can either execute once, interactively, or
stick in config.fish, and it will do the right thing.

Some options are included to choose some slightly different behavior,
like setting $PATH directly instead of $fish_user_paths, or moving
already existing components to the front/back instead of ignoring
them, or appending new components instead of prepending them.

The defaults were chosen because they are the most safe, and
especially because they allow it to be idempotent - running it again
and again and again won't change anything, it won't even run the
actual `set` because it skips that if all components are already in.

Fixes #6960.
2020-05-29 20:51:05 +02:00
Donovan
bc2eb383d4
Funcsave with --directory option (#7041)
* funcsave: add option --directory

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix synopsis

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix completion

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix error message

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix parameter expansion

Signed-off-by: Donovan Jean <commit@dkrm.dev>
2020-05-27 20:13:44 +02:00
Charles Gould
b673f32b93 Add fish debugging examples 2020-05-19 21:07:33 +02:00
Fabian Homborg
e3c4692031 docs/bind: Overhaul 2020-05-18 20:48:36 +02:00
Fabian Homborg
ec759fb45e printf: Overhaul docs 2020-05-18 20:48:36 +02:00
Fabian Homborg
56f24f08d7 printf: Don't print an error if not given an argument 2020-05-18 20:48:36 +02:00
Johannes Altmanninger
67531acc25 fish --help: remove outdated information about exit status 2020-05-16 10:33:13 +02:00
Fabian Homborg
389c5e7ece Update set --show docs
See #6944
2020-04-26 17:55:17 +02:00
Fabian Homborg
1f459622cb docs: Add fish_posterror
Also remove the "event will be emitted even if the command is invalid"
because it's not the case anymore, AFAICT.

See #6880.
2020-04-25 09:25:03 +02:00
Jason Nader
18efd7dd48 Fix string split docs 2020-04-21 18:36:56 +02:00
Jason Nader
ea65db9421 string split: update docs 2020-04-20 22:39:48 +02:00
Charles Gould
2421eb6180 docs: Add completions for fish_key_reader 2020-04-19 07:06:31 +02:00
Weisi Dai
6ab2d78936 Doc: Fix dead link to POSIX man page "test". 2020-04-19 04:25:04 +02:00
Delapouite
8d20748f4a doc: add section about directory history / stack
This PR also adds "See Also" section in the related commands.
2020-04-18 10:40:48 +02:00
Charles Gould
d3e720a045 docs: Use underscore in argument placeholder 2020-04-17 22:29:12 +02:00
Charles Gould
44976a5d31 docs: Remove extra colon to fix formatting 2020-04-17 22:29:12 +02:00
Johannes Altmanninger
1634a3b15c docs: don't quote code snippets
The added single quotes don't look great in HTML, and it's already clear
that the monospaced text is to be interpreted literally.
2020-04-13 22:56:22 +02:00
Jason Nader
7cb1d3a646 Add string split --fields 2020-04-04 15:30:08 +02:00