Skip to main content

ChromaTerm

Build status Coverage status Downloads Maintainability PyPI version

ChromaTerm (ct) is a Python script that colors your terminal's output using regular expressions. It even works with interactive programs, like SSH.

alt text

Installation

pip3 install chromaterm

Usage

Prefix your command with ct. It's that simple.

ct ssh somewhere

You can also pipe data into ct, but some programs behave differently when piped, like less would output the entire file.

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

Persistence

To always highlight a program, set up an alias in your .bash_profile. For instance, here's one for ssh.

alias ssh="ct ssh"

If you want to highlight your entire terminal, have ChromaTerm spawn your shell by modifying the shell command in your terminal's settings to /usr/local/bin/ct /bin/bash --login. Replace /bin/bash with your shell of choice.

Highlight Rules

ChromaTerm reads highlight rules from a YAML configuration file, formatted like so:

rules:
- description: Obligatory "Hello, World"
  regex: Hello,?\s+World
  color: f#ff0000

- description: Spit some facts (emphasize "NOT" so they get it)
  regex: Pineapple does (NOT) belong on pizza
  color:
    0: bold
    1: blink italic underline

The configuration file can be placed in one of the locations below. The first one found is used.

  • $HOME/.chromaterm.yml
  • $XDG_CONFIG_HOME/chromaterm/chromaterm.yml ($XDG_CONFIG_HOME defaults to $HOME/.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, but it can be switched to PCRE2 (see relevant section below).

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, you can also use blink, bold, invert, italic, strike, and underline. Though, not all terminals support those styles; you might not see their effects.

Group

Colors can be applied per RegEx group (see the 2nd example rule). Any group in the RegEx can be referenced, including group 0 (entire match) and named groups.

Exclusive

When multiple rules match the same text, ChromaTerm highlights the text with all of the colors of the matching rules. If you want the text to be highlighted only by the first rule that matches it, use the exclusive flag.

- regex: hello
  color: bold
  exclusive: true

In the code above, no other rule will highlight hello, unless it comes first and has the exclusive flag set.

Palette

You can define colors in a palette and reference them by name. For instance:

palette:
  # Created from https://coolors.co/9140f5-bd5df6-e879f6
  purple-1: '#9140f5'
  purple-2: '#bd5df6'
  purple-3: '#e879f6'

rules:
- regex: hello
  color: f.purple-1

- regex: hi
  color: b.purple-3

When referencing a palette color, prefix it with b. for background and f. for foreground.

PCRE2

If the PCRE2 library is present, you can use it instead of Python's re engine. When present, an option in ct -h becomes available.

While the performance improvement is significant (~2x), the two RegEx engines have a few differences; use this option only if you have a good understanding of their unique features.

The default rules work on both engines.

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)

Metadata

Release files for chromaterm 0.10.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chromaterm 0.10.7
File Size Uploaded Provenance Actions
chromaterm-0.10.7.tar.gz 41.0 kB Without provenance Details for chromaterm-0.10.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chromaterm 0.10.7
File Interpreter ABI Platform Actions
chromaterm-0.10.7-py3-none-any.whl Python 3 none any Details for chromaterm-0.10.7-py3-none-any.whl

Total release size: 83.3 kB

Release files / chromaterm-0.10.7.tar.gz

Download URL chromaterm-0.10.7.tar.gz
Size 41.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a31934c0f245a9c067b2ed5a9d6d804bd2a7dc1df9f4305281d968eb4b2b8c6a
BLAKE2b-256 checksum
How to use checksums
6abf01299628cca998dbe8dfd397121e38ead219814b8ed1dc32e8c173b5b7bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / chromaterm-0.10.7-py3-none-any.whl

Download URL chromaterm-0.10.7-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a0425fe247770cbde7c21f4244e2287da3eac2ebdb2bb97e22d701ef3f60924
BLAKE2b-256 checksum
How to use checksums
28e78672a466a65629789600407d3e4e871b58c8cdfb6bd1779bd0121ccbfe59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for chromaterm 0.10.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page