Commit Graph

5035 Commits

Author SHA1 Message Date
Johannes Altmanninger
e934e1b009 Test that bind output can recreate the same bindings 2024-04-09 00:22:41 +02:00
Johannes Altmanninger
8949c44574 Fix __fish_complete_command with multiline tokens 2024-04-09 00:07:27 +02:00
Johannes Altmanninger
3b9e3e251b Emit OSC 133 sequences to mark prompt/command output regions
This allows terminals like foot and kitty to
* scroll to the previous/next prompt with ctrl-shift-{z,x}
* pipe the last command's output to a pager with ctrl-shift-g

Kitty has existing fish shell integration
shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish which we
can simplify now. They keep a state variable to decide which of prompt start,
command start or command end to output.  I think with our implementation
this is no longer necessary, at least I couldn't reproduce any difference.
We also don't need to hook into fish_cancel or fish_posterror like they do;
only in the one place where we actually draw the prompt.

As mentioned in the above shell integration script, kitty disables reflow
when it sees an OSC 133 marker, so we need to do it ourselves,
otherwise the prompt will go blank after a terminal resize.

Closes #10352
2024-04-06 22:22:56 +02:00
Johannes Altmanninger
33701faa8c completions/set: offer private variables if token starts with _ 2024-04-06 21:20:53 +02:00
Johannes Altmanninger
18f6492564 completions/set: strip cursed descriptions from history/fish_killring
If I type

    $ echo $SOME_VARIABLE_WIHT_A_TYPO
    $ set -S SOME_VARIABLE_WIHT

and press tab, I'm always extremely surprised that this completes to

    $ set -S fish_history

which is because $history[1] contains the typo'd variable name.  I don't
think anyone intends to filter by that last 3-4 history items, so let's
remove this pitfall.

Note that I usually hit this scenario with undefined variables, not necessarily
typos.. "set -S" is usually redundant but it's still quite nice in this case,
to rule out any weird empty strings/empty lists.
2024-04-06 19:12:25 +02:00
Johannes Altmanninger
444cda20bc Document focus events 2024-04-06 18:14:17 +02:00
phanium
0a6e8468cc Avoid invoking extra subshell in __fish_md5 2024-04-05 15:26:48 +02:00
phanium
aa1a390504 Replace __funced_md5 with __fish_md5 2024-04-05 15:26:48 +02:00
phanium
b121b9649b Fix completions for pactree, pkgfile 2024-04-05 15:26:06 +02:00
Klaus Hipp
3c9b5713c9 Update code completions 2024-04-05 15:25:32 +02:00
Armin Brauns
3c0d7d0feb Add typst completions 2024-04-05 15:24:36 +02:00
Felix Luciano Salomon
8bbf760860
Added bruno completions (#10388)
* Added bruno completions

* Modified format completion to include formats as closed list arguments
2024-04-05 15:23:29 +02:00
Johannes Altmanninger
cb58a30bf2 Report $PWD changes unconditionally
Similar to 20bbdb68f (Set terminal title unconditionally, 2024-03-30).

While at it, get rid of a few unnecessary guards (we are never called from
a command substitution, so the check only adds confusion).
2024-04-03 13:14:02 +02:00
Johannes Altmanninger
9870faa8be Remove workarounds for Emacs ansi-term
I'm not sure if it's worth supporting a terminal that mishandles unknown OSC
and CSI sequences. Better to fix the terminal.  Note that there are Emacs
terminals available that don't have this problems; for example "vterm".
2024-04-03 13:09:27 +02:00
Fabian Boehm
ec603790d1 nim prompt: Don't use test
A single-argument use, even!

Fixes #10404
2024-04-02 17:33:30 +02:00
Johannes Altmanninger
8bf8b10f68 Extended & human-friendly keys
See the changelog additions for user-visible changes.

Since we enable/disable terminal protocols whenever we pass terminal ownership,
tests can no longer run in parallel on the same terminal.

For the same reason, readline shortcuts in the gdb REPL will not work anymore.
As a remedy, use gdbserver, or lobby for CSI u support in libreadline.

Add sleep to some tests, otherwise they fall (both in CI and locally).

There are two weird failures on FreeBSD remaining, disable them for now
https://github.com/fish-shell/fish-shell/pull/10359/checks?check_run_id=23330096362

Design and implementation borrows heavily from Kakoune.

In future, we should try to implement more of the kitty progressive
enhancements.

Closes #10359
2024-04-02 14:35:16 +02:00
Johannes Altmanninger
22717339b4 fish_clipboard_paste: don't bypass pager search field.
To do so add an ad-hoc "commandline --search-field" to operate on pager
search field.

This is primarily motivated because a following commit reuses the
fish_clipboard_paste logic for bracketed paste. This avoids a regression.
2024-04-02 14:35:16 +02:00
Felix Luciano Salomon
1f68d66692
Added pbpaste command completions (#10389)
* Added pbpaste command completions
2024-03-30 22:35:53 -05:00
Johannes Altmanninger
62a49acda3 completions/iwctl: fix spurious error on "iwctl device foo" 2024-03-25 20:56:08 +01:00
Johannes Altmanninger
f5d6ea6cf6 Basic completions for gdbserver 2024-03-25 05:42:16 +01:00
Fabian Boehm
ec7c0e19d0 help: Always print what is used
Makes it easier to debug
2024-03-24 08:51:52 +01:00
Fabian Boehm
bdfa7341e7 help: Only use open on macOS
Unfortunately on Debian "open" is a symlink to "openvt", and there's
no way from outside to tell.

This prevents fish from failing because no browser could be found.
2024-03-24 08:48:58 +01:00
Johannes Altmanninger
39ea1d710d Vi mode: add "+yy for fish_clipboard_copy and friends
Obviously not fully correct, and the implementation is not greate but it's
a start.
2024-03-23 14:24:51 +01:00
Johannes Altmanninger
25db4e803c Vi mode: don't cross newline on escape 2024-03-23 14:12:21 +01:00
Johannes Altmanninger
54b8817937 Vi mode: add + as clipboard alias, like * 2024-03-23 14:12:21 +01:00
Johannes Altmanninger
d51f669647 Vi mode: avoid placing cursor beyond last character
Today fish_cursor_selection_mode controls whether selection mode includes
the cursor. Since it's by default only used for Vi mode, perhaps use it to
also decide whether it should be allowed to select one-past the last character.

Not allowing to select to select one-past the last character is much nicer
in Vi mode.  Unfortunately Vi mode sometimes needs to temporarily select
past end (using forward-single-char and such), so reset fish_cursor_selection_mode
for the duration of the binding.

Also fix other things like cursor placement after yank/yank-pop.

Closes #10286
Closes #3299
2024-03-23 14:12:21 +01:00
Johannes Altmanninger
bffc9515a8 Fix bracketed paste regression from input event queue changes
We have

    bind --preset -M $mode --sets-mode paste \e\[200~ __fish_start_bracketed_paste

Commit c3cd68dda (Process shell commands from bindings like regular char
events, 2024-03-02) made it so __fish_start_bracketed_paste is no longer
executed before the bind mode is  updated.
This is a long-awaited fix but it broke __fish_start_bracketed_paste's
assumption that $fish_bind_mode is the mode before we entered paste mode.
This means we never exit paste mode.

Work around that. I forgot about this issue because I already replaced our
bracketed paste handling on my fork.
2024-03-23 14:08:55 +01:00
Johannes Altmanninger
8baf7de4c0 Vi mode: remove stale comment 2024-03-23 10:38:28 +01:00
Johannes Altmanninger
789a280ee8 Fix {Alt,Shift}-Return bindings not expanding abbreviations
Today,

    bind foo "commandline -f expand-abbr; commandline -i \n"

does not work because this
1. enqueues an expand-abbr readline event
2. "commandline -i" inserts \n
3. processes the expand-abbr readline event

Since there is no abbreviation on the new line, this doesn't do anything.

PR https://github.com/fish-shell/fish-shell/pull/9398 would fix this
particular instance however it does not fix the issue that "commandline -i"
is run before the expand-abbr is processed by the reader. This is harmless
here but there would be a problem if "commandline" tried to read commandline
state that was created by a preceding command.

It's not super clear to me whether the above binding should work as one
would naively expect. That would imply that "commandline" would need to
drain all input events (at least all synthetic ones) from the input queue,
to ensure it sees the current state.

Fortunately the parent commit makes it so if we separate them

    bind foo "commandline -f expand-abbr" "commandline -i \n"

both will be separate events and the commandline state will be synced after
each of them. This fixes abbreviation expansion here.

Also, we can now mix readline cmds and shell commands, which makes it shorter.
2024-03-23 10:06:11 +01:00
Johannes Altmanninger
c1f601f31e Don't bind Alt-Return in Vi normal mode
It seems wrong because it's for text insertion; if someone actually wants
to use it we can add it back.
2024-03-23 09:54:18 +01:00
Johannes Altmanninger
865118e3b4 On Shift+Return, insert a newline instead of executing the commandline
Most chat programs I found use Shift+Return to insert a newline while plain
Return sends the message. One user reported having only tried Shift+Return
and not knowing about Alt+Return.

No release notes yet because this only works on a very small number of
terminals. Once we enable CSI u, this should work on most modern terminals.
2024-03-23 09:54:18 +01:00
Fabian Boehm
0ff1e50a33 rustc: Protect against lines starting with -
Fixes #10379
2024-03-19 16:49:46 +01:00
Johannes Altmanninger
cd71359c42 completions/git: complete files iff last token is not a fixupish
Closes #10371
2024-03-16 10:45:57 +01:00
Johannes Altmanninger
62d1720605 completions/htop: fix --sort-key completions 2024-03-16 10:31:01 +01:00
fortifiedhill
8678ad8ca0 Update htop completions
Added and updated completions and updated htop link.
2024-03-16 09:00:42 +01:00
Xiretza
8271021fb6 Add completions for dmidecode 2024-03-16 08:57:43 +01:00
Fabian Boehm
0aa2426552 completions/wg-quick: Complete files after the subcommand
Fixes #10366
2024-03-12 17:32:51 +01:00
Johannes Altmanninger
d8d491741b edit_command_buffer: preserve external editor's cursor position
Unless the editor changed to a different file for some reason.

Note that the Kakoune integration uses -always to export the cursor even if
the user temporarily suppressed hooks - possibly a "fish_indent" hook.
2024-03-10 11:08:12 +01:00
Johannes Altmanninger
5fa743337c edit_command_buffer: also detect aliases with arguments
For example

    complete my-vim --wraps 'vim -x'
2024-03-10 11:06:38 +01:00
amiyzku
bb6b3101ff
Shortened some which.fish completions. (#10347)
* Shortened some which.fish completions.

* improve descriptions for which command options
2024-03-09 20:52:55 -06:00
RomainGiraud
f8757d154c
Fix scp completion for WSL (with ssh.exe) (#10290)
* Fix scp completion for WSL (with ssh.exe)

* Be more explicit
2024-03-09 15:39:57 -06:00
Johannes Altmanninger
836ee93617 Vi bindings: Control-N to accept autosuggestion
One of the things that keep me from using Vi mode is that it doesn't define an
insert-mode shortcut to accept autosuggestions. Let's use Control-N because
that Vim key is the closest equivalent.

Closes #10339
2024-03-09 11:03:57 +01:00
QianChenglong
b3c610feff add completion for mycli
Closes #10309
2024-03-09 10:28:03 +01:00
Felix Luciano Salomon
90b9bce174 Added completion for ollama
Closes #10327
2024-03-09 10:28:03 +01:00
Next Alone
a1d44a92be
fix: #10184 causes adb file completion failures (#10349)
Signed-off-by: NextAlone <12210746+NextAlone@users.noreply.github.com>
2024-03-08 21:56:37 -06:00
Johannes Altmanninger
6eddaa37af Revert "feat: adb completion cleared of awk"
It's broken,  see https://github.com/fish-shell/fish-shell/pull/10184
and doesn't really help I don't think.

This reverts commit ee837f254b.
2024-03-08 07:33:18 +01:00
John
b75e5ee823
remove repetitive words (#10348)
Signed-off-by: hishope <csqiye@126.com>
2024-03-07 18:35:41 -06:00
zuisong
a1e46a94f6
Add --url-query completion for curl (#10332)
Add missing completion for curl's `--url-query` option
2024-02-29 12:09:51 -06:00
Fabian Boehm
78c9482822 Reformat share/**.fish with newlines collapsed 2024-02-27 16:25:01 +01:00
Mathis Chenuet
73d760560b
Add completion for pstree (#10317)
* Add completion for pstree.fish

* use fish functions, much better
2024-02-26 17:39:11 +01:00