Customized text color in terminal

Hello everybody,

Is there a sexy possibility to change the text color of the terminal (if possible, not only users shell), during boot? like for example display text in red instead of gray.

After looking in /boot, I have found screen.4th and I had try to edit the fg line (commanted as: Set foreground color). But I had not seen any effect...

Many thanks for all idea.

Sai
 
Red text .. eek!

Well, it's your terminal ... You can change it with some kernel options.
You will need to recompile your kernel, see chapter 8 of the FreeBSD handbook for details.

From sc(4):

Code:
     SC_NORM_ATTR=_attribute_

     SC_NORM_REV_ATTR=_attribute_

     SC_KERNEL_CONS_ATTR=_attribute_

     SC_KERNEL_CONS_REV_ATTR=_attribute_
            These options will set the default colors.  Available colors are
            defined in <machine/pc/display.h>.  See EXAMPLES below.

[...]

    The following lines will set the default colors.  The normal text will be
     green on black background.  The reversed text will be yellow on green
     background.  Note that you cannot put any white space inside the quoted
     string, because of the current implementation of config(8).

           options SC_NORM_ATTR=(FG_GREEN|BG_BLACK)
           options SC_NORM_REV_ATTR=(FG_YELLOW|BG_GREEN)

     The following lines will set the default colors of the kernel message.
     The kernel message will be printed bright red on black background.  The
     reversed message will be black on red background.

           options SC_KERNEL_CONS_ATTR=(FG_LIGHTRED|BG_BLACK)
           options SC_KERNEL_CONS_REV_ATTR=(FG_BLACK|BG_RED)
 
Yup .. that's exactly the way to do it ...
Here are the relevant lines on my kernel conf file:

Code:
[gonzalo@inferna ~]% grep SC_ /usr/src/sys/i386/conf/INFERNA
options     SC_PIXEL_MODE
options     SC_NORM_ATTR=(FG_WHITE|BG_BLACK) # The normal text will be white on black background
options     SC_KERNEL_CONS_ATTR=(FG_WHITE|BG_RED) # Kernel message will be white on red background
[gonzalo@inferna ~]%

The only problem I have is that I wanted it to look as the OpenBSD boot does (the colored background stops at the end of each line) but It doesn't work that way in here (the background is colored even if there's no text on it).
 
I just have a last question: do the prompt color (by default in gray) can be modified too?

I believe this could be possible with some other options then
options SC_NORM_ATTR=_attribute_
options SC_NORM_REV_ATTR=_attribute_
options SC_KERNEL_CONS_ATTR=_attribute_
options SC_KERNEL_CONS_REV_ATTR=_attribute_
...but I don't know them.

Anyway red text over black background is really awesome.
 
You sure can ..

You should use:

Code:
options SC_NORM_ATTR=_attribute_
options SC_KERNEL_CONS_ATTR=_attribute_

on your kernel conf file to set default sc(4) fg and bg color.

If you want to set the "prompt" color, you should refer to the man page of the shell you use ...

I use csh .. so .. here's how I do it:

Code:
[gonzalo@inferna ~]% grep prompt .cshrc
if ($?prompt) then
    set prompt = "[%n@%{\033[1;31m%}%m%{\033[0m%} %~]% "
[gonzalo@inferna ~]%

that results in a colored "hostname" (%m) .. so I know what computer I'm working on just by taking a look at the prompt's color (pretty useful if you use ssh ;) ).

and here's the color code for tcsh(1):

Code:
0   to restore default color
1   for brighter colors
4   for underlined text
5   for flashing text
30  for black foreground
31  for red foreground
32  for green foreground
33  for yellow (or brown) foreground
35  for purple foreground
36  for cyan foreground
37  for white (or gray) foreground
40  for black background
41  for red background
42  for green background
43  for yellow (or brown) background
44  for blue background
45  for purple background
46  for cyan background
47  for white (or gray) background

If you are using a shell other than csh, then you will have to take a look at your shell's man page and edit it's config file to suit your needs.

Have fun :)
 
My apologies, I think I have making a mistake between 'prompt' and 'cursor' word...
For instance when the system is booting, or when I'm using vi editor, and then I'm moving the active cursor in the document, I see my cursor (such as ᚁ) stay on gray (even if all the text is red on black).

Sorry for my poor english, hehe
 
Back
Top