7

I've altered the /etc/bashrc file.

I commented out the previous definition and inserted my own:

PS1="--bash: (\u@\h:\w) $"

This is not having any affect. When I make this change at the command prompt, it works great, but then it's not permanent.

1 Answer 1

9

/etc/bashrc is the system setting. The usual place to change the prompt would be the per-user file, ~/.bashrc. You might already have a setting there that's overwriting the system default. Put your prompt string in ~/.bashrc.

Furthermore, there is a quirk in bash's handling of initialization files. The /etc/bashrc and ~/.bashrc files are only read for interactive instances of bash that are not login shell. If you run a login shell, bash only reads /etc/profile, and ~/.bash_profile (or ~/.profile if it doesn't exist). You need to explicitly source your .bashrc from your .bash_profile if the login shell is interactive:

# Work around a well-known bash design bug: bash does not read .bashrc if
# it is invoked as a login shell.
case "$-" in *i*) if test -r ~/.bashrc; then . ~/.bashrc; fi;; esac
2
  • This can go as a comment in your question, or in this answer. As such, I'm posting in the correct answer that needs more info. If you're looking at customizing your prompt after following Giles Answer, see Gentoo: Prompt Magic Commented Nov 22, 2014 at 1:30
  • @eyeoung100 - This link is no longer valid Commented Jan 4, 2022 at 16:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.