I know this is weird but out of the blue, today I copied a long command into the terminal and instead of word wrapping as its supposed to, it started overwriting the same line. The command executed just fine, but it became unreadable. Typically when something like this happens, you can just press Enter a few times and it fixes, but not in this case. I restarted terminal and even rebooted and its the same story.

I might think it has something to do with the fact that I edited my /etc/bash.bashrc file to customize the prompt with color, etc. but I did that several days ago and this didn't happen after I edited it. I saved a backup just in case so if anyone thinks it might be that, I've included the output of the diff of the two files:

$ diff /etc/bash.bashrc /etc/bash.bashrc.bak 
< PS1='\e[1;32m\u: \e[m\w\n\e[1;33m\$\e[m '
> PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

Any ideas are helpful, this is a really strange problem.


Try using this PS1:

PS1='\[\e[1;32m\]\u: \[\e[m\]\w\n\[\e[1;33m\]\$\[\e[m\] '

The difference is that the escape sequences (\e..) are wrapped in \[ .. \], which helps Bash keep track of the cursor better.

| improve this answer | |
  • I have been dealing with this for months, THANK YOU – sunshinekitty May 25 '14 at 9:39

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.