问题
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?
回答1:
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\] '
来源:https://stackoverflow.com/questions/17306348/long-lines-overlap-in-bash-ps1-prompt