I have found myself in a very dark and silly rabbit hole, trying to save myself a few seconds/minutes over my lifetime by doing hours of research. I’ve been using Linux for many years and usually I just adapt to learn how to do things the Linux way, but this 1 time I thought I’d try to make Linux behave like I want, since my muscle memory is going to press the key combination anyway. This thought has resulted in many hours of searching and 54 open tabs related to this issue, but although I have learned a lot, I still don’t feel any closer to solving the problem. So, I am here to ask for help.
I would like to be able to press
Ctrl+Backspace and see the functionality “backspace 1 whole word” in the terminal. However, I can’t seem to split my terminal emulator’s understanding of
Ctrl+Backspace away from
Backspace, which according to
showkey -a, both are sending
Some light background - I know there are simple alternatives available to me right away.
Ctrl-W works just fine, and after learning about
stty, I found that I can make whatever keystroke I want perform a
werase, which works as I like. I just can’t get it working for
In GUI-based applications,
Ctrl-W is reserved for “close window” function, or in tabbed applications like Notepad++ or your browser, this keystroke will close a tab. I have even gotten
Ctrl-Shift-W closing a tab stack in Vivaldi.
Ctrl-Backspace is used in these cases to provide the backwards-kill-word or werase functionality in these GUI-based systems. I would like to be able to retain my muscle memory by using these newer keystrokes as previously learned, especially when using GUI-based Linux distributions and switching between the terminal and a browser, for example.
What I have tried & learned
showkey -ais a useful command for letting the terminal respond with the (ascii?) input that I sent as seen by the terminal emulator.
echo $TERMIn theory shows me my terminal emulator. I assume the rest of my OS configuration is being truthful to this variable, but things also get a bit sticky later when I get into
Given these 2 facts, this is what I have observed:
- WSL - fedoraremix, ubuntu, etc. are using
Ctrl-Backspace. Looking good.
- 2 systems, Pop!_OS and Manjaro based, each report the following over a
So, that isn’t right. I have come to understand a few things about these results:
- When the terminal emulator interprets
^?for both key combinations, anything I configure for
sttywill apply for both key combinations. i.e. both
backwards-delete-word. Hence, I need to resolve the terminal emulator’s interpretation of my key combination before I can select an action/command for that key combination to perform.
- According to Stack Exchange,
tmuxwill interpret the calling shell’s configuration upon launch. It will however report
screenas the running terminal emulator. Hence, I must resolve the terminal emulator’s interpretation of my key combination before I can forward the configuration to
With this in mind, I first thought to check the
PuTTY configuration, and thought I landed on something solid with the
Terminal > Keyboard settings, but actually this
Backspace key configuration will make things backwards, such that if you set the non-standard
Backspace will send
Ctrl-Backspace will send
^?. This does well to separate the keystrokes, but sends them in the opposite pattern observed on a local shell or WSL as exampled earlier. Without trying to get my nuts in a twist, I undid that and went back to looking.
I did find some pretty good articles on configuring x or xterm, but this is the first time I’ve tried doing so and I’m running into some problems. I like this user’s approach (assigning a totally unused escape sequence), so I tried it first: Use of CtrlBackSpace in xterm
They suggest setting the following configuration in “an X resource”:
*VT100*translations: #override \n\ Ctrl<Key>BackSpace: string("\033[7;5~")
I had to search some to find that most people these days use
~/.Xresources. My system did not have this file so I created it and added the configuration. Since this was my first time configuring this file, I had to find information about how to reload it for a first-time or test config. I found someone say
xrdb -merge ~/.Xresources should do the trick. When I execute this, I get an error
xrdb: Can't open display ''. I tried searching this error online but mostly return results on forums asking “which window manager are you using”, but to reiterate I am operating this machine over ssh via PuTTY, which from my understanding does not have a window manager like dwm or i3, because there is no GUI. Is there something silly I’m missing here, like some fundamental assumption about xterm that assumes there will be a GUI?
So… From here I’m not sure where to go. I know I need to resolve the xterm keystroke interpretations, but I can’t even seem to set up a basic
~/.Xresources, even when carefully checking the whitespace or attempting to apply a different background color instead of focusing on my keystroke problem.
If there’s anything I’m doing wrong or anything I can learn, please say it. That’s why I’m here asking for advice. There’s nothing business critical about this, just trying to find a true solution to set my fickle mind at ease, after which maybe I’ll find a way to make the solution into some lovely infrastructure as code via configuration management so I can propagate the configuration to all my machines. I think the ideal solution may also be looking into switching away from PuTTY, since it would leave the terminal emulator to its default config and fix the problem client-side, but that also comes with downsides such as no longer being able to use PuTTY and mRemoteNG. Well, I better end this here as it’s already gotten super long. Thank you sincerely for your time, and any suggestions that you have to offer.