All Projects → hSaria → ChromaTerm

hSaria / ChromaTerm

Licence: MIT license
Color your Terminal with RegEx!

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ChromaTerm

chalk
🖍️🎨Composable and simple terminal highlighting package for OCaml.
Stars: ✭ 29 (-80.54%)
Mutual labels:  color, highlight
Rainbow
🌈 Colorize commands output or STDIN using patterns.
Stars: ✭ 217 (+45.64%)
Mutual labels:  color, regex
Nord Highlightjs
An arctic, north-bluish clean and elegant highlight.js theme.
Stars: ✭ 49 (-67.11%)
Mutual labels:  color, highlight
colocat
Fegeya Colocat, Colorized 'cat' implementation. Written in C++17.
Stars: ✭ 14 (-90.6%)
Mutual labels:  color, highlight
texthighlighter
a no dependency typescript npm package for highlighting user selected text
Stars: ✭ 17 (-88.59%)
Mutual labels:  color, highlight
Qolor
An atom package to color your queries!
Stars: ✭ 18 (-87.92%)
Mutual labels:  color, highlight
Colorhighlight
🎨 Lightweight Color Highlight colorizer for Sublime Text
Stars: ✭ 76 (-48.99%)
Mutual labels:  color, highlight
Xcolor
Lightweight color picker for X11
Stars: ✭ 209 (+40.27%)
Mutual labels:  color
Spectra
A Javascript color library. Quickly manipulate and convert colors.
Stars: ✭ 235 (+57.72%)
Mutual labels:  color
Colors.lol
🎨 Overly descriptive color palettes
Stars: ✭ 207 (+38.93%)
Mutual labels:  color
Efcolorpicker
A lightweight color picker in Swift.
Stars: ✭ 205 (+37.58%)
Mutual labels:  color
ethereum-regex
Ξ Regular expression for matching Ethereum (ETH) addresses.
Stars: ✭ 19 (-87.25%)
Mutual labels:  regex
Hexbot
Every request returns a different hex code—all 16,777,216 of them.
Stars: ✭ 251 (+68.46%)
Mutual labels:  color
Sketch
Sketch have a lot of basic functions to develop a drawing app for iPhone. Anyone can easily create drawing iOS Application.
Stars: ✭ 229 (+53.69%)
Mutual labels:  color
Django Colorfield
color field for django models with a nice color-picker in the admin. 🎨
Stars: ✭ 238 (+59.73%)
Mutual labels:  color
Contrast Swatch
🅰️ Image microservice for color contrast information
Stars: ✭ 210 (+40.94%)
Mutual labels:  color
Get Childitemcolor
Add coloring to the output of Get-ChildItem Cmdlet of PowerShell.
Stars: ✭ 251 (+68.46%)
Mutual labels:  color
Uigradient
A simple and powerful library for using gradient layer, image, color
Stars: ✭ 208 (+39.6%)
Mutual labels:  color
Dynamiccolor
Yet another extension to manipulate colors easily in Swift and SwiftUI
Stars: ✭ 2,677 (+1696.64%)
Mutual labels:  color
Colorseekbar
A colorful SeekBar for picking color
Stars: ✭ 249 (+67.11%)
Mutual labels:  color

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)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].