Commit Graph

8493 Commits

Author SHA1 Message Date
slama
beba9df406 add job expansion wrapper for disown 2018-04-19 00:13:16 -05:00
Mahmoud Al-Qudsi
156d4fb9b9 Complete npm package names for npm install via all-the-package-names
`npm search` was _way_ too slow to be used for dynamic completions, so
using a cached list of all avaialable NPM packages to match against.

This is a bit brave for a fish completion, but the npm package
`all-the-package-names` has a list of, well, all the package names
avaialable for installation via the default npm registry. Installing a
copy locally to $HOME/.cache/fish/npm_completions and using that to
search for packages matching the tokenized command line.

Preference would be to call `__update_atpm` in the background, but that
emits an ugly "job has completed" message..

Should also use this for completions for `yarn add`.
2018-04-18 22:42:46 -05:00
Mahmoud Al-Qudsi
c2e66b002a Dynamically invoke yarn completions so they aren't cached
Correct `-a (something)` to `-a '(something)'`
2018-04-18 21:43:39 -05:00
Mahmoud Al-Qudsi
9d9afd8264 Speed up ./configure completion by not running ./configure --help
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.
2018-04-18 15:40:52 -05:00
Mahmoud Al-Qudsi
6c5e5d35a9 Add real completions for ./configure
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.
2018-04-17 21:35:51 -05:00
Mahmoud Al-Qudsi
c8af566330 Stop completion skipping in case of valid ./command
complete.cpp strips the path from commands before parsing for
completions, meaning that when we called `path_get_path()` against
`cmd`, if `./cmd` were typed in at the command line but `cmd` does not
exist in the PATH, then the command would incorrectly be flagged as not
present and the completions would be skipped.

This is also faster when an absolute/relative path is used for a
command, as we now search with the original path which skips searching
PATH directories unnecessarily.

Found when debugging why completions for `./configure` wouldn't work.
2018-04-17 21:34:22 -05:00
Mahmoud Al-Qudsi
c2cfc65cf2 Correct read behavior for unset values and update tests accordingly
`read` with IFS empty was expected to set all parameters after the first
n filled variables to an empty string, but that was inconsistent with
the behavior of `read` everywhere else.

I'm not sure why fish differed from the spec with regards to the
behavior in the event of an empty IFS: we eschew IFS where possible, yet
here we adopt non-standard behavior splitting on every (unicode)
character instead of not splitting at all with IFS empty. We still do
that, but now the unset variables are treated as they normally would be,
i.e. cleared and not set to an empty string (which is what an empty
value between two IFS separators would contain).
2018-04-17 21:34:22 -05:00
Mahmoud Al-Qudsi
3742a7827f Support multiple read --line variable outputs
ref #4861. Also closes #4917.
2018-04-17 21:34:22 -05:00
Mahmoud Al-Qudsi
bd8c8ceb59 Add line-delimited read presets with --line and --all-lines
Refer to changes in doc_src/read.txt for more info. Closes #4861.
2018-04-17 21:34:22 -05:00
Mahmoud Al-Qudsi
d00474f0fc Optimize split_about 2018-04-17 21:34:22 -05:00
Mahmoud Al-Qudsi
7a07e9fc76 Stop ignoring .out files in tests/ directory 2018-04-17 21:34:22 -05:00
Kevin Ballard
afc5c0a6e7 Tweak the error message for history delete --exact foo
The old message made it sound like the `--exact` flag wasn't supported.
2018-04-14 21:59:18 -07:00
Mahmoud Al-Qudsi
a9b582d2a8 Block .dll files from completion as potential heads under WSL 2018-04-14 23:56:30 -05:00
Kevin Ballard
9216544437 Add completion for --case-sensitive flag to history 2018-04-14 21:45:25 -07:00
Mahmoud Al-Qudsi
a2cb9cceaf Erase default autojump completions in j.fish completions
The default completions that autojump ships with for fish are broken
(emitting output like "1\___\#...") as they use hackes to work around
the previous lack of `complete -k`. The history-based autojump
completions fully replace it.
2018-04-14 23:23:33 -05:00
Mahmoud Al-Qudsi
2961dcc4be Stop echo from swallowing passthrough arguments
The job expansion wrapper was swallowing `-n` (and presumably `-e` and
others) when that was the literal argument we needed to emit. Using
`printf %s ...` instead.
2018-04-14 23:19:25 -05:00
Mahmoud Al-Qudsi
7ec761fc75 Revert "Fix wait test with no process expansion"
This reverts commit b38ac1e35d as wait now
supports process expansion (via the wait wrapper).
2018-04-14 21:42:57 -05:00
Mahmoud Al-Qudsi
9a9238a253 Add job expansion wrapper for kill 2018-04-14 21:17:23 -05:00
Mahmoud Al-Qudsi
e35983438e Blow away existing $fish_data_dir on (re)install
Fixes #4314 (under cmake, at least)
2018-04-14 21:01:52 -05:00
Mahmoud Al-Qudsi
9f3059b7f4 Add wrappers for fg/bg/wait to support job expansion
See commit 1c8bbfdb6d for an alternative
approach, if this isn't desired.
2018-04-14 17:11:04 -05:00
Mahmoud Al-Qudsi
1c8bbfdb6d Support job expansion for jobs builtin
This brings back expansion of `%n` where `n` is a job id, but not as a
general parser syntax. This makes `jobs -p %n` work, which can be used
as part of the job control command chain, i.e.

```
cat &
fg (jobs -p %1)
```

fg/bg/wait can either be wrapped in a function to call `jobs -p` for
`%n` arguments, or they can be updated to take `%n` arguments
themselves.
2018-04-14 16:47:05 -05:00
Mahmoud Al-Qudsi
facdc88c0c Improve completions for ssh by completing from history 2018-04-12 22:28:50 -05:00
Fabian Homborg
14d59c53f6 Stop using fuzzy translations in autotools build
We've already stopped doing this for cmake, and as we've seen in
issue #4847, it can cause _crashes_.
2018-04-10 21:56:37 +02:00
Fabian Homborg
60c4a66c57 Fix crash in wait in english
Wrong specifier in the localization again.

Note that this was already alleviated by not using fuzzy
translations in the cmake build.

Fixes #4847.
2018-04-10 21:56:21 +02:00
Fabian Homborg
d53750bee6 Let read -s also output to stdout
This was caused by "to_stdout" being automatically enabled if argc was
0 _before_ removing options.

Fixes #4859.
2018-04-10 21:46:43 +02:00
Fabian Homborg
ea49c14c62 Fix read to stdout output appearing first
echo banana (read)

will output whatever read reads _first_ because it uses a direct
write_loop().

This also removes some duplicate code.
2018-04-10 21:45:28 +02:00
Fabian Homborg
701259d372 Remove ":" from argparse docs
Also improve some of the wording.

Fixes #4871.

[ci skip]
2018-04-10 21:26:02 +02:00
Fabian Homborg
a89e9e7ba3 Improve read docs re splitting
Intentionally make no mention of $IFS, because it is deprecated.

Fixes #4861.
2018-04-10 21:26:02 +02:00
Kevin Ballard
f7ba2a6a00 Don't corrupt memory when setting a slice with wrong # of args
Fixes #4881.
2018-04-10 21:09:31 +08:00
Wilke Schwiedop
5d01399586 add file readability-test 2018-04-09 01:09:49 +02:00
Wilke Schwiedop
8ae9b716a0 fix 'grep ... | sed' 2018-04-09 01:09:49 +02:00
Wilke Schwiedop
bd24e8662e fix 'sort | uniq' 2018-04-09 01:09:49 +02:00
Thom Chiovoloni
25169a44ed Add alias -s/--save, which saves the alias.
Also updates the `alias` documentation to mention the `-h`/`--help` option,
which was previously undocumented.
2018-04-09 01:08:56 +02:00
George Christou
6c0f31d622 completions: [git] Use builtin git truncation 2018-04-09 01:07:52 +02:00
George Christou
c6e7b7ef00 prompt: Show untracked Git files relative to root directory (#4874)
* prompt/git: Match untracked files relative to root directory

* prompt/git: Move untracked file logic to a separate function
2018-04-09 01:05:03 +02:00
Fabian Homborg
01f24f2df6 Fix typo in emacs completions
Fixes #4885.

[ci skip]
2018-04-09 00:46:35 +02:00
Mahmoud Al-Qudsi
366933413b Fix string match argument parsing in __fish_seen_argument 2018-04-03 21:13:11 -05:00
Mahmoud Al-Qudsi
d8a1928c24 Convert list of builtins from sorted array to unordered_set
The order of this list does not need to be strictly maintained any
longer.

Benchmarked with `hyperfine` as follows, where `bench1` is the existing
approach of binary search and `bench2` is the new unordered_set code,
(executed under bash because fish would always return non-zero). The
benchmark code checks each argv to see if it is a builtin keyword (both
return the same result):

```
hyperfine './bench1 $(shuf /usr/share/dict/words)' './bench2 $(shuf /usr/share/dict/words)'
Benchmark #1: ./bench1 $(shuf /usr/share/dict/words)

  Time (mean ± σ):      68.4 ms ±   3.0 ms    [User: 28.8 ms, System: 38.9 ms]

  Range (min … max):    60.4 ms …  75.4 ms

Benchmark #2: ./bench2 $(shuf /usr/share/dict/words)

  Time (mean ± σ):      61.4 ms ±   2.3 ms    [User: 23.1 ms, System: 39.8 ms]

  Range (min … max):    58.1 ms …  67.1 ms

Summary

'./bench2 $(shuf /usr/share/dict/words)' ran
    1.11x faster than './bench1 $(shuf /usr/share/dict/words)'
```
2018-04-03 15:47:21 -05:00
Mahmoud Al-Qudsi
c492d03f51 Overhaul completions for set and add new completions for set -e
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.
2018-04-03 14:42:26 -05:00
Mahmoud Al-Qudsi
cc50103e53 Unblock builtins from completions
The `head_exists` value was being reset after being set to true for most
builtins, causing completions to not trigger.
2018-04-03 14:05:11 -05:00
Mahmoud Al-Qudsi
99ecaec175 Use system web browser under WSL
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).
2018-04-02 18:36:14 -05:00
ridiculousfish
358e9def5b Fix the git completion
Commit 6e56637cf ran fish_indent on the git completion and mangled some
of it. Manually revert the non-essential changes.
2018-04-02 10:26:40 -07:00
David Adam
61ab3aea8c webconfig: import webbrowser with empty TERM
Re-introduces the changes from 168d25e780
which were inadvertently removed in
20bcbcc252.

Work on #4299. Re-commit of #1132.
2018-04-02 21:35:10 +08:00
David Adam
5c56765d12 hg prompt: fix infinite loop due to incorrect scoping
4b079e16e5 fixed some unintended behaviour
which the hg prompt was apparently relying upon, producing an infinite
loop whenever called.
2018-04-02 21:24:52 +08:00
ridiculousfish
f922875dbc Fix the Linux build 2018-04-01 17:59:42 -07:00
ridiculousfish
a98cc75f9e Reword warning inside fish_universal_variables file
Prior to this fix, the fish universal variables file claimed that
changes to it would be overwritten. This no longer true and has not
been true for a long time. Remove that warning.
2018-04-01 17:51:53 -07:00
ridiculousfish
ba8bdbb3ae Reference issue for removing uvars MAC address in CHANGELOG 2018-04-01 17:47:43 -07:00
ridiculousfish
0d0a65dc87 CHANGELOG removal of MAC address from uvars file
Part of #1912
2018-04-01 17:46:02 -07:00
ridiculousfish
ff10e504a1 Remove MAC address from universal variables file
This switches the universal variables file from a machine-specific
name to the fixed '.config/fish/fish_universal_variables'. The old file
name is migrated if necessary.

Fixes #1912
2018-04-01 17:43:12 -07:00
ridiculousfish
ca13e816ce Make fish more resilient to empty key bindings
If fish_key_bindings gets set to empty, fish will become unusable.
In this case reset it to fish_default_key_bindings.
2018-04-01 16:11:12 -07:00