summaryrefslogtreecommitdiff
path: root/bin/myhledger
blob: a7d81d6f7a22ea26de6c2a7366ba4a0f0e65dba7 (plain)
  1. #!/bin/sh
  2. # use hledger with piles of journal chunks
  3. #
  4. # Example usage:
  5. #
  6. ## Check expenses against bank account
  7. # myhledger register liabilities:payable -B --date2 -p "from 2011"
  8. #
  9. # myhledger balance -p "every 6 months in 2012" --date2
  10. # myhledger balance -p "from 2012-07 to 2013"
  11. # myhledger reg :kp
  12. # myhledger reg desc:012001
  13. set -e
  14. basedir="${basedir:-data}"
  15. years="${years:-$(find "$basedir" -mindepth 1 -maxdepth 1 -type d -regex '.*/[0-9]+' -printf '%f\n')}"
  16. journal() {
  17. set -e
  18. cd "$basedir"
  19. cat *.ledger 2> /dev/null || true
  20. for year in $years; do
  21. cat $year/*.ledger 2> /dev/null || true
  22. cat $year/assets/*.ledger 2> /dev/null || true
  23. cat $year/income/*.ledger 2> /dev/null || true
  24. cat $year/expenses/*.ledger 2> /dev/null || true
  25. done
  26. }
  27. journal | hledger -f- "$@"