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.

We frequently sg to switch to a "shared" effective group. I want a visible reminder that we are not using our default group. Was thinking of having the bash prompt change color or display the effective group.

Any ideas how I should do this?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Add id -gn to PS1: E.g: export PS1='[\u@\h $(id -gn) \W]\$ ' can be placed in a bash profile file /etc/profile.d/set_prompt.sh.

share|improve this answer
1  
Will it work after issuing sg? I don't think so. –  mailq Dec 9 '11 at 22:01
    
It does. I tested my answer. You need to put it in a bash profile as sg starts a new shell. –  Mark Wagner Dec 10 '11 at 0:36
    
Then it's cool stuff. –  mailq Dec 10 '11 at 0:39

Blatantly copying embobo's answer, you need to set up your $PROMPT_COMMAND bash variable, such as :

fran@orion ~ # export PROMPT_COMMAND='export PS1="[\u@\h $(id -gn) \W]\$ "'

fran@orion (20111209231004) ~ # 
fran@orion (20111209231005) ~ # 
fran@orion (20111209231006) ~ # 

HTH

share|improve this answer
    
You don't need to use $PROMPT_COMMAND as sg will start a new shell . –  Mark Wagner Dec 10 '11 at 0:41

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.