Color your output to terminal
Project description
ChromaTerm
ChromaTerm (ct
) is a Python script that colors your output to terminal using
regular expressions. It works with interactive programs, like SSH.
Installation
pip3 install chromaterm
Usage
Think of ct
like grep
; just pipe data into it, like ssh somewhere | ct
.
echo "Jul 14 12:28:19 Message from 1.2.3.4: Completed successfully" | ct
If you want to always highlight a program, you can set up a function in your
.bash_profile
. For instance, here's one for ssh
:
ssh() { /usr/bin/ssh "$@" | ct; }
Some programs behave differently when piped, like less
. In that case, ct
can
hide the pipe by spawning your program. You just have to prefix the command with
ct
, like ct less file.txt
.
Highlight Rules
ChromaTerm reads highlight rules from a YAML configuration file, formatted like so:
rules:
- description: My first rule colors the foreground
regex: hello.+world
color: f#ff0000
- description: Make "there" bold and italic. Paint "buddy" red
regex: Hey (there), (buddy)
color:
1: bold italic
2: b#ff0000
ChromaTerm will look in the following locations for the config file and use the first one it finds:
$HOME/.chromaterm.yml
$XDG_CONFIG_HOME/chromaterm/chromaterm.yml
(if$XDG_CONFIG_HOME
is not set, it defaults to~/config
)/etc/chromaterm/chromaterm.yml
If no file is found, a default one is created in your home directory.
Check out
contrib/rules
; it has some topic-specific rules that are not included in the defaults.
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
).
Style
In addition to the background and foreground, the following styles are supported, though some terminals ignore them:
- Blink
- Bold
- Italic
- Strike
- Underline
Group
A color can be applied per RegEx group (see the 2nd example rule). Any group in the regular expression can be referenced.
Help
If you've got any questions or suggestions, please open up an issue (always appreciated).
Windows support
To use ChromaTerm on Windows, you will need to run it with the
Windows Subsystem for Linux (WSL
)
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 Distribution
Hashes for chromaterm-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c3e5c1dbc4a8e202f11d36722f12c5eed0ce03e1c39cc7c28e865f77c670bd |
|
MD5 | f724aef1f41a903faef189727c0c3dba |
|
BLAKE2b-256 | 65d7ae06aef9ff7a50c2e6e2c79a038cf8fd70729d776ecf453c2b13e28ffd5a |