Commandline overwrites itself when the commands get too long

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 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.


I've just solved this myself.

It was just some color escapes in the PS1 command prompt:

LTGREEN="\033[40;1;32m"
LTBLUE="\033[40;1;34m"
CLEAR="\033[0m"
LIGHT_GRAY="\033[40;1;33m"
export PS1="$LTGREEN\u$LTBLUE@\h:$LIGHT_GRAY\w$CLEAR ❯ "

The issue is that the color literals are not enclosed in brackets. Placing escaped brackets around them fixes the issue entirely:

LTGREEN="\[\033[40;1;32m\]"
LTBLUE="\[\033[40;1;34m\]"
CLEAR="\[\033[0m\]"
LIGHT_GRAY="\[\033[40;1;33m\]"
export PS1="$LTGREEN\u$LTBLUE@\h:$LIGHT_GRAY\w$CLEAR ❯ "

Hope this helps.


Try:

eval $(resize)

ََََََََََ