Skip to content

Usage

Installation

rich-gradient-cli requires Python 3.11 or newer. Install it with any of:

uv tool install rich-gradient-cli               # uv
pip install rich-gradient-cli                   # pip

With Homebrew, trust the tap first. Homebrew won't load formulae from a third-party tap until you do:

brew tap maxludden/tap
brew trust maxludden/tap
brew install maxludden/tap/rich-gradient-cli

New releases reach the Homebrew tap about a day after PyPI.

Check that it works with gradient --version.

Text

Literal text and stdin (echo "piped text" | gradient -) are printed as gradient text. Rich console markup such as [b]bold[/b] is parsed unless you pass --no-markup.

gradient --colors 'red,#ff9900,#ffff00,lime,cyan' -s bold 'Hello gradient'

text

gradient -p '[bold]Bold[/bold], [italic]italic[/italic] and [u]underlined[/u]' --colors red,gold,lime

print

To style particular words or patterns, use --highlight-word WORD=STYLE or --highlight-regex PATTERN=STYLE. Both can be repeated.

gradient --colors magenta,cyan --highlight-word 'error=bold white on red' -s bold 'Highlight error text'

highlight

Files and URLs

The file extension picks the renderable:

Extension Rendered as
.md, .markdown Markdown
.rst reStructuredText
.ipynb Jupyter notebook
.json Pretty-printed JSON
.csv, .tsv Table
.txt, no extension Gradient text
anything else Syntax-highlighted code

http(s):// URLs and - (stdin) work the same way as files. A URL uses the extension of its path. Stdin has no extension, so add a mode flag such as --markdown when you pipe in anything other than plain text.

gradient README.md
gradient doc.rst
gradient notebook.ipynb
gradient data.csv
gradient config.json
gradient pyproject.toml -n -g --head 20
gradient https://example.com/page.md
cat <<'EOF' | gradient - --markdown --colors magenta,cyan
# Hello

Some **bold** and *italic* text.

- one
- two
EOF

markdown

cat <<'EOF' | gradient - --rst --colors orange,magenta
Title
=====

Some *emphasis* and a list:

- one
- two
EOF

rst

cat <<'EOF' | gradient - --ipynb --colors cyan,magenta
{"cells":[{"cell_type":"code","execution_count":1,"source":["print(1 + 1)"],"outputs":[{"output_type":"stream","text":["2\n"]}]}],"metadata":{"kernelspec":{"language":"python"}}}
EOF

ipynb

cat <<'EOF' | gradient - --json --colors cyan,magenta
{"name": "gradient", "tags": ["cli", "rich"], "stars": 5}
EOF

json

cat <<'EOF' | gradient - --csv --colors cyan,magenta
name,language,stars
rich,python,50000
typer,python,15000
uv,rust,40000
EOF

csv

gradient pyproject.toml --lexer toml --line-numbers --head 8 --colors yellow,magenta

syntax

Panels and rules

--panel BOX wraps any renderable in a gradient panel. The box styles are ascii, ascii2, square, rounded, heavy, double and none. Add --title and --caption to label the panel, and --border-only to color just the border and leave the content as it is.

--rule draws a horizontal rule with the text as its title.

gradient --panel rounded --title Error --colors 'red,#ff7090' -s bold 'This is an error message.'

panel

gradient --rule 'Blue to Green to Cyan' --colors 'blue,#00ff00,cyan'

rule

Trees, columns, spectrum and inspect

--tree shows a directory (or lines of text) as a tree, --columns lays each line out as a column cell, --spectrum shows the color palette, and --inspect reports on a Python object.

gradient --tree src --colors lime,cyan

tree

cat <<'EOF' | gradient - --columns --colors red,blue
alpha
beta
gamma
delta
epsilon
EOF

columns

gradient --spectrum --hues 7

spectrum

gradient str --inspect --colors green,cyan

inspect

Warning

--inspect imports or evaluates its argument as Python. Never pass it text you don't trust.

Animation

--animate animates the gradient in an interactive terminal. Add --duration SECONDS to stop automatically; otherwise press Ctrl+C to stop it.

When the output is not a terminal (for example, piped to a file), a single static frame is printed instead. --animate cannot be combined with --export-svg, --export-html or --pager.

Export and paging

gradient README.md --export-svg readme.svg   # print, then also save as SVG
gradient README.md -o readme.html            # ... or as HTML
gradient README.md --pager                   # scroll through it in a pager

Telemetry

Telemetry is off by default. Manage it with gradient --telemetry enable|disable|status. Even when enabled, events are sent only if AMPLITUDE_API_KEY is also set.