Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backspace not working in tmux command prompt

Tags:

tmux

I'm having trouble with my Backspace key on the tmux command prompt. The backspace deletes previous characters (as expected) within tmux but not on the tmux command prompt. For example, <PREFIX>:lists<DEL> will not delete the 's' character. Using C-h instead of the Delete key does delete the 's' character in this situation. C-? does NOT delete the 's' character. Some debugging I've done within the tmux window:

$TERM=screen-256color
infocmp reports kbs=\177                  (good)
appres XTerm | grep backarrowKeyIsErase   reports as true (good)
appres XTerm | grep ptyInitialErase       reports as true (good)
stty -a | grep erase                      reports as "^H" (bad, I think I want ^?)

I've also tried binding the Backspace key in the .tmux.conf as shown below to both C-h and C-?, neither work. :list-keys within tmux confirms that the mapping is occurring.

bind-key -n BSpace send-keys C-?

I've done a stty erase ^? as well, both before and after invoking tmux and that does not affect the behavior. Finally, I've removed my .tmux.conf entirely and still get the same behavior.

Does the command line use a different set of key bindings that would affect BSpace functionality?

like image 890
Greg Ruhl Avatar asked Jul 24 '18 00:07

Greg Ruhl


People also ask

Why my Backspace is not working in Linux terminal?

Checking Terminal Settings with stty The -a flag will give a human-readable output of the control characters. Look for the "erase" character. If it says "^H," then it uses the older Backspace character. Fortunately, you can also fix this with the stty command.

How do you go Backspace in Terminal?

Pressing the backspace key on a computer terminal would generate the ASCII code 08, BS or Backspace, a control code which would delete the preceding character. That control code could also be accessed by pressing Control-H, as H is the eighth letter of the Latin alphabet.

How do I Backspace on Linux?

The Linux kernel default lets Ctrl-Backspace generate BackSpace - this is sometimes useful as emergency escape, when you find you can only generate DELs. The left Alt key is sometimes called the Meta key, and by default the combinations AltL-X are bound to the symbol MetaX.


1 Answers

As I got from Backspace bad behaviour #321:

I had the same problem (with backspace plus getting addition characters from auto completion) whenever I entered a tmux session. I removed the .tmux.conf and the problem disappeared so I changed the following in my .tmux.conf

changed from: set -g default-terminal "tmux-256color" to: set -g default-terminal "xterm-256color"

This solved the problem. Removing this line altogether also worked but it seemed better to be explicit.

It works for me. Note: after changed the settings, you might need run

tmux kill-server

to make the changes take effect.

like image 199
civic.LiLister Avatar answered Dec 22 '22 03:12

civic.LiLister