1

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?

2

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.

| 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
0

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

| 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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