4

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

Runium
  • 28,811
Brad
  • 203

3 Answers3

3

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.

Emanuel Berg
  • 6,903
  • 8
  • 44
  • 65
  • In /sys/module/vt/parameters/default_red I have: 0,170,0,170,0,170,0,170,85,255,85,255,85,255,85,255 In /sys/module/vt/parameters/default_grn I have: 0,0,170,85,0,0,170,170,85,85,255,255,85,85,255,255 I'm not exactly sure what I need to change - what do you mean by index three/fourth slot? – Brad Apr 30 '13 at 12:14
  • By the way I ran the commands you suggested above. The text is still orange/brown. See the following screenshot: http://picpaste.com/4-30-2013_8-23-37_AM-ODRQImBd.jpg – Brad Apr 30 '13 at 12:25
  • @Brad: Yes, you need to change the fourth (4th) digit to 255 (or any digit higher than what you have now: 170 and 85) for red and green to make it brighter. The first digit has index 0, so the fourth digit has index 3. This is why, when you use this color, you use tput setaf 3 (and not 4). – Emanuel Berg Apr 30 '13 at 17:33
1

Usually you should use ncurses library to use terminal features.

In your case you can use highlight on:

PS1="[\033[33;1m][\u@\h \W]$ [$Color_Off]"
Mircea Vutcovici
  • 1,834
  • 14
  • 9
0

ANSI colors are translated by modern terminals into user-defined colors, so that someone can get a yellow on pink prompt, or sometimes to give the opportunity to protect the user from eyestrain.

The color you are refering to is defined in the profile of your terminal. In PuTTY, right click on the windows title and go to "Change Settings". Then Windows -> Colours. It will give you how the yellow you want is defined. Then, in the "local console", click Edit -> Profiles -> Edit Default. You'll find how to redefine colors. If your "local console" is xTerm, you'll find online what are the parameters to feed xterm with in order to redefine colors.

Pascail
  • 101
  • This server doesn't have a GUI - so there's no right click option. As far as changing the colors in Putty - I'm aware that can be done but I want the color right from the start. There are many people that connect to this system and its not practical to ask them all to modify their SSH application to display the correct color. Thanks though. – Brad Apr 30 '13 at 12:09
  • Added a source in Berg's answer that describes how to set numbers in /sys/module/... files. I learned something thanks to you :) – Pascail Apr 30 '13 at 15:18