Colorize your output using RegEx
Project description
ChromaTerm
A tool for colorizing the output of programs.
About
ChromaTerm (ct
) reads from standard input and colors it according to user-configurable rules.
Think of ChromaTerm like grep
; just pipe data into it. However, unlike other programs which line-buffer, ct
works with interactive applications, like ssh
. In fact, I have ssh() { /usr/bin/ssh $* | ct; }
in my .bash_profile
to give my sessions color.
Here's an example using the rules in the default configuration file:
Installation
pip3 install chromaterm
If you have the legacy version of ChromaTerm, be sure to uninstall it first.
# If installed using HomeBrew brew uninstall chromaterm # If installed from source git clone -b legacy git@github.com:hSaria/ChromaTerm.git cd ChromaTerm/src/ && ./configure && make uninstall
Usage
By default, ChromaTerm reads .chromaterm.yml
in your home directory. As an example, run the following:
echo "Jul 14 12:28:19 Message from 1.2.3.4: Completed successfully" | ct
The default config file is copied to your home directory if it's not there.
Highlight Rules
All of the highlight rules are placed under the rules
array in the configuration file. Here's an example config file:
rules:
- description: My first rule colors the foreground
regex: hello.+world
color: f#ff0000
- description: Color the foreground and background for "there" and make it bold. Paint "buddy" red.
regex: Hey (there), (buddy)
color:
1: b#abcabc f#123123 bold
2: b#ff0000
Description
Optional. It's purely for your sake.
RegEx
The RegEx engine used is Python's re.
Color
Background and Foreground
The color is a hex string prefixed by b
for background (e.g. b#123456
) and f
for foreground (e.g. f#abcdef
).
You can color the foreground and background simultaneously by separating them with a space, like b#123456 f#abcdef
.
Style
In addition to the foreground and background, the following styles are supported, though some terminals ignore them:
- Blink
- Bold
- Italic
- Strike
- Underline
Group-Specific
A color can be applied per RegEx group (see the 2nd example rule). Any group can be referenced as long as it's in the RegEx.
Help
If you've got any questions or suggestions, please open up an issue (always appreciated).
There is no planned support for Windows due to the lack in standards support.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for chromaterm-0.4.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34564674563e46c2daa0f9261215f51ed325175c6381641b63b1f5d023994ad6 |
|
MD5 | ce65e8555ce778cca91f82bf165dbb2a |
|
BLAKE2b-256 | 1c4093571cd25f6bdab7725f981e30d1fe10caae795ea60186ff9a15768bbfbd |