Investigate: Ctrl-Space seems to work strangely for some folks #15826

Open
opened 2026-01-31 04:49:36 +00:00 by claunia · 11 comments
Owner

Originally created by @DHowett on GitHub (Nov 10, 2021).

I'm using Git Bash (from Git 2.32.0.2) in Windows Terminal 1.9.1942.0 (installed via Windows Store), on Win10.

I connect to another machine via SSH and use screen there.
In screen I should be able to switch between the "windows" with Ctrl-A Space.

Right now this only works if I don't press Ctrl anymore when pressing Space - I'm pretty sure it wasn't like this before, and it definitely isn't like that with the (Putty-based, AFAIK?) mintty Terminal emulator that comes with Git for Windows (or any terminal emulator I tried on Linux).
So Ctrl-A release keys Space works, Ctrl-A- keep pressing those keys Space does not work (when using Windows Terminal), even though it should (and after almost 20 years of doing this I don't think I can retrain my muscle memory).

UPDATE: When I connect to a Linux machine per SSH and run cat -v and then press Ctrl-Space, it prints ^@ with mintty (from git) and nothing at all with Windows Terminal.

Originally posted by @DanielGibson in https://github.com/microsoft/terminal/issues/2865#issuecomment-914471061

Originally created by @DHowett on GitHub (Nov 10, 2021). I'm using Git Bash (from Git 2.32.0.2) in Windows Terminal 1.9.1942.0 (installed via Windows Store), on Win10. I connect to another machine via SSH and use screen there. In screen I should be able to switch between the "windows" with `Ctrl-A Space`. Right now this only works if I don't press Ctrl anymore when pressing Space - I'm pretty sure it wasn't like this before, and it definitely isn't like that with the (Putty-based, AFAIK?) **mintty** Terminal emulator that comes with Git for Windows (or any terminal emulator I tried on Linux). So `Ctrl-A` *release keys* `Space` works, `Ctrl-A-` *keep pressing those keys* `Space` does not work (when using Windows Terminal), even though it should (and after almost 20 years of doing this I don't think I can retrain my muscle memory). **UPDATE:** When I connect to a Linux machine per SSH and run `cat -v` and then press `Ctrl-Space`, it prints `^@` with mintty (from git) and nothing at all with Windows Terminal. _Originally posted by @DanielGibson in https://github.com/microsoft/terminal/issues/2865#issuecomment-914471061_
claunia added the Issue-BugArea-InputProduct-TerminalPriority-2 labels 2026-01-31 04:49:36 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Nov 10, 2021):

Ah okay so this is different from the AltGr+Space one over in #11649, got it.

@zadjii-msft commented on GitHub (Nov 10, 2021): Ah okay so this is different from the AltGr+Space one over in #11649, got it.
Author
Owner

@zadjii-msft commented on GitHub (Feb 14, 2022):

From @eej71 in #12481

Windows Terminal Preview Version: 1.13.10395.0

Windows Version: [Version 10.0.19043.1466]

User Action: Connect to a bash prompt. Run od -c to see the exact characters that are received. Type in Control '@' (Control Shift 2 on a US keyboard)

Expected Result: The od -c invocation should look like this.

od -c
^@^@^@^@^@^@
0000000  \0  \0  \0  \0  \0  \0  \n

That's the output that I receive when I do the test through putty.

Actual Result: Nothing. The invocation of od -c is unaware that anything has been sent.

Comments: I know this issue has some history so I can appreciate if its something that is not easily resolved.

@zadjii-msft commented on GitHub (Feb 14, 2022): From @eej71 in #12481 > **Windows Terminal Preview Version**: 1.13.10395.0 > > **Windows Version**: [Version 10.0.19043.1466] > > **User Action**: Connect to a bash prompt. Run od -c to see the exact characters that are received. Type in Control '@' (Control Shift 2 on a US keyboard) > > **Expected Result**: The `od -c` invocation should look like this. > > ``` > od -c > ^@^@^@^@^@^@ > 0000000 \0 \0 \0 \0 \0 \0 \n > ``` > > That's the output that I receive when I do the test through putty. > > **Actual Result**: Nothing. The invocation of `od -c` is unaware that anything has been sent. > > **Comments**: I know this issue has some history so I can appreciate if its something that is not easily resolved.
Author
Owner

@eej71 commented on GitHub (Feb 16, 2022):

I found the version of ssh.exe that comes with Git-for-Windows to see if using a more modern ssh would resolve the issue. But sadly, the issue still exists even when running OpenSSH_8.8p1 from within powershell inside of Windows Terminal.

@eej71 commented on GitHub (Feb 16, 2022): I found the version of ssh.exe that comes with Git-for-Windows to see if using a more modern ssh would resolve the issue. But sadly, the issue still exists even when running OpenSSH_8.8p1 from within powershell inside of Windows Terminal.
Author
Owner

@zadjii-msft commented on GitHub (Sep 2, 2022):

For reference: https://github.com/PowerShell/Win32-OpenSSH/issues/1842

That's of course for win32-openssh's ssh.exe that ships with Windows. But this issue seems to refer to the git bash ssh, so that's different.

@zadjii-msft commented on GitHub (Sep 2, 2022): For reference: https://github.com/PowerShell/Win32-OpenSSH/issues/1842 That's of course for win32-openssh's ssh.exe that ships with Windows. But this issue seems to refer to the git bash ssh, so that's different.
Author
Owner

@rurbina commented on GitHub (Sep 2, 2022):

I don't think this ticket is clear enough: control+space is completely broken. I don't see it working "strangely", it doesn't work at all, doesn't work when SSHing into a linux host, doesn't work on the WSL console and doesn't work when running a Cygwin shell binary. I know because it's a very common emacs keybinding. I tried opening a new ticket (#13910) and it got closed because this one's the right one, so I'm posting my followup here.

Try Windows Terminal 1.14.2281.0 on Windows 10.0.19043.1889 and OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2.

Instead of OpenSSH_for_Windows, you can use Cygwin's Zsh 5.8 (x86_64-pc-cygwin). It didn't work on WSL Debian either. It's not an OpenSSH bug, it's just that that's the simplest way to try it.

Steps to reproduce

Disable the default Paste binding as ctrl+v. SSH into any linux host. Press ctrl+v (to send the next input as verbatim) then ctrl+space.

Expected Behavior

You should get a ^@ character on screen, as seen on the bottom part of the picture (which is mintty).

image_2022-09-02_091923063

Actual Behavior

Nothing happens, no character is sent at all.

Thanks.

@rurbina commented on GitHub (Sep 2, 2022): I don't think this ticket is clear enough: control+space is completely broken. I don't see it working "strangely", it doesn't work _at all_, doesn't work when SSHing into a linux host, doesn't work on the WSL console and doesn't work when running a Cygwin shell binary. I know because it's a very common emacs keybinding. I tried opening a new ticket (#13910) and it got closed because this one's the right one, so I'm posting my followup here. Try Windows Terminal 1.14.2281.0 on Windows 10.0.19043.1889 and OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2. Instead of OpenSSH_for_Windows, you can use Cygwin's Zsh 5.8 (x86_64-pc-cygwin). It didn't work on WSL Debian either. _It's not an OpenSSH bug_, it's just that that's the simplest way to try it. ### Steps to reproduce Disable the default _Paste_ binding as `ctrl+v`. SSH into any linux host. Press `ctrl+v` (to send the next input as verbatim) then `ctrl+space`. ### Expected Behavior You should get a `^@` character on screen, as seen on the bottom part of the picture (which is mintty). ![image_2022-09-02_091923063](https://user-images.githubusercontent.com/2152961/188169322-d0fa6b80-0b6a-4b95-a316-d956bfadc263.png) ### Actual Behavior Nothing happens, no character is sent at all. Thanks.
Author
Owner

@zadjii-msft commented on GitHub (Sep 2, 2022):

@rurbina That's definitely not all true. Ctrl+Space works just fine for wsl:
image

Perhaps there's a similar bug in the way the cygwin zsh is run outside of mintty. What's the exact commandline you're specifying for running zsh?

FWIW, I closed out #13910 cause it specifically mentioned using openssh 8.1, which has a known bug with ctrl+space. Finding repros that don't involve ssh.exe are helpful here ☺️

@zadjii-msft commented on GitHub (Sep 2, 2022): @rurbina That's definitely not all true. Ctrl+Space works just fine for `wsl`: ![image](https://user-images.githubusercontent.com/18356694/188173812-33f7b5ea-da1e-4c60-8579-3f9f8ea1b1c7.png) Perhaps there's a similar bug in the way the cygwin zsh is run outside of mintty. What's the exact `commandline` you're specifying for running `zsh`? FWIW, I closed out #13910 cause it _specifically_ mentioned using openssh 8.1, which has a known bug with ctrl+space. Finding repros that don't involve `ssh.exe` are helpful here ☺️
Author
Owner

@rurbina commented on GitHub (Sep 2, 2022):

Ok, just tried on WSL, and it doesn't work on zsh, but it does work on emacs. WSL seems good, I was wrong. I made a profile and I'm running zsh as C:\cygwin64\usr\bin\zsh.exe, just that.

Then there's this. I got a showkey for Cygwin. It works fine on Mintty, but neither Terminal nor Console can send it a ctrl+space, which is reported as <NUL>.

image_2022-09-02_113621367

I don't know if Windows' OpenSSH uses anything from Cygwin, but using Cygwin's own OpenSSH doesn't work either. It doesn't seem related to OpenSSH. Or maybe it's two different bugs?

@rurbina commented on GitHub (Sep 2, 2022): Ok, just tried on WSL, and it doesn't work on zsh, but it does work on emacs. WSL seems good, I was wrong. I made a profile and I'm running zsh as `C:\cygwin64\usr\bin\zsh.exe`, just that. Then there's this. I got a `showkey` for Cygwin. It works fine on Mintty, but neither Terminal nor Console can send it a `ctrl+space`, which is reported as `<NUL>`. ![image_2022-09-02_113621367](https://user-images.githubusercontent.com/2152961/188199186-c176a0f6-9269-41d8-add8-ec6a3ec98245.png) I don't know if Windows' OpenSSH uses anything from Cygwin, but using Cygwin's own OpenSSH doesn't work either. It doesn't seem related to OpenSSH. Or maybe it's two different bugs?
Author
Owner

@DHowett commented on GitHub (Sep 3, 2022):

Sorry, I'm coming away from this pretty confused!

Ok, just tried on WSL, and it doesn't work on zsh, but it does work on emacs. WSL seems good, I was wrong. I made a profile and I'm running zsh as C:\cygwin64\usr\bin\zsh.exe, just that.

When you said it "doesn't work on zsh," were you referring to zsh inside WSL, or Cygwin ZSH?

There's an additional wrinkle here, and that's Cygwin's translation layer. When it is talking to a console (conhost or Windows Terminal), it uses its own translation layer. When it's talking to mintty, it doesn't.

Can you report the value of TERM inside Cygwin when you use it via Windows Terminal or Windows Console? TERM=cygwin means that it'll translate everything (input and output) and TERM=xterm-(something) means that it may only translate output. It may still translate input.

For what it's worth, in "VT Input" mode this is exactly what Windows Terminal sends:

image

(Output is in gray, input is in red; this is the "debug tap" which shows the raw I/O transactions that Terminal is performing. NU is the "Control Pictures" representation of NUL, or 0x00)

Terminal is emitting a raw NUL when I press Ctrl+Space. Once it goes through the console subsystem, it comes out the other side as NUL (as evidenced by wsl showkey -a). I'd guess that any mistranslation in the middle is up to Cygwin.

@DHowett commented on GitHub (Sep 3, 2022): Sorry, I'm coming away from this pretty confused! > Ok, just tried on WSL, and it doesn't work on zsh, but it does work on emacs. WSL seems good, I was wrong. I made a profile and I'm running zsh as `C:\cygwin64\usr\bin\zsh.exe`, just that. When you said it "doesn't work on zsh," were you referring to zsh inside WSL, or Cygwin ZSH? There's an additional wrinkle here, and that's Cygwin's translation layer. When it is talking to a console (conhost or Windows Terminal), _it uses its own translation layer._ When it's talking to `mintty`, it doesn't. Can you report the value of `TERM` _inside Cygwin_ when you use it via Windows Terminal or Windows Console? `TERM=cygwin` means that it'll translate _everything_ (input and output) and `TERM=xterm-(something)` means that it may only translate output. It may still translate input. For what it's worth, in "VT Input" mode this is exactly what Windows Terminal sends: <img width="64" alt="image" src="https://user-images.githubusercontent.com/189190/188245379-0f5095fe-9a1a-4b83-be2d-abf7c6f92de7.png"> (Output is in gray, input is in red; this is the "debug tap" which shows the raw I/O transactions that Terminal is performing. `NU` is the "Control Pictures" representation of `NUL`, or 0x00) Terminal is emitting a raw `NUL` when I press <kbd>Ctrl+Space</kbd>. Once it goes through the console subsystem, it comes out the other side as `NUL` (as evidenced by `wsl showkey -a`). I'd guess that any mistranslation in the middle is up to Cygwin.
Author
Owner

@rurbina commented on GitHub (Sep 3, 2022):

When you said it "doesn't work on zsh," were you referring to zsh inside WSL, or Cygwin ZSH?

That was zsh inside WSL. ctrl+v and ctrl+space didn't bring a ^@ as I expected... but showkey and emacs work fine; showing the ^@ might be a side-effect of something else, it's not really important.

If Cygwin is not treating Terminal the same as Mintty then I'm moving my argument to their support channels. Then that's a different issue. I failed to see that, I'm sorry. Thank you for taking your time to clarify this for me!

I'll keep following this issue, as using Terminal to ssh into linux hosts is part of my everyday. Thanks again!

@rurbina commented on GitHub (Sep 3, 2022): > When you said it "doesn't work on zsh," were you referring to zsh inside WSL, or Cygwin ZSH? That was zsh inside WSL. `ctrl+v` and `ctrl+space` didn't bring a `^@` as I expected... but showkey and emacs work fine; showing the ^@ might be a side-effect of something else, it's not really important. If Cygwin is not treating Terminal the same as Mintty then I'm moving my argument to their support channels. Then that's a different issue. I failed to see that, I'm sorry. Thank you for taking your time to clarify this for me! I'll keep following this issue, as using Terminal to ssh into linux hosts is part of my everyday. Thanks again!
Author
Owner

@yabb85 commented on GitHub (Jun 8, 2023):

I had the same issue in ubuntu launch with wsl the ctrl+space not work at all..

Terminal Windows
Version : 1.16.10261.0

@yabb85 commented on GitHub (Jun 8, 2023): I had the same issue in ubuntu launch with wsl the ctrl+space not work at all.. Terminal Windows Version : 1.16.10261.0
Author
Owner

@FJRMaverick commented on GitHub (Apr 9, 2024):

same problem here:
ctrl+space is working in WSL2 (ArchLinux), but not when SSHin into a real ArchLinux on another machine

Windows Terminal
Version: 1.19.10573.0

@FJRMaverick commented on GitHub (Apr 9, 2024): same problem here: ctrl+space is working in WSL2 (ArchLinux), but not when SSHin into a real ArchLinux on another machine Windows Terminal Version: 1.19.10573.0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15826