Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经配置了PS1 bash 提示符。
我的~/.bashrc文件:
~/.bashrc
if [[ $EUID -ne 0 ]]; then PS1='\n\e[0;33m☛ \W\e[0m \n\e[1;35m⤷\e[0m ' fi
问题是新行与前一行重叠。知道如何解决这个问题吗?
在 bash 提示符中使用非打印字符时,您必须将非打印序列(例如颜色代码)指定为非打印,使用\[...\]:
\[...\]
PS1='\n\[\e[0;33m\]☛ \W\[\e[0m\] \n\[\e[1;35m\]⤷\[\e[0m\] '