So I recently decided to change my bash prompt and I have a problem. After pressing up arrow a few times so I don't have to write the command I used like a minute ago the command suddenly breaks the whole prompt and the characters are randomly shattered.
I added this to my bash profile:
export PS1="[\e[32m]\u[\e[m]@[\e[32m]\s[\e[m]-[\e[32m]\W[\e[m] >> "
After pressing the up arrow like two or three times, the characters become totally scrambled like this:
do nano ~/.bash_profile-[]Downloads[] >> source ~/.bash_profile
pwd sudo nano
~/.bash_profile
Guys please help me, it's really annoying. Thanks.
Already answered in comments. Here is the answer:
You need \[...\] around non-printing characters, not [...]. That's why you have a bunch of [] scattered throughout your prompt.
Thanks