Font colors in bash

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Alexander
Date:  
Subject: Font colors in bash
Here's my bash prompt:

COLOR1="\033[1;35m"
COLOR2="\033[1;36m"
COLOR3="\033[1;32m"
COLOR4="\033[0m"
PS1="[$COLOR2\u$COLOR4@$COLOR1\h $COLOR3\w$COLOR4]\$ "

If you want to output a color in a shell script, just use echo -e
For example,

echo -e "\033[1;36mHello World\033[0m"

Or in Perl:

perl -e 'print "\033[1;35mHello World\033[0m\n"'

If you have a "friend" that you'd like to torment, set their PS1 in
.bash_profile and .bashrc to:

PS1="\033[01;05;37;41m\$ "

~M


On Thu, 29 Jan 2004, Nathan England wrote:

> <dummymode>
> I am playing with the color schemes that knoppix uses when outputing
> message while booting.
>
> CRE="^M^[[K"
> NORMAL="^[[0;39m"    #Normal Color
> RED="^[[1;31m"        #Failure
> GREEN="^[[1;32m"    #Success
> YELLOW="^[[1,33m"    #Unused
> BLUE="^[[1;34m"        #System Messages
> MAGENTA="^[[1;35m"    #Description
> CYAN="^[[1;36m"        #Unused
> WHITE="^[[1;37m"    #Unused

>
> But I'm failing somewhere.
> I tried
> echo "${BLUE}Hello there.${NORMAL}"
>
> But, it doesn't work.
> it comes back
> echo "^[[1;31mHello there.^[[0;39m
>
> How do I make this work? Obviously I've never used ansi colors before.
>
> Thanks for any input.
>
> </dummymode>
>
>