These don't really belong in config.fish. Put them in function files,
like similar wrappers. The redundancy is ugly but if it's a problem
we can use code generation to fix that.
parse_escape_sequence() can self-recurse once, to parse sequences of
the form "\e\e...", where we attempt to interpret the first byte as
either legacy alt (if the "\e..." suffix decodes to a key), or legacy
escape (if it doesn't).
On "\e\e]11;rgb:ffff/ffff/ffff\e\\", i.e. with the inner sequence
being an OSC which doesn't produce a key event, we (tragically)
stop parsing the sequence and assume legacy escape.
Rewrite the logic to keep parsing whole escape sequences whenever
possible. Also, don't drop any leading \e even if we later error.
Also, make sure each key event gets the correct "originating sequence".
This makes
tmux new-session fish -C '
bind alt-b "echo alt-b"
bind escape "echo escape"
bind alt-escape "echo alt-escape"
sleep 2
'
output the following after quickly pressing "escape" five times
followed by "b" one time:
escape
alt-escape
escape
alt-b
which is weird but fine because "alt-escape" is rarely used.
If this proves to be a problem, we could disable translation of "\e\e"
to "alt-escape"?
Closes#12379
A following commit wants to make "on_byte_read()" potentially return
multiple CharEvent values, in case there is a legacy escape.
Today "parse_csi()" and friends simply insert into the input queue.
This makes it hard to get the ordering right when we return multiple
events.
Change the parsing functions to return their result rather than
queuing directly.
This directory is no longer since 0fafff2c89 (CMake: stop installing
embedded files, 2026-05-08). Instead of telling users to see "status
list-files", refer them to the source directly.
A following commit wants to inject mock input bytes in unit tests.
Allow this in a quick-and-dirty way by making the input-byte-yielding an
overridable trait method again. Unfortunately this needs to be in the
shared trait; we can't specialize a private trait since specialization
is not supported in stable Rust.
Commit af137e5e96 (scrollback-push to query for indn/cuu via XTGETTCAP,
2025-01-05) extracted a bool variable
recursive_invocation = buffer.len() == 2
It replaced another instance of "buffer.len() == 2" with that variable,
but that's wrong because buffer has grown since then (so it's either
2 or 3). Flip the bool to fix this.
While at it, tighten an assertion.
While at it, rename "input mapping" to "binding", to be consistent
with builtin bind. The "input" bit is already implied by the module
hierarchy.
Also, merge definitions of "enum ReadlineCmd" and
"INPUT_FUNCTION_METADATA" using a macro.
Review with
git show --color-moved=zebra --color-moved-ws=allow-indentation-change
Types like Environment are sometimes imported using their FQN and
sometimes via their re-export in the parent module; it seems better
to have one canonical name. I think we usually use the re-exports
already, so use them always.
It't not as trivial to enforce this in child modules (such as "mod
tests" which) but that's not a big loss.
While at it, make some other consistency improvements to imports.
This is a potential bikeshed project but if fish is being used as a
proper noun, it should either be capitalised all the time or none of the
time, and the latter looks better.
This command typically does
ioctl(open("/dev/tty"), KDSKBMODE, K_UNICODE)
printf '\033%%G'
stty iutf8
Other shells don't do this; it seems like this is typically already done
before the shell is started, for example by systemd's vconsole-setup.
We only do it in very specific scenarios (login shells on linux), so
if this is really needed, we should make it reliable. Bravely remove it.
Make abbreviations with `--position anywhere` appear in the completion
menu when tabbing in argument position (e.g. `cat foo.log pg<TAB>`
shows pgr, pgrv, pjq, etc.), not just in command position.
Lift "do_file" into an enum, so we don't have to check "is_redirection"
twice, and can express more accurately the reason for not completing
abbreviations after redirection.
Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
Closes#12764
This loop iterates over all bindings and crashes if a mode filter
argument is given for a mode that has no binding. Fix this by
continuing the loop earlier.
Fixes 11d6e92cb5 (Show file location when querying bindings with bind, 2025-12-28)
Fixes#12798
Reintroduce a subset of 0e4a75c0b5 (Do not print greeting with empty
$fish_greeting and --private, 2019-11-08) after it has been removed
in 72a44460c6 (Move fish_greeting to a function, 2020-05-30).
Closes#12796