按向上箭头并更改 bash 提示后文本破碎

Text shatters after pressing up arrow and changing bash prompt

所以我最近决定更改 bash 提示,但我遇到了问题。按了几次向上箭头,这样我就不用写我一分钟前使用的命令了,命令突然打断了整个提示符,字符随机破碎。

我将此添加到我的 bash 个人资料中:

export PS1="[\e[32m]\u[\e[m]@[\e[32m]\s[\e[m]-[\e[32m]\W[\e[m] >> "

按两三下向上箭头后,字符完全乱成这样:

do nano ~/.bash_profile-[]Downloads[] >> source ~/.bash_profile  
pwd                                                      sudo nano 
~/.bash_profile

各位帮帮我,真烦人。谢谢

已在评论中回答。这是答案:

You need \[...\] around non-printing characters, not [...]. That's why you have a bunch of [] scattered throughout your prompt.

谢谢