Skip to content

Instantly share code, notes, and snippets.

@asciiphil

asciiphil/balance-sheet.sh

Last active Feb 14, 2020
Embed
What would you like to do?
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