summaryrefslogtreecommitdiff
path: root/bin/myhledger
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2013-03-19 20:06:12 +0100
committerJonas Smedegaard <dr@jones.dk>2013-03-19 20:06:12 +0100
commit262564cb35affa8d8da081ace45b90e895151647 (patch)
tree777796e3a327c0f935320114f41c118a7aede331 /bin/myhledger
parentf6d0e02e11da4ffda729eb267917172e196e342d (diff)
Add hledger convenience wrapper.
Diffstat (limited to 'bin/myhledger')
-rwxr-xr-xbin/myhledger31
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/myhledger b/bin/myhledger
new file mode 100755
index 0000000..4439474
--- /dev/null
+++ b/bin/myhledger
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# use hledger with piles of journal chunks
+#
+# Example usage:
+#
+# myhledger balance -p "from 2012 to 2012-07-01" --effective
+# myhledger balance -p "from 2012-07-01 to 2013"
+
+set -e
+
+defaultbasedir="$HOME/Doc/Jones/ledger"
+
+if [ -n "$basedir" ]; then
+ :
+elif [ -d invoices ] && [ -d receipts ]; then
+ basedir=.
+elif [ -d ../invoices ] && [ -d ../receipts ]; then
+ basedir=..
+else
+ basedir="$defaultbasedir"
+fi
+
+journal() {
+ cat $basedir/bank/*.ledger 2> /dev/null || true
+ cat $basedir/invoices/*.ledger 2> /dev/null || true
+ cat $basedir/receipts/*.ledger 2> /dev/null || true
+ cat $basedir/taxes/*.ledger 2> /dev/null || true
+}
+
+journal | hledger -f- "$@"