Skip to content

Instantly share code, notes, and snippets.

@asciipip
Last active February 14, 2020 16:51
Show Gist options
  • Save asciipip/98d56d64ed2f0ce56a0931382f8aae55 to your computer and use it in GitHub Desktop.
Save asciipip/98d56d64ed2f0ce56a0931382f8aae55 to your computer and use it in GitHub Desktop.
Ledger Balance Sheet
#!/bin/bash
DEPTH=2
LG="ledger -f main.ledger --force-color --depth=$DEPTH"
BALANCE_FORMAT="%(justify(scrub(display_total), 10, -1, true, color)) %(depth_spacer)%-(ansify_if(partial_account(options.flat), blue if color))\n%/%\$1\\n%/----------\\n"
$LG source </dev/null || exit 1
paste -d '|' \
<($LG --balance-format="$BALANCE_FORMAT" bal "$@" ^Assets) \
<($LG --balance-format="$BALANCE_FORMAT" --invert bal "$@" ^Liabilities ^Equity) \
| column -nt -s '|' \
| less -RF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment