I have MacOS and
export PS1="\[\e[0;31m$\]\[\e[m\] \[\e[0;32m\w\e[m\] : \]"
as a result I have pwd printed in terminal like this:
but when I press up and down arrows to use terminal history I have bug:
looks like you don't have the escaping brackets quite right. They are there to surround non-printing sequences, so bash can accurately figure how wide your prompt is. Try this:
PS1="\[\e[0;31m\]\$ \[\e[0;32m\]\w\[\e[0m\] : " # 1.........1 2.........2 3......3
So the printing bits (
\w, the colon and the spaces) are outside the brackets.
Further reference: https://www.gnu.org/software/bash/manual/bashref.html#Controlling-the-Prompt