PS1 不回显反斜杠
PS1 does not echo backslash
我想要这个 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$:'
^ ^^ ^^ ^
我想要这个 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$:'
^ ^^ ^^ ^