MobaXterm backspace sends ^H
Long question:
I'm trying to test my simple HTTP Server by Telnet-ing alot of requests and seeing how the server reacts. But when i make a typo and press Backspace to erase the previous character, MobaXterm sends ^H
instead of removing the character from the string. When i press Shift+Backspace everything works the way i want it to, but after a while this gets very annoying... So, is there a solution that just changes the functionality of backspace?
Short question:
Is it possible to make backspace delete a character instead of sending ^H
?
MobaXterm also proposes a checkbox setting "Backspace sends ^H" that you can try to toggle (in MobaXterm global settings --> "Terminal" tab).
If you are using a saved session, you will have to edit this session, go to the "Terminal settings" tab and toggle the "Backspace sends ^H" checkbox.
In MobaXterm, there exists an option to change the behavior of the backspace key. (answer below is based on MobaXterm personal v11.1)
The option is called: "Backspace sends CTRL-H"
The option is only shown in the session-specific configuration, not in the global settings: Create/edit a new/existing user session of type SSH in Moba, and access its settings. Under the "Terminal Settings" tab, uncheck "Backspace sends CTRL-H", save, and reload.
Can the behavior be changed for all sessions? I haven't figured out a way to change the behaviour globally yet. MobaXterm uses Putty code underneath, which does have a corresponding toggle setting for the backspace key behavior, but unfortunately that`s not exposed to the global settings window in MobaXTerm. Not in the free version anyways.
The professional version of Moba does offer a separate configuration tool which shows more config options to you. I suspect this might translate into a MobaXTerm.ini setting. I can't verify.
Alternative: change the behavior on the server
If you login with ssh <server>
from a local terminal not attached to any user session, the global setting applies -- which is to send ^H
. This causes some issues with editors, namely emacs, and anything else using readline like telnet. A workaround is to patch the terminal behavior on the remote site by issuing an stty command (on debian, this comes with package coreutils
):
# interpret incoming ^H as backspace/erase
stty erase \^H
I don't recommend adding this to ~/.bashrc if you login via other sorts of terminals, however. So the user-session config key is a better approach.
The key labeled "backspace" is a matter of contention. Technically, it ought to send ^H
simply because that is the name of the ASCII control character. Others differ, because their expectations have been affected by the history of this feature (see Why doesn't my delete key work?).
In a discussion where you say you are typing, the usual connotation (lacking clarification) is that you have started a terminal, then run a program within the terminal. For that case, there is a corresponding terminal initialization, e.g., using a shell and program such as stty
. This is run on the local machine (where you are typing). MobaXterm provides stty
since Version 3.2 (2011-05-30).
Given that, if MobaXterm sends ^H
, your terminal initialization should use
stty erase \^H
See for example What does the command stty erase ^H
do?.
On the other hand, you could have (not apparent in the question) constructed a situation where the terminal is started in a manner that precludes using stty
to make the application and terminal consistent. Or you may have some other reason for changing the behavior of the backspace key. PuTTY (like xterm) provides two mechanisms for this:
- one (originally implemented in rxvt) lets you use the shift modifier to toggle the code sent from "backspace" between ASCII backspace (BS = 8 =
^H
) and delete (DEL = 127, often shown as^?
). - the other is the terminal configuration (a dialog setting in the Keyboard section of the Terminal section).
xterm provides a third mechanism which PuTTY appears to lack (see XTerm Control Sequences):
CSI ? Pm h
DEC Private Mode Set (DECSET).
Ps = 6 7 -> Backarrow key sends backspace (DECBKM).
If PuTTY did implement that, your application could set the behavior of the terminal directly. Rather, during initialization, PuTTY checks the initial state of its configuration and (depending on platform) also checks (like xterm) the terminal modes set in the device, and chooses a backspace versus delete behavior which you can accommodate or amend as noted.