Linux Console Colors

What you say?

Yeah, I'm talking about coloring the 'linux console' - the little thing that you get when you login without X.

Most people I know use a framebuffer. That's due to the fact that non-framebuffered text is huge by default. Typically, you'll set vga=791 or something, and the text gets more readable, and it's left at that.

Yes, some people out there prefer bootsplash/gensplash/usplash/wtf-splash... I don't (though I do use grub-gfx from the AUR - grub with the background pixmap patch). However, when one boots into a framebuffer mode, you typically chose a color depth (personally, my laptop doesn't like anything over 16bit color, but that's good enough for me).

Ok, so I'm sure some people have asked "well, if I'm not using a splash screen, what use is all this color depth malarky?" - I'll show you. My ~/.bashrc contains the following lines:

if [ "$TERM" = "linux" ]; then
    echo -en "\e]P0222222" #black
    echo -en "\e]P8222222" #darkgrey
    echo -en "\e]P1803232" #darkred
    echo -en "\e]P9982b2b" #red
    echo -en "\e]P25b762f" #darkgreen
    echo -en "\e]PA89b83f" #green
    echo -en "\e]P3aa9943" #brown
    echo -en "\e]PBefef60" #yellow
    echo -en "\e]P4324c80" #darkblue
    echo -en "\e]PC2b4f98" #blue
    echo -en "\e]P5706c9a" #darkmagenta
    echo -en "\e]PD826ab1" #magenta
    echo -en "\e]P692b19e" #darkcyan
    echo -en "\e]PEa1cdcd" #cyan
    echo -en "\e]P7ffffff" #lightgrey
    echo -en "\e]PFdedede" #white
    clear #for background artifacting

Yeah, it's confusing, I know... however, these are console escapes specific to the linux console.

As with all escape codes, it begins with a little prefix indicating what the escape is actually doing: in this case "e]P", which is the "set color" escape. The format for the data is "XRRGGBB" where X is the number of the color to modify (in hex). This is a standard 16 color notation, which I have commented above. The colors above are taken verbatim from my ~/.Xdefaults file, with "color0" converted to "e]P0" and "color16" converted to "e]PF".

Note the last 'clear'. If you set these colors without clearing the terminal, the background color will change (assuming 'color0' changed) only for new text. You will get odd artifacting.

Here is a screenshot of my current, non-X setup, using the terminus consolefont (ter-112n) and the above colors.


| source