What does bashrc PS1 check [ "$PS1" = "\\s-\\v\\\$ " ] mean?

0

In bashrc file in Fedora/Red Hat I see following line:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

What is the check being done in [ "$PS1" = "\\s-\\v\\\$ " ] and why is PS1 set only if the test succeeds?

Akilan

Posted 2017-08-02T12:19:20.370

Reputation: 528

Answers

1

"\\s-\\v\\\$ " is a default bash unprivileged prompt.

This line:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

change bash prompt only if it is set to default.

Some useful elements for bash prompt:

  • \s - shell name
  • \v - shell version
  • \u - username
  • \h - hostname
  • \t - current time
  • \d - current date
  • \W - current directory

Tomasz Jakub Rup

Posted 2017-08-02T12:19:20.370

Reputation: 598