From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout04.t-online.de (mailout04.t-online.de [194.25.134.18]) by sourceware.org (Postfix) with ESMTPS id D21A5385B512 for ; Fri, 18 Aug 2023 08:11:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D21A5385B512 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=t-online.de Received: from fwd87.aul.t-online.de (fwd87.aul.t-online.de [10.223.144.113]) by mailout04.t-online.de (Postfix) with SMTP id CC24A943C for ; Fri, 18 Aug 2023 10:11:50 +0200 (CEST) Received: from [192.168.2.101] ([79.230.164.114]) by fwd87.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qWuaA-0KmZBA0; Fri, 18 Aug 2023 10:11:46 +0200 Subject: Re: Cygwin console: Different default background color when terminal runs as Admin? To: cygwin References: From: Christian Franke Message-ID: <37195ea6-c5da-dbbd-55d4-b73cac89589f@t-online.de> Date: Fri, 18 Aug 2023 10:11:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.16 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TOI-EXPURGATEID: 150726::1692346306-F4FE1704-A43514F2/0/0 CLEAN NORMAL X-TOI-MSGID: f0668a7c-3c35-4cd1-9572-55ccd0a91989 X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: 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 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 -- Regards Christian