Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am attempting to use a simple shell script on a base Ubuntu 12.04 server install to set prompt colors for users system wide.

I would like to have Puppet place the file color.sh in /etc/profile.d/ -- with permission 744

but the file isn't being sourced by users at all. ~/.bashrc appears to override this.

    if [[ ${EUID} == 0 ]] ; then
        PS1="\\[\\033[01;31m\\]\\h\\[\\033[01;34m\\] \\W \\$\\[\\033[00m\\] "
else
        PS1="\\[\\033[01;32m\\]\\u@\\h\\[\\033[01;34m\\] \\w \\$\\[\\033[00m\\] "
fi

I would prefer not to manipulate ~/.bashrc files with Puppet, but instead have this work globally with profile.d script.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The default Ubuntu ~/.bashrc will overwrite any earlier values of PS1 which is what you're seeing. You could make PS1 read only

declare -r PS1=...

but this will cause the default ~/.bashrc to emit

-bash: PS1: readonly variable

which may not be desirable. You can edit /etc/skel/.bashrc to remove the lines that set PS1 so that new users will not get init scripts that by default try and overwrite your global PS1 definition. That won't stop them from adding their own PS1 definitions but the error message above would clue them in.

share|improve this answer
    
Thank you! I ended up using /etc/skel/.bashrc and put the prompt colors for user and root in there. Works great now. –  sepulworld Mar 20 '13 at 4:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.