Change Command Prompt - Variables are literal, and changes to .bashrc or .bash_profile not making a difference
Trying to change my command prompt in OS X 10.8 / Mountain Lion. Changes to ~/.bashrc and ~/.bash_profile do not make any difference. Like:
export PS1="\W \$"
It defaults to the host name ("\h\%"). Even if I try to set PS1 in the terminal, it changes but displays the variables literally, as below:
ws10% PS1="\W \$"
\W $
(with ws10 being the host name)
My ~/.bashrc file:
export PS1="\W \$ "
Any ideas? I keep getting lost when I cd up and down the directory structure! Thanks a lot.
Solution 1:
Typically on Mac OS X, only .bash_profile
is executing when starting a new terminal. A common solution is to source one file into the other, for example in ~/.bashrc
:
[ -r ~/.bash_profile ] && source ~/.bash_profile
Apart from that, your example works perfectly fine for me when put in .bash_profile. If you still experience problems, maybe you are overlooking something else?
Solution 2:
I copied my .bashrc and .profile from an old mac and was seeing this issue. It came down to the fact that .bashrc was checking for a specific terminal emulation name "xterm-color". In Mountain Lion, xterm-color was renamed to xterm-16color and a new xterm-256color emulator was added:
check to see if your .bashrc has this check:
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
and add the new term names, so it looks like this:
case "$TERM" in
xterm-color) color_prompt=yes;;
xterm-16color) color_prompt=yes;;
xterm-256color) color_prompt=yes;;
esac