Commit graph

721 commits

Author SHA1 Message Date
Johannes Altmanninger
9158395d10 Fix __fish_list_current_token and friends for multiline commandlines
Some of these handled multiline prompts but not multiline command lines. We
first need to move the cursor to the end of the commandline, then we can
print a message.  Finally, we need to move the cursor back to where it was.
2024-04-12 12:00:24 +02:00
Johannes Altmanninger
a583fe7230 "commandline -f foo" to skip queue and execute immediately
Commit c3cd68dda (Process shell commands from bindings like regular char
events, 2024-03-02) mentions a "weird ordering difference".
The issue is that "commandline -f foo" goes through the input
queue while other commands are executed directly.
For example

    bind ctrl-g "commandline -f end-of-line; commandline -i x"

is executed in the wrong order. Fix that.

This doesn't yet work for "commandline -f exit" but that can be fixed easily.

It's hard to imagine anyone would rely on the existing behavior.  "commandline
-f" in bindings is mostly used for repainting the commandline.
2024-04-09 00:22:41 +02:00
Johannes Altmanninger
7fd018e851 Minor changelog update 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
f285e85b0c Enable focus reporting only just before reading from stdin
Some terminals send the focus-in sequences ("^[I") whenever focus reporting is
enabled.  We enable focus reporting whenever we are finished running a command.
If we run two commands without reading in between, the focus sequences
will show up on the terminal.

Fix this by enabling focus-reporting as late as possible.

This fixes the problem with `^[I` showing up when running "cat" in
gnome-terminal https://github.com/fish-shell/fish-shell/issues/10411.

This begs the question if we should do the same for CSI u and bracketed paste.
It's difficult to answer that; let's hope we find motivating test cases.
If we enable CSI u too late, we might misinterpret key presses, so for now
we still enable those as early as possible.

Also, since we now read immediately after enabling focus events, we can get
rid of the hack where we defer enabling them until after the first prompt.
When I start a fresh terminal, the ^[I no longer shows up.
2024-04-06 11:22:19 +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
af1b599818 On redo, restore pre-undo cursor position 2024-04-03 13:09:27 +02:00
Fabian Boehm
53961c7759 Fix doc formatting
This is RST, not markdown
2024-04-02 17:39:39 +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
20bbdb68fa Set terminal title unconditionally
Terminal titles are set with an OSC 0 sequence.  I don't think we want to
support terminals that react badly to unknown OSC (or CSI) sequences.

So let's remove our feature detection.

This will fix future false negatives along the lines of
https://github.com/fish-shell/fish-shell/pull/10037
2024-04-02 14:35:16 +02:00
Fabian Boehm
b535213ac0 CHANGELOG abbr decorators 2024-03-27 22:13:27 +01:00
Johannes Altmanninger
58e477fab3 Changelog Vi mode changes
Closes #10338
2024-03-23 14:26:08 +01:00
Johannes Altmanninger
c3cd68dda5 Process shell commands from bindings like regular char events
A long standing issue is that bindings cannot mix special input functions
and shell commands. For example,

    bind x end-of-line "commandline -i x"

silently does nothing. Instead we have to do lift everything to shell commands

    bind x "commandline -f end-of-line; commandline -i x"

for no good reason.

Additionally, there is a weird ordering difference between special input
functions and shell commands. Special input functions are pushed into the
the queue whereas shell commands are executed immediately.

This weird ordering means that the above "bind x" still doesn't work as
expected, because "commandline -i" is processed before "end-of-line".

Finally, this is all implemented via weird hack to allow recursive use of
a mutable reference to the reader state.

Fix all of this by processing shell commands the same as both special input
functions and regular chars. Hopefully this doesn't break anything.

Fixes #8186
Fixes #10360
Closes #9398
2024-03-23 10:06:11 +01:00
Johannes Altmanninger
232483d89a History pager to only operate on the line at cursor
Multiline search strings are weirdly broken (inserting control characters
in the command line) and probably not very useful anyway.
On the other hand I often want to compose a multi-line command
from single-line commands I ran previously.

Let's support this case by limiting the initial search string to the current
line; and replace only that line.

Alternatively this could operate on jobs (that is, replace a surrounding
"foo | bar") instead of using line boundaries.
2024-03-23 09:54:18 +01:00
David Adam
a551432f5c Merge branch 'Integration_3.7.1' 2024-03-19 20:14:40 +08:00
David Adam
80394ea4e3 Release 3.7.1 2024-03-19 11:40:45 +08:00
David Adam
445fba4464 CHANGELOG: work on 3.7.1 2024-03-18 22:53:13 +08:00
David Adam
98662ae076 CHANGELOG: work on 3.7.1 2024-03-18 22:26:49 +08:00
Johannes Altmanninger
bc246d87b2 Add closed issues and PRs to 3.8 changelog
I used below script to list all GitHub issues and PRs that are not yet
mentioned in the changelog. It's almost empty now.

While at it, curate the "notable" section and move some entries around,
notably from "interactive improvements"  to "bindings".

```shell
ms="fish next-3.x"
{
    gh issue list --state closed --milestone "$ms" -L 500
    gh pr list --state all --search "milestone:\"$ms\"" -L 500
} | sort -n | while IFS='
' read line; do
    set -- $line
    grep -qE '\W'$1 CHANGELOG.rst ||
    echo https://github.com/fish-shell/fish-shell/issues/$1 "$line"
done
```
2024-03-17 11:41:32 +01:00
Johannes Altmanninger
068f92ce7e Changelog update 2024-03-16 10:31:01 +01:00
Fabian Boehm
9b9cfc207f CHANGELOG for 3.7.1 2024-03-13 18:24:01 +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
Fabian Boehm
f60b6e6cd4 CHANGELOG 2024-02-27 16:28:20 +01:00
Fabian Boehm
8712bd5a4b CHANGELOG terminfo 2024-02-22 20:15:24 +01:00
Johannes Altmanninger
0627c9d9af Render control characters as Unicode Control Pictures
Inserting Tab or Backspace characters causes weird glitches. Sometimes it's
useful to paste tabs as part of a code block.

Render tabs as "␉" and so on for other ASCII control characters, see
https://unicode-table.com/en/blocks/control-pictures/. This fixes the
width-related glitches.

You can see it in action by inserting some control characters into the
command line:

	set chars
	for x in (seq 1 0x1F)
		set -a chars (printf "%02x\\\\x%02x" $x $x)
	end
	eval set chars $chars
	commandline -i "echo '" $chars

Fixes #6923
Fixes #5274
Closes #7295

We could extend this approach to display a fallback symbol for every unknown
nonprintable character, not just ASCII control characters.

In future we might want to support tab properly.
2024-02-15 01:39:45 +01:00
Henrik Hørlück Berg
59fa7479ee
Add documentation and release notes for #10282 2024-02-11 12:43:13 +01:00
Johannes Altmanninger
47aa79813d Open command script in external editor on Alt+o
Fish functions are great for configuring fish but they don't integrate
seamlessly with the rest of the system. For tasks that can run outside fish,
writing scripts is the natural approach.

To edit my scripts I frequently run

    $EDITOR (which my-script)

Would be great to reduce the amount typing for this common case (the names
of editor and scripts are usually short, so that's a lot of typing spent on
the boring part).

Our Alt+o binding opens the file at the cursor in a pager.  When the cursor
is in command position, it doesn't do anything (unless the command is actually
a valid file path). Let's make it open the resolved file path in an editor.

In future, we should teach this binding to delegate to "funced" upon seeing
a function instead of a script. I didn't do it yet because funced prints
messages, so it will mess with the commandline rendering if used from
a binding.  (The fact that funced encourages overwriting functions that
ship with fish is worrysome. Also I'm not sure why funced doesn't open the
function's source file directly (if not sourced from stdin). Persisting the
function should probably be the default.)

Alternative approach: I think other shells expand "=my-script" to
"/path/to/my-script".  That is certainly an option -- if we do that we'd want
to teach fish to complete command names after "=".  Since I don't remember
scenarios where I care about the full path of a script beyond opening it in
my editor, I didn't look further into this.

Closes #10266
2024-02-07 00:07:47 +01:00
Fabian Boehm
ea5adcac9d CHANGELOG: Work on next release
Including some preliminary bits on packaging.
2024-02-04 09:47:21 +01:00
Johannes Altmanninger
b768b9d3f5 Use fuzzy subsequence completion for options names as well
Version 2.1.0 introduced subsequence matching for completions but as the
changelog entry mentions, "This feature [...] is not yet implemented for
options (like ``--foobar``)".  Add it. Seems like a strict improvement,
pretty much.
2024-01-27 17:57:48 +01:00
Johannes Altmanninger
368017905e builtin commandline: -x for expanded tokens, supplanting -o
Issue #10194 reports Cobra completions do

    set -l args (commandline -opc)
    eval $args[1] __complete $args[2..] (commandline -ct | string escape)

The intent behind "eval" is to expand variables and tildes in "$args".
Fair enough. Several of our own completions do the same, see the next commit.

The problem with "commandline -o" + "eval" is that the former already
removes quotes that are  relevant for "eval". This becomes a problem if $args
contains quoted () or {}, for example this command will wrongly execute a
command substituion:

    git --work-tree='(launch-missiles)' <TAB>

It is possible to escape the string the tokens before running eval, but
then there will be no expansion of variables etc.  The problem is that
"commandline -o" only unescapes tokens so they end up in a weird state
somewhere in-between what the user typed and the expanded version.

Remove the need for "eval" by introducing "commandline -x" which expands
things like variables and braces. This enables custom completion scripts to
be aware of shell variables without eval, see the added test for completions
to "make -C $var/some/dir ".

This means that essentially all third party scripts should migrate from
"commandline -o" to "commandline -x". For example

    set -l tokens
    if commandline -x >/dev/null 2>&1
        set tokens (commandline -xpc)
    else
        set tokens (commandline -opc)
    end

Since this is mainly used for completions, the expansion skips command
substitutions.  They are passed through as-is (instead of cancelling or
expanding to nothing) to make custom completion scripts work reasonably well
in the common case. Of course there are cases where we would want to expand
command substitutions here, so I'm not sure.
2024-01-27 09:28:06 +01:00
Fabian Boehm
b8b062eb84 docs: Update qmark-noglob status
Note: The version number needs to be adjusted
2024-01-25 18:47:41 +01:00
Johannes Altmanninger
5dfcfa336b edit_command_buffer: if aliasee is a recognized editor, pass cursor position too
If I alias "e" to "emacsclient" it will probably accept the same options.
Let's dereference the alias so we can detect support for passing the cursor
position in more cases.

This does not solve the problem for recursive cases (e.g. alias of another
alias). If we want to handle that we would need cycle detection.
2024-01-21 09:39:59 +01:00
Johannes Altmanninger
fff8e8163b Control-C to simply clear commandline buffer again
Commit 5f849d0 changed control-C to print an inverted ^C and then a newline.

The original motivation was

> In bash if you type something and press ctrl-c then the content of the line
> is preserved and the cursor is moved to a new line. In fish the ctrl-c just
> clears the line. For me the behaviour of bash is a bit better, because it
> allows me to type something then press ctrl-c and I have the typed string
> in the log for further reference.

This sounds like a valid use case in some scenarios but I think that most
abandoned commands are noise. After all, the user erased them. Also, now that
we have undo that can be used to get back a limited set of canceled commands.

I believe the original motivation for existing behavior (in other shells) was
that TERM=dumb does not support erasing characters. Similarly, other shells
like to leave behind other artifacts, for example when using tab-completion
or in their interactive menus but we generally don't.

Control-C is the obvious way to quickly clear a multi-line commandline.
IPython does the same. For the other behavior we have Alt-# although that's
probably not very well-known.

Restore the old Control-C behavior of simply clearing the command line.

Our unused __fish_cancel_commandline still prints the ^C. For folks who
have explicitly bound ^C to that, it's probably better to keep the existing
behavior, so let's leave this one.

Previous attempt at #4713 fizzled.

Closes #10213
2024-01-17 19:54:57 +01:00
Fabian Boehm
4286b049ca docs: Fix two formatting errors
sphinx *really* needs an empty line after a `::` code block starter
2024-01-05 16:49:49 +01:00
David Adam
1b6374d2ce Merge branch 'Integration_3.7.0' 2024-01-02 00:08:49 +08:00
David Adam
0e4d088b11 Release 3.7.0 2024-01-01 23:15:17 +08:00
David Adam
be0ea9862c CHANGELOG: work on 3.7.0 2024-01-01 22:01:45 +08:00
Fabian Boehm
d6833edf54 CHANGELOG 2024-01-01 00:14:26 +01:00
Fabian Boehm
5c532ace5a CHANGELOG umask fix 2023-12-31 19:40:18 +01:00
David Adam
8a447355a2 CHANGELOG: work on 3.7.0 2023-12-31 22:37:18 +08:00
David Adam
8508cc50b0 CHANGELOG: work on 3.7.0 2023-12-31 13:07:02 +08:00
ridiculousfish
b28eae8be9 Allow custom completions to have leading dots
By default, fish does not complete files that have leading dots, unless the
wildcard itself has a leading dot. However this also affected completions;
for example `git add` would not offer `.gitlab-ci.yml` because it has a
leading dot.

Relax this for custom completions. Default file expansion still
suppresses leading dots, but now custom completions can create
leading-dot completions and they will be offered.

Fixes #3707.

(cherry picked from commit b7de768c73)
2023-12-31 09:55:09 +08:00
David Adam
f6676350a7 CHANGELOG: work on 3.7.0 2023-12-31 09:53:20 +08:00
Amy Grace
36ed2b79c2 completions: add xxd
Closes #10137
2023-12-30 10:18:30 +01:00
tangowithfoxtrot
7370e38069 add completions for bws
Closes #10165
2023-12-30 09:31:33 +01:00
David Adam
ba57704276 CHANGELOG: work on 3.7.0 2023-12-29 23:56:46 +08:00
David Adam
c02cb3b260 CHANGELOG: work on 3.8.0 2023-12-29 23:48:44 +08:00
ridiculousfish
534c00bdbf Changelog fix for #10168 2023-12-28 13:38:01 -08:00
Christian Fersch
7008e0eec2 git completion: Handle aliases referencing other aliases (#9992)
(cherry picked from commit 1980a22522)
2023-12-28 11:06:04 +08:00
David Adam
6f7d5f427b CHANGELOG: work on 3.8.0 2023-12-27 22:59:24 +08:00
David Adam
8707c05b7b CHANGELOG: work on 3.7.0 2023-12-27 22:58:33 +08:00
David Adam
ecf8ac6f66 CHANGELOG: work on 3.7.0 2023-12-26 23:24:00 +08:00
Shou Ya
b44bdea230 Enable globbing in history-pager
The existing subsequence search commonly returns false positives.
Support globs, to allow searching for disconnected substrings in a better way.

Closes #10143
Closes #10131
2023-12-24 09:08:03 +01:00
David Adam
b12c36e72d CHANGELOG: work on 3.7.0 2023-12-23 23:24:45 +08:00
David Adam
60777f99b4 CHANGELOG: update current branch to aim for 3.8.0 2023-12-23 23:20:34 +08:00
David Adam
446a41e23a CHANGELOG: work on 3.7.0 2023-12-20 00:23:45 +08:00
Quinten Roets
95c3a4045b fish_vi_cursor: add new variable for external cursor mode (#9565)
* add new variable for external cursor mode

* fix backwards compatibility

* add documentation

* document change in changelog

(cherry picked from commit f5506803d7)
2023-12-20 00:06:56 +08:00
David Adam
313b2993f5 Merge branch 'Integration_3.6.4' into Integration_3.7.0 2023-12-08 11:49:02 +08:00
David Adam
112178a2ac Release 3.6.4 2023-12-05 22:16:18 +08:00
David Adam
4a618f14f1 Release 3.6.3 2023-12-04 23:54:24 +08:00
David Adam
a51437ec83 Release 3.6.2
Fix for CVE-2023-49284.
2023-12-04 23:00:02 +08:00
David Adam
c0de5dd804 CHANGELOG: fix date for 3.6.1
(cherry picked from commit e2579a59ba)
2023-12-04 23:00:01 +08:00
Christian Fersch
1980a22522
git completion: Handle aliases referencing other aliases (#9992) 2023-11-24 17:03:02 +01:00
Nicholas Rodrigues Lordello
66401f8575 ls No Longer Sets LS_COLORS
(cherry picked from commit 5cf36bf3f8)
2023-11-07 19:59:29 +01:00
Nicholas Rodrigues Lordello
5cf36bf3f8 ls No Longer Sets LS_COLORS 2023-11-07 17:45:45 +01:00
Fabian Boehm
c883d73145 Work on 3.7.0 CHANGELOG 2023-10-17 17:49:34 +02:00
Kevin F. Konrad
269c9c3f0c
add completions for crc and oc (#10034) 2023-10-01 08:38:27 +02:00
Gregory Anders
33c6eee9d2 Check terminfo for ts capability to determine title setting support 2023-09-30 10:09:52 +02:00
ghostflyby
c17fc65321 Update CHANGELOG.rst 2023-09-01 10:27:18 -07:00
Fabian Boehm
e52e7cea43 CHANGUELOGUE 2023-08-30 23:15:01 +02:00
Fabian Boehm
36a7924fa8 CHANGELOG: Document incompatible changes 2023-08-22 15:27:00 +02:00
Gregory Anders
69ef51f417 Enable PWD reporting for iTerm2 2023-08-14 18:09:12 +02:00
Emily Grace Seville
f9d21cc21d
Add horcrux completion (#9922)
* feat(completions): horcrux

* feat(changelog): mention completion

* fix(completion): condition for -n
2023-08-09 17:30:34 +02:00
Fabian Boehm
bc56a0436b CHANGELOG: Add 3.6.2 section 2023-08-03 18:17:05 +02:00
Henrik Hørlück Berg
6dd2cd2b20 Fix behaviour in the presence of non-visible width
Padding with an unprintable character is now disallowed, like it was for other
zero-length characters.

`string shorten` now ignores escape sequences and non-printable characters
when calculating the visible width of the ellipsis used (except for `\b`,
which is treated as a width of -1).
Previously `fish_wcswidth` returned a length of -1 when the ellipsis-str
contained any non-printable character, causing the command to poentially
print a larger width than expected.

This also fixes an integer overflows in `string shorten`'s
`max` and `max2`, when the cumulative sum of character widths turned negative
(e.g. with any non-printable characters, or `\b` after the changes above).
The overflow potentially caused strings containing non-printable characters
to be truncated.

This adds test that verify the fixed behaviour.
2023-07-27 22:00:03 -07:00
Emily Grace Seville
6ce2ffbbb0
Add Krita completions (#9903)
* feat(completions): support Krita

* feat(completions): support summary options for Krita

* feat(completions): support remaining options for Krita

* feat(completions): remove debug instructions

* feat(completions): hide completions for sizes for Krita

* feat(completions): fix Krita

* feat(changelog): mention new completion

* fix(completions): refactor Krita

* fix(completion): reformat

* feat(completion): dynamically generate workspace list

* fix(completion): refactor

* fix(completion): krita

* fix(completions): use printf
2023-07-27 17:43:51 +02:00
Emily Grace Seville
8d3885b9cb
Add Blender completions (#9905) 2023-07-27 17:42:55 +02:00
EmilySeville7cfg
3fde15fd9a feat(changelog): explain changes 2023-07-23 15:09:35 -07:00
Henrik Hørlück Berg
6325b3662d Fix #9899 integer overflow in string repeat
We could end up overflowing if we print out something that's a multiple of the
chunk size, which would then finish printing in the chunk-printing, but not
break out early.
2023-07-17 15:41:08 +02:00
elyashiv
0dfef25b4c [CHANGELOG.rst] added line about escaping jobs 2023-07-10 18:38:26 +02:00
ridiculousfish
b4570623e9 Changelog fix for #9863 2023-07-01 11:08:53 -07:00
ridiculousfish
908e234bf6 Changelog fix for #9833
Also relevant is #9812
2023-06-04 13:44:36 -07:00
Kevin F. Konrad
ffb6168221 implement completion for age and age-keygen 2023-05-27 11:15:37 -07:00
ridiculousfish
d4c3c77318 Changelog fix in #9776 2023-05-07 14:34:19 -07:00
AsukaMinato
36e4b0ff30
add completion for ar (#9720)
* add completion for ar

* clean the function

* update CHANGELOG
2023-04-10 11:01:47 +02:00
ridiculousfish
de24e84a48 Changelog fix for #9722 2023-04-09 11:34:45 -07:00
ridiculousfish
0ad3e3a45d Changelog fix for #9717 2023-04-08 20:23:21 -07:00
ridiculousfish
0b6605b026 CHANGELOG fix for #9700 2023-04-01 10:07:13 -07:00
ridiculousfish
df3f2d678c Changelog fix for #9699 2023-03-31 20:29:26 -07:00
David Adam
e2579a59ba CHANGELOG: fix date for 3.6.1 2023-03-25 22:57:24 +08:00
David Adam
83a9555b47 Merge branch 'Integration_3.6.1' 2023-03-25 17:19:33 +08:00
David Adam
f39bc9317d Release 3.6.1 2023-03-25 14:50:41 +08:00
David Adam
2f47f7d9c0 CHANGELOG: work on 3.6.1 2023-03-25 11:31:12 +08:00
NextAlone
37e7e90bff completion/ssh-copy-id: add completion (#9675)
Add completions for ssh-copy-id.

Refactored __ssh_history_completions into its own file for autoloading across
completions.

(cherry picked from commit 45b6622986)

Conflicts:
	CHANGELOG.rst
2023-03-22 12:30:01 -05:00
NextAlone
45b6622986
completion/ssh-copy-id: add completion (#9675)
Add completions for ssh-copy-id.

Refactored __ssh_history_completions into its own file for autoloading across completions.
2023-03-22 12:24:18 -05:00
David Adam
a1f79b3acc CHANGELOG: work on 3.6.1 2023-03-18 00:41:09 +08:00
David Adam
88043088f2 CHANGELOG: work on 3.6.1 2023-03-18 00:14:24 +08:00
Quinten Roets
f5506803d7
fish_vi_cursor: add new variable for external cursor mode (#9565)
* add new variable for external cursor mode

* fix backwards compatibility

* add documentation

* document change in changelog
2023-03-14 10:50:20 +01:00
David Adam
6ac8d76b2b CHANGELOG: work on 3.6.1 2023-03-11 22:59:36 +08:00
Fabian Boehm
fdd9fe27b8 CHANGELOG 2023-03-05 16:10:50 +01:00