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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.