Re: RFC: root/non-root bash prompts different colours?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Once upon a time, Richard June <rjune@xxxxxxxxxxxxxxxxx> said:
> Wow, that's ugly for both users and root.
> why not set root's foreground to blink?

Because blinking is damn annoying.

If anyone is going to do anything like this, please use tput to get
terminal capabilities before doing it (not everyone uses the same
terminal, not all terminals have color, and not all terminals use the
same escape sequences).

Something like:

colors=`tput colors`
if [ `id -un` = root ]; then
	if ((${colors:-0} > 7)); then
		standout=`tput setaf 5`
	else
		standout=`tput bold`
	fi
else
	if ((${colors:-0} > 7)); then
		standout=`tput setaf 6`
	else
		standout=""
	fi
fi
if [ "$standout" != "" ]; then
	normal=`tput sgr0`
	if ((${colors:-0} > 7)); then
		other=`tput setaf 2`
	else
		other="$normal"
	fi

	if [ "$normal" = "" ]; then
		standout=""
		other=""
	else
		standout="\[$standout\]"
		other="\[$other\]"
		normal="\[$normal\]"
	fi
fi

PS1="${other}[${standout}\u@\h \W${other}]\$${normal} "
unset standout other normal

-- 
Chris Adams <cmadams@xxxxxxxxxx>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux