I am trying to change the prompt value for all users of a system (the $PS1 variable) to the same value.
I have the following stored in file /etc/ps1:
PS1='`
if [ $? -eq 0 ];
then echo -n "\[\033[00;35m\]\u\[\033[01;32m\]@\[\033[00;35m\]\h\[\033[00;32m\](\[\033[01;35m\]\W\[\033[01;32m\])\[\033[00;32m\]\$";
else echo -n "\[\033[00;35m\]\u\[\033[01;31m\]@\[\033[00;35m\]\h\[\033[01;31m\](\[\033[35m\]\W\[\033[31m\])\[\033[00;31m\]\$";
fi`\[\033[0m\]'
Under my single user account I can add source /etc/ps1
to my ~/.profile file it works (interestingly it didn't work when I added that to ~/.bashrc). If I add this to /etc/profile or /etc/bashrc.basrch to make this happen for all users, nothing happens. I'm puling my hair out trying to get this to work. This is on Debian 7.1.0 (Linux 3.2.46).
Best Answer
Add your modified PS1 setting to
/etc/profile.d/custom_ps1.sh
. Files under/etc/profile.d
are automatically sourced from/etc/profile
:Which is called whenever a login shell is spawned. From the
bash
manpage: