Jobs Fast Jobs Fast

Script to Show All Font/Background Colors in Bash

gnome-terminal makes up about 50% of my windows open on my linux boxes — but it defaults to a color scheme that is pretty dark if you choose to change the background to black (like I do).

In order to adjust the color scheme, you can go into Edit -> Profile Preferences -> Colors Tab.

However, its kind of hard to tell how the colors will look until they’re displayed on the screen with the black background. The following simple script will generate a text in every font color, in every background color, and in all the styles:

#!/bin/bash

# The syntax for escaped color sequences looks like:
#
#    BLUE="\[\033[0;34m\]"
#
# Lets see what we can find...

NONE="\033[0m"

for COLOR in $(seq 30 40) ; do
    for STYLE in $(seq 0 1) 4 5 7; do
        TAG="\033[${STYLE};${COLOR}m"
        STR="Color:${COLOR}--Style:${STYLE}"

        echo -ne "${TAG}${STR}${NONE}  "
    done
    echo
done

The output looks like:

Tango (default) theme

Linux Console theme

Xterm theme

Posted Thursday, March 1st, 2012 under linux, shell scripting, tips and tricks.

Leave a Reply