Commit Graph

8586 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
20395339a4 Fix python{,2,3} argument completions
Only the first non-switch parameter to python must be a .py file, but
everything thereafter is "just another argument". This enables file
completions for 2nd+ arguments.
2018-05-12 23:40:40 -05:00
Mahmoud Al-Qudsi
5f1168002e Complete current commandline token with __fish_complete_directories if
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.
2018-05-12 14:06:03 -05:00
Mahmoud Al-Qudsi
82c8abc4dc Add completions for ttx 2018-05-12 14:06:03 -05:00
Fabian Homborg
84fe46e763 [make completions] Reenable files if token contains "="
Fixes #4967.
2018-05-12 18:52:51 +02:00
Mahmoud Al-Qudsi
3cda5ac59b Clean up complete.cpp code
Embrace C++11 ranged for loops.
2018-05-12 11:23:43 -05:00
Fabian Homborg
feb6e9c90b Make DEFAULT_PROMPT and DEFAULT_TITLE work without functions
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.
2018-05-12 13:53:45 +02:00
Fabian Homborg
ef66b99721 Remove some dead code
This was a remnant from us checking `string length`. Now that we check
if the variable is set, this code does nothing.
2018-05-12 13:48:32 +02:00
Mahmoud Al-Qudsi
b635863509 Fix warnings when compiling under clang
Introduced by #4849 (add wait for processes by name)

../src/builtin_wait.cpp:23:14: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
    while (j = jobs.next()) {
           ~~^~~~~~~~~~~~~
../src/builtin_wait.cpp:23:14: note: place parentheses around the assignment to silence this warning
    while (j = jobs.next()) {
             ^
           (              )
../src/builtin_wait.cpp:23:14: note: use '==' to turn this assignment into an equality comparison
    while (j = jobs.next()) {
             ^
             ==
1 warning generated.
2018-05-11 11:11:53 -05:00
Fabian Homborg
1764716718 Merge branch 'pr/4849'
Yeah, this merge is a bit dirty. Sorry!
2018-05-11 17:01:15 +02:00
Fabian Homborg
c053065e91 Fix wait tests
This was probably the result of a botched merge.

Unfortunately these tests take quite a while, so maybe we should
remove some?
2018-05-11 16:58:55 +02:00
Fabian Homborg
a4f55d95d4 Detect GNU make via "--version"
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.
2018-05-11 16:16:14 +02:00
Fabian Homborg
7c5297e785
Merge branch 'master' into issue_4848 2018-05-11 16:06:27 +02:00
Fabian Homborg
9929acd9d8 Revert "Use git ls-files to generate completions for git"
While this is a bit faster (mostly because it needs less processing on fish's side),
it lacks the neat description bit and the ":/" stuff doesn't work.

The boost is also not large in absolute terms (a few milliseconds).

This reverts commit 1f8e4dad9f.
2018-05-11 16:00:45 +02:00
Mahmoud Al-Qudsi
1f8e4dad9f Use git ls-files to generate completions for git
This uses the same logic that git uses to determine the satus of files
and doesn't require any parsing on our end. Brings in support for
relative paths (such as `git add ../f<TAB>`). Should be faster and more
reliable than manually parsing porcelain status.

This doesn't support as many cases as the old `__git_ls_files` function
did (e.g. `renamed` is not supported, nor is `added`), both of which
_can_ be implemented on top of the new logic - but neither of which were
actually being used, anyway.

Usefulness is decreased by #4970, speed still bottlenecked by #4969.

cc @faho
2018-05-10 14:04:20 -05:00
Fabian Homborg
ceddd1e684 Restore . alias for source
The breakage is just too annoying.

This reverts 55bef3cd2e.
2018-05-09 16:51:52 +02:00
Fabian Homborg
1e3d26f744 [git completions] Remove impossible error message
We already read the rest into a "_" garbage variable.
2018-05-08 23:16:39 +02:00
Fabian Homborg
183b7f7017 [git completions] Complete deleted files after "--" for "reset" 2018-05-08 23:16:10 +02:00
Fabian Homborg
39e3c3c0b1 [git completions] Readd "unique remote branches"
This is based on what the official git completions do, and it's quite
fast.

Also only complete files after a "--" separator for `checkout`.

Fixes #4858.
2018-05-08 23:14:49 +02:00
Fabian Homborg
34fc390e13 [git completions] Shorten commit SHA ourselves
This is much quicker - on the order of 100ms vs 50ms.

We shorten to 10 characters, which is statistically suitable - 3 out
of 600k commits in the linux kernel need 11 characters.
2018-05-08 23:12:13 +02:00
Fabian Homborg
88b688c544 [hg prompt] Use hg status -q
For some reason, `hg status -q` prints the exact same output as `hg
status`, but about 20% faster.
2018-05-08 22:52:16 +02:00
Fabian Homborg
2c312d05df [docs] Add more subsections
They are great!
2018-05-08 17:26:56 +02:00
Fabian Homborg
5b1731331e [math] Add subsection headers to the docs
Otherwise this is printed as "math-syntax" in the man page.
2018-05-08 17:11:48 +02:00
Fabian Homborg
e35d248f64 Fix clearing abandoned line with VTE (#4243)
Turns out the segfaults we've been getting in our tests are because we set $TERM to "dumb".

So we only clear the line if the terminal isn't dumb.

This reverts commit 745a88f2f6.

Fixes #2320.
2018-05-08 13:07:47 +02:00
David Adam
21890ccac7 function: restore '%self' functionality for --on-process-exit
One key use of process expansion, used in currently-shipped code, is for running a function on
current shell exit.

Restore the use of %self as a valid argument (and add `self`) and document this change.

(faho: Remove bare "self")
2018-05-08 11:17:07 +02:00
ridiculousfish
98d736f916 Teach fish_indent about escaped newlines
Correctly indents code like:

   alpha | \
     # comment
     beta
2018-05-07 21:40:53 -07:00
ridiculousfish
6f57fef8f8 Teach the tokenizer to report escaped newlines
Add fields and flags so that escaped newlines can be reported, for the
benefit of fish_indent.
2018-05-07 21:39:30 -07:00
ridiculousfish
678fd86107 Minor cleanup of parse_ll_t::accept_tokens 2018-05-07 14:20:45 -07:00
ridiculousfish
5f787cfe55 Correct format string in dump_tree_recursive
This was passing two unused arguments to the format string. Use one
and drop the other.
2018-05-07 13:44:26 -07:00
Mahmoud Al-Qudsi
91f75d84d3 Completions for optipng 2018-05-06 18:55:12 -05:00
Mahmoud Al-Qudsi
6dc74d3b6c New helper functions __fish_is_first_arg and __fish_prev_arg_in
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.
2018-05-06 18:55:12 -05:00
Luc J. Bourhis
d652b9b606 Use --tool-help to find available tools for difftool/mergetool 2018-05-06 13:12:42 -07:00
Luc J. Bourhis
d7a9e25e17 Completion of git difftool and git mergetool: add missing options 2018-05-06 13:12:42 -07:00
ridiculousfish
aba69ac6ae Merge branch 'futurefeatures'
This merges support for feature flags.

Closes #4940
2018-05-06 12:31:51 -07:00
ridiculousfish
060643a3b0 Changelog feature flags 2018-05-06 12:31:32 -07:00
ridiculousfish
d623ac5040 Add future feature flags to the documentation 2018-05-06 12:06:06 -07:00
ridiculousfish
87eb073ff9 Remove some references to ^ redirection from the docs
Replace these with 2>
2018-05-06 11:53:14 -07:00
ridiculousfish
4194b4efee Add a feature_test() function
This is a convenience over fish_features().test()
2018-05-06 11:20:15 -07:00
ridiculousfish
762c31be87 Feature flag support for ? wildcard
This partially reverts 6e56637cf0 and #4520
by bringing back the ? wildcard, guarded by the qmark-noglob feature flag.
2018-05-06 11:20:15 -07:00
ridiculousfish
dc8d603f98 Add a qmark-noglob feature flag
This adds a feature flag for controlling whether question marks are globs.
It is not yet hooked up.
2018-05-06 11:20:15 -07:00
ridiculousfish
d3201ad887 Set features from the environment
This enables users to opt in (or out) of specific features by setting
the fish_features environment variable.

For example `set -U fish_features stderr-nocaret` to opt into removing the
caret redirection.
2018-05-06 11:20:14 -07:00
ridiculousfish
902af26253 Bring back caret redirections under a feature flag
This partially reverts 5b489ca30f, with
carets acting as redirections unless the stderr-nocaret flag is set.
This flag is off by default but may be enabled on the command line:

fish --features stderr-nocaret
2018-05-06 11:20:14 -07:00
ridiculousfish
8a96f283ba Allow setting feature flags on the command line
This introduces a new command line option --features which can be used for
enabling or disabling features for a particular fish session.

Examples:
  fish --features stderr-nocaret
  fish --features 3.0,no-stderr-nocaret
  fish --features all

Note that the feature set cannot be changed in an existing session.
2018-05-06 11:20:14 -07:00
ridiculousfish
782cae2d21 Add status subcomannds: features and test-feature
This teaches the status command to work with features.
'status features' will show a table listing all known features and whether
they are currently on or off.
`status test-feature` will test an individual feature, setting the exit status to
0 if the feature is on, 1 if off, 2 if unknown.
2018-05-06 11:20:14 -07:00
ridiculousfish
14f766b66d Add support for feature flags
This introduces a new type features_t that exposes feature flags. The intent
is to allow a deprecation/incremental adoption path. This is not a general
purpose configuration mechanism, but instead allows for compatibility during
the transition as features are added/removed.

Each feature has a user-presentable short name and a short description. Their
values are tracked in a struct features_t.

We start with one feature stderr_nocaret, but it's not hooked up yet.
2018-05-06 11:20:14 -07:00
ridiculousfish
7cbc0c371a Remove a "common fish problems" section in the docs
This wasn't really that common.
2018-05-06 11:19:58 -07:00
Fabian Homborg
1a1ee352ff [commandline] Change "--selection" to "--current-selection"
Plus documentation.

Work towards #4255.
2018-05-05 21:41:03 +02:00
Fabian Homborg
f533189a28 [default bindings] Bind \e\b as well
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.
2018-05-04 12:28:20 +02:00
Fabian Homborg
b5d6c1102e [git prompt] Only set chars/colors when necessary
Either on start or when something has changed.

This saves about 8ms on every call except the first.
2018-05-04 12:28:20 +02:00
Ray Juang
ba68efd543 Updating adb completion to enable tab-completing file paths for adb shell and pull commands 2018-05-03 16:41:04 +02:00
Fabian Homborg
b0368fd85b Set $IFS in C++
This was done in share/config.fish, but leads to surprising results if
that isn't read - e.g. because someone just built fish in the git
directory to test it without installing.

It's also not something that is any more or less complicated.

For compatibility, keep it in config.fish as well for the time being.
2018-05-03 12:49:21 +02:00