package ochre-cli

  1. Overview
  2. Docs
Command-line interface for ochre syntax highlighter

Install

dune-project
 Dependency

Authors

Maintainers

Sources

ochre-1.0.0.tbz
sha256=820412863edca3173c7365cf16b4b4bad41c8fffbb4bfba8f0d87a40d4ad525b
sha512=f8a16876281504e714fe465df8a1a9894a90f06fc6cead07534722c0aa83abf955d9951e66549ac78a016e27fe8cdc5596f415e26f1c5309ee893722078f56ae

doc/cli.html

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

  • LANG — Language identifier (e.g. ocaml, javascript, python). Required.
  • FILE — Input file path. Optional when piping/redirection stdin is used.

Options

  • --theme NAME_OR_PATH, -t NAME_OR_PATH — Optional. Built-in theme name (for example dark, light, or tokyonight) or path to a VS Code / TextMate theme JSON file.
  • --theme-dark NAME_OR_PATH — Theme used when terminal mode is detected as dark (same name-or-path resolution as --theme).
  • --theme-light NAME_OR_PATH — Theme used when terminal mode is detected as light (same name-or-path resolution as --theme).
  • --grammar FILE, -g FILE — Path to a .tmLanguage.json grammar file. Can be specified multiple times.
  • --format FORMAT, -f FORMAT — Output format: html (default), ansi, or tokens.

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:

  • dark — Default dark ochre theme
  • light — Default light ochre theme
  • tokyonight — Based on the Tokyonight theme
  • everforest — Based on the Everforest theme
  • ayu — Based on the Ayu dark theme
  • catppuccin — Based on the Catppuccin theme
  • catppuccin-macchiato — Based on the Catppuccin theme
  • gruvbox — Based on the Gruvbox theme
  • kanagawa — Based on the Kanagawa theme
  • nord — Based on the Nord theme
  • matrix — Hacker-style green on black theme
  • one-dark — Based on the Atom One Dark theme