Commit Graph

5432 Commits

Author SHA1 Message Date
Lucas Garron
3d7d57d612 Add completions for iconutil (macOS).
Closes #11392
2025-04-18 18:05:49 +02:00
exploide
fb314b28ff completions(tcpdump): suppress stderr + updates 2025-04-18 17:17:39 +02:00
Johannes Altmanninger
721c9a2c14 completions/set: add some special variables 2025-04-16 11:24:33 +02:00
Johannes Altmanninger
7337bfee47 completions/set: sort 2025-04-16 11:24:33 +02:00
Johannes Altmanninger
123b262e97 fish_jj_prompt: remove not-so-useful bits
Things like branch and tag name can take up a lot of space on the screen. The
empty status may be useful but we're still looking for evidence.  For now let's
keep only the conflict status, which is fairly familiar from the Git prompt.

See also #11183
2025-04-16 11:24:33 +02:00
Ilya Grigoriev
76a6ffe59e status get/list-files: fix minor bugs when compiled without embedded files (#11390)
* man: redirect stderr to /dev/null when checking for embedded files

This fixes a bug where `man status` results in "status: fish was not
built with embedded files⏎" printed.

* fish_config and status completions: redirect stderr to /dev/null when checking for embedded files

I am less sure about this commit, can get rid of it.

* status get-file/list-files: add \n to error message when not compiled with embedded files
2025-04-16 08:46:22 +02:00
Fabian Boehm
6ede047680 completions/cargo: Fix package completion
The original only worked in the manifest directory *and* didn't even
list the right packages.

E.g. for fish it listed "printf", when the package is called
"fish-printf". So we're not keeping it because it's wrong.

Instead let's parse the actual json. It's a shame there is no
simple command to just get it line-delimited, of course.

Fixes #11384
2025-04-15 20:23:03 +02:00
Fabian Boehm
ab7d52d727 completions/rustup: Simplify listing installable targets 2025-04-15 20:21:10 +02:00
ndrew222
827bc32561 added completion for uv and uvx 2025-04-16 00:36:42 +08:00
Johannes Altmanninger
92510c0488 man.fish: fix spurious error on embed-data builds
Commands like "man grep" print an error because __fish_data_dir[1] is no
longer defined. Fix that.
2025-04-12 20:25:08 +02:00
Fabian Boehm
b815fff292 Set $__fish_data_dir to empty for embed-data builds
These builds do not use it, and setting it makes it possible to use
stale files.

So instead, we set it to empty. All uses I could find are either fine
with that (`set fish_function_path $__fish_data_dir/functions` - which
would also just be empty, which means it reads the embedded
functions),

or would break even if the variable was set but the directory was
empty (`source $__fish_data_dir/completions/git.fish`).
2025-04-11 17:29:22 +02:00
Fabian Boehm
329cd7d429 Make functions, completions and tests resilient to running on an embed-data fish
In case a completion needs a function from another script, run
`complete -C"foo "` to load it, so the full autoloading logic is used.

Otherwise these things break if the path is off. E.g. cargo's version
will fail if you override the cargo completion in
~/.config/fish/completions without also overriding the rustup
completions.

In other cases, fix for empty $__fish_data_dir, which will be coming in the next commit
2025-04-11 17:29:22 +02:00
Fabian Boehm
1a96db1708 functions/*: Extract data when needed
Technically the fish_update_completions files could also be piped to
python, but they'd have to be one file.

So for now, if you start a single-file fish, you'll have to run
fish_update_completions manually.

That fits the idea of having a single file that you move somewhere
better, given that it otherwise would run a script in the background
that creates a bunch of files
2025-04-11 17:29:22 +02:00
Fabian Boehm
ee2a6a851d Document and complete status get-file/list-files 2025-04-11 17:29:22 +02:00
Fabian Boehm
b56b876a98 Add status list-files
This allows us to implement fish_config using embedded files
2025-04-11 17:29:22 +02:00
Fabian Boehm
ca3a7f8356 Add status get-file
This allows getting embedded files, so we can use them in functions
2025-04-11 17:29:22 +02:00
Johannes Altmanninger
17b4b39c8b Stop reading terminfo database
Our use of the terminfo database in /usr/share/terminfo/$TERM is both
1. a way for users to configure app behavior in their terminal (by
   setting TERM, copying around and modifying terminfo files)
2. a way for terminal emulator developers to advertise support for
   backwards-incompatible features that are not otherwise easily observable.

To 1: this is not ideal (it's very easy to break things). There's not many
things that realistically need configuration; let's use shell variables
instead.

To 2: in practice, feature-probing via terminfo is often wrong.  There's not
many backwards-incompatible features that need this; for the ones that do
we can still use terminfo capabilities but query the terminal via XTGETTCAP
directly, skipping the file (which may not exist on the same system as
the terminal).

---

Get rid of terminfo. If anyone finds a $TERM where we need different behavior,
we can hardcode that into fish.

* Allow to override this with `fish_features=no-ignore-terminfo fish`
  Not sure if we should document this, since it's supposed to be removed soon,
  and if someone needs this (which we don't expect), we'd like to know.
  * This is supported on a best-effort basis; it doesn't match the previous
    behavior exactly.  For simplicity of implementation, it will not change
    the fact that we now:
    * use parm_left_cursor (CSI Ps D) instead of  cursor_left (CSI D) if
      terminfo claims the former is supported
    * no longer support eat_newline_glitch, which seems no longer present
      on today's ConEmu and ConHost
* Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580
* add `man fish-terminal-compatibility` to state our assumptions.
  This could help terminal emulator developers.
* assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP
* Extract all control sequences to src/terminal_command.rs.
* Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really
  needed.
* assume it's generally okay to output 256 colors
  Things have improved since commit 3669805627 (Improve compatibility with
  0-16 color terminals., 2016-07-21).
  Apparently almost every actively developed terminal supports it, including
  Terminal.app and GNU screen.
  * That is, we default `fish_term256` to true and keep it only as a way to
    opt out of the the full 256 palette (e.g. switching to the 16-color
    palette).
    * `TERM=xterm-16color` has the same opt-out effect.
* `TERM` is generally ignored but add back basic compatiblity by turning
  off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably
  not set accidentally.
* Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in
  tests. Unset it instead.
* Note that our pexpect tests used a dumb terminal because:
  1. it makes fish do a full redraw of the commandline everytime, making it
     easier to write assertions.
  2. it disables all control sequences for colors, etc, which we usually
     don't want to test explicitly.
  I don't think TERM=dumb has any other use, so it would be better
  to print escape sequences unconditionally, and strip them in
  the test driver (leaving this for later, since it's a bit more involved).

Closes #11344
Closes #11345
2025-04-11 15:11:22 +02:00
exploide
83963287d6 completions(resolvectl): updated to newer version 2025-04-09 19:11:59 +08:00
Bec Donald-Wilson
68a8ab9667 Fix alt-right binding 2025-04-03 02:01:49 +02:00
Johannes Altmanninger
50a6e486a5 Allow explicit shift modifier for non-ASCII letters, fix capslock behavior
We canonicalize "ctrl-shift-i" to "ctrl-I".
Both when deciphering this notation (as given to builtin bind),
and when receiving it as a key event ("\e[105;73;6u")

This has problems:

A. Our bind notation canonicalization only works for 26 English letters.
   For example, "ctrl-shift-ä" is not supported -- only "ctrl-Ä" is.
   We could try to fix that but this depends on the keyboard layout.
   For example "bind alt-shift-=" and "bind alt-+" are equivalent on a "us"
   layout but not on a "de" layout.
B. While capslock is on, the key event won't include a shifted key ("73" here).
   This is due a quirk in the kitty keyboard protocol[^1].  This means that
   fish_key_reader's canonicalization doesn't work (unless we call toupper()
   ourselves).

I think we want to support both notations.

It's recommended to match all of these (in this order) when pressing
"ctrl-shift-i".

	1. bind ctrl-shift-i do-something
	2. bind ctrl-shift-I do-something
	3. bind ctrl-I do-something
	4. bind ctrl-i do-something

Support 1 and 3 for now, allowing both bindings to coexist. No priorities
for now. This solves problem A, and -- if we take care to use the explicit
shift notation -- problem B.

For keys that are not affected by capslock, problem B does not apply.  In this
case, recommend the shifted notation ("alt-+" instead of "alt-shift-=")
since that seems more intuitive.
Though if we prioritized "alt-shift-=" over "alt-+" as per the recommendation,
that's an argument against the shifted key.

Example output for some key events:

	$ fish_key_reader -cV
	# decoded from: \e\[61:43\;4u
	bind alt-+ 'do something' # recommended notation
	bind alt-shift-= 'do something'
	# decoded from: \e\[61:43\;68u
	bind alt-+ 'do something' # recommended notation
	bind alt-shift-= 'do something'

	# decoded from: \e\[105:73\;6u
	bind ctrl-I 'do something'
	bind ctrl-shift-i 'do something' # recommended notation
	# decoded from: \e\[105\;70u
	bind ctrl-shift-i 'do something'

Due to the capslock quirk, the last one has only one matching representation
since there is no shifted key.  We could decide to match ctrl-shift-i events
(that don't have a shifted key) to ctrl-I bindings (for ASCII letters), as
before this patch. But that case is very rare, it should only happen when
capslock is on, so it's probably not even a breaking change.

The other way round is supported -- we do match ctrl-I events (typically
with shifted key) to ctrl-shift-i bindings (but only for ASCII letters).
This is mainly for backwards compatibility.

Also note that, bindings without other modifiers currently need to use the
shifted key (like "Ä", not "shift-ä"), since we still get a legacy encoding,
until we request "Report all keys as escape codes".

[^1]: <https://github.com/kovidgoyal/kitty/issues/8493>
2025-04-03 00:51:35 +02:00
Fabian Boehm
5e25cdaa6f fish_print_hg_root: Don't break if $PWD includes newlines
Fixes #11348
2025-04-02 16:59:21 +02:00
Fabian Boehm
9c5be2a2d8 completions/cargo: Complete -Z options 2025-04-02 16:58:47 +02:00
Fabian Boehm
18371fbd4e completions/cargo: Speed up
This does two things:

- it stops completing cargo- tools because `cargo --list` already
includes them. This speeds up loading especially with a long $PATH
- it stops using `cargo search` for `cargo add` and install.
  this removes a network call, which may be unexpected and can take a
  long time

Fixes #11347
2025-04-02 16:57:32 +02:00
Johannes Altmanninger
892c970bfa webconfig: remove legacy and raw key name parser for now
This parser was pretty nice but it has some issues with the new syntax.
It's not really needed when most bindings use the new syntax.

Let's remove it altogether.
2025-04-02 01:05:51 +02:00
Johannes Altmanninger
defd041863 webconfig: clarify invariant
We're splitting at most twice, so there can only be three or fewer parts.
2025-04-02 01:05:51 +02:00
Johannes Altmanninger
d4082893ae completions/bind: complete super modifier 2025-04-02 01:05:51 +02:00
Johannes Altmanninger
fb2d427a45 Remove "bind -k" terminfo key names, update "bind --key-names"
I don't think there's a relevant terminal where the "bind -k" notation is
still needed. The remaining reason to keep it is backwards compatibility.

But "bind -k" is already subtly broken on terminals that implement either
of modifyOtherKeys, application keypad mode or the kitty keyboard protocol,
since those alter the byte sequences (see #11278).

Having it randomly not work might do more harm than good. Remove it.

This is meant go into 4.1, which means that users who switch back and forth
between 4.1 and 4.0 can already use the new notation.

If someone wants to use the bind config for a wider range of versions they
could use "bind -k 2>/dev/null" etc.

While at it, use the new key names in "bind --key-names", and sort it like
we do in "bind --function-names".

Closes #11342
2025-04-02 01:05:51 +02:00
Johannes Altmanninger
415da8fc3b Remove obsolete st \e[P binding for delete
Since we request application keypad mode, st sends \e[3~ instead which we
already decode.
2025-04-01 17:00:48 +02:00
Johannes Altmanninger
4c212776bf Remove obsolete st \e[Z binding for shift-tab
We already decode this to shift-tab (not to mention that up-line was the
wrong action, no?).
2025-04-01 17:00:48 +02:00
Fabian Boehm
446f1344fc completions/patch: Put CYGWIN code first
Just so we don't error with non-0
2025-03-30 19:46:01 +02:00
memchr
95b93c6bff completions/btrfs: add new options and commands
Also add completion for balance filters
2025-03-29 13:47:38 +01:00
Jonathan Palardy
269ed5ddf4 completions/git: Added autostash option to git merge 2025-03-29 13:11:35 +01:00
memchr
795d6b6c40 completions/git: add --filter option
supported subcommands:
- clone
- fetch
- submodule update
- rev-list
2025-03-29 13:10:59 +01:00
Johannes Altmanninger
360cfdb7ae completions/git: fix arg completion for third-party git commands, again
Commit 50e595503e (completions/git: fix completions for third-party git
commands, 2025-03-03) wasn't quite right, as we can see in the linked
reproduction:

	$ fish_trace=1 complete -C 'git machete add --onto '
	----> complete -C git-machete\ add\n--onto\

The recursive completion invocation contains a spurious newline, which means
that "--onto" is the command name.  The newline is produced by "string escape
-- add --onto" inside a command substitution.

Fix this by interpreting newlines as list separators, and then joining
by spaces.

Fixes #11319
2025-03-25 11:16:18 +01:00
memchr
5012bcb976 completions/cryptsetup: complete device mapping names
The commands 'close', 'resize', and 'status' each take 'name' as their solo argument.

Signed-off-by: memchr <memchr@proton.me>
2025-03-24 18:43:38 +01:00
memchr
3744c02a01 completions/systemd-analyze: add new options and subcommands
options:
- instance
- image
- image-policy
- tldr
- unit
- table
- no-legend
- detailed
- scale-svg
- malloc

subcommands:
- filesystems
- compare-versions
- inspect-elf
- fdstore
- has-tpm2
- pcrs
- srk
- architectures
- smbios11

fix a typo in timespan completion

Signed-off-by: memchr <memchr@proton.me>
2025-03-24 18:43:30 +01:00
Clément Martinez
ea8e122fad Add wlr-randr completions 2025-03-22 13:06:01 +01:00
Johannes Altmanninger
66115490d8 Use the cache directory owner for cache entries
Commit f086bc9564 (Maintain ownership when rewriting universal variables
file, 2015-09-26) fixed an issue where "sudo -E fish" would create root-owned
~/.config/fish/fish_variables that break the users's shell.

A simlar issue exists for files in ~/.cache/fish; fix that.

Note that ~/.cache/fish is currently created on first run when we generate
completions from manpages.

See the issue described in #11292
2025-03-21 10:41:39 +01:00
Johannes Altmanninger
733f704267 Fix Vi mode delete key bindings while numlock is active
Commit 8bf8b10f68 (Extended & human-friendly keys, 2024-03-30)
add bindings that obsolete the  terminfo-based `bind -k` invocations.

The `bind -k` variants were still left around[^*]. Unfortunately it forgot to
add the new syntax for some special keys in Vi mode.  This leads to issues if
a terminal that supports the kitty keyboard protocol sends an encoding that
differs from the traditional one.  As far as I can tell, this happens when
capslock or numlock is active.  Let's add the new key names and consistently
mark `bind -k` invocations as deprecated.

Fixes #11303

[^*]: Support for `bind -k` will probably be removed in a future release -
it leads to issues like https://github.com/fish-shell/fish-shell/issues/11278
where it's better to fail early.
2025-03-19 09:23:07 +01:00
Ilya Grigoriev
932010cd04 jj completions: use dynamic completions by default, also fix
This uses jj's dynamic completions when possible.

This avoids an annoying problem. After 04a4e5c4, jj's dynamic
completions (see the second paragraph of
<https://jj-vcs.github.io/jj/latest/install-and-setup/#command-line-completion>)
do not work very well in fish if the user puts `COMPLETE=fish jj |
source` in their `~/.config/fish/config.fish`. When the user types `jj
<TAB>`, they are instead overridden by fish's built-in non-dynamic
completions.

The difference is subtle. One problem I saw is that `jj new <TAB>` works
as expected (and shows revisions) while `jj new -A <TAB>` becomes broken
(and shows files).

If the user puts `COMPLETE=fish jj | source` in
`~/.config/fish/completions/jj.fish` there is no problem. However, users
might be confused if they run `COMPLETE=fish jj | source` or put it in
their config and it works in a broken fashion. I certainly was.

Meanwhile, I checked that if the user has `jj completion fish | source`
in their `config.fish`, executing `COMPLETE=fish jj
__this_command_does_not_exist | source` afterwards still works
correctly.

Let me know if there's a better approach to this problem.
2025-03-17 19:06:48 +01:00
Farhood Etaati
48306409ef Adds git subtree completion
Closes #11063
2025-03-15 21:54:25 +01:00
Ilya Grigoriev
bdb8f7da3a completion/tmux: quick fixup to conflict resolution in b85e405
Delete a line that should have been replaced with the following line (with --keep-order)

Closes #11288
2025-03-15 21:24:17 +01:00
Johannes Altmanninger
f43b16b1cb completions/pulumi: disable update check
As seen in GitHub Actions:

	132/193 Test  #17: check-completions.fish ...................***Failed   16.28 sec
	checks/check-completions.fish..Failure:

	  There were no remaining checks left to match stdout:1:
	    OUTPUT from /home/runner/work/fish-shell/fish-shell/share/completions/pulumi.fish: warning: A new version of Pulumi is available. To upgrade from version '3.154.0' to '3.156.0', visit https://pulumi.com/docs/install/ for manual instructions and release notes.
2025-03-15 21:24:17 +01:00
Fabian Boehm
19267ce3fc completions/pulumi: Silence stderr
This apparently checks for updates and warns if one is available on
start.

I don't love it.
2025-03-15 12:59:27 +01:00
Ilya Grigoriev
b85e4057bc completions/tmux: show all session panes in pane completions
This makes several changes:

- All panes in the current session are now show, instead of just the
  current window.

- Instead of using window names when referring to panes (e.g.
  "fish-dev.1"), we now use either window indicies ("3.1") or absolute
pane ids (%12). This is mainly because several windows often share the
same window name, e.g. many of my panes are automatically named "fish"
if they are currently running the shell and nothing else.

  I put the window names in the descriptions. Because fish uses the
descriptions for completions, completing `fish-dev` is still helpful.

- I include the pane name into the description for a similar reason,
  truncated to 15 chars.

- The panes are now ordered carefully, with panes in this window listed
  first, then panes are ordered by window, and finally panes are listed
by their id (which does not change when panes are moved between windows)

Example output after `tmux selectp -t <TAB>` for a session with a few
windows. Note that windows 0, 1, and 4 are all named
`fish`. A pane in the current window can be accessed in 3 ways: `3`,
`2.3`, or `%57`.


```
0         (%4 [fish-dev] ~/d/fish-shell <active pane>)  3.1                    (%58 [fish] man tmux ~/.c/f...)
1     (%8 [fish-dev] hwatch "jj.logs... <active win.>)  4.0                     (%1 [sshd] tmux rename-win...)
2    (%15 [fish-dev] /U/i/d/fish-she... <active win.>)  %1                     (4.0 [sshd] tmux rename-win...)
3        (%57 [fish-dev] ~/d/fish-shell <active win.>)  %4       (2.0 [fish-dev] ~/d/fish-shell <active pane>)
0.0                                    (%100 [fish] ~)  %8   (2.1 [fish-dev] hwatch "jj.logs... <active win.>)
1.0                         (%11 [fish] ~/d/_/nixpkgs)  %11                         (1.0 [fish] ~/d/_/nixpkgs)
1.1                    (%38 [fish] ~/.c/f/completi...)  %15  (2.2 [fish-dev] /U/i/d/fish-she... <active win.>)
2.0       (%4 [fish-dev] ~/d/fish-shell <active pane>)  %38                    (1.1 [fish] ~/.c/f/completi...)
2.1   (%8 [fish-dev] hwatch "jj.logs... <active win.>)  %41                         (3.0 [fish] ~/.c/f/conf.d)
2.2  (%15 [fish-dev] /U/i/d/fish-she... <active win.>)  %57      (2.3 [fish-dev] ~/d/fish-shell <active win.>)
2.3      (%57 [fish-dev] ~/d/fish-shell <active win.>)  %58                    (3.1 [fish] man tmux ~/.c/f...)
3.0                         (%41 [fish] ~/.c/f/conf.d)  %100                                    (0.0 [fish] ~)
```

Compared to before:

```
0  (pane)  2  (pane)  0:fish-dev.0  (session:window.pane)  0:fish-dev.2  (session:window.pane)  fish-dev  (window)
1  (pane)  3  (pane)  0:fish-dev.1  (session:window.pane)  0:fish-dev.3  (session:window.pane)
```

Note that the "before" version describes the same 3 panes several times
in a row, and all the entries involving "fish-dev" are suspect since
there could be another "fish-dev" window (or, more likely, this window
and others could all be named "fish").

Closes #11115
2025-03-15 12:30:00 +01:00
Ilya Grigoriev
f30a85f538 completions/tmux: more send-keys completions, add switch-client key table argument
The switch client option is a bit weird (why does this command have a
key table-related function?), but seems helpful to add.
2025-03-15 12:27:20 +01:00
Ilya Grigoriev
5fecc2e355 completions/tmux: fixups to key table commands, update to post-2017 tmux
There are some minor updates.

Also, the syntax seems to have changed in tmux 2.4 in 2017,
ef68debc8d/CHANGES (L1484)

Notably, many of the key table commands now use `-T` in place of
the correct `-t`, and the list of key binding tables has changed.
2025-03-15 12:27:20 +01:00
Yann Soubeyrand
052a010b57 feat(completions): add argocd, cue, dagger, kubebuilder and pulumi
These tools use the Cobra framework for argument parsing, which can
generate completions ready to be sourced.
2025-03-15 12:27:14 +01:00
Johannes Altmanninger
5b94af6367 Restore cursor shape when deactivating Vi mode
Running

	fish_vi_key_bindings
	fish_default_key_bindings

ought to maintain cursor shape, at least in the default configuration,
so let's do that.

Fixes 9ef76860e6 (Default Vi cursor shapes for insert/replace mode, 2024-10-26).
2025-03-11 20:22:27 +01:00
Johannes Altmanninger
ea6e819a33 completions/set: add fish_cursor_* variables 2025-03-10 22:28:40 +01:00