Commit Graph

4586 Commits

Author SHA1 Message Date
Fabian Boehm
f3444bd0cb Check for less before calling it 2022-10-18 18:05:16 +02:00
Fabian Boehm
c84e2eeac1 completions/git: Fix option
This was typoed in bef706b8f1
2022-10-14 23:14:49 +02:00
Mahmoud Al-Qudsi
acb77ad1a3 completions/git.fish: Sort in order of likelihood
In the presence of modified files, assume `git checkout ...` is being
invoked/completed with the intention of restoring modifications. Even if not the
case, this list is likely going to be shortest if someone is about to change
branches.

Afterwards, list branches (with local branches sorted by recency), then remote
unique remotes, heads, tags, and recent commits. The order of these last four
is up for debate, and honestly if any of them generate a lot of results it makes
finding what you're actually looking for in the autocompletions a lot harder.

It may be better to merge these last contenders and sort them by individual
recency instead, but that does make the pager entries rather messy (and we would
need to add a new function to do that in order to interleave them in the desired
sort order but preserve the overall sort after the completions subshell
terminates).
2022-10-14 15:29:46 -05:00
Mahmoud Al-Qudsi
bef706b8f1 completions/git.fish: always group -k with -a
It's really hard to see where -k is applied to git completions, so always group
it with -a to make it more consistent and easier to spot.

There should be no functional changes in this commit.
2022-10-14 15:20:41 -05:00
Bart Libert
759ca16b37
completions: Add dua (#9277) 2022-10-14 18:52:14 +02:00
Kjetil Thuen
c3052a6218
Add clojure completions (#9272)
* Add clojure completions

* More ideomatic fish code

* Clojure completions in separate file

* Aboid use of psb using bb -e

* Return early when bb can not be found

* Remove superflous escape

* Another superflous escape
2022-10-14 18:50:47 +02:00
Alexander Sieg
8f394f5771
Add completions for direnv (#9268)
* Add completions for direnv

* Update share/completions/direnv.fish
2022-10-14 18:48:38 +02:00
Mahmoud Al-Qudsi
22f6668914 completions/cargo.fish: Drop removed subcommand
`describe-future-incompatibilities` is no longer a supported subcommand. It was
also never something very popular so we don't have to worry about older
versions.

[ci skip]
2022-10-13 12:38:41 -05:00
Mahmoud Al-Qudsi
835230a82f fish_config: Fully erase existing globals before replacing
We only erase existing globals for some of the theme-related variables
but not for all the `known_colors`, causing `fish_config` to still emit
warnings for these if saving a theme choice after trying it.
2022-10-12 21:21:25 -05:00
Fabian Boehm
1e7a4b076d vi-mode: Bind "/" to history-pager
This is unused currently, so we can just use it here. Ctrl-s as the
inverse stays because that's shared.

Fixes #2271
2022-10-11 17:47:13 +02:00
Charles Maher
1dd8a113f2
Add feature to fish_commandline_prepend and fix minor issue (#9261)
* Prepending will now respect leading spaces instead of doubling it up.
* Removing a prefix no longer sends the cursor to the end of the line.
2022-10-06 14:27:28 -05:00
Gustavo Costa
62794446b7 Add asciinema completions 2022-10-05 18:53:54 +02:00
Sergei Shilovsky
e274ef6c0d
commandline --selection-start and --selection-end implementation
Fixes #9197
2022-10-05 18:51:00 +02:00
Mahmoud Al-Qudsi
82b78cfdbe Add missing -k to git completions
This is made much harder than it has to be by the fact that -k (where specified)
may be in any of a million different places, including as the first parameter,
as -ka, as a random standalone parameter, or tagged on to some other parameter
elsewhere; making it difficult to tell where it's actually missing!

Next job: automate cleaning up the order of arguments in this completions file.
2022-10-04 13:06:15 -05:00
Collin Styles
a5764663e7 Exclude current directory ('.') from rsync completions
Completing to '.' isn't useful and just gets in the way.
2022-10-04 12:53:17 -05:00
Fabian Boehm
e4f07fe010 Stop using alias for fish_indent/fish_key_reader 2022-10-04 17:01:19 +02:00
Mahmoud Al-Qudsi
cdfa76221e Completions: Adjust apt-cache output limit
The limit has been reduced to 2500 to match the limit on what we actually
consume downstream in the actual `complete -c apt ...` rule, as discussed [0].

[0]: https://github.com/fish-shell/fish-shell/commit/b88b2577267c6837886c93c
2022-10-03 18:31:40 -05:00
NextAlone
ef844a63b9
completion/adb: rework completions (#9233)
* add adb options

only complete device serial when space after '-s' option

* keep current `adb -s` completion

* add adb reboot fastboot

* only show tcp/ip devices for disconnect

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>

* fix: files not complete when options given

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>

* fix: use old-style options for adb generic options

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
2022-10-01 11:21:52 -05:00
NextAlone
794926d28e
completion/completions: use string match to detect usbip remote
* completion/usbip: use string-match to detect remote (#9250)

* simplify output

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
2022-10-01 11:19:29 -05:00
Mahmoud Al-Qudsi
40a0ea9bea Completions: sort local git branches by recency
I have about fifty git branches for fish and I almost always `git checkout`
between the most recent two or three - this makes the completions list more
usable. If you're using `git cherry-pick` or `git merge`, etc. you also most
likely to want to reference a recently changed branch.

The decision was made to only sort local branches and not remote ones in the PR
at #9248.

The performance of changing from one `git for-each-ref` invocation to two
separate ones (so we could sort them separately) was checked and found to be OK.

Food for future thought: consider ergonomics, caveats, and performance of
excluding the current branch's name from the list of completions (or perhaps
only from the first completion). Or maybe there's another way to have
`for-each-ref` give priority to a different branch while still sorting by
recency?
2022-09-30 19:05:27 -05:00
Mahmoud Al-Qudsi
6df57a6712 git completions: Change some default ASC/DESC for sort
Dates and file sizes are kept DESC while names, emails, and hashes are now
defaulted to ASC.
2022-09-30 15:09:14 -05:00
Mahmoud Al-Qudsi
d9bb91f1e1 git completions: fix spelling of committer everywhere
Some of the fixes are only for descriptions, others affect functionality.
2022-09-30 15:08:32 -05:00
Mahmoud Al-Qudsi
ce451f67c5 Suggest arguments for recently added git rebase --onto
It takes a wide variety of values, but I think branches are probably the most
common payloads. We can also include recent commits?
2022-09-29 16:57:23 -05:00
NextAlone
ffdef493c5
completion: add git rebase --onto (#9244)
Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
2022-09-29 15:34:47 -05:00
NextAlone
d065ea31a9
completion/usbip: don't use old-style completions (#9243) 2022-09-28 20:37:46 -05:00
Mahmoud Al-Qudsi
072dbfd6ed Remove __fish_seen_argument_from
Despite its somewhat misleading name, `__fish_seen_argument` can already handle
multiple arguments in one go and doesn't need a wrapper function!
2022-09-27 18:49:22 -05:00
Mahmoud Al-Qudsi
77941ea823 Completions: add git xxx --sort completions
The list of subcommands that emit a list of refs when executed bare may or may
not be complete; I just put the ones I know of.
2022-09-27 14:19:37 -05:00
Mahmoud Al-Qudsi
725c720d3d Completions: add git for-each-ref subcommand and its arguments 2022-09-27 14:19:37 -05:00
Mahmoud Al-Qudsi
1501693949 Add __fish_seen_argument_from wrapper
There are a million existing ways of skinning this cat, but it's a good parallel
to `__fish_seen_argument` to have, in a similar vein to
`__fish_seen_subcommand_from`.
2022-09-27 14:19:37 -05:00
Mahmoud Al-Qudsi
0cccbfcaaa Extend __fish_seen_argument to support raw arguments
This allows it to just directly match any literals (passed after `--`) without
treating them as pre-processed short/long/old arguments.
2022-09-27 14:19:37 -05:00
Fabian Boehm
5d5709b859 completions/ls: Remove dubious old-style option
Confirmed on NetBSD: The `ls -o` option groups. I tested `ls -gon` and
it didn't give an error.

It's quite suspect that this one option couldn't be grouped, so I'm
assuming this was a typo.
2022-09-26 21:31:21 +02:00
Fabian Boehm
47a4eeff99 completions/kcmshell5: Silence stderr
This can print errors about .desktop files not being 100% correct.

Like those shipped by KDE, with krunner.
2022-09-26 20:43:31 +02:00
Fabian Boehm
23bf98e6bb Remove unused __fish_cursor_1337 function
Last use removed in 011af34d62
2022-09-26 17:20:33 +02:00
Fabian Boehm
011af34d62 fish_vi_cursor: Use xterm sequence for iterm
This has been supported since 2012, allows blinking cursors and works
in tmux.

Fixes #9172
Fixes #3741
2022-09-26 17:06:14 +02:00
Fabian Boehm
42602ba4fc
completions/ffmpeg: Add missing parenthesis
Going by the other `string match`, this appears to just be missing a ")".

Fixes #8514
2022-09-26 15:11:58 +02:00
Ryuhei Yoshida
51177ef0ae Fix completions/tox 2022-09-26 09:45:54 +02:00
NextAlone
4b9c7fa534
Add usbip completions
Closes #9237
2022-09-25 15:30:34 -05:00
Fabian Boehm
b88b257726 Stringify apt completions again
Commit 09685c3682 tried making the apt
completions faster by doing two things:

1. Introduce a limiting "head"
2. Re-replace our "string" usage with tr

Unfortunately, in doing so it introduced a few issues:

1. The "tr" had a dangling "+" so it cut apart package
   descriptions that contained a "+".
   This caused e.g. "a C++ library" to generate another completion
   candidate, "library".
2. In reusing "tr" it probably reintroduced #8575,
   as tr is not 8-bit-clean.
3. It filtered too early, on the raw apt-cache output,
   which caused it to fill up with long descriptions.
   So e.g. for "texlive" it would only generate 10 completions,
   where it should have matched 54 packages.

Because most of the speedup is in the "head" stopping early, we
instead go back to the old string way, but introduce a limiting "head"
after the "sed" (which will have removed everything but the package
name line and the first line of the description)

In my tests this is about ~10% slower than doing head early and using
tr, but it's more correct.

Admittedly I haven't been able to reproduce the 35s scenario that
09685 talks about, but the most likely cause of that is *apt-cache*
being slow - I don't see how string can be that much slower on another
system - and so it will most likely also be fixed by doing head here.

Future possibilities here include:

1. Using "apt-cache search --names-only", which gives a much nicer
format (but only for non-installed packages - the search strings are
apparently ANDed?)
2. Switching to `string split`, possibly using NUL and using `string
split0`?
3. Introducing a `string --null-in` switch so we can get by with one
`string`
4. (multi-threaded execution so the `string`s run in parallel)
2022-09-23 15:37:40 +02:00
Mahmoud Al-Qudsi
09685c3682 Make apt completions useable once again
`apt-cache` is just so incredibly slow that filtering against the final results
just doesn't cut it. Attempting to match against 'ac.*' (already taking
advantage of changing short search terms into prefix-only matches) would take
35 seconds, all of bottlenecked before the filtering step. This change uses more
of a heuristic to filter `apt-cache` results directly (before additional
filtering) to speed things up.

A variety of different limits from 100 to 5000 were timed and their result sets
compared to see what ended up artificially limiting valid completions vs what
took too long to be considered functional/usable and this is where we ended up.
2022-09-22 13:43:38 -05:00
Fabian Boehm
af3a5b86d8 Call __fish_config_interactive also for interactive read
Not doing this results in our emergency keybindings being set up for
`read`.

Fixes #9227
2022-09-21 17:02:25 +02:00
NextAlone
549958a7ea
add adb logcat completions (#9219)
* add adb logcat completions

and suppress adb devices file completions

* fix lost space
2022-09-19 17:52:09 +02:00
NextAlone
404cee579b add fastboot oem subcommand completions 2022-09-19 17:51:40 +02:00
Mahmoud Al-Qudsi
c2155b770d [completions] Handle errors thrown by gh
`gh` doesn't write its errors to stderr and doesn't exit with a non-zero status
code in case of failure. The completions are short enough that buffering them
isn't a huge deal.
2022-09-16 16:44:18 -05:00
Fabian Boehm
309fae9a12 completions/pkginfo: Silence stderr 2022-09-14 17:50:58 +02:00
Fabian Boehm
8621852ec5 completions/git: Unify sorting for using_command
This removes one more call
2022-09-12 21:01:03 +02:00
Fabian Boehm
795e618864 completions/git: Check for stash separately
This cuts down `__fish_git_using_command` calls from 75 to 68, saving
some time in the common case.

(it would be possible to remove the check from
`__fish_git_stash_using_command` now, but that's brittle and it's one
call, so it's not a big issue)
2022-09-12 20:59:33 +02:00
Fabian Boehm
5844353e85 completions/git: Fix apply --apply
This used the wrong function
2022-09-12 20:59:33 +02:00
Maxime Bouillot
d50e9ffff3
Add the possibility to ignore arguments in alliases (#9199)
* Replace ";" with "\n" in alias-generated functions

This can let us add a "#" in our aliases to make
them ignore additional arguments.

* Update changelog about aliases that ignore arguments

* Update test for alias.fish

This is now compliant with the aliases that can
ignore arguments.
2022-09-11 09:55:11 +02:00
Fabian Boehm
a750b28eb4 funced: Use a read prompt *string*
This used a prompt command, but since the prompt was interpolated and
included a `?` it would be run as a glob without qmark-noglob.

Since it's simpler to pass a prompt string, just do that.
2022-09-10 17:42:16 +02:00
Fabian Boehm
7f1e9bf57f Also convert fish_job_summary 2022-09-09 18:49:57 +02:00