Commit Graph

3660 Commits

Author SHA1 Message Date
Fabian Homborg
4bfda47449 Bind ctrl-r to search history if the commandline isn't empty
This is super cheesy.

One of the most common feature requests we get is "control-r must
search", even tho just using history-search-backward via e.g. up-arrow
is perfectly capable. The only real difference is that ctrl-r search
in other shells allows editing the search term by default, while we
stop the history search and edit the new commandline in those cases.

So, since the major problem is muscle-memory on ctrl-r,
let's just use that!

This makes ctrl-r do nothing on empty commandlines, and do
history-search-backward otherwise, so the basic flow of "press ctrl-r
to start history search, enter your search term, press ctrl-r to cycle
through matches" just works (except the first ctrl-r is useless and it
doesn't show anything).

See #602.
2020-10-23 13:42:54 +02:00
Mahmoud Al-Qudsi
7990bd3046 [npm/yarn] Add support for namespaced packages
The regex previously in use did not allow for namespaced packages and
wouldn't match against things like @types/foo.
2020-10-21 22:26:52 -05:00
Johannes Altmanninger
943cf03d8e Only send the PID of the last process in a job to builtin fg
jobs -p %1 prints all processes in the first job.
fg is special because it only takes one argument.  Using the last process
in the pipeline works for the cases I can think of.

Fixes #7406
2020-10-18 19:36:48 +02:00
Johannes Altmanninger
b633b443ba fixup! completions/git: handle "1 .A" files 2020-10-17 07:45:22 +02:00
Johannes Altmanninger
14855de95a completions/git: handle "1 .A" files
Fixes #7403
[ci skip]
2020-10-16 22:11:01 +02:00
Fabian Homborg
2a6547dd7c completions/mysql: Complete database name
Gosh this interface is awful - we really really need to strip the
weird ascii table and the "Database" header.

[ci skip]
2020-10-12 19:50:20 +02:00
Mahmoud Al-Qudsi
3f0e2ef1dc [openssl] Support openssl 1.1.0 completions 2020-10-10 11:53:57 -05:00
Johannes Altmanninger
863b4700f8 Use builtin command in spago completions, add to changelog 2020-10-10 13:11:53 +02:00
matoruru
d544cda937 Add completions/spago.fish 2020-10-10 13:07:27 +02:00
Johannes Altmanninger
f20e8e5860 alias: don't add --wraps for wrappers with the same name
These aliases seem to be common, see #7389 and others.  This prevents
recursion on that example, so `alias ssh "env TERM=screen ssh"` will just
have the same completions as ssh.

Checking the last token is a heuristic which hopefully works for most
cases. Users are encouraged to use functions instead of aliases.
2020-10-10 09:24:49 +02:00
Johannes Altmanninger
03e0ec82af alias: use original body instead of escaping back and forth 2020-10-10 09:24:49 +02:00
Johannes Altmanninger
a635d78976 competions/env: only invoke subcommand completions once
This prevents a seemingly infinite loop in
fish -c 'alias ssh "env ssh"; complete -C "ssh "'

It still prints "maximum recursion depth exceeded", but a follow-up commit
will work around that.

Fixes #7389
2020-10-10 09:24:49 +02:00
Johannes Altmanninger
f917211f3b completions/ssh: history --max=n might be better than head -n 2020-10-10 09:24:49 +02:00
Johannes Altmanninger
1173e8bda4 Clarify that some complete calls just need a command with no user-defined completion 2020-10-10 09:24:49 +02:00
Fabian Homborg
fb57ca8791 __fish_apropos: Use macOS' stat explicitly
Overrides the GNU tools some people use.

Fixes #7390.
2020-10-09 18:58:35 +02:00
Fabian Homborg
468c6ff0f8 abbr: Erase all abbrs in one go
Simplifies returns, also allows erroring out without erasing anything
if an abbr name was bogus
2020-10-04 12:34:51 +02:00
Fabian Homborg
420fa68c54 abbr: Fix check for spaces in the name
This used a non-existent variable
2020-10-04 12:34:51 +02:00
Fabian Homborg
135c5a9746 abbr: Don't write an error if erasing nonexisting abbrs
Fixes #7376.
2020-10-04 12:34:38 +02:00
Fabian Homborg
2ab4c10c47 abbr: Allow erasing multiple
Fixes #7377.
2020-10-04 12:27:59 +02:00
Joni Salmi
f845f267bd umount.fish Add long flags and fix long description in completion #6981 2020-10-03 17:16:39 -07:00
ridiculousfish
a6686ca310 Run makewhatis in the background
In the new __fish_apropos, makewhatis is run explicitly to generate the
whatis database. However this can be a little slow. Run it in the
background, after the apropos call completes so as to avoid a weird
race.

This means that descriptions may not be available the first time the
user invokes it, but that's better than appearing to hang for a while.
2020-10-03 17:09:00 -07:00
Folke Lemaitre
a6a0d43c9c Better __fish_describe_command for Macos
override MANPATH used by apropos with local whatis database and update it once a day

get rid of xargs

Created __fish_apropos and fixed __fish_complete_man to use that as well

moved macos apropos comment
2020-10-03 16:18:44 -07:00
Johannes Altmanninger
a1fd9e1b85 Fix invalid flags for builtin type
This combination of flags doesn't work anymore, which makes sense.
2020-09-30 21:46:43 +02:00
Johannes Altmanninger
f758d39535 string pad: handle padding characters of width > 1
If the padding is not divisible by the char's width without remainder,
we pad the remainder with spaces, so the total width of the output is correct.

Also add completions, changelog entry, adjust documentation, add examples
with emoji and some tests.  Apply some minor style nitpicks and avoid extra
allocations of the input strings.
2020-09-27 21:59:15 +02:00
Johannes Altmanninger
46746b4b26 completions/git: offer commit ranges for range-diff
A match made in heaven!
2020-09-27 21:59:15 +02:00
Johannes Altmanninger
e9582c41b2 Remove __fish_complete_external_command
It's no longer used.
2020-09-25 19:33:01 +02:00
Johannes Altmanninger
618705285d completions/git: support ... range notation
https://git-scm.com/docs/gitrevisions#_revision_range_summary
2020-09-25 19:33:01 +02:00
Johannes Altmanninger
2a95b283ee completions/git: complete only right commit if cursor is beyond the ".."
This enables completion for the right part of a range in many cases, like
`git log HEAD~10..`.
2020-09-25 19:33:01 +02:00
Fabian Homborg
293a3a628d Remove pipestatus_with_signal
This was a wrapper around status_to_signal, just because that only
handled a single argument.

Instead, just teach status_to_signal to handle multiple arguments and
be done.
2020-09-24 20:14:10 +02:00
Fabian Homborg
dde8318e50 print_pipestatus: Simplify
Just some minor stylistic nits
2020-09-24 20:08:16 +02:00
Mahmoud Al-Qudsi
533957fc2e [apt] Add --with-new-pkgs completion
[ci skip]
2020-09-22 21:52:47 -05:00
Fabian Homborg
ef9c924960 Make type a builtin
This is too important to not be one.

For one if it couldn't be loaded for any reason it would
break a lot of fish scripts.

Also this is faster by ~20x.

Fixes #7342
2020-09-21 20:58:34 +02:00
Fabian Homborg
a3e20a4d38 Don't use abbreviated long options
"function --argument" is not a thing, it's "--argument-names". This only
accidentally works because our getopt is awful and allows abbreviated
long options.

Similarly, one argparse test used "--d" instead of "-d" or "--def".
2020-09-19 11:47:41 +02:00
exploide
ca730cf714 added completions for micro 2020-09-18 19:41:44 +02:00
Johannes Altmanninger
6ec0b583f5 __fish_paginate: move the cursor to end of recalled commandline
When pressing \ep on an empty commandline, the cursor would stay at the
beginning of the commandline. Move it to the end of the previous command,
this feels a bit more natural.
2020-09-17 18:44:54 +02:00
Johannes Altmanninger
07c8608034 Fix make -j description 2020-09-17 18:44:54 +02:00
Mahmoud Al-Qudsi
304649acc6 [zfs] Add completions for new dataset prefix
[ci skip]
2020-09-16 14:37:59 -05:00
Fabian Homborg
e86a31f6d4 Use the newly fixed test -t in isatty
Removes a weird dependency on the test command.
2020-09-16 21:02:59 +02:00
Fabian Homborg
1c43030d79 cd: Remove unneeded code
This now works in cd proper, so it's unneeded in the function.
2020-09-12 20:17:30 +02:00
Fabian Homborg
0072367512 fish_add_path: Don't resolve symlinks
The case for symlinked directories being duplicated a lot isn't there,
but there *is* a usecase for adding the symlink rather than the
target, and that's homebrew.

E.g. homebrew installs ruby into /usr/local/Cellar/ruby/2.7.1_2/bin,
and links to it from /usr/local/opt/ruby/bin. If we add the target, we
would miss updates.

Having path entries that point to the same location isn't a big
problem - it's a path lookup, so it takes a teensy bit longer. The
canonicalization is mainly so paths don't end up duplicated via weird
spelling and so relative paths can be used.
2020-09-12 19:28:01 +02:00
Fabian Homborg
691deac1e4 Print default error in the pacman cnf-handler
Pacman *only* prints the package if it exists, no error or anything.

Fixes #7327.
2020-09-11 20:58:02 +02:00
Fabian Homborg
34be1b458a Add fish_command_not_found handler for pacman
Since version 5 (IIRC), pacman has a file database.

This is useful for people who don't have pkgfile, but we still prefer
that because it's much faster - pacman takes a full *second* on my system.
2020-09-09 17:44:25 +02:00
Mahmoud Al-Qudsi
bf31333622 [ffmpeg] Prevent -codec from matching -codec:[vas]
This was preventing the narrowing of matching completions.

[ci skip]
2020-09-07 16:52:47 -05:00
Mahmoud Al-Qudsi
2a4289dcd1 [ffmpeg] Fix variable name in __fish_ffmpeg_complete_regex
[ci skip]
2020-09-07 16:52:47 -05:00
Joost-Wim Boekesteijn
0cec12c6c0 ffprobe completions: show_stream -> show_streams
This should be `show_streams` instead of `show_stream` according to:

31b6b6685e:/doc/ffprobe.texi#l218
2020-09-07 18:52:08 +02:00
Fabian Homborg
576ce5f9f5 Remove __fish_command_not_found_handler
This could lead to an infinite loop (well, stack overflow) because
fish_command_not_found would also be defined to call
__fish_command_not_found_handler.

Since this is for

- missing command errors
- when downgrading

we can just remove it.
2020-09-06 13:50:38 +02:00
Fabian Homborg
0131974378 Use OpenSUSE command-not-found via $PATH
We check the full $PATH, so it's not guaranteed that it is in /usr/bin.
2020-09-06 11:15:54 +02:00
Fabian Homborg
340de73172 Call "fish_command_not_found" if a command wasn't found
Previously, when a command wasn't found, fish would emit the
"fish_command_not_found" *event*.

This was annoying as it was hard to override (the code ended up
checking for a function called `__fish_command_not_found_handler`
anyway!), the setup was ugly,
and it's useless - there is no use case for multiple command-not-found handlers.

Instead, let's just call a function `fish_command_not_found` if it
exists, or print the default message otherwise.

The event is completely removed, but because a missing event is not an error
(MEISNAE in C++-speak) this isn't an issue.

Note that, for backwards-compatibility, we still keep the default
handler function around even tho the new one is hard-coded in C++.

Also, if we detect a previous handler, the new handler just calls it.

This way, the backwards-compatible way to install a custom handler is:

```fish
function __fish_command_not_found_handler --on-event fish_command_not_found
    # do a little dance, make a little love, get down tonight
end
```

and the new hotness is

```fish
function fish_command_not_found
    # do the thing
end
```

Fixes #7293.
2020-09-06 11:15:54 +02:00
Johannes Altmanninger
55bc6a27c6 Make prompts forward compatible with fish 3.1.2 by passing locally exported variable
Commit 5d135d555 (prompts: fix pipestatus for jobs prefixed with "not")
introduced a backwards compatibility hack about adding an optional argument
to __fish_print_pipestatus. This hack would break downgrading to fish 3.1.2
if the user copied the new prompt to their config - they would get a backtrace
on every prompt which is arguably worse than the patch's minor improvement.

This does away with the error trace - old fish just won't show the fancy
new pipestatus on `not true`.

Implemented by passing the last $status as the poor man's kwarg, which works
since 3.1.0 (9b86d5dd1 Export all local exported variables in a new scope).

The prompts don't work with fish 3.0.0 or older; downgrading does not seem
too important in general but I think this patch is an okay simplification.
2020-09-05 09:58:55 +02:00
Johannes Altmanninger
89724f9366 prompts: guard against missing fish_is_root_user
Prevents error spew when running one of these prompt on fish 3.1.2.
2020-09-05 09:48:47 +02:00
Mahmoud Al-Qudsi
4331face4a [vips] Add vips completions
Just a skeleton completion file, but the list of available
actions/completions is at least dynamically generated (there's a lot of
them, they are impossible to remember, and they depend on build
options).

[ci skip]
2020-09-04 21:40:27 -05:00
Mahmoud Al-Qudsi
fe6fb23f43 [ffmpeg] Add -f formats completions
[ci skip]
2020-09-04 13:43:26 -05:00
Charles Gould
6fd68d553d Stop initializing fish_color_match, it is no longer used 2020-09-04 19:46:38 +02:00
V
fc13dd362c
Colourise diff(1) output, if supported (#7308) 2020-09-04 18:43:09 +02:00
Fabian Homborg
1041e59c5b fixup! Do actually use the correct command
Sorry!
2020-09-04 16:59:08 +02:00
Fabian Homborg
0ae37ac83a Add alias completions
Fixes #7305
2020-09-04 16:58:41 +02:00
Fabian Homborg
bfb5b28d0f Let command, jobs and type take --query instead of --quiet
Now command, jobs, type, abbr, builtin, functions and set take `-q` to
query for existence, but the long option is inconsistent.

The first three use `--quiet`, the latter use `--query`. Add `--query`
to the first three, but keep `--quiet` around.

Fixes #7276.
2020-09-04 16:55:09 +02:00
Mahmoud Al-Qudsi
91b2edd51d [apt] Add --no-install-recommends
[ci skip]
2020-09-03 21:47:21 -05:00
Mahmoud Al-Qudsi
326fd8d750 [cargo] Add dynamic --package completions
[ci skip]
2020-09-03 13:41:37 -05:00
Akatsuki
4f0f5daea9 go.fish: add some missing options
also fix long descriptions #6981
2020-09-02 20:58:29 +02:00
Shun Sakai
244feee692
Add completions for some missing GLib's tools (#7300) 2020-09-01 05:15:23 +02:00
Fabian Homborg
ee84223138 Webconfig: Run prompts one at a time if necessary
Termux doesn't support sem_open, which means python doesn't support
multiprocessing.

So we have to resort to brute force.

Fixes #7298.
2020-08-31 16:50:07 +02:00
Fabian Homborg
be3a7c03ba Move truecolor detection to C++
This allows us to send proper debug messages via FLOG, and it removes
more things from share/config.fish.

Note that the logic differs in some subtle ways. For instance it will
now obey $COLORTERM, so if that isn't "truecolor" or "24bit" it will
deactivate truecolor.
2020-08-31 16:49:57 +02:00
Mahmoud Al-Qudsi
c1cb462854 [ffmpeg] Complete some popular codec-specific options 2020-08-30 22:23:25 -05:00
Mahmoud Al-Qudsi
010db9e7be [ffmpeg] Complete filter graphs
Dynamically generate a list of supported filters and transmogrify the
typed out filter graph into a fish completion.

[ci skip]
2020-08-30 22:23:25 -05:00
Mahmoud Al-Qudsi
3d5e1a061c [ffmpeg] Add enumeration of pixel formats
[ci skip]
2020-08-30 22:23:25 -05:00
Mahmoud Al-Qudsi
280e99467d [ffmpeg] Enumerate codecs for numbered streams
* This adds support for enumerating codecs after, e.g., -c✌️0
* (Also adds support for indeterminate codecs without a/s/v specified)

[ci skip]
2020-08-30 22:23:25 -05:00
Mahmoud Al-Qudsi
0d3f4db33a [cargo] Use filesystem for --example completions
`cargo run --example` no longer lists examples and never listed examples
that were not built.
2020-08-29 17:06:33 -05:00
Akatsuki
f88d7dd312 btrfs.fish: fix long descriptions 2020-08-28 20:10:12 +02:00
Fabian Homborg
6a21a2ce16 Prompts: Don't color space before pipestatus
These passed " [" to __fish_print_pipestatus as the left brace.

If the color contained a background, that would also color the space
in, leading to a weird unbalanced space before and none after.

Instead, prepend the whitespace when printing later.

[ci skip]
2020-08-27 18:41:38 +02:00
Fabian Homborg
f88c3389da fish_prompt: Don't do work outside of the function
That just makes it annoying to use `funced`.

Also sync the classic_vcs prompt again.
2020-08-27 17:07:23 +02:00
chref
81d87d1c7f
fix Subversion prompt (#7278)
* fix Subversion prompt

- after switching to "string match", some SVN status symbols need
  proper escaping
- the __fish_svn_prompt_flag_names list was missing
  "versioned_obstructed" and was therefore not in line with
  the symbols from __fish_svn_prompt_chars
- when checking for individual SVN status symbols, use
  "string match -e" to handle the case where multiple different
  symbols appear in one status column
- use "sort -u" before merging all symbols from a column into
  one line

Fixes #6715

* use regex for SVN status matching

Using regex matching will prevent different match behaviour
depending on qmark-noglob feature.
Also, counting the resulting matches is unnecessary.

* use list instead of string for SVN status

Make $column_status a list be not removing newlines from SVN status
output. This makes checking for the individual status types within
a column easier because it doesn't require regex matching.

* added quotes for string length test (-n)
2020-08-26 18:31:23 +02:00
exploide
167a96fdeb corrected grep completions 2020-08-24 20:28:46 +02:00
Daniel Bengtsson
23f9373d26 Fix the description for ping.
Fix the long description for ping.
2020-08-24 19:31:48 +02:00
Fabian Homborg
72a44460c6 Move fish_greeting to a function
This adds a "fish_greeting" function that prints the variable of the
same name.

In doing so, it makes $fish_greeting default to a global
variable (this is of little cost because of the `_` builtin)

This means that:

- We have fewer universal variables by default
- If we change the default greeting people will actually get
- it (unless they have a leftover universal, of course)
- If the user changes their language the variable changes with it
2020-08-21 20:46:23 +02:00
Tom Dunlap
dc411b373d Remove "go run" from commands with exclusive args
`go run` compiles and runs a go program passing along the trailing args to the compiled program. Limiting `go run` to only complete *.go files means that if you are running a go file that takes a file path as a command line argument, you frustratingly cannot use tab completion.
2020-08-21 20:40:23 +02:00
Daniel Bengtsson
9ffaade0db Fix the long description for ansible.
Maybe it's not necessary to display the default path here.
2020-08-20 21:40:11 +08:00
Charles Gould
bb23385baa completions: add missing options for history builtin 2020-08-20 20:15:56 +08:00
Johannes Altmanninger
eb59d4eb14 Run fish_indent on share/**.fish 2020-08-17 17:40:28 +02:00
Colin Woodbury
a0b46e6204 Update Aura completions 2020-08-13 00:29:55 +02:00
Johannes Altmanninger
46a69d6b90 Simplify prime-run completions 2020-08-10 20:46:07 +02:00
oriko1010
8b02a78887 Add completion for prime-run 2020-08-10 20:44:20 +02:00
Johannes Altmanninger
9c327b19a6 Fix extra or missing newlines at end of file in our fish scripts
New fish_indent does that too, so this will make any future reformatting
diffs smaller.

Done using either of:

	perl -pi -e 'undef $/; s/\n*$/\n/' share/**.fish
	kak -n -f '<a-/>\n*<ret>d' share/**.fish
2020-08-09 23:53:46 +02:00
Johannes Altmanninger
918c62863e Fix typo 2020-08-09 23:53:46 +02:00
Johannes Altmanninger
93cb0e2abb __fish_complete_suffix: enable fuzzy completion, simplify
fish's internal completion logic is much smarter than the globbing in this
function, so let's just reuse "complete -C", and filter directories and
files with the given suffix.

Thanks to @Kratacoa for reporting on Gitter.

Using "complete -C" works well no prefix is given. Since in this repository
only the openocd completions pass a prefix, I left the prefix-case as is.
It could probably be improved and simplified as well.  The prefix argument was
introduced to avoid cd's side effects inside a completion. Using cd is tempting
though because it would allow to use the same logic as without a prefix.
2020-08-08 22:59:41 +02:00
Johannes Altmanninger
0dd334ee46 __fish_complete_suffix: replace prefix only at start 2020-08-08 22:56:54 +02:00
Johannes Altmanninger
b7bd7e9916 Clean up some __fish_complete_suffix usage
Also don't cd in pine completions.
2020-08-08 22:56:54 +02:00
Fabian Homborg
203061292f Remove unused "__fish_prompt_cwd" variable
The repaint handler erased a variable that was just a dumb cache when `set_color` wasn't a builtin.

It was removed in 3f11d90744 in 2014.
2020-08-07 21:06:16 +02:00
Fabian Homborg
677e699a7a Stop repainting after paste
"repaint" here is a bit of a misnomer. It *doesn't* re-highlight, that
just happens on its own.

It re-runs the prompt, which can take quite a while (depending on the
configuration), and which is also useless in this context as this
isn't something the prompt will be reacting to (theoretically it
could, but I doubt the utility of displaying "PASTE" for a few milliseconds).
2020-08-07 21:06:16 +02:00
Fabian Homborg
be9d17b08a help: Add the other pages 2020-08-07 21:06:16 +02:00
Johannes Altmanninger
d7ccc475cf Cleanup __fish_complete_subcommand
The external-commands-only completion was briefly added in 3.1.0 and removed
in 3.1.1 (see #6798), which means we can remove some dead code.

Maybe we should just remove __fish_complete_external_command - it could break
users, but then again, we don't really have a way to stop people from starting
to use this deprecated function. The underscores ought to communicate that
this is function is private to fish but that is not enforced.
2020-08-06 21:24:26 +02:00
Soumya
916ffe8273 Only bold status in default prompt when set by last command
Uses regular text when the status is carried over, e.g. after a background job.
2020-08-05 12:23:49 -07:00
Allen Sobot
54823c9243
Implement XBPS completions (#7239) 2020-08-05 20:01:19 +02:00
Johannes Altmanninger
ac1f63781d __fish_complete_suffix: don't fail when a part of the suffix is present
Resolves #7233
2020-08-01 17:04:03 +02:00
Daniel Kravetz
7a77907b62
Update k3d completions (#7232) 2020-08-01 13:41:44 +02:00
Olivier FAURE
e7f0b5801d Add forward-single-char input command
This allows users to add custom keybindings to autocomplete only one
character at a time.

Resolves https://github.com/fish-shell/fish-shell/issues/4984
2020-08-01 12:09:31 +02:00
ridiculousfish
1c2323e76f Use dashes instead of underscores pervasively in tutorial anchors
This fixes some broken help completions.
2020-07-31 12:10:16 -07:00
Gokul Soumya
b259fe17f9 vi-keybingings: Add missing abbr triggers for command terminators
Abbr expansion on command terminators were added
back in ec74c739 in response to #6970, but vi mode
was not updated.
2020-07-30 01:04:03 +02:00
Fabian Homborg
84b25855b0 alias: Escape the first word again
See https://stackoverflow.com/questions/63115744/alias-with-spaces-and-arguments-in-fish-3

This was broken in 115892ccd2
2020-07-27 17:19:44 +02:00
Johannes Altmanninger
233945b58b completions/git.fish: fix completions for "git config"
gui.fontui can be like "-family ..."
2020-07-25 18:53:24 +02:00