This use of eval is unsafe, not really all that useful and can spew
errors that can't be suppressed. So let's remove it, and in future add
a thing that can do expansions in a safe manner
Fixes#6456.
"-C" is short for "--case-sensitive", which is entirely okay with "--delete".
The one that isn't okay is "-X", which is short for "--Clear".
Seen on gitter.im
This prefixes files beginning with `-` with a `./` when generating
completions *in fish code*. Standard completions for directory listings
generated by the C++ directory traversal code are not afected by this
patch.
Most fish completions defer to `__fish_complete_suffix` to generate the
file/directory completions, these *will* be corrected.
* Make `type -p` and `type -P` behave as documented
* Recognize `-` as an additional sign of no path
Functions created via `source` (like by `alias`) cause `functions --details` to return `-`
rather than `stdin` when invoked upon them.
* Add the `--succinct` flag to `type`
* Use `echo` rather than `printf`
* Change `succinct` to `short`; print path if known
* Clean up the printing logic ever so slightly
This was mostly dead, since $fish_color_host is set to normal in
__fish_config_interactive. The assignment was only used if the user
explicitly unsets fish_color_host (which they shouldn't, really).
Anyway it's weird to use cyan, use normal instead.
[ci skip]
The colors are set in __fish_config_interactive before the prompt is
painted for the first time.
Also initialize the $fish_color_status for the (pipe) status, bump the
version for that.
[ci skip]
If a command fails, print the pipestatus in red instead of yellow and
don't print the status of the last process again. See #6375.
Also use $fish_color_status for coloring status consistently.
Also use __fish_pipestatus_with_signal to print SIGPIPE instead
of a numeric code on e.g.: yes | less +q
[ci skip]
(command pwd) uses the system's implementation of pwd. At least the GNU
coreutils implementation defaults to -P, which resulted in symlinks being
expanded when switching between directories with nextd/prevd.
This did some weird unescaping to try to extract the first word.
So we're now more likely to be *correct*, and the alias benchmark is
about 20% *faster*.
Call it a win-win.
Fix 'string length: Unknown option': add `--` before $subcommand
Fix count $subcommand always = 1 with `sudo` and `doas`:
give argv as array to __fish_complete_subcommand
[ci skip]
This mostly fixes some wrong indents or replaces some stray tab indents.
I excluded alignment on purpose, because we have a whole bunch of code
that goes like
```fish
complete -c foo -n 'some-condition' -l someoption
complete -c foo -n 'some-longer-condition' -l someotheroption
```
and changing it seems like a larger thing and would include more
thrashing.
See #3622.
This would have prevented #6323.
While we don't want to pepper `command` everywhere, `psub` is kind of
a core thing, so we should try to proof it against common problems.
This reverts commit f620ddf03b.
Setting the paste handler isn't performance-sensitive.
On the other hand setting it this way makes things less transparent,
less flexible (if e.g. a paste handler is installed while the shell is running),
and causes #6286.
Fixes#6286.
[ci skip]
Presently the completion engine ignores builtins that are part of the
fish syntax. This can be a problem when completing a string that was
based on the output of `commandline -p`. This changes completions to
treat these builtins like any other command.
This also disables generic (filename) completion inside comments and
after strings that do not tokenize.
Additionally, comments are stripped off the output of `commandline -p`.
Fixes#5415Fixes#2705
This just makes more sense, as people don't want to enter exact
matches if they delete interactively.
It also brings it in line with "search".
Fixes#6142
Rejects #6070
MacOS Catalina apparently ships a stripped down svn that doesn't have
`svnversion`, which we use to print the revision.
For now skip the entire step to remove error spam.
Fixes#6267.
[ci skip]
Every builtin or function shipped with fish supports flag -h or --help to
print a slightly condensed version of its manpage.
Some of those help messages are longer than a typical screen;
this commit pipes the help to a pager to make it easier to read.
As in other places in fish we assume that either $PAGER or "less" is a
valid pager and use that.
In three places (error messages for bg, break and continue) the help is
printed to stderr instead of stdout. To make sure the error message is
visible in the pager, we pass it to builtin_print_help, every call of which
needs to be updated.
Fixes#6227
* functions/__fish_print_hostnames: Fix ssh_configs no values return
`string replace` not working with mutlilines variable.
So split per line first.
* functions/__fish_print_hostnames: remove quotes at `split '\n'`
"\n with quotes" will cause `string split` weird issues.
* functions/__fish_print_hostnames: using `read -alz -d \n`
Fix `$contents` issues together
Corrects #6110
BSD `seq` produces a down-counting sequence when the second argument is
smaller than the first, e.g.:
$ seq 2 1
2
1
$
While GNU `seq` produces no output at all:
$ seq 2 1
$
To accommodate for this behavior, only run `seq` when we are sure that
the second argument is greater than or equal to the first (in this case,
the second argument `line_count` should be greater than 1).
Revert "gut gpg.fish/gpg1.fish/gpg2.fish; migrate functionality to __fish_complete_gpg.fish"
This reverts commit d558218d03.
Revert "break version-specific completions out into independent function;"
This reverts commit 9160e77b01.
Revert "split gpg2- and gpg1-specific completions to conditional block"
This reverts commit a069b95f63.
* Fix default Alt+W keybinding
The old keybinding would chop off the last line of the `whatis` output
when using a multi-line prompt. This fix corrects that.
* Make variable local and remove unneeded if statement
* Test that token is non-empty
Reproducer: type `: \<RET><M-p>`. This used to print an error due to builtin test receiving
too many arguments.
It looks like (commandline -j) can return multiple items, because a job can be broken up in multiple
lines terminated by backslashes.
With the new support for self-insert inserting a bound sequence,
the default binding for space as expanding abbreviations can be simplified
to just `self-insert expand-abbr`. This also fixes the bug where space
would cancel pager search.
By not manipulating each line or even each file at a time, we can go
back to `string` and piece together a pipeline that will execute
significantly faster than shelling out to `awk` will. This also removes
one of the few dependencies on `awk` in the codebase.
With this change, `__fish_print_hostnames` now finishes ~80% faster than
it used to a few commits back.
Reordering the `getent hosts` and read from `/etc/hosts` combined with
minimizing shelling and job invocations for parsing the output results
in a profiled and benchmarked ~42% decrease in the time it takes to run,
and that's on a machine with a very small hosts list in the first place.
This update also fixes the hadling of IPv6 addresses in the hosts
output, which were previously ignored, and ignores 127.* loopback
addresses in addition to the 0.0.0.0 address (plus adds support for
shorter IPv4 notations).
$__fish_git_prompt_use_informative_chars will use the informative
chars without requiring informative mode (which is really frickin'
slow!).
See #5726.
[ci skip]
This previously effectively checked `string split ' '`s return status,
which was false if it didn't split anything. And while that should be
true if getent fails (because it should produce no output), it's also
true if it doesn't print a line with multiple aliases. Which should be
fairly typical.
Instead we use our new-found $pipestatus to check what getent returns,
in the assumption that it'll fail if it doesn't support hosts.
Follow up to 8f7a47547e.
[ci skip]
`getent hosts` is expensive-ish - ~50ms, so we don't want to run it
twice just to figure out it works.
Apparently this works everywhere but CYGWIN and possibly older
OpenBSD, but we don't want to explicitly blacklist those.
[ci skip]
If you changed $__fish_git_prompt_show_informative_status, it
triggered a variable handler, which erased the chars, but neglected to
unset $___fish_git_prompt_init, so we just kept chugging along with
empty characters.
What's the hardest thing in CS again? Cache something something?
[ci skip]
This way we use our core file completion code, which is much more
flexible than we can easily achieve directly in script (which would
require e.g. an `expand` builtin, and case-insensitive globs).
Fixes#5896.
This was quite famously rather complicated.
We drop a bunch of cases - we can't handle tmux-starting-terminals
100% accurately, so we just don't try. It should be quite rare that
somebody starts a different terminal from tmux.
We drop the `tput` since it is useless (like terminfo in general for
feature-detection, because everyone claims to be xterm).
So we just check if we are in konsole, iTerm, vte or genuine-xterm.
Fixes#3696.
See #3481.
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.
If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
Dealing with macOS output in a fast manner using `string` is surprisingly hard, given that it features lines like
gls(1), ls(1) - list directory contents
Printing the "gls" with the description and the "ls" with the description requires a `while read` loop, and that's too slow.
This reverts commit 7784a5f23c.
[ci skip]
I did not realize builtins could safely call into the parser and inject
jobs during execution. This is much cleaner than hacking around the
required shape of a plain_statement.
* Honour `dirprev` scope
Honour the scope of the `dirprev` variable if it is universal
and avoid to shadow it with a global. This enables to share
the `cd` history between sessions.
* Honor dirnext and __fish_cd_direction scope
If these variables exist in the universal scope, do not shadow them
`eval` has always been implemented as a function, which was always a bit
of a hack that caused some issues such as triggering the creation of a
new scope. This turns `eval` into a decorator.
The scoping issues with eval prevented it from being usable to actually
implement other shell components in fish script, such as the problems
described in #4442, which should now no longer be the case.
Closes#4443.
If we switch the bind mode, we add a "force-repaint" there just to
redraw the mode indicator.
That's quite wasteful and annoying, considering that sometimes the prompt can take
half a second.
So we add a "repaint-mode" function that just reexecutes the
mode-prompt and uses the cached values for the others.
Fixes#5783.
* Add "expand-abbr" bind function
This can be used to explictly allow expanding abbreviations.
* Make expanding abbr explicit
NOTE: This accepts them for space only, we currently also do it for \n
and \r.
* Remove now dead code
We no longer trigger an abbr implicitly, so we can remove the code
that does it.
* Fix comment
[ci skip]
This searched for package.json in any parent, so just like finding
.git and .hg directories it _needs_ to use the physical pwd because
that's what git/hg/yarn use.
In general, if you do _any_ logic on $PWD, it should be the physical
path. Logical $PWD is basically only good for display and cd-ing
around with symlinks.
[ci skip]
This called `eval $fish_browser --version` to figure out if it is
lynx.
That's really not worth it just to support edge-cases using a rather
unusual browser, to work around a bug in it.
Instead we just see if the browser name starts with "lynx", which
should work in 99.9% of cases.