package ochre-cli
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
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 exampledark,light, ortokyonight) 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.jsongrammar file. Can be specified multiple times.--format FORMAT,-f FORMAT— Output format:html(default),ansi, ortokens.
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:
- VS Code extensions:
~/.vscode/extensions/ - shikijs/textmate-grammars-themes on GitHub
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 themelight— Default light ochre themetokyonight— Based on the Tokyonight themeeverforest— Based on the Everforest themeayu— Based on the Ayu dark themecatppuccin— Based on the Catppuccin themecatppuccin-macchiato— Based on the Catppuccin themegruvbox— Based on the Gruvbox themekanagawa— Based on the Kanagawa themenord— Based on the Nord themematrix— Hacker-style green on black themeone-dark— Based on the Atom One Dark theme
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page