summaryrefslogtreecommitdiff
path: root/bin/myhledger
blob: 233faa5d4e5fd891484f12b24589a20aa0c71183 (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 "from 2012-07 to 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. }
  24. journal | hledger -f- "$@"