Commit graph

1150 commits

Author SHA1 Message Date
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
Johannes Altmanninger
16ae532368 Fix typos in docs 2020-09-25 19:33:01 +02:00
Fabian Homborg
7cac8886bf docs: Some more on argument handling
Reword and expand the list section, and add another explicitly on
argument handling.

Fixes #4630

[ci skip]
2020-09-23 18:48:05 +02:00
Fabian Homborg
c1912e5624 docs: Change hybrid_binding function name
Just "hybrid_bindings" won't trigger the mode prompt.

(yes, this is cheesy)

[ci skip]
2020-09-23 18:15:53 +02:00
Fabian Homborg
8008dfda1e Reorder FAQ
Try to keep related things together - first the variable questions,
then the prompt questions, then more customization, then syntax
incompatibilities, ...

I'm not convinced all of these are actually frequently asked, or that
all frequently asked questions are here, but that's for later.

[ci skip]
2020-09-22 17:34:42 +02:00
Fabian Homborg
1da56f9937 Make history search smartcase
This makes history searches case-insensitive, unless the search string
contains an uppercase character.

This is what vim calls "smartcase".

Fixes #7273.
2020-09-22 16:13:24 +02:00
Fabian Homborg
a5c1d72bd0 docs: Use "fish" without markup in tutorial
Work towards #6785.

[ci skip]
2020-09-20 20:17:08 +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
c4b7abc6ef docs: Misc changes
Some formatting improvements, an explanation of $PWD, and some updates
- --on-process-exit is gone, the fish_command_not_found event is gone,
nobody has sent enhancements via the mailing list in years.

[ci skip]
2020-09-18 17:19:44 +02:00
Fabian Homborg
c53107a3ad docs: Destuffify
There really is no need to show our technical writing prowess here, we
can use plain english.

[ci skip]
2020-09-18 17:10:40 +02:00
Fabian Homborg
d95dc15dac docs: Some more on custom bindings
Show another fish_key_reader run, explain what keys we pressed,
explain the escape delay.
2020-09-18 17:09:44 +02:00
Fabian Homborg
7845539990 docs: Change "Builtin Commands" section
This harkens back to the days of fish's "we don't need no stinkin'
echo" minimalism. That's long past, we have a bunch useful builtins
now just because they are useful, not because they have to be builtins.

[ci skip]
2020-09-18 17:03:56 +02: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
c188ecf6c7 docs: Reword Tab Completion section
[ci skip]
2020-09-18 16:46:52 +02:00
Fabian Homborg
63adb6871b docs: "fish" is a normal word
We don't need to emphasize it with a monospace block.

Just on index.rst for now.

Work towards #6785.

[ci skip]
2020-09-18 16:40:09 +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
Charles Gould
5e5b9d75e6 docs: Fix background color for interactive examples
For the few weird code blocks where default highlighting does not work,
we must add the 'highlight' class manually to get matching backgrounds.
This reuses the background color defined in pygments.css.
2020-09-04 19:46:38 +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
Fabian Homborg
021d4157ca Fix hybrid binding instructions
This needs to have the vi-bindings take precedence, so they need to be
executed *last*.

It just needs to tell them that they shouldn't erase all the bindings.

[ci skip]
2020-08-28 20:50:24 +02:00
Fabian Homborg
bc715c6eb4 docs: Reword some of the Special Variables section
[ci skip]
2020-08-27 17:07:23 +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