This is the mail archive of the
mailing list for the Cygwin project.
Re: Change PS1 when running as administrator
- From: "Chris J. Breisch" <chris dot ml at breisch dot org>
- To: cygwin at cygwin dot com
- Date: Mon, 16 Jun 2014 15:00:21 -0400
- Subject: Re: Change PS1 when running as administrator
- Authentication-results: sourceware.org; auth=none
- References: <1402944031 dot 26368 dot YahooMailNeo at web172202 dot mail dot ir2 dot yahoo dot com>
On Monday, 16 June 2014, 12:25, Frank Fesevur<email@example.com> wrote:
I recently bought a new home computer, so I switched from XP to Win81.
With Win81 every now and then I need to start cygwin as administrator
(right click shortcut or tile, run as administrator) to do things that
I can't do as a normal user.
When I run as administrator I change my PS1 from "$" to "#" with these
line in ~/.bashrc.
if id -Gn | grep -i Administrators> /dev/null
PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n# '
PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
I don't know if the test can be done a better/easier way, but it works
for me on a Dutch Win81. I tested it with both 1.7.30 and a recent
If more people like this idea, maybe it could included in /etc/bash.bashrc?
Personally I use a test like: if [ -w /etc ] for this, which works provided a write ACL has not been added for ordinary users on the directory \cygwin\etc. Administrators have write access to this directory.
Bash supports regular expressions, so if [[ `id` =~ Administrators ]] is a shorter test equivalent to your example.
You might want to look at this thread:
I use the registry test, but the id method would also work.
Chris J. Breisch
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple