I can change the bash command prompt for the Terminal for an ordinary user without issue. (In my case, I modified the $PS1 variable in /etc/bashrc.) However, that change does not modify the command prompt when one elevates privileges to root using sudo -s
.
Does anyone know where the command prompt preference is stored on a macOS Sierra (10.12.5) machine for an admin user who has elevated his privileges to root using sudo -s
?
I have tried modifying the following files…
- /var/root/.bash_profile
- /var/root/.bash_rc
- /var/root/bash_rc
- /var/root/.profile
- ~/.profile
I have also tried using the command export PS1="Some prompt here# "
, which changes the root prompt temporarily, but it does not stick when the session is ended and a new one is started.
Best Answer
From the
sudo
manual:An interactive shell would read the invoking user's
.bashrc
. So, Tony Williams' solution would work if it is in your.bashrc
. But da4's solution should also work if it is placed in your.bash_profile
.