A output colorizer for your favorite commands.
To install ChromaShift, run the following script:
curl -s https://raw.githubusercontent.com/Nadim147c/ChromaShift/main/scripts/install.gh-release.sh | sh
Simply run your favorite commands through ChromaShift to see the output in enhanced colors. For example:
cshift -- <your-command>
List of available command can be found in config.toml file.
If your favorite command is not supported yet, feel free to create an issue. If you want to contribute your rules for any specific command, follow the guide below.
To create your own colorization rules, you’ll need a basic understanding of regular
expressions (regex). Let’s walk through an example where you want to create a
colorization rule for the du
command (note: a rule for du
already exists).
-
First, create the configuration file if it doesn’t exist:
mkdir -p ~/.config/Chromashift touch ~/.config/Chromashift/config.toml
Then, add an entry in the configuration file located at
~/.config/Chromashift/config.toml
like this:[du] regexp = '^([/\w\.]+/)?du\b' file = 'du.toml'
Here's how it works:
ChromaShift
first checks if the command name matchesdu
exactly, then loads the correspondingdu.toml
file to apply the colorization rules. If it doesn’t find a direct match, it uses the specifiedregexp
to check the command. This means runningcshift -- /usr/bin/du
will also work as expected. -
Next, create a TOML file in
~/.config/Chromashift/rules/
. The file name should match what you specified inconfig.toml
, in this case,du.toml
:mkdir -p ~/.config/Chromashift/rules touch ~/.config/Chromashift/rules/du.toml
-
For schema validation, add the following line to the top of your TOML file:
"$schema" = '../rule.schema.json'
This ensures that the rules you define will be validated according to the schema, providing helpful feedback as you work on them.
-
How do rules work?
Each rule is defined as an array block within the TOML file. Here's an example of a rule for highlighting totals:
[[rules]] # Total regexp = '(.*)\s+(total)$' colors = 'bold yellow bgblue'
In this example:
regexp
is the regular expression that matches the text you want to style.colors
specifies the styles to apply. You can use multiple styles by separating them with spaces (e.g.,bold yellow bgblue
applies bold yellow text with a blue background).
If you want to apply different styles to different capture groups in your regex, separate the styles with a comma (
,
).[[rules]] # Destination regexp = '^\[download\] (Destination): (.*)' colors = 'yellow,magenta'
In this rule:
- The word "Destination" is colored yellow.
- The second group (anything that comes after "Destination") is colored magenta.
-
More Options:
pty
: Executes the command inside a pseudo-terminal (pty).stderr
: Colors the output of stderr instead of stdout.rules.overwrite
: Overwrites a matching rule if another rule applies to the current line.rules.priority
: Sets the priority for a rule if multiple rules match a line.rules.type = path
: Colors the path using LS_COLORS and file permissions.
If you want to share your rule with the community, add it to the official ChromaShift repository. To do this:
- Copy your rule file to the repository’s
rules/
directory. - Update the repository's
config.toml
accordingly. - Submit a pull request.
By following these steps, you can easily create new colorization rules for any command!
ChromaShift is licensed under the GNU-GPL-3. Most of its features have been shamelessly stolen from garabik/grc.