Skip to content

Color configuration files

Ralf Kilian edited this page Dec 3, 2023 · 24 revisions

Color configuration files

Table of contents


Configuration file

Structure

Each line has the same format which is a color name followed by a term, for example:

lightred    fail
yellow      warn
lightgreen  success

The given terms will be processed case-insensitive and must neither contain unescaped spaces nor any quotes. Multiple consecutive terms per rule are supported, see example 5 below for details.

Highlight using colors

For highlighting you can either choose from 16 pre-defined color names (see below) or give a number from 0 to 255 to use a 256-color palette (depending on the terminal emulator on the graphical user interface). Notice that when using a pure text-based user interface (tty) you can only use the 16 pre-defined colors.

You may run Salomon with the command-line argument to view the color table

./salomon.sh --color-table

to see which colors are supported by the terminal emulator and to get the corresponding numbers to use for each color.

Pre-defined colors

Below are the 16 pre-defined colors mentioned above. You can either give the color names or its HTML specifications. Notice that the hexadecimal values are only for informational purposes and not supported for color configuration.

Pre-defined color palette
# Color name HTML spec Hex code
1 darkred maroon #800000
2 darkgreen green #008000
2 brown olive #808000
4 darkblue navy #000080
5 darkpurple purple #800080
6 darkcyan teal #008080
7 lightgray silver #c0c0c0
8 darkgray gray #808080
9 lightred red #ff0000
10 lightgreen lime #00ff00
11 yellow yellow #ffff00
12 lightblue blue #0000ff
13 lightpurple fuchsia #ff00ff
14 lightcyan aqua #00ffff
15 white white #ffffff
16 black black #000000

Highlight using formatting options

Furthermore, you can also highlight lines with the additional formatting options like bold and underlined text.

Notice that terminal emulators must support these options. Among them, the underline option should directly work, the bold option depends on the preferences of the terminal emulator, as bold text can be disabled permanently.

However, these formatting options do not have any (or at least unexpected) effects on a pure text-based interface (tty).

Before using them (no matter in which environment or terminal emulator), run Salomon with the command-line argument to view the format list

./salomon.sh --format-list

to get an overview which options are available and if they are displayed correctly, see example 6 for details.

Top

Usage examples

These can also be found in the file sample_colors.cfg inside the colors sub-directory.

Example 1

Requested result:

  • Lines containing the term fail shall be highlighted red.
  • Lines containing the term warn shall be highlighted yellow.
  • Lines containing the term success shall be highlighted green.
lightred    fail
yellow      warn
lightgreen  success

Example 2

Requested result:

  • Lines containing the term notice or info shall be highlighted blue.
lightblue   notice
lightblue   info

Example 3

Requested result:

  • Lines containing the term important shall be highlighted in orange.

There is no color name for orange, so it must be given via color code from the 256-color palette. As already mentioned above, there may be some restrictions, depending on the terminal emulator.

Inside the palette there are various shades of orange, color 214 amongst them. So, instead of a color name, the corresponding number must be given.

214         important

Example 4

Different colors for the same term or different colors for multiple terms in the same line do not cause any errors. However, the colorization depends on the order of the given terms.

For example, if you have the following line

2014-04-02 01:04:34 Warning: At least one process has failed

with the following color definitions the line will be highlighted in yellow, due to the fact, that the term warning is the first one that occurs inside the log line.

yellow      warning
lightred    failed
lightgray   process

Example 5

If you want to highlight several words in a row, for example has failed in a line like this

2014-04-02 01:04:34 Warning: At least one process has failed

you can do this as follows. Notice that spaces must be escaped using a backslash as enclosing by quotes will not work. Furthermore, the given terms must be directly consecutive.

lightred    has\ failed

Example 6

Another additional way of highlighting lines are the additional formatting options like bold and underlined text.

Notice that terminal emulators must support these options in order to use them. Among those, the underline option should directly work, the bold option depends on the preferences of the terminal emulator, as bold text can be disabled permanently.

However, these formatting options do not have any (or at least unexpected) effects on a pure text-based interface (tty).

Available options are the following which can also be combined:

Option Effect
-b, -bold Bold
-bl, -blink Blinking
-d, -dim Dimmed
-i, -italic Italic
-s, -strikethrough Striked through
-u, -underline , -underlined Underlined

For example:

lightred-bold               failed
yellow-underlined           warning
lightgreen-bold-underlined  success

Same with short variants of the formatting options:

lightred-b      failed
yellow-u        warning
lightgreen-b-u  success

Example 7

It is also possible to use random colors. This feature is only intended for highlighting corresponding lines in different colors. However, this does not make much sense with multiple random-colored terms.

Notice that this only works on terminal emulators which support 256 colors and not on a pure text-based interface (tty). Furthermore, the formatting options for bold and underlined text are not available when using random colors.

random      foobar

Top