These are fantastic!  A nice way to port ledger around in your pocket,
without needing to write up a full UI.

I've taken the liberty of re-writing them to use 'case' instead of a
sequence of if statements:

-----
#!/bin/sh
# script to
# accept input:
#      * amount
#      * account
#      * note
# output:
#      * ledger format text
# automatically includes date and source account (wallet)
#

fname='wallet.ledger'
if [ -z "$2" ]; then
  echo "usage: $0 amount account [note]"
  exit 255
fi

case "$2" in
"d")
  account='expenses:simon:drinks'
  ;;
"g")
  account='expenses:simon:gift'
  ;;
"f")
  account="expenses:simon:food"
  ;;
"o")
  account='expenses:simon:transportation:oil'
  ;;
"p")
  account='expenses:simon:transportation::parking'
  ;;
"t")
  account='expenses:simon:telecom'
  ;;
esac

echo `date +%Y/%m/%d` ' ' $3 >> $fname
echo '    ' $account '    ' $1 >> $fname
echo '     assets:cash:wallet' >> $fname
echo >> $fname

fi
----

P.S. +1 for using cash everywhere.

Reply via email to