summaryrefslogtreecommitdiff
path: root/bin/myhledger
blob: f0da9dc71be22f28582ead693b06a62939c48bae (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. defaultbasedir="$HOME/Doc/Jones/ledger"
  12. if [ -n "$basedir" ]; then
  13. :
  14. elif [ -d invoices ] && [ -d receipts ]; then
  15. basedir=.
  16. elif [ -d ../invoices ] && [ -d ../receipts ]; then
  17. basedir=..
  18. else
  19. basedir="$defaultbasedir"
  20. fi
  21. journal() {
  22. cat $basedir/bank/*.ledger 2> /dev/null || true
  23. cat $basedir/invoices/*.ledger 2> /dev/null || true
  24. cat $basedir/receipts/*.ledger 2> /dev/null || true
  25. cat $basedir/taxes/*.ledger 2> /dev/null || true
  26. }
  27. journal | hledger -f- "$@"