delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/06/16/15:00:48

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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
q=dns; s=default; b=fezGTbEOM/0CRE1936RGNRVhErAfI/Bh9l1wUCUwjeo
OMN+GUlB2WkKXXmDAznhPAPcp+T00aaC1JVvRVgPScUmhDYvbWXqGcfNPb2phWwr
lbLiBnrC8dnJG9qbpKNt3+C+GlxTs+6iJ1l7+TpPEDUAY+Qr0vAhbtpnG7yvyy0o
=
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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
s=default; bh=EoQXUsSrKX1WVQE3gxSd5JDtneY=; b=pjcNHUt+f4W1KUmRl
kf04WYISPJ5BJjeydo+09l1Auya691rRyrg3oaj36ca36ABpEBQv24ap+QRfmPFr
LJO1GmvI5fFQQPSeN/ZJOJDHjxpcZJB8kYmJ+SzuFzcAiHXhVe+0cHbcNB1PBeTB
GSpFgEvfpowYXzkt4tLVvG6rmM=
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=-1.0 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ie0-f169.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=Eu3KRpX344Auk30WMQtZ2l0xSoPMdOC5KQ969NPQZbs=; b=IL1EAJzGtXvHWxebimBoy2YAKuqBbtc+5YnEYntS5Z3z+r42as9GM9KvoX9s8m6IYN j4VkObtQz1lXAsRHLYOGD49Yy2fhSgzYNd2dNazCEHsQIa/L/O0fWkCZZC9kOqCBgwxm i+2aPKgiwUPTAQ0WU4xC6T+CQEH+XmLHvCRwrYQ6H6UoGxhBraGH81Mgo3w+2rRo5x1a TrNKupU75jPcLaVBin53wKx9C+jCdAtgTK/FT3OofS5ZC4vAGTANBjDXXQ48sleL7tCu r0a9pWb3RiDUypVgQfHhbwjIoNsVS6ZBZxAH2pUYH5CQ3Anvm6mpIeOZW/6yOVbCQAm0 xhOw==
X-Gm-Message-State: ALoCoQmTYUO6JgWABJXCCWBUZ7uifxInKoMFexEM9dfg+7jTZeIYtvWGmdM6GWVPa/o86+i9J8Ii
X-Received: by 10.50.43.138 with SMTP id w10mr28157080igl.36.1402945225956; Mon, 16 Jun 2014 12:00:25 -0700 (PDT)
Message-ID: <539F3EC5.6040403@breisch.org>
Date: Mon, 16 Jun 2014 15:00:21 -0400
From: "Chris J. Breisch" <chris DOT ml AT breisch DOT org>
User-Agent: Postbox 3.0.11 (Windows/20140602)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Change PS1 when running as administrator
References: <1402944031 DOT 26368 DOT YahooMailNeo AT web172202 DOT mail DOT ir2 DOT yahoo DOT com>
In-Reply-To: <1402944031.26368.YahooMailNeo@web172202.mail.ir2.yahoo.com>
X-IsSubscribed: yes

GrahamC wrote:
> On Monday, 16 June 2014, 12:25, Frank Fesevur<ffes AT users DOT sourceforge DOT net>  wrote:
>
>> Hi,
>>
>> I recently bought a new home computer, so I switched from XP to Win81.
>> With Win81 every now and then I need to start cygwin as administrator
>> (right click shortcut or tile, run as administrator) to do things that
>> I can't do as a normal user.
>>
>> When I run as administrator I change my PS1 from "$" to "#" with these
>> line in ~/.bashrc.
>>
>> if id -Gn | grep -i Administrators>  /dev/null
>> then
>>      PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n# '
>> else
>>      PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
>> fi
>>
>> I don't know if the test can be done a better/easier way, but it works
>> for me on a Dutch Win81. I tested it with both 1.7.30 and a recent
>> AD/SAM snapshot.
>>
>> If more people like this idea, maybe it could included in /etc/bash.bashrc?
>>
>> Regards,
>> Frank
>
> Personally I use a test like:  if [ -w /etc ] for this, which works provided a write ACL has not been added for ordinary users on the directory \cygwin\etc. Administrators have write access to this directory.
>
> Bash supports regular expressions, so if [[ `id` =~ Administrators ]] is a shorter test equivalent to your example.

You might want to look at this thread: 
https://sourceware.org/ml/cygwin/2014-04/msg00256.html

I use the registry test, but the id method would also work.


-- 
Chris J. Breisch

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