Greetings, Warren Young!
> I just came up with this recipe to change the default PS1 value to use red
> for the user@host part of the prompt and to change the $ character to a #:
> if id | grep -qi 'member of administrators group'
> then
> export PS1=$(echo "$PS1" | sed -e 's_32_31_' -e 's_\\\$_#_')
> fi
> I’m not certain the string match on the output of id(1) works everywhere.
> Is there a better way to check for admin privileges under Cygwin? You can’t
> check for UID or EUID == 0, for example, as you’d do on a true POSIX system.
> Perhaps something like this should go into the default /etc/profile?
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
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*|putty*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
--
With best regards,
Andrey Repin
Tuesday, March 15, 2016 20:23:26
Sorry for my terrible english...