Bash – understand the output of stty -a and change ctrl backspace to just backspace

bashcygwin;stty

I am working in bash shell on a Solaris environment and whenever I type "backspace" it clears out the entire line.

Do you have any suggestions for me to change the backspace clearing entire line to just a character which is the expected behavior of it?

Hhow do I interpret the output of stty -a command in my local cygwin environment:

$ stty -a <br/>
speed 38400 baud; rows 34; columns 125; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = ^Z; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -tostop echoctl echoke

Best Answer

From the wording of your question, I'm assuming that you're using cygwin to access a Solaris machine.

stty -a displays all the current settings for the terminal. I won't go through each one. But you can read up on what each one does on the man pages.

But of particular note to your problem is erase = ^?;. ^? is the ASCII Control Character for DEL (delete). What you want is the control character for BS (backspace).

From the command line you can type the following:

stty erase ^H

But note that the ^H is a control character and not ^H. So I believe the way that you would type this is as follows:

Ctrl+vbackspace

And that should result in ^H being printed to the screen.

That should change the behavior of backspace to what you want. But it would only last for the current session.

According to this Oracle blog, you can permanently change the configuration by opening /kernel/drv/options.conf and looking for the following line:

ttymodes="2502:1805:bd:8a3b:3:1c:7f:15:4:0:0:0:11:13:1a:19:12:f:17:16";

Change the 7f to 8 to permanently remap backspace from DEL to BS. This will require a reboot to take effect.

Related Question