0

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

1 Answer 1

3

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.

1
  • I have been dealing with this for months, THANK YOU May 25, 2014 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .