0

I want this Bash prompt:

/\ /\
root@debian$:

I do:

PS1="/\  /\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"

Or:

PS1="/\  /\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"

But I have:

/\  /
root@debian$:
Biffen
  • 6,249
  • 6
  • 28
  • 36
achille
  • 173
  • 1
  • 3
  • 12

1 Answers1

3

PS1 itself does an extra layer of interpretation:

PS1="/\  /\\\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"
          ^^^^ 4 backslashes

Or better yet:

PS1="/\\\\  /\\\\\n${debian_chroot:+($debian_chroot)}\u@\h\$:"

Output I get:

/\  /\
ibug@ubuntu$:

Pro-tip: Use single quotes to save yourself quite some escapes:

PS1='/\\  /\\\n'"${debian_chroot:+($debian_chroot)}"'\u@\h\$:'
    ^          ^^                                  ^^        ^
iBug
  • 35,554
  • 7
  • 89
  • 134