summaryrefslogtreecommitdiff
path: root/bin/myhledger
diff options
context:
space:
mode:
Diffstat (limited to 'bin/myhledger')
-rwxr-xr-xbin/myhledger27
1 files changed, 12 insertions, 15 deletions
diff --git a/bin/myhledger b/bin/myhledger
index f0da9dc..f35601e 100755
--- a/bin/myhledger
+++ b/bin/myhledger
@@ -11,23 +11,20 @@
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
+basedir="${basedir:-data}"
+years="${years:-$(find "$basedir" -mindepth 1 -maxdepth 1 -type d -regex '.*/[0-9]+' -printf '%f\n')}"
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
+ set -e
+ cd "$basedir"
+ cat *.ledger 2> /dev/null || true
+ for year in $years; do
+ cat $year/*.ledger 2> /dev/null || true
+ cat $year/income/*.ledger 2> /dev/null || true
+ done
+ cat ../bank/*.ledger 2> /dev/null || true
+ cat ../receipts/*.ledger 2> /dev/null || true
+ cat ../taxes/*.ledger 2> /dev/null || true
}
journal | hledger -f- "$@"