delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/03/15/12:20:24

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:from:content-type:content-transfer-encoding
:subject:message-id:date:to:mime-version; q=dns; s=default; b=So
o8VeYVd7hLK2FlZwk4BdYU8kbFMXsC5JrNC6RFkQ07s5g+s+cNHeXUowA7TOQjs7
jO7m8Foi3PvAWFgj9qXbs16NZR7gDJ+C17z6QEYQQRMofw9nVHVc+oJ9DdpOma5P
AojQwfPWaYd6oWyuJtvr/o1lX0GCnd20O2x8sv+CA=
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:from:content-type:content-transfer-encoding
:subject:message-id:date:to:mime-version; s=default; bh=OZH9bfy9
XMCASMcMiXWjz/dO2nc=; b=xpLD7dKut9ZZ1PiEMyxjNbMK5yxBcnn4GlSiQVx0
sgjaZg2geSoPxaJ9ORLTe/xCYgG49u81M16TK+83coJXUkbAQfAIH1IyHgHN/8Ya
lltululUv3kYUlbiRVLmfvoo3Wm/1Xdg0KY79NM/rFL91HTh5hj+/OfWa46iU35z
rZQ=
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.0 required=5.0 tests=AWL,BAYES_20,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=U*user, administrator, H*r:envelope-sender, you
X-HELO: etr-usa.com
From: Warren Young <wyml AT etr-usa DOT com>
Subject: Change PS1 when run as administrator
Message-Id: <F7CDFE45-BFA7-4599-B510-B40BCA19142F@etr-usa.com>
Date: Tue, 15 Mar 2016 10:20:00 -0600
To: The Cygwin Mailing List <cygwin AT cygwin DOT com>
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id u2FGKKb3023576

I just came up with this recipe to change the default PS1 value to use red for the user AT host part of the prompt and to change the $ character to a #:

    if id | grep -qi 'member of administrators group'
    then
        export PS1=$(echo "$PS1" | sed -e 's_32_31_' -e 's_\\\$_#_')
    fi

I’m not certain the string match on the output of id(1) works everywhere.  Is there a better way to check for admin privileges under Cygwin?  You can’t check for UID or EUID == 0, for example, as you’d do on a true POSIX system.

Perhaps something like this should go into the default /etc/profile?
--
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