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?

link|improve this question

feedback

2 Answers

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.

link|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
feedback

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

link|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
feedback

Your Answer

 
or
required, but never shown

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