Commandline overwrites itself when the commands get too long

Viewed 32392

I'm using PuTTY to log into a Debian server. I have this odd problem that when a command I'm typing gets too long, it doesn't wraparound and start a new line. Instead, it starts at the beginning of the same line and starts to overwrite the prompt and then the beginning of the command.

The command will run just fine, but it is really annoying, I'm assuming there is some setting that would fix this for me?

8 Answers

I've seen this behavior when you resize the Putty window while another command is running since bash doesn't get the signal telling it the window has resized.

If this is the problem adding:

shopt -s checkwinsize

should make it go away.

Try:

eval $(resize)

ََََََََََ

Try pressing Ctrl + L. (Or maybe Alt + L - something + L anyway.) If I remember rightly this reruns the code to figure out your terminal size and adjusts accordingly.

This one helps me to resolve this after searching lot of places.

PS1='\[\e[0;31m\]\t\[\e[m\]-\[\e[0;32m\]\u\[\e[m\]@\[\e[0;36m\]\h\[\e[m\]:\[\e[0;23m\]\w\[\e[m\e[0;32m\]\$\[\e[m\]'

Enclosing enclosing each of the colour escape sequences in escaped square brackets.

Nothing to do with putty its a "bash"ism.

Its quite useful once you are used to it, but, if it bothers you you can switch to "ksh" which does something different with long command lines (not sure what on Debian!)

Related