2 ms·
I have now tried several terminals, but most lack one feature: I use zsh's [autocompletion plugin], and I'd like to call the suggestion with Ctrl+Enter. On the
by fdw 8y ago
I have now tried several terminals, but most lack one feature: I use zsh's [autocompletion plugin], and I'd like to call the suggestion with Ctrl+Enter. On the other hand, sometimes I want to execute only what I typed in, with Enter.
However, almost all terminals cannot differentiate between Enter and Ctrl+Enter. The one that could is Terminator, but that depends on gconf and I don't need the tiling. Sakura, urxvt and Alacritty cannot. Does anybody have a suggestion for me, or a better mapping?
[autocompletion plugin] https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions
- aumerle 8y agoSimply remap Ctrl+Enter to send some other key combination and bind that in zsh. You can do the remapping either in X or using the terminals native remapping features many terminals have them, for instance kitty.
- emj 8y agoI recently did a similar overview of terminals since I needed to pass all keypresses to the terminal, I ended up with something like this in xterm, but I hear it works in urxvt as well: .Xdefaults-localhost *VT100.Translations: #override \ Shift<Key>Return: string("shift return")\n\ Ctrl<Key>Return: string("ctrl return")\n\ Alt<Key>Return: string("alt return")\n\ Super<Key>Return: string("super return") Here are the escape sequences used by Kitty for sending modifiers to the shell from the terminal: https://github.com/kovidgoyal/kitty/blob/master/protocol-extensions.asciidoc#keyboard-handling https://github.com/kovidgoyal/kitty/blob/master/protocol-ext... (thanks aumerle)
- coldtea 8y ago>However, almost all terminals cannot differentiate between Enter and Ctrl+Enter. Don't let them do the differentiation them. Hook a script/something between the keyboard and the terminal that does it for them.
- JdeBP 8y ago> almost all terminals cannot differentiate between Enter and Ctrl+Enter On the contrary, many (perhaps even most) of them can. This is a matter of having a keyboard map that makes these into two distinguishable actions. For many terminal (emulators, at least) this is indeed entirely within the remit of the keyboard map and not limited by the terminal emulator itself at all. Easy to find example: The us.kbd keyboard map on FreeBSD, used by the terminal emulator that is built in to the kernel and that provides the kernel virtual terminals, distinguishes between these two chords, mapping the former to CR and the latter to LF. /usr/share/vt/keymaps % sed -n -e '3,5p;/089/p' us.kbd # scan cntrl alt alt cntrl lock # code base shift cntrl shift alt shift cntrl shift state # ------------------------------------------------------------------ 089 cr cr nl nl cr cr nl nl O /usr/share/vt/keymaps % Note that to take advantage of a mapping like this, one has to turn off the crnl input mode in the terminal line discipline. Again, though, the kernel line discipline is a separate thing to the terminal emulator and this is not a mechanism of the terminal emulator.