Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reattaching to screen daemon makes backspace kill whole line

Tags:

gnu-screen

As part of my startup script to set up my desktop, I initialize a screen with several windows. I do this by starting a daemon and sending it -X screen and -X stuff commands, finally reattaching with -r.

Unfortunately, the "create daemon and reattach" method makes all the windows I created turn backspace into a "kill whole line" action. If I create new windows within screen with C-c c, the new windows do not have this behavior. Is this a screen bug, or can I do something special to fix this behavior? I'm using xfce4 and ubuntu 12.10 if that matters

Repro with the following:

screen -S -dm
screen -r

Type several characters and press backspace.

like image 858
J. Ian Johnson Avatar asked Jan 02 '14 15:01

J. Ian Johnson


1 Answers

I'm not sure if I'm having the exact same problem as you, as your repro steps didn't work for me, but I did have the same bad behavior in screen (backspace killing the whole line), and managed to fix it.

For me, somehow I repeatedly get into a state where the output of stty is this:

$ stty
speed 9600 baud;
lflags: echoe echok echoke echoctl
iflags: -ixany -imaxbel ignpar
oflags: tab3
cflags: cs8 -parenb -hupcl clocal
eol     eol2    erase2  kill    min     
^@      ^@      ^@      ^H      0       

Two things to note here:

  1. There is no erase, only erase2
  2. kill is mapped to ^H

#2 explains my issue, though #1 needs fixing, too. Normally, ^U is "kill line", but here it is ^H instead.

If I type Ctrl-V, <backspace>, my terminal outputs ^H. So due to that mapping above, that causes the kill (kill line) to happen.

This fixed it for me:

$ stty kill ^U
# now, backspace outputs a literal ^H to the screen, so...
$ stty erase ^H

Note that in order to input the ^H and ^U, you have to use the literal control characters. I do this on my terminal with Ctrl-V, <backspace> and Ctrl-V, Ctrl-U, respectively.

I hope it helps!

like image 73
jwd Avatar answered Sep 22 '22 07:09

jwd