From edb1b5f33316fa0d1834e1f314d96dc5f6b1fc5f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 11 May 2025 21:20:37 +0200 Subject: [PATCH] Share alt-{b,f} with Vi mode, to work around Terminal.app/Ghostty more Commit f4503af037c (Make alt-{b,f} move in directory history if commandline is empty, 2025-01-06) had the intentional side effect of making alt-{left,right} (move in directory history) work in Terminal.app and Ghostty without other, less reliable workarounds. That commit says "that [workaround] alone should not be the reason for this change."; maybe this was wrong. Extend the workaround to Vi mode. The intention here is to provide alt-{left,right} in Vi mode. This also adds alt-{b,f} which is odd but mostly harmless (?) because those don't do anything else in Vi mode. It might be confusing when studying "bind" output but that one already has almost 400 lines for Vi mode. Closes #11479 (cherry picked from commit 3081d0157bffed6ded47a8cc3b219b228f924a9f) --- share/functions/__fish_shared_key_bindings.fish | 3 +++ share/functions/fish_default_key_bindings.fish | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index aabf9fd72..419430124 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -59,6 +59,9 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod $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-b prevd-or-backward-word + bind --preset $argv alt-f nextd-or-forward-word + 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 diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index 2271eb0a7..327c597c5 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -60,8 +60,6 @@ function fish_default_key_bindings -d "emacs-like key binds" bind --preset $argv alt-backspace backward-kill-word bind --preset $argv ctrl-backspace backward-kill-word bind --preset $argv ctrl-delete kill-word - bind --preset $argv alt-b prevd-or-backward-word - bind --preset $argv alt-f nextd-or-forward-word bind --preset $argv alt-\< beginning-of-buffer bind --preset $argv alt-\> end-of-buffer