Skip to content
On this page

Labctl color reference

CLI command

The labctl color command allows you to run any normal shell command and add some color. Labctl will use regular expressions to search for text of interest in the output and can then highlight these using defined colors.

labctl color --help
Usage: labctl color <cmd> ...

Add some color to any Linux command (i.e. ssh).

Arguments:
  <cmd> ...

Flags:
  -h, --help    Show context-sensitive help.

Global Flags
  -d, --debug=INT          Enable debug mode.
      --settings=STRING    Settings yaml file.

labctl: error: expected "<cmd> ..."

Example

labctl color ssh 10.0.0.1

TIP

When you use labctl color any flags should be before the color command!

Correct: labctl -d color ssh 10.0.0.1

Wrong: labctl color -d ssh 10.0.0.1 (-d will be interpreted as part of the ssh command)

Colors

Valid colors include: black, red, green, yellow, blue, magenta, cyan, white. You can add the following prefixes to colors: hi - Highlight, fg - Foreground, bg - Background

Valid styles include: bold, faint, italic, blinkslow, blinkrapid, reversevideo, concealed, crossedout

You can see a list of colors on how they are displayed on your terminal by using the --test flag

bash
labctl color --test

colors

TIP

The screenshot was made on Microsoft's Windows Terminal. It supports all the colors and a blinking blinkrapid

Labctl settings

You can provide your own color settings by creating ~/.labctl.yml and adding regex/color pairs under the colorize key

Labctl includes default settings, they are kept here in case you want to propose updates, below an extract from settings.

yaml
colorize:
  - regex: '\d+\.\d+\.\d+\.\d+(/\d+)?'
    color: magenta
  - regex: "(?i)\b(true|valid|used)\b"
    color: hiwhite,bold
  - regex: "(?i)(false|none)"
    color: hired
  - regex: shutdown
    color: yellow
  - regex: '(?i)\b(error|down)\b'
    color: red
  - regex: '(?i)(\benabled?|\bup\b)'
    color: green
  - regex: "(?i)\bdisabled?"
    color: yellow

The setting are displayed when you run labctl color --test or when you add the debug flag labctl -d color ...