Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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:

PS1='[\[\e[0;32m\]\u\[\e[m\]@\h \W]\$ '

This results in output like this:

[username@hostname cwd]$

With the username coloured green.

I had edited my PS1 lines so that normal users had their username in red, 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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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