I use PuTTY to SSH to my linux server. Today I noticed that when I enter a long command that goes beyond the right hand of the screen, instead of wrapping down to the next line, the text starts at the left of the screen on the same line, writing over the top of the characters. I can't figure out what might have changed to cause this. Can anyone give any pointers at what might cause this, and how to resolve? I have Auto wrap mode initially on ticked in PuTTY.
I haven't made any changes to the PuTTY settings for this server, so at a loss why this stopped working correctly.
After submitting the question, I had better thought it out, and another search on Google gave me this which pretty much explains it:
http://web.archive.org/web/20110102214648/http://drnathan.teamhackaday.com/2009/04/03/fix-your-linux-terminal-line-wrap-issues/
My fancy PS1 string was:
PS1='\e[0;32m[\u\e[m@\h \W]\$ '
but this included non printing characters (the \e parts which change colour of the username). I needed to escape these non printing characters using\[
. The following fixed the issue:This results in output like this:
With the username coloured green.
I had edited my PS1 lines so that normal users had their username in green, but if su'd to root, root would be in red (
\e[0;31m
in case you are interested). I guess since I did that I didn't enter any long commands...