termbook/gallery

v0.3 · open source · self-hosted

/ termbook

Generate browsable HTML galleries from CLI terminal output. Like Storybook, but for command-line tools. Captures ANSI in a real PTY and renders it as a static page with a sidebar nav, dark/light themes, and a fuzzy filter.

4 live galleries
0 deps for users
PTY real terminal capture

live galleries

bat – cat with wings · eza – modern ls · ripgrep – fast recursive search · teamcity cli

Each one was generated from the same two commands you'll use: termbook record termbook build.

§ 01
CLI
termbook --help
$ termbook --help
Beautiful, browsable reference pages for your CLI
 
Usage:
  termbook [command]
 
Available Commands:
  build       Render gallery.html from the manifest and captures
  completion  Generate the autocompletion script for the specified shell
  diff        Compare current captures against a baseline
  help        Help about any command
  record      Capture a command's output and add it to the manifest
 
Flags:
  -h, --help      help for termbook
  -v, --version   version for termbook
 
Use "termbook [command] --help" for more information about a command.
termbook record --help
$ termbook record --help
Run a command in a PTY, capture its ANSI output, and upsert it into the
manifest. The first invocation scaffolds .termbook/termbook.yml.
 
With --only <id>, re-captures an existing entry's command and overwrites
its capture file without changing the manifest.
 
With --all, re-captures every entry in the manifest. Useful in CI before
running `termbook diff`.
 
Usage:
  termbook record [command...] [flags]
 
Flags:
      --all                re-capture every entry in the manifest
      --cat string         category name (default "Screens")
      --desc string        screen description
  -h, --help               help for record
      --id string          screen id (defaults to a slug of the command)
      --only string        re-capture an existing entry by id without modifying the manifest
      --timeout duration   per-command timeout (default 30s)
      --title string       screen title (defaults to the command)
      --width int          PTY columns (default: manifest width or 120)
termbook build --help
$ termbook build --help
Render gallery.html from the manifest and captures
 
Usage:
  termbook build [flags]
 
Flags:
  -h, --help            help for build
      --only string     render only the screen with this id
  -o, --output string   output HTML path (default "gallery.html")
termbook diff --help
$ termbook diff --help
Compare the captures under .termbook/captures/ to a baseline and
report what changed. Defaults to comparing against the captures committed
at git HEAD; use --baseline to point at any directory containing
<id>.ansi files instead.
 
Manifest-level redact: rules are applied before comparison, so volatile
bits like timestamps don't drown out real diffs.
 
Exits 1 when any screen has changed, added, or been removed.
 
Usage:
  termbook diff [flags]
 
Flags:
      --baseline string       directory of <id>.ansi files (default: git HEAD)
      --baseline-ref string   git ref to use as baseline (e.g. main); default HEAD
  -h, --help                  help for diff
      --quiet                 print summary only, no per-line hunks
      --report-html string    also write an HTML report to this path
      --report-md string      also write a Markdown report (suitable for PR comments) to this path
cat ../examples/eza/.termbook/termbook.yml
$ cat ../examples/eza/.termbook/termbook.yml
title: eza – modern ls
accent: "#3FB950"
github: https://github.com/eza-community/eza
width: 120
redact:
  - pattern: '\b\d{1,2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2}:\d{2}\b'
    replace: 'DD MMM HH:MM'
  - pattern: '\b\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b'
    replace: 'YYYY-MM-DD HH:MM'
categories:
  - name: Listing
    id: listing
    screens:
      - id: basic
        title: default listing
        command: eza corpus
      - id: long
        title: long form
        command: eza corpus -l
      - id: long-all
        title: long with hidden
        command: eza corpus -la
      - id: header
        title: with header row
        command: eza corpus -l --header
      - id: classify
        title: classify markers
        command: eza corpus --classify=always
      - id: one-per-line
        title: one per line
        command: eza corpus -1 --color=always
      - id: grid-long
        title: grid sort
        command: eza corpus -lx
  - name: Sizes
    id: sizes
    screens:
      - id: totals
        title: human totals
        command: eza corpus -lh --total-size
      - id: by-size
        title: sorted by size
        command: eza corpus -lS
      - id: by-time
        title: sorted by time
        command: eza corpus -l --sort=time --reverse
      - id: rel-times
        title: relative times
        command: eza corpus -l --time-style=relative
      - id: iso-times
        title: ISO timestamps
        command: eza corpus -l --time-style=long-iso
  - name: Tree
    id: tree
    screens:
      - id: tree
        title: tree (level 2)
        command: eza corpus/ --tree --level=2
      - id: tree-gitignore
        title: tree respecting .gitignore
        command: eza corpus/ --tree --level=3 --git-ignore
      - id: tree-long
        title: long tree
        command: eza corpus/ --tree --level=2 -l --no-permissions --no-user
  - name: Git
    id: git
    screens:
      - id: git-status
        title: git status column
        command: eza corpus -l --git --git-repos