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=Bldh24UHIiOCb3lcPStKArlVJKYg cV2tlaUyWmNQCdDf1qkNq+NsR3dgvF2aCR6S9ArDIGEsj2HQZGuQAx7ey1+Gi1z3 32iwmV16Lsi51tGLlFQlNk2OLmo76pL66+h/t0djg5GyVSYKonUVWwqRgWbKNGgC FQ2A9TLGSipfj9I= 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=zyz6yve9TKY4CgxNKUuwkXAwNWs=; b=tE oaXF76l94udkK+SjEkelNrJFz9hgp1Gp92wTcQ7MVbxRsex1tZMa5FuQz3SKO4rr Ayd2TLJqzHU6J0mD9lDKvINcicU46KJriblgNv8VjwkVIIcSKVtEJsZOtp5aYsgU iLjlFzAlF1cVNzbweXjuPqBHR4ko8+5T4uCNEP80Q= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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.7 required=5.0 tests=AWL,BAYES_60,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=GID, anrdaemon AT yandex DOT ru, anrdaemonyandexru, sk:anrdaem X-HELO: etr-usa.com Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: Change PS1 when run as administrator From: Warren Young In-Reply-To: <28210846.20160315202354@yandex.ru> Date: Tue, 15 Mar 2016 13:45:33 -0600 Message-Id: References: <28210846 DOT 20160315202354 AT yandex DOT ru> To: cygwin AT cygwin DOT com X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id u2FJjluN012103 On Mar 15, 2016, at 11:23 AM, Andrey Repin wrote: > > PS1_TAIL="$( > x="$" > for group in $(id -G); do > { > test $group -eq 114 && { x="#"; break; } > test $group -eq 544 && { x="#"; break; } > test $group -eq 0 && { x="Please remove well-known SID overrides from your /etc/group file#"; break; } > } > done > echo $x > )" > if [ "$color_prompt" = yes ]; then > PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\007\]\n$PS1_TAIL ' > else > PS1='\u@\h:\w\007\n$PS1_TAIL ' > fi > unset color_prompt force_color_prompt Here’s a simpler version that’s closer to the stock version in color and style, with the quoting errors fixed: PS1_COLOR=32 PS1_PCHAR='$' for group in $(id -G); do test $group -eq 114 && { PS1_PCHAR='#'; PS1_COLOR=31; break; } test $group -eq 544 && { PS1_PCHAR='#'; PS1_COLOR=31; 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’ve split the last line to avoid wrapping. I’ve gone with the “check engine light” approach to error reporting for the GID=0 case. If someone wants to apply this to Cygwin’s stock /etc files, it needs to go in /etc/bash.bashrc in Cygwin, not /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