summaryrefslogtreecommitdiff
path: root/bin/myhledger
blob: 443947477bca6788e40084c8c5c66b7a706068d3 (plain)
  1. #!/bin/sh
  2. # use hledger with piles of journal chunks
  3. #
  4. # Example usage:
  5. #
  6. # myhledger balance -p "from 2012 to 2012-07-01" --effective
  7. # myhledger balance -p "from 2012-07-01 to 2013"
  8. set -e
  9. defaultbasedir="$HOME/Doc/Jones/ledger"
  10. if [ -n "$basedir" ]; then
  11. :
  12. elif [ -d invoices ] && [ -d receipts ]; then
  13. basedir=.
  14. elif [ -d ../invoices ] && [ -d ../receipts ]; then
  15. basedir=..
  16. else
  17. basedir="$defaultbasedir"
  18. fi
  19. journal() {
  20. cat $basedir/bank/*.ledger 2> /dev/null || true
  21. cat $basedir/invoices/*.ledger 2> /dev/null || true
  22. cat $basedir/receipts/*.ledger 2> /dev/null || true
  23. cat $basedir/taxes/*.ledger 2> /dev/null || true
  24. }
  25. journal | hledger -f- "$@"