This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Change PS1 when running as administrator

> Frank Fesevur writes:
>> When I run as administrator I change my PS1 from "$" to "#" with these
>> line in ~/.bashrc.
>> if id -Gn | grep -i Administrators > /dev/null
> If anything I'd check for membership in group 544.  "Administrators"
> surely is one of these strings that gets localized depending on the
> phase of the moon or something.  I can't look right now, but I'm pretty
> sure it says "Administratoren" in a german Windows version.

> On all my Dutch Windows all group names are localized apart from
> 544/Administrators.

># id
>uid=1000(Frank) gid=513(Geen)

>But I agree checking the numeric value is better.

>> If more people like this idea, maybe it could included in /etc/bash.bashrc?
> I'll have to think about it, but I lean toward putting it into profile.d
> instead.

>Thanks for considering.
>The other PS1 setting (user@host dir) is also in bash.bashrc. That's
>why I suggested bash.bashrc.


If we are looking for other alternatives the GROUPS environment variable can also be used:

PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
for G in "${GROUPS[@]}"; do
    if [ "$G" = 544 ]; then
        PS1='\[\e]0;Administrator \w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n# '

Somebody really clever with regular expressions could probably make an equivalent one line test.

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]