Question

I have configured a PS1 bash prompt.

My ~/.bashrc file:

if [[ $EUID -ne 0 ]]; then
        PS1='\n\e[0;33m☛ \W\e[0m \n\e[1;35m⤷\e[0m '
fi

The problem is that the new line overlaps the previous one. Any idea how to fix this?

Was it helpful?

Solution

When using non-printing characters in a bash prompt, you have to specify non-printing sequences (e.g. color codes) as non-printing, using \[...\]:

PS1='\n\[\e[0;33m\]☛ \W\[\e[0m\] \n\[\e[1;35m\]⤷\[\e[0m\] '
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top