-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to have different escapes for Ctrl+key and Ctrl+Shift+key #406
Comments
I don't believe there is an encoding for standard control keys with shift held down. xterm and urxvt both emit |
I see: there is an xterm configuration option that allows you to specifically rebind what any particular key combination sends.
This doesn't appear to be standard, unfortunately. |
Yes, that's what I would put in a |
That's correct - I supposed having a file for overriding keybindings is something we could add support for in the future. |
Thanks! That would open so much configurability! Hope someone picks this up :) |
I use the emacs bindings for powershell Except the third thing that is ingrained into my fingers and can never, ever be unlearned is ctrl-w to delete the last entire word. Which promptly closes the entire tab. 😱 Please have some way that will let me switch the tab-killing behavior of ctrl-w to windows-w. |
I don't know if this is related or if this is a separate bug. I'm using ubuntu.exe inside Windows Terminal. I'm ssh'd into a remote location. I'm using emacs in terminal mode. Normally in emacs Alt+Shift+5 starts search and replace. According to emacs, it's receiving Ctrl-u 5. Normally Alt is mapped to Ctrl+[, so if I do Ctrl+[, Shift 5, then search and replace works as expected. If I just run ubuntu.exe, ssh in to the same remote host, start emacs in terminal mode, and use Alt+Shift+5, it passes through as expected. |
To add more examples to this. I use Emacs 26.2 in WSL. I can confirm the same behaviour as @atwok. To add to that, pressing Furthermore, the standard emacs keys for going to start and end of buffer namly All of the above (both escape- and alt-based procedures) works in a standard PowerShell 5 window (in which you can invoke wsl.exe) and of course using WSL directly. |
To add another example, I have a key binding in Neovim for Shfit-Tab, but this does not work when using Windows Terminal+ssh. This does work when using PuTTY, which maps Shift-Tab to |
Hey so I just stumbled across this in the backlog. We'll probably not actually end up doing this with
(also vaguely related, #4999, but not really relevant to using that in WSL) |
A little more guidance on this in case it helps me or others in the future: To set this up, open up the settings JSON file (when I checked, it didn't seem you could add "actions": [
{
"command": { "action": "sendInput", "input": "\u001b[210~" },
"keys": "ctrl+shift+o"
}
], After saving, open a new WSL tab and test that you get the right escape sequence sent. E.g. if you used the example action above, then typing ctrl+v ctrl+shift+o should output Try pressing your key combination (e.g. ctrl+shift+o) without ctrl+v to see if this does anything in your terminal. This will help you avoid using an escape sequence that the terminal is already using. E.g. Windows terminal uses Finally, you can set up your shell to do some custom behavior when it receives these special escape sequences. The exact method required will be shell-specific; for bash, you can put a line like this
in your |
This is really great, @neighthan! Thanks! I might recommend changing the example binding to not be Recording.2023-04-12.143437.mp4 |
Hah, yeah, I didn't know what a good escape sequence to use would be. I got that one from chatgpt, but then I realized a few minutes ago that my pasting was messed up. I'm using \e[210~ now and haven't had issues yet. I'll update the example to use that for now to avoid causing issues for anybody else! Let me know if there's a better example code (or ideally range of codes?) to use that doesn't conflict with anything else. I just checked, and this sequence seems to make the Windows terminal output |
Microsoft Windows [Version 10.0.17134.648]
I am using WSL with zsh and have a nice list of keybindings, using e.g.
bindkey "^K" kill-line
to bind pressing "Ctrl+k" to deleting all text from the cursor position to the EOL, like I have it in my atom text editor. I would now like to bind "Ctrl+Shift+k" to delete the entire line. Unfortunately, the WSL terminal has the same escape sequence for both, so it cannot detect the difference. I checked that using usingsed -n l
. How can I configure WSL to have different escape sequences?Is it xterm below? If yes, can I just configure the underlying xterm to do what I want, e.g. in a
.Xresources
file?I would have expected different escape sequences, such that I can bind different zsh widgets to them
The text was updated successfully, but these errors were encountered: