From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) by sourceware.org (Postfix) with ESMTPS id 5FA6C3858401 for ; Fri, 18 Aug 2023 10:44:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FA6C3858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=towo.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=towo.net Received: from [192.168.178.23] ([92.219.164.66]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N7zJl-1pjqT90FRj-0152tz for ; Fri, 18 Aug 2023 12:44:04 +0200 Message-ID: <8a99139c-45cf-7836-8bd9-ddb15b1e95d0@towo.net> Date: Fri, 18 Aug 2023 12:44:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: Cygwin console: Different default background color when terminal runs as Admin? To: cygwin@cygwin.com References: <37195ea6-c5da-dbbd-55d4-b73cac89589f@t-online.de> From: Thomas Wolff In-Reply-To: <37195ea6-c5da-dbbd-55d4-b73cac89589f@t-online.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:GCRPpPul/NeRmfk+4cANiUklkgbeKUWx8QrEQa5vvTjtQR95Zvn FtsZK1HK2CLy3PA5hgr4sfxh/KjJxzLBniNBme/9gcxHplxhWYaqLFFkMZI530kV0SgCU2G G9azwR6Tqf3Y677OFHuGHsKX9/jF6rCIkBCJeujxoxcYRrLnUf7plCcvzgPxIa8LNnbumgU vyAJeqQjGzx0PX+aEyKtQ== UI-OutboundReport: notjunk:1;M01:P0:McU9Jy+NUgY=;daFqitOWtTN5T0WiyF+EaeBSyhc B5HnvDv/6XBO43K0cPlsAxYxseC/S+LWm2k3+0wlN2EOHEZ3Pc3UNkOJp3RXGKwNjNwlfDeb3 FRL+JRpjF0V2uI9AeRzuXWFIxLZWRWlZ6DkMoKKj/UUQst2SaP8f51sPmYBcQTuLRHcrhwPlH lW8LIHGlROiDn7VVsXCM8Mq8iM7eLDF/9/YaSYwSRIsb11OhG6urMg5YL5+QkfDoT20wZTt92 yfoL/sXs9jx8KqVhSIGbza2MgxUZi0uWzRBtRRh7uWf+3dv8rahmJOZkmpa5sejVx5l7BG4Wt msDU5fKv/TzJ8I1HXNlRpMMFJqMID/24KfyaSi34A2JVDIEH8E1yb9cljfqdgpYfPBvvCUyuz zbcsAesgPbdqa12lWpFINRFMb2/wrbm6CiNKazoPC5swwR5hHYrqqtEgdmo139zumkSPsiMaX q0Q/47jMlnCRhclgha9efNBtWi9RJcDxj4+GXcd1OipBDp4336RPtK3FSLtEFUcUKMx2UCYd/ jTZP2OCSkQGerRxcwZaIzL1iEVSyQfnJgiFoW6N8ZaoGPf8/u8rn8vSZ75tPiq5zosp2z7e2Z hp3M9K1ZsFpvJMsXA0jb/qB4QT+2HQDihVvGNnLxGqsUQYExgHq0fxzjd54MAXOOSZk+y8Mgw yCqZuD6So4Cc/qplgM7p0W3fV7l33a5X5gBTjSNE/LKFfBoG5AXJ7zqtzUzzCPJQNGcIhRZLF j0V5Qo0pFB5e77c5UZfLYT5ujSJWG7BWT60x3jsdRN2e64ZfGR+BrXmtE/VuasOaeoW8Kgvhc RWGfuf/M4q4YDapdIMcgztzI+IevHM4RHkhetsJJbyF7Via8HDqXGx34Mpw4ONN2Lkdo32CXN AFaULTjA1VlKYNg== X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,BODY_8BITS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Am 18.08.2023 um 10:11 schrieb Christian Franke via Cygwin: > Jonathon Merz via Cygwin wrote: >> On Thu, Aug 17, 2023 at 7:13 PM Martin Wege via Cygwin >> >> wrote: >> >>> Just an idea: Could the default background color of the Cygwin console >>> be changed from black to grey (or RED) if the terminal has been >>> started with Administrator rights? >>> >> Assuming that: >> 1. The Administrators group is called "Administrators" >> 2. There aren't any non-administrative groups with "Administrators" >> in the >> name >> 3. You're using mintty for your terminal >> >> You can run the following in bash or zsh with the desired RGB values: >> >> if [[ `id -Gn` == *Administrators* ]] >> then >>      echo -ne "\e]11;#FFBBEE\a"; >> fi > > A alternative that should work with any shell, does not rely on > (unfortunately localized) group names and only assumes that the > Administrators group S-1-5-32-544 isn't remapped by /etc/group: > > case " $(/usr/bin/id -G) " in >   *\ 544\ *) printf '\e]11;#FFFF80\a' ;; > esac or like this case " `id -G` " in *" 544 "*|*" 0 "*)    echo admin;; esac Note the embedding spaces in the case expression. I'm adding the 0 for a profile portable with Linux. You could also use     if id -G | grep -qE '\<(544|0)\>' at the cost of an additional process creation. In earlier Windows versions, you could also check for group 547 which was some kind of half-admin user. Thomas > > Or use a check of actual access rights: > > if [ -r /proc/registry/HKEY_LOCAL_MACHINE/SAM/SAM ]; then ...; fi > > > I use this in .bashrc to add "(root)" to the default mintty title and > set '#' as root prompt: > > case " $(/usr/bin/id -G) " in >   *\ 544\ *) PS1=${PS1/\\e]0;\\w/\\e]0;\\w (root)}; PS1=${PS1/\\\$ /\# > } ;; > esac >