This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Change PS1 when running as administrator
- From: Andrey Repin <anrdaemon at yandex dot ru>
- To: Ernie Rael <err at raelity dot com>, cygwin at cygwin dot com
- Date: Tue, 17 Jun 2014 20:34:19 +0400
- Subject: Re: Change PS1 when running as administrator
- Authentication-results: sourceware.org; auth=none
- References: <1402994703 dot 51470 dot YahooMailNeo at web172206 dot mail dot ir2 dot yahoo dot com> <53A06B0D dot 9050806 at raelity dot com>
- Reply-to: cygwin at cygwin dot com
Greetings, Ernie Rael!
> On 6/17/2014 1:45 AM, GrahamC wrote:
>> If we are looking for other alternatives the GROUPS environment variable can also be used:
>>
>> PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
>> for G in "${GROUPS[@]}"; do
>> if [ "$G" = 544 ]; then
>> PS1='\[\e]0;Administrator \w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n# '
>> fi
>> done
> Speaking of alternatives,
> For matching in bash, something like
> [[ $(id -G) =~ \b544\b ]]
> was suggested (the suggestion used symbolic name instead of a number and
> didn't use word boundary). Seems like word boundary is needed, but I
> couldn't get this to work. Are the regex boundary matchers not
> supported by bash =~ operator?
I don't think bash equivalent of test implements Perl RE.
Neither the base test implementation, to that extent.
> Can use something like
> id -G | grep -q "\b544\b"
> (or echo ${GROUPS[@]} | ...)
--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 17.06.2014, <20:30>
Sorry for my terrible english...
--
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