How to customize PS1 properly?
There is no issue with the \n
. This is yet again the old escape sequence length problem: \e[0m
and similar do not contribute to the actual length of the prompt, so you have to enclose them in \[
..\]
to indicate this to the interpreter:
PS1="\[\e[0;36m\]\h\[\e[m\] \[\e[0;33m\]\w/\[\e[m\]\n \[\e[0;31m\]\$ →\[\e[m\] "