From 865118e3b42b80167633ceadb610d566d574f670 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 22 Mar 2024 07:18:04 +0100 Subject: [PATCH] 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. --- share/functions/__fish_shared_key_bindings.fish | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 36dc582fb..9cbe8a66a 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -186,6 +186,10 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod bind --preset $argv "&" self-insert expand-abbr bind --preset $argv ">" self-insert expand-abbr bind --preset $argv "<" self-insert expand-abbr + # Shift+Return as sent with XTerm.vt100.formatOtherKeys: 0 + bind --preset $argv \e\[27\;2\;13~ "commandline -f expand-abbr; commandline -i \n" + # Shift+Return CSI u sequence, sent with XTerm.vt100.formatOtherKeys: 1 + bind --preset $argv \e\[13\;2u "commandline -f expand-abbr; commandline -i \n" # Closing a command substitution expands abbreviations bind --preset $argv ")" self-insert expand-abbr # Ctrl-space inserts space without expanding abbrs @@ -198,9 +202,6 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod # Make Control+Return behave like Return because it's easy to mistype after accepting an autosuggestion. bind --preset $argv \e\[27\;5\;13~ execute # Sent with XTerm.vt100.formatOtherKeys: 0 bind --preset $argv \e\[13\;5u execute # CSI u sequence, sent with XTerm.vt100.formatOtherKeys: 1 - # Same for Shift+Return - bind --preset $argv \e\[27\;2\;13~ execute - bind --preset $argv \e\[13\;2u execute end end