# ChromaTerm2
[](https://badge.fury.io/py/chromaterm2)
ChromaTerm (`ct`) is a Python script that colors your terminal's output using
regular expressions. It even works with interactive programs, like SSH.
> **Original project by [hSaria](https://github.com/hSaria). This is a maintained and refactored version.**

## Installation
```shell
pip3 install chromaterm2
```
> **Note**: This is a maintained fork of the original ChromaTerm project. The original [chromaterm](https://github.com/hSaria/ChromaTerm) package is archived.
## Usage
Prefix your command with `ct`. It's that simple.
```shell
ct ssh somewhere
```
You can also pipe data into `ct`, but some programs behave differently when piped,
like `less` would output the entire file.
```shell
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`.
```shell
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:
```yaml
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`](https://github.com/hSaria/ChromaTerm/tree/main/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](https://docs.python.org/3/library/re.html),
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](https://docs.python.org/3/howto/regex.html#non-capturing-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.
```yaml
- 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:
```yaml
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](https://github.com/rgcr/ChromaTerm/issues/new) (always
appreciated).
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for detailed information about changes in each version.
### Windows support
To use ChromaTerm on Windows, you will need to run it with the
[Windows Subsystem for Linux (`WSL`)](https://docs.microsoft.com/en-us/windows/wsl/about)
Raw data
{
"_id": null,
"home_page": "https://github.com/rgcr/ChromaTerm",
"name": "chromaterm2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9.0",
"maintainer_email": "rgcr <roger.dev@pm.me>",
"keywords": "terminal, color, regex, highlighting, cli",
"author": "rgcr",
"author_email": "rgcr <roger.dev@pm.me>",
"download_url": "https://files.pythonhosted.org/packages/bc/a3/2ba8cd37aa5f7853546c7d635de47d0f64fe998e04a56c9c1473b4c45e86/chromaterm2-2.0.0.tar.gz",
"platform": null,
"description": "# ChromaTerm2\n\n[](https://badge.fury.io/py/chromaterm2)\n\nChromaTerm (`ct`) is a Python script that colors your terminal's output using\nregular expressions. It even works with interactive programs, like SSH.\n\n> **Original project by [hSaria](https://github.com/hSaria). This is a maintained and refactored version.**\n\n\n\n## Installation\n\n```shell\npip3 install chromaterm2\n```\n\n> **Note**: This is a maintained fork of the original ChromaTerm project. The original [chromaterm](https://github.com/hSaria/ChromaTerm) package is archived.\n\n## Usage\n\nPrefix your command with `ct`. It's that simple.\n\n```shell\nct ssh somewhere\n```\n\nYou can also pipe data into `ct`, but some programs behave differently when piped,\nlike `less` would output the entire file.\n\n```shell\necho \"Jul 14 12:28:19 Message from 1.2.3.4: Completed successfully\" | ct\n```\n\n### Persistence\n\nTo always highlight a program, set up an alias in your `.bash_profile`. For\ninstance, here's one for `ssh`.\n\n```shell\nalias ssh=\"ct ssh\"\n```\n\nIf you want to highlight your entire terminal, have ChromaTerm spawn your shell by\nmodifying the shell command in your terminal's settings to `/usr/local/bin/ct /bin/bash --login`.\nReplace `/bin/bash` with your shell of choice.\n\n## Highlight Rules\n\nChromaTerm reads highlight rules from a YAML configuration file, formatted like so:\n\n```yaml\nrules:\n- description: Obligatory \"Hello, World\"\n regex: Hello,?\\s+World\n color: f#ff0000\n\n- description: Spit some facts (emphasize \"NOT\" so they get it)\n regex: Pineapple does (NOT) belong on pizza\n color:\n 0: bold\n 1: blink italic underline\n```\n\nThe configuration file can be placed in one of the locations below. The first one\nfound is used.\n\n * `$HOME/.chromaterm.yml`\n * `$XDG_CONFIG_HOME/chromaterm/chromaterm.yml` (`$XDG_CONFIG_HOME` defaults to\n `$HOME/.config`)\n * `/etc/chromaterm/chromaterm.yml`\n\nIf no file is found, a default one is created in your home directory.\n\n> Check out [`contrib/rules`](https://github.com/hSaria/ChromaTerm/tree/main/contrib/rules);\n> it has some topic-specific rules that are not included in the defaults.\n\n### Description\n\nOptional. It's purely for your sake.\n\n### RegEx\n\nThe RegEx engine used is Python's [re](https://docs.python.org/3/library/re.html),\nbut it can be switched to PCRE2 (see relevant section below).\n\n### Color\n\n#### Background and Foreground\n\nThe color is a hex string prefixed by `b` for background (e.g. `b#123456`) and\n`f` for foreground (e.g. `f#abcdef`).\n\n#### Style\n\nIn addition to the background and foreground, you can also use `blink`, `bold`,\n`invert`, `italic`, `strike`, and `underline`. Though, not all terminals support\nthose styles; you might not see their effects.\n\n### Group\n\nColors can be applied per RegEx group (see the 2nd example rule). Any group in\nthe RegEx can be referenced, including group `0` (entire match) and\n[named groups](https://docs.python.org/3/howto/regex.html#non-capturing-and-named-groups).\n\n### Exclusive\n\nWhen multiple rules match the same text, ChromaTerm highlights the text with all\nof the colors of the matching rules. If you want the text to be highlighted only\nby the first rule that matches it, use the `exclusive` flag.\n\n```yaml\n- regex: hello\n color: bold\n exclusive: true\n```\n\nIn the code above, no other rule will highlight `hello`, unless it comes first\nand has the `exclusive` flag set.\n\n## Palette\n\nYou can define colors in a palette and reference them by name. For instance:\n\n```yaml\npalette:\n # Created from https://coolors.co/9140f5-bd5df6-e879f6\n purple-1: '#9140f5'\n purple-2: '#bd5df6'\n purple-3: '#e879f6'\n\nrules:\n- regex: hello\n color: f.purple-1\n\n- regex: hi\n color: b.purple-3\n```\n\nWhen referencing a palette color, prefix it with `b.` for background and `f.` for\nforeground.\n\n## PCRE2\n\nIf the `PCRE2` library is present, you can use it instead of Python's `re`\nengine. When present, an option in `ct -h` becomes available.\n\nWhile the performance improvement is significant (~2x), the two RegEx engines\nhave a few differences; use this option only if you have a good understanding\nof their unique features.\n\n> The default rules work on both engines.\n\n## Help\n\nIf you've got any questions or suggestions, please open up an\n[issue](https://github.com/rgcr/ChromaTerm/issues/new) (always\nappreciated).\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for detailed information about changes in each version.\n\n### Windows support\n\nTo use ChromaTerm on Windows, you will need to run it with the\n[Windows Subsystem for Linux (`WSL`)](https://docs.microsoft.com/en-us/windows/wsl/about)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Color your Terminal with Regex! (Maintained fork of ChromaTerm)",
"version": "2.0.0",
"project_urls": {
"Changelog": "https://github.com/rgcr/ChromaTerm/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/rgcr/ChromaTerm",
"Issues": "https://github.com/rgcr/ChromaTerm/issues",
"Repository": "https://github.com/rgcr/ChromaTerm.git"
},
"split_keywords": [
"terminal",
" color",
" regex",
" highlighting",
" cli"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "eeba6fc829b53652e594aa4dc5d33eca370f91e6c183b74d8c6b052279081b7c",
"md5": "dd75bae2909a8670bd6a0565c483f433",
"sha256": "608eda7544b6a4e284f44c51fcb037be7a2fe392a865d999337aba582cc6b696"
},
"downloads": -1,
"filename": "chromaterm2-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dd75bae2909a8670bd6a0565c483f433",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9.0",
"size": 35768,
"upload_time": "2025-07-31T02:21:56",
"upload_time_iso_8601": "2025-07-31T02:21:56.170957Z",
"url": "https://files.pythonhosted.org/packages/ee/ba/6fc829b53652e594aa4dc5d33eca370f91e6c183b74d8c6b052279081b7c/chromaterm2-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bca32ba8cd37aa5f7853546c7d635de47d0f64fe998e04a56c9c1473b4c45e86",
"md5": "65bb5f9da55f6d985fac81d7aee2a758",
"sha256": "2c96182703a432191bc807c9c02cbf5ffff06a26b2b65b669a7e0704c88b7188"
},
"downloads": -1,
"filename": "chromaterm2-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "65bb5f9da55f6d985fac81d7aee2a758",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9.0",
"size": 35344,
"upload_time": "2025-07-31T02:21:57",
"upload_time_iso_8601": "2025-07-31T02:21:57.398334Z",
"url": "https://files.pythonhosted.org/packages/bc/a3/2ba8cd37aa5f7853546c7d635de47d0f64fe998e04a56c9c1473b4c45e86/chromaterm2-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 02:21:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rgcr",
"github_project": "ChromaTerm",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "chromaterm2"
}