How to backspace or delete?
Asked Answered
M

3

11

In Windows 10, when I launch MS PowerShell to ssh through a container in Kitematic at windows, I've noticed that I can't backspace or delete, instead I get ^H for backspace instead of actually delete previous character.

Do I miss something?

Mani answered 2/1, 2016 at 12:55 Comment(0)
M
10

The temporary solution is set the tty erase command to whatever your backspace key sends in the terminal, when connected via ssh.

stty erase ^H

The ^H sequence above is not the literal text but a control character entered by pressing ctrl-v and then backspace.

You can add this command to your .bashrc file on the docker VM to have it set automatically each time you connect. When editing the file in a terminal you have to enter the string with the same escape sequence as above.

Doing this in .bashrc will set erase for all logins to the VM so you may negatively impact the way erase works for other terminal types that connect.

You would normally fix this on the client side rather than the server. For example, PuTTY has a specific setting for this. I'm not sure why your powershell/ssh combo doesn't have erase mapped correctly as Docker normally works out of the box. Check what your Docker shortcuts do when launching the docker/ssh terminal and do the same when you launch your terminal to manually connect.

Manville answered 3/1, 2016 at 0:4 Comment(1)
The answer by "krystan honour" is better because it allows proper input into the terminal without all those weird outputs like ^H. See his answer below.Thiel
N
12

The accepted answer works, but I thought I'd point out that if you launch bash rather than stay in sh then it all works so just type bash at the # prompt and you will get the functionality you require.

Northerly answered 12/2, 2016 at 22:43 Comment(2)
this should be the accepted answer since it fixes a number of other interfacing issues.Thiel
this should totally be the accepted answer! worked perfectly!Harvell
M
10

The temporary solution is set the tty erase command to whatever your backspace key sends in the terminal, when connected via ssh.

stty erase ^H

The ^H sequence above is not the literal text but a control character entered by pressing ctrl-v and then backspace.

You can add this command to your .bashrc file on the docker VM to have it set automatically each time you connect. When editing the file in a terminal you have to enter the string with the same escape sequence as above.

Doing this in .bashrc will set erase for all logins to the VM so you may negatively impact the way erase works for other terminal types that connect.

You would normally fix this on the client side rather than the server. For example, PuTTY has a specific setting for this. I'm not sure why your powershell/ssh combo doesn't have erase mapped correctly as Docker normally works out of the box. Check what your Docker shortcuts do when launching the docker/ssh terminal and do the same when you launch your terminal to manually connect.

Manville answered 3/1, 2016 at 0:4 Comment(1)
The answer by "krystan honour" is better because it allows proper input into the terminal without all those weird outputs like ^H. See his answer below.Thiel
C
1

In case someone stumbles on this at this late stage - similar situation - using MS POWERSHELL openSSH implementation. Remoting into AIX / ksh.

Had to set TERM to vt100 (edited .profile) to get vi to work in a way that was not aggravating:

TERM=vt100  
EXPORT TERM

And then added this line to my .profile.

stty erase '^?' echoe

erase '^?' takes the backspace provided by windows ssh.

echoe forces the edit to show up on the screen.

without echoe I would type

$123456[backspace][backspace][backspace][backspace][enter]  

$12 is not recognized as a command

on the entry line - each backspace appended to the line with a little question mark in a box.

Chilly answered 22/10, 2020 at 20:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.