I have this in .bashrc;
PS1='$'
However, I see this still in terminal:
mas-macbook:some/path mas$
I want
$
I have this in .bashrc;
PS1='$'
However, I see this still in terminal:
mas-macbook:some/path mas$
I want
$
You may have to escape the $ symbol. This works in my system... PS1="\$"
If that don't work, please run the command 'echo $PS1' and let us know the results. You may also have to send the .bashrc file - it possible that you have set the PS1 variable before including the global /etc/bashrc file. If that's the case, the global file will overwrite the variable. You will have to set the PS1 variable after including the /etc/bashrc file.
PS1
should already have been exported long before you get to your .bashrc
file, at least for a login shell. In that case, setting PS1
should simply overwrite the value (not its export status).
One thing to keep in mind is that bash itself does not run your .bashrc
file for a login shell. The actual sequence of execution is:
/etc/profile
, if there.~/.bash_profile
, ~/.bash_login
or ~/.profile
.I'm fairly certain that, if you want .bashrc
to run for a login shell, it has to be sourced from one of those above.
For example, /etc/profile
may call /etc/profile.local
or all the scripts in the /etc/profile.d/
directory. Similarly, my .bash_profile
calls the following, if they exist:
with the following snippet:
if [ -e /etc/bash.bashrc ] ; then
source /etc/bash.bashrc
fi
if [ -e "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
fi
When I change PS1
and echo "hello
" in my .bashrc
, but comment out the sourcing of it in .bash_profile
, the prompt doesn't get changed (nor the string printed) when I log in. When I uncomment the sourcing, I get both the string printed and the prompt changed when I log in.
To make sure that your .bashrc
is called for your login shells, put that echo hello
statement just after setting PS1
, then log in to check.
If it is being called when you log in, you can execute "export -p
" from your shell to get a list of all the exported variables - make sure PS1 has a "declare -x
" in front of it. If not, just change your .bashrc
to export it as well:
export PS1='$'
If it's already exported, then something is changing it after your set
statement. In that case, you'll need to actually look at the login execution path to see what's getting called before it gives you control.