There's some good research there on your part, coupled with a bit of a misunderstanding of the terminal situation in WSL.
The question/answer you linked to specifically gave those xrdb
instructions for xterm
. There are many terminals that might be used, and the method for remapping differs for each. That particular answer even gave solutions for three different terminals:
And while it's possible to use those under WSL (see the end of this answer), none of those are the default WSL terminal. There are two possible default terminals for WSL:
- In Windows 10, the legacy Windows Console Host. This is the same terminal that is used for CMD and PowerShell.
- In Windows 11, the (fairly) new Windows Terminal replaces Console Host. It's quite advanced compared to its predecessor, including many additional features. Terminal can also be installed in Windows 10, but it can't be set as the default there.
So you need instructions for the terminal you are using, not really for WSL.
Windows Console Host, to my knowledge, doesn't include any key remapping features. However, you could use something like AutoHotkey or (possibly) AutoIt to intercept the Ctrl+i and send the correct escape sequence. It appears to me that at least AutoHotkey has this ability, but I haven't tried it for this purpose.
However, I would recommend going ahead and installing Windows Terminal (if you haven't already). It's available in the Microsoft Store for Windows 10 (and automatically installed in recent Windows 11 versions).
It does include the ability to remap keys, but it's a little "hidden" behind the configuration file. While Terminal now includes a GUI for editing some settings, advanced features like this do require manually editing of the settings.json
.
To do so:
In Windows Terminal, go to the dropdown menu and open Settings
At the bottom left corner of the Settings, select the "Open JSON file" option.
Side-note: It's recommended that you have VSCode installed, or at least some editor that can handle JSON well. VSCode has the added advantage of understanding the Windows Terminal schema, so it will auto-complete the options as you type.
Add the following in the "actions"
list:
{
"command": {
"action": "sendInput",
"input": "\u001b[105;5u"
},
"keys": "ctrl+i"
}
While I haven't tested this with Emacs, I did confirm in the Fish shell's fish_key_reader
that Ctrl+i is sending the specified control codes rather than a Tab character.
Using Linux/X terminals in WSL
If you do want to use one of the Linux terminals, you can do so with WSL. You'll just need to either be using Windows 11 with WSLg support (which allows you to run Linux GUI applications in WSL2) or configure GUI support in Windows 10 using one of the methods I detail in this Super User answer. With that in place, you could, if you want to, run Xterm and use the instructions from the answer you linked.