Skip to main content

Colorize your output using RegEx

Project description

ChromaTerm--

A tool for colorizing the output of a terminal.

About

ChromaTerm-- (ct) reads from standard input and highlights it according to user-configurable rules. Here's an example using the rules in the included configuration file:

alt text

Installation

HomeBrew

brew install hSaria/tap/chromaterm
curl https://raw.githubusercontent.com/hSaria/ChromaTerm--/master/.chromatermrc > ~/.chromatermrc

You can uninstall with brew uninstall chromaterm

Compile from Source

git clone https://github.com/hSaria/ChromaTerm--.git
cd ChromaTerm--/src/ && ./configure && make install

You must have PCRE2 or legacy PCRE development installed. PCRE2 is recommended (much faster).

You can uninstall with make uninstall

Usage

By default, ChromaTerm-- reads a file at ~/.chromatermrc which would have your highlight rules. As an example, run the following:

echo "Jul 14 12:28:19: Message from 1.2.3.4" | ct

Think of ChromaTerm-- like grep; just pipe things into it. However, unlike other programs which line-buffer, ct works with interactive applications, like ssh. In fact, I have this in my .bash_profile ssh() { /usr/bin/ssh $* | ct; }.

During installation, the default config file was copied to ~/.chromatermrc; modify it to your liking.

Highlight Rules

The syntax for a rule is HIGHLIGHT {REGEX} {ACTION} {PRIORITY}

REGEX

The RegEx engine used is PCRE. If supported, PCRE2 is used (much faster).

ACTION

Once something matches the RegEx of a rule, the action of that rule is applied. The action can be a named (predefined) action or a custom one. Multiple actions can make up a single action as long as they are from the same category. For example: {bold red} or {<fca><BAF>}

The named actions are:

  • VT100: bold, dim, underscore, blink, b black, b blue, b cyan, b green, b magenta, b red, b white, b yellow, black, blue, cyan, white, and yellow.
  • xterm-256: b azure, b ebony, b jade, b lime, b orange, b pink, b silver, b tan, b violet, azure, ebony, jade, light azure, light ebony, light jade, light lime, light orange, light pink, light silver, light tan, light violet, lime, orange, pink, silver, tan, and violet.

Terminals that support xterm-256 codes will support VT100 codes, as well.

To use a custom action, man ct has more info on that. Run ct -d to see the full range of colors.

PRIORITY

(Optional) If a part of the text is matched by two rules, the rule with the lower priority value overrides the action of the higher priority value; lower priority value = higher precedence. Default priority is 1000.

Help

ChromaTerm-- includes a manual; check out man ct.

Questions, Suggestions, or Bugs

Please open up an issue (always appreciated).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for chromaterm, version 0.3.91
Filename, size File type Python version Upload date Hashes
Filename, size chromaterm-0.3.91-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size chromaterm-0.3.91.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page