Configure virtual console colors

From ArchWiki
Revision as of 13:33, 16 November 2010 by Halhen (talk | contribs) (Initial version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The colors in the Linux virtual console running on the framebuffer can be changed. This is done by writing the escape code Template:Codeline where Template:Codeline is the hexadecimal index of the color from 0-F, and Template:Codeline is a traditional hexadecimal RGB code.

Reusing ~/.Xdefaults settings

If you configure your X terminal colors in ~/.Xdefaults, you can add the following snippet to your shell init script (.bashrc/.zshrc/...) to use the same colors in the console.

if [ "$TERM" = "linux" ]; then
    _SEDCMD='s/.*\*color\([0-9]\{1,\}\).*#\([0-9a-fA-F]\{6\}\).*/\1 \2/p'
    for i in $(sed -n "$_SEDCMD" $HOME/.Xdefaults | \
               awk '$1 < 16 {printf "\\e]P%X%s", $1, $2}'); do
        echo -en "$i"