Talkback for article: 335, May2004

Colorful shells -- Using ANSI color codes

Back to:

From: Alain Gauthier <algaurythme(at)> [ date: 2004-05-08 ]
Excellent, very interesting article and I am going to use some hints from it, sure I will, Merci
From: iczhie [ date: 2004-05-18 ]
Nice article :)
From: Guncha Ashaiz <cmz(at)> [ date: 2004-05-18 ]
This article is good one, I found out some new things :)
There is just this one little problem: bash somehow calculates, where to break command line to next line, and counts in ALL the characters, not just the visible ones. So when using this technique, bash will screw up the display, if a long command line is entered.

Any ideas how to prevent it?
From: Nico Golde <nico(at)> [ date: 2004-05-18 ]
Guncha you are right, but for this problem there are the \[ \] tags in the lines.
regards nico
From: ecks <njvsny(at)> [ date: 2004-06-01 ]
Very informational. I was looking for a good tutorial on ANSI coloring for a long time. Thank you. A very small error, I discovered though. In your first example, you forgot to close off the tag to make it the default shell color when writing. Thought I'll point it out. Regards.
From: Cadu <cadusk(at)> [ date: 2004-07-04 ]
Nico, i've read your article and noticed that at your last example (the cron startup script) we should use "echo -e" instead of "echo" in order to get scaped commands interpreted correctly.
regards Cadu
From: Nico Golde <nico(at)> [ date: 2004-07-10 ]
Hi Cadu,
i use "echo" instead of echo -e and it works correct.
From: Egon <egon.w(at)> [ date: 2004-08-01 ]
I noted a small error in the text. When the second PS1 is discussed, the result lacks the hostname... \u@\h gives something like "johndoe@linux10".
From: Henry [ date: 2004-08-14 ]
Hi, there is a project that lets we easily access all text formats and colors on terminals, take a look at .
From: Compass [ date: 2004-09-07 ]
Here is mine:

[0m\] '


From: senate [ date: 2005-01-06 ]
here is mine. very nice I think :)

PS1="\n\[\033[0;30m\]\[\033[1;30m\](\[\033[0;37m\]\u\[\033[1;37m\]@\[\033[0;37m\]\h\[\033[1;30m\])\[\033[0;30m\]-\[\033[1;30m\](\[\033[0;37m\]$OSTYPE\[\033[1;30m\])\[\033[0;30m\]-\[\033[1;30m\](\[\033[0;37m\]\t \d\[\033[1;30m\])\[\033[0;30m\]->
\[\033[0;30m\]\[\033[1;30m\](\[\033[1;37m\]\w/\[\033[1;30m\])\[\033[0;30m\]->\[\033[1;37m\] "

obs. 2 rows
From: Vishal [ date: 2005-01-22 ]
A superb artical to set foreground color of console.Although I was not able to change complete background color but even then It really solved my purpose.really a good to the point text.

From: antares [ date: 2005-04-18 ]
that works only after you log in. i want to change the default setting from gray to white - the bootprocess output should be white as well.
So how can I get it?
From: Newton [ date: 2005-08-16 ]
ANSWER To Prevent bash from miscalculation of line-length, You just habve to escape the sequence of non-printable characters with \[ and \] before and afterwards.
From: mashihoor rahman <mashihoor(at)> [ date: 2005-09-08 ]
this is quite helpfull for me.
and I will be gerring it
From: alltux <alltux<at>> [ date: 2006-04-04 ]
Yes thank you very much indeed for this really helpful article.I pointed my teenage son to your explanations and he read and appreciated the way you did it.Also he gives you far more "authority" on the subject as you are in the same generation (I suppose) as he.!!We had some fun also making humorous prompts etc for ourselves and family and friends.Many thanks again from two New Zealand BASH-lovers.
From: Wuhaa [ date: 2006-07-24 ]

Thats Nice!

Is it possible to do the color change in a php shell script? If so, how?

17 talkbacks

Due to the increased amount of web spam we have deciced to removed the talkback posting possibility. You can read old talkbacks but you can no longer post new ones.

Back to

Please contact webmaster(at) if you have any questions with regards to this talkback

lftalkback version 3.10