Akin to __fish_complete_suffix, __fish_complete_directories now attempts
to complete the current commandline token if no token is explicitly
passed in as an argument.
The prompt is a fallback that is overridden via a function file
anyway.
Do that with the title as well, so we can use just builtins.
This removes error messages when $fish_function_path is borked.
Turns out that `make -pn` actually takes a while - about 300ms on
fish's makefile.
That's quite a bit of time just to throw away the output and use the
exit code.
So we just check for "GNU" in the version string.
It would be nice to just _do_ the completion and fall back on the
BSD-style if it doesn't work, but that is tricky to do with the pipe
to `awk` - the awk expression actually does not fail if `make` does
not print output.
And I don't know enough about awk to change that.
For usage in completion scripts.
Unlike `__fish_is_first_token` (which is probably not correctly named),
`__fish_is_first_arg` returns true regardless of whether existing tokens start with `-`
or not, to be used when an arg cannot be used with any other argument.
`__fish_prev_arg_in` is similar to `__fish_seen_...` but it explicitly
tests the preceding token only, for arguments that take only a single
parameter.
As it turns out, for some terminals backspace is \b but only when
preceded by \e.
All this makes about as much sense as the english language.
Fixes#4955.
The previous completion generation was broken for several reasons:
* ./foo would break detection of suffix due to the leading . being
interpreted an extension marker,
* ./foo would be completed as foo, which would be excluded from
matching inrcomplete.cpp
To be used by completions to directly determine whether it is either
possible or preferable to complete a switch (instead of a subcommand),
(presuming that switches must come before subcommands).
* __fish_can_complete_switches: we are in a position where a switch may
be placed.
* __fish_should_complete_switches: we're in a position to accept a
switch and the current token starts with `-` so we have no choice but
to do so.
Instead, attempt to extract the message that _would_ be displayed on
execution of `./configure --help` by relying on some markers present in
autoconf-generated configure files.
As measured with 'hyperfine' on a laptop running in reduced frequency
power savings mode, `fish -c "__fish_parse_configure ./configure"`
runtime dropped from ~1.25s to ~0.8ms, which is inline with the
previously observed ~350ms execution time for `./configure --help`.
fish's own startup time is approximately 75ms before parsing begins.
Still very slow, but much better.
This relies on the new `read --line/-L` support as an entire parser for
the output of `./configure --help` was written in fishscript. Also
doesn't work without 72f32e6d8a7905b064680ec4b578c41dea62bf84.
The completion script is slow... a function of both the autotools
configure script itself being written in a shell script combined with a
fishscript output parser.
fish's own `./configure --help` takes around 350ms to execute, while
`__fish_parse_configure ./configure` (which runs that behind the scenes)
takes around 660ms to run, all-in-all - a not insignificant overhead.
Output can be cached (based off of ./configure hash or mtime) in the
future if this is a big deal.
Now the description includes the variable scope, `set [-e] -[Ugl]`
completions only provide variables matching that scope, and completions
that shouldn't be modified are hidden from the user. Completions that
are often modified but rarely unset (`fish_*` variables) are omitted
from `set -e` completions.
A new helper function `__fish_seen_argument` has been added that makes
it easy to only provied completions for a specific flag.
Launch `cmd.exe /c "start URL"` under WSL for both `fish_config` and
`help`. This works around #4299 but does not address the underlying
issue (#1132).
no-op function for compatibility with sh, bash, and others.
Often used to insert a comment into a chain of commands without having
it eat up the remainder of the line, handy in Makefiles.
In similar vein to how fish_default_key_bindings works, parameters
passed to the function are automatically passed to bind upstream.
Additionally, -s is automatically added if no parameters had been
specified to prevent startup error messages. See 46d1334.
Closes#4494
Can be used to retrieve a list of parent paths, useful for searching
ancestors recursively via their absolute paths. Paths are returned from
deepest to shallowest, starting from the path passed in. Paths are not
validated for performance reasons. (Usually the input to
__fish_parent_directories would be (pwd) or (dir $file).)