0

I am frequently running into an issue where the text on my screen is out of sync with the cursor.

As you can see here, and here, when I hit backspace, it thinks that it is the (left) end of the line, but if I Ctrl+C, it will go back to the normal and treat the close bracket as the end of the line. This can happen when pasting things, when hitting the up arrow to go to previous commands, Ctrl+r, etc.

In addition to this sometimes it goes as far as where the command that I'm typing is like a full 10 characters off, say, if it hit the up arrow to go through the history, and try to edit it inline. The text it displays on the screen is different from where my cursor is or where I'm inserting the characters.

I've tried changing some character encodings, report terminal type and some other various things, but have not been able to correct it.

Does anybody have any idea what I can even attempt to change?

0

I would first check your terminal emulation settings. I don't have a mac handy at the moment, but try echo $TERM and see what it is. Typically, for ssh, I've used vt100 or xterm or sometimes ansi. You may want to try a different terminal application all together, it it exists.

You can set this (per bash/sh session) using export TERM=vt100 and then try your ssh connection again.

Another thing that may cause the issue is simply clearing the terminal. In Linux, this can be done using clear or CTRL+L (macs are likely different). This will clear all the scrollback, sometimes fixing the cursor issue.

Another command (on Linux, again maybe a mac equiv) that sometimes fixes this is the reset command. This resets various settings on the terminal, not sure which.

On older Solaris 7 boxes, I used to have to use control characters to reset the terminal. Not sure this works on mac, but you can give it a shot: echo ^[c. This is achieved by hitting CTRL+V at the same time, then let up CTRL+V and press the ESC key once (to get the carat). and then just the letter C. Hit enter and it will reset the terminal.

If none of those seem to change anything, I would check the server side sshd configuration for something odd. Usually this isn't the case. From there, I would check for a flaky connection, cable, switch or NIC. I've had crummy layer 1 stuff mess with the ssh session before when it wasn't otherwise apparent that something was wrong.

PS: an "easier" CTRL+V ESC C is here (echo -e '\033c'): https://unix.stackexchange.com/questions/79684/fix-terminal-after-displaying-a-binary-file

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.