How to bind CTRL + Enter in zsh?

I want to bind Ctrl+ Enter ↵in zsh:

bindkey '^M' autosuggest-execute

But it seems that the terminal sends the same escape sequence for any modifier key except Alt.

$ showkey -a

Press any keys - Ctrl-D will terminate this program

^M       13 0015 0x0d # Enter
^M       13 0015 0x0d # CTRL  + Enter
^M       13 0015 0x0d # SHIFT + Enter
^[^M     27 0033 0x1b # ALT   + Enter
         13 0015 0x0d

I am not sure what the problem is specific to gnome-terminal. I also tested this in mate-terminaland xterm, and the results were the same. Is there any way to detect CTRL + Enter?

+4
source share
1 answer

Here is a solution for xterm, gnome-terminal, and any other terminal emulator for the XWindow system.

, Ctrl + Enter xterm , , X-. gnome- , XWindow, gnome-. , , .

-, , xterm:

Ctrl + Enter , : xterm , X, . , Esc + M. bindkey zsh ZLE (autosuggest-execute ).

, :

1- xterm :

% xterm -xrm '*.VT100.translations: #override Ctrl <Key>Return: string(0x1b) string("M")'

: Return, Enter, .

2- xterm bindkey:

% bindkey '^[M' autosuggest-execute

3 CTRL-Enter, autosuggest-execute

:

, Ctrl + Enter , ( Esc + M). Compose (5) X11: $HOME/.XCompose, Ctrl + M. bindkey zsh, ZLE (autosuggest-execute ).

, :

1- $HOME/.XCompose

:

include "%L"
! Ctrl <Return> : "\033M"

1: Return, Enter, .

2: ! , .

3: (include...) (, ^ + e, ê).

2- gnome-terminal

3- gnome-terminal, bindkey:

% bindkey '^[M' autosuggest-execute

4- CTRL-Enter, autosuggest-execute

0

Source: https://habr.com/ru/post/1674882/


All Articles