Date: Mon, 02 Feb 2004 10:05:31 -0500 From: Chris Riley <criley@lumeta.com> To: Nathan Kinkade <nkinkade@ub.edu.bz> Cc: freebsd-questions@freebsd.org Subject: Re: customize set prompt question Message-ID: <401E673B.6030201@lumeta.com> In-Reply-To: <20040202144617.GL3937@npkfbsd> References: <0HSG002S0E0D8R@mail.etat.lu> <20040202144617.GL3937@npkfbsd>
next in thread | previous in thread | raw e-mail | index | archive | help
FWIW this is what I use in my .bashrc. The contol codes are for an ANSI
terminal, the shell doesn't care what to use. The \[ and \] are bash
specific, you'll want to remove them for csh.
BLACK="\[\e[0;30m\]"
BLUE="\[\e[0;34m\]"
GREEN="\[\e[0;32m\]"
CYAN="\[\e[0;36m\]"
RED="\[\e[0;31m\]"
PURPLE="\[\e[0;35m\]"
BROWN="\[\e[0;33m\]"
LIGHT_GRAY="\[\e[0;37m\]"
DARK_GRAY="\[\e[1;30m\]"
LIGHT_BLUE="\[\e[1;34m\]"
LIGHT_GREEN="\[\e[1;32m\]"
LIGHT_CYAN="\[\e[1;36m\]"
LIGHT_RED="\[\e[1;31m\]"
LIGHT_PURPLE="\[\e[1;35m\]"
YELLOW="\[\e[1;33m\]"
WHITE="\[\e[1;37m\]"
NO_COLOR="\[\e[0m\]"
who am i | grep '^root' > /dev/null
if [ $? = 0 ] ;then
COLOR=$RED
else
COLOR=$LIGHT_GREEN
fi
export PS1="$COLOR\u$NO_COLOR:$YELLOW\w$NO_COLOR\$ "
Nathan Kinkade wrote:
> On Mon, Feb 02, 2004 at 11:48:13AM +0100, Didier WIROTH wrote:
>
>>Hi,
>>
>>I would like to colorize this prompt:
>>set prompt="@%m:%~# "
>>
>>How do I have to modify the prompt so that the entire prompt is of "red"
>>color.
>>Only the prompt should be red, not what is typed or the results of any
>>output.
>>
>>many thanks
>
>
> Does csh understand ansi escape sequences? If so you could try this:
>
> $ set prompt="\[\e[1;31m\]@%m:%~# \[\e[m\]"
>
> I don't know if this will work in csh, but it definitely works in bash.
> For bash it would be:
>
> $ export PS1="\[\e[1;31m\]@%m:%~# \[\e[m\]"
>
> Nathan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?401E673B.6030201>
