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