Bash – Colorize Bash Console Color

bashcentoscolorslinux

I need to be able to set my CentOS 6.4 bash prompt color to yellow.

I've managed to find where to set this (.bashrc) and the ANSI color for yellow (\e[0;33m).

I've setup my prompt as follows:
PS1="[\033[33m][\u@\h \W]$ [$Color_Off]"

This all works fine when I ssh into our a system BUT when I use the local console it comes out as BROWN.

How can I modify bashrc so that its yellow regardless of weather I use SSH or the local console?

Please don't suggest I use a different color – for various reasons it would be a significant amount of effort to use a different color.

See the following for what I mean:

colors in putty

local colors

http://picpaste.com/putty_coloring-9clungcS.jpg

http://picpaste.com/local_console_color-hApaEX8U.jpg

Best Answer

Here /sys/module/vt/parameters are three files:

default_blu
default_grn
default_red

Yellow is green and red. If you want to "boost" the normal color yellow (which you may have as brown), change the color with index three (the fourth slot) - set it to 255 in the green and red files.

Then, echo -n '\033]R'; tput setaf 3; echo hi and you should get yellow.

For me, it seems this is already the color for bright yellow, in which case you'd use: tput bold; tput setaf 3; echo hi.

If you need to setup the prompt differently in the console and in X, in your .rc file, before you set PS1, find out if you are in the console or in X. Set the color accordingly.