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.
This commit is contained in:
Johannes Altmanninger 2024-03-22 07:18:04 +01:00
parent 232483d89a
commit 865118e3b4

View File

@ -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