delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/03/15/18:31:10

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:content-type:mime-version:subject:from
:in-reply-to:date:content-transfer-encoding:message-id
:references:to; q=dns; s=default; b=xp3Nu0c1AV9MllqRHlQsbeUegI9x
jImryEe939S/yDHwsLdtUqkx3bvcie5nnRh1WARYMg6ZksHsG4x13SS9Q/GiTCO0
3UC/zugL85QofJKTUve0mXnMS8NQc3J08OoiwYxFD+inY+HGmVE//qgINLB4y3VW
1ox+qdKSfr+IZlE=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:content-type:mime-version:subject:from
:in-reply-to:date:content-transfer-encoding:message-id
:references:to; s=default; bh=6vJP9Pd+JC9JWx6t8EJudyxwZCE=; b=oh
szFwb+xr45M9oYayaFgQYnNp2uuqMYR7JRgR/B+fTfeemwhShFzNeesQLXj0arm3
+GvYlH9Baob4OyZe9Q0X6lMtXymuU+O9AuG4sJVOuWkSyCcM4K9A+3eKRGKrvzJr
fWFtf2/rC1A36q09IDCtKoqS+neI8zzH1hhgbj184=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.6 required=5.0 tests=AWL,BAYES_60,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-languages-length:884, ps1_color, n'$ps1_pchar, ps1_pchar
X-HELO: etr-usa.com
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
Subject: Re: Change PS1 when run as administrator
From: Warren Young <wyml AT etr-usa DOT com>
In-Reply-To: <56E87FF2.3080100@towo.net>
Date: Tue, 15 Mar 2016 16:30:53 -0600
Message-Id: <EA14B479-6B66-4A50-A826-9A3BD3EC599B@etr-usa.com>
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>
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id u2FMV6mO030513

On Mar 15, 2016, at 3:34 PM, Thomas Wolff <towo AT towo DOT 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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019