I want my prompt to display:
a) current (absolute) working directory, colored in green and
b) in a NEW line, the dollar sign and an empty space.
I am using this line in
export PS1='\e[0;32m$(pwd)\n\e[m$ '
However, sometimes when hitting the up arrow to re-run previous commands, at the start of the prompt a random char sequence appear that does not seem to go away unless I hit enter
I have never hit a
cd cd Desktop command
The weirdest part is that backspace won't even delete the first one of the two
cd commands above!
You must make sure the non-printing characters in the prompt are in escaped square brackets, otherwise bash cannot calculate the size of the prompt correctly. I think I have fixed it for you: