ochre CLI

Command-line interface for the ochre syntax highlighter.

Synopsis

ochre LANG [FILE] [--theme NAME_OR_PATH] [--theme-dark NAME_OR_PATH] [--theme-light NAME_OR_PATH] [--grammar FILE]... [--format FORMAT]

Arguments

Options

Examples

Highlight an OCaml file to HTML

ochre ocaml file.ml --grammar ./grammars/ocaml.tmLanguage.json --theme theme.json

Highlight from stdin with ANSI terminal colors:

cat file.js | ochre javascript --grammar ./grammars/javascript.tmLanguage.json --format ansi

Load multiple grammars (e.g. for embedded languages)

ochre html index.html \
  --grammar ./grammars/html.tmLanguage.json \
  --grammar ./grammars/css.tmLanguage.json \
  --grammar ./grammars/javascript.tmLanguage.json \
  --theme theme.json

or using the short flag:

ochre html index.html -g ./grammars/html.tmLanguage.json -g ./grammars/css.tmLanguage.json -g ./grammars/javascript.tmLanguage.json

Grammars

Each --grammar flag takes a path to a .tmLanguage.json file. The language identifier is derived from the filename (e.g. ocaml.tmLanguage.json registers as ocaml).

Common sources for grammars:

Themes

Themes use the VS Code / TextMate JSON format with colors and tokenColors fields. See VS Code Theme Gallery for available themes.

For the CLI, --theme is optional. ochre uses a built-in theme and auto-picks dark/light from your terminal (using OCHRE_THEME_MODE, TERM_THEME, or COLORFGBG).

You can also pass a built-in name directly, for example --theme dark, instead of a file path.

Built-in themes: