Customizing the shell prompt causes some quirks

bashcommand lineterminal

I have customized the shell prompt with the following code in my ~/.bash_profile, but there is one quirk left I can't seem to fix:

export PS1="\u:\[\e[32;1;32m\W\e[m\] \$ "

(code is also on github)

This works well, including for long commands. But if I page through the command history with the arrow keys, the prompt will sometimes get a bit "weird". Sometimes it will include a partial command in the prompt or other times the space after the $ will be disappear. Is there something missing from the code above that I should tweak?

Thanks!

Best Answer

You didn't close the brackets for the first escape, and add the escape for the second

export PS1="\u:\[\e[32;1;32m\]\W\[\e[m\] \$ "
#---------------------------^^--^^