【发布时间】:2019-04-18 09:46:46
【问题描述】:
我想要这个 Bash 提示:
/\ /\
root@debian$:
我愿意:
PS1="/\ /\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
或者:
PS1="/\ /\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
但我有:
/\ /
root@debian$:
【问题讨论】:
我想要这个 Bash 提示:
/\ /\
root@debian$:
我愿意:
PS1="/\ /\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
或者:
PS1="/\ /\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
但我有:
/\ /
root@debian$:
【问题讨论】:
PS1 本身做了一层额外的解释:
PS1="/\ /\\\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
^^^^ 4 backslashes
或者更好:
PS1="/\\\\ /\\\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
我得到的输出:
/\ /\
ibug@ubuntu$:
专业提示:使用单引号来节省自己相当多的转义:
PS1='/\\ /\\\n'"${debian_chroot:+($debian_chroot)}"'\u@\h\$:'
^ ^^ ^^ ^
【讨论】: