This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Change PS1 when run as administrator
- From: Warren Young <wyml at etr-usa dot com>
- To: The Cygwin Mailing List <cygwin at cygwin dot com>
- Date: Tue, 15 Mar 2016 16:30:53 -0600
- Subject: Re: Change PS1 when run as administrator
- Authentication-results: sourceware.org; auth=none
- References: <F7CDFE45-BFA7-4599-B510-B40BCA19142F at etr-usa dot com> <98egebtkn3kakah2g5m9nhr393mag7qm8j at 4ax dot com> <20160315170819 dot GA11488 at calimero dot vinschen dot de> <56E87FF2 dot 3080100 at towo dot net>
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