Add back legacy bindings to address modifyOtherKeys regressions in iTerm2<3.5.12

As of 303af07, iTerm2 3.5.11 on two different machines has two different
behaviors. For unknown reasons, when pressing alt-right fish_key_reader
shows "\e\[1\;9C" on one machine and "\e\[1\;3C" on another.

Feels like iTerm2 interprets modifyOtherKeys differently, depending on
configuration.

We don't want to risk asking for the kitty
keyboard protocol until iTerm2 3.5.12 (see
https://github.com/fish-shell/fish-shell/issues/11004#issuecomment-2571494782).

So let's work around around this weirdness by adding back the legacy
bindings removed in c0bcd817ba (Remove obsolete bindings, 2024-04-28) and
plan to remove them in a few years.

Note that fish_key_reader still reports this as "left", which already has
a different binding, but it looks like literal matches of legacy sequences
have precedence.

Fixes the problem described in
https://github.com/fish-shell/fish-shell/issues/11192#issuecomment-2692247060

Closes #11192
This commit is contained in:
Johannes Altmanninger
2025-03-01 16:27:59 +01:00
parent 50e595503e
commit 44d5abdc05

View File

@@ -56,9 +56,13 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv alt-right nextd-or-forward-word
bind --preset $argv alt-left prevd-or-backward-word
$legacy_bind --preset $argv \e\[1\;9C nextd-or-forward-word # iTerm2 < 3.5.12
$legacy_bind --preset $argv \e\[1\;9D prevd-or-backward-word # iTerm2 < 3.5.12
bind --preset $argv alt-up history-token-search-backward
bind --preset $argv alt-down history-token-search-forward
$legacy_bind --preset $argv \e\[1\;9A history-token-search-backward # iTerm2 < 3.5.12
$legacy_bind --preset $argv \e\[1\;9B history-token-search-forward # iTerm2 < 3.5.12
# Bash compatibility
# https://github.com/fish-shell/fish-shell/issues/89
bind --preset $argv alt-. history-token-search-backward