summaryrefslogtreecommitdiff
path: root/bin/myhledger
blob: f35601eb2ed274907cb124436c454178500ef61e (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/income/*.ledger 2> /dev/null || true
  20. done
  21. cat ../bank/*.ledger 2> /dev/null || true
  22. cat ../receipts/*.ledger 2> /dev/null || true
  23. cat ../taxes/*.ledger 2> /dev/null || true
  24. }
  25. journal | hledger -f- "$@"