This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Change PS1 when run as administrator


On Mar 15, 2016, at 3:34 PM, Thomas Wolff <towo@towo.net> wrote:
> 
> Is there also a universal replacement for
>    elif id | grep -e "gid=.*(Power Users)" > /dev/null
> ?

Give this a try:

PS1_COLOR=32
PS1_PCHAR='$'
for group in $(id -G); do
   test $group -eq 544 && { PS1_PCHAR='#'; PS1_COLOR=31; break; }
   test $group -eq 547 && { PS1_PCHAR='>'; PS1_COLOR=36; break; }
   test $group -eq 0   && { PS1_PCHAR='!'; PS1_COLOR=41; break; }
done
PS1='\[\e]0;\w\a\]\n\[\e['$PS1_COLOR'm\]\u@\h '
PS1=$PS1'\[\e[33m\]\w\[\e[0m\]\n'$PS1_PCHAR' '

I chose the color and prompt character mnemonically from PowerShell.

The color is actually cyan rather than the true blue of PowerShell because blue-on-black is difficult for me to read.  (Chromatic aberration due to glasses.)

This is untested since the Power Users group seems to have disappeared in Windows 10.
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]