ledgerfmt

Quickstart

From install to a formatted journal in about a minute.

1. Format a file

By default ledgerfmt prints the formatted result to stdout and leaves the file untouched:

ledgerfmt accounts.journal

Pass --write to rewrite the file in place:

ledgerfmt --write accounts.journal

2. Format a whole directory

ledgerfmt --write ledger/

Directories are walked recursively. Files matching .ledgerfmtignore are skipped, using the same pattern syntax as .gitignore.

3. Check without writing

--check exits with status 1 when any file would change. This is the mode to use in CI:

ledgerfmt --check ledger/

4. Wire it into git

Add a pre-commit hook so formatting never lands in a diff:

#!/bin/sh
ledgerfmt --check $(git diff --cached --name-only --diff-filter=ACM | grep '\.journal$') || {
  echo "run: ledgerfmt --write" >&2
  exit 1
}

Next

Alignment width, currency placement and indentation are all configurable — see Configuration.