summaryrefslogtreecommitdiff
path: root/hledger-fadd
diff options
context:
space:
mode:
Diffstat (limited to 'hledger-fadd')
-rwxr-xr-xhledger-fadd13
1 files changed, 5 insertions, 8 deletions
diff --git a/hledger-fadd b/hledger-fadd
index be713e4..36e762a 100755
--- a/hledger-fadd
+++ b/hledger-fadd
@@ -16,9 +16,8 @@ function fz {
fi
}
-# cache accounts for speed
-accounts=$(mktemp)
-hledger accounts > $accounts &
+accounts=$(cache hledger accounts)
+payees=$(cache hledger payees)
date=$(for n in $(seq 0 31); do date -d"$n days ago" "+%Y/%m/%d (%a)"; done \
| fzf --height 50% --reverse --delimiter '/' \
@@ -29,7 +28,7 @@ date=$(for n in $(seq 0 31); do date -d"$n days ago" "+%Y/%m/%d (%a)"; done \
)
echo "date: $date"
-payee=$(hledger payees | fz --prompt="payee: " --preview='hledger print payee:{..}')
+payee=$(fz --prompt="payee: " --preview='hledger print payee:{..}' <<< $payees)
echo "payee: $payee"
# store past txs in a file, in the background, so I don't have to wait for the
@@ -38,13 +37,11 @@ past_txs=$(mktemp)
hledger print payee:"$payee" > $past_txs &
read -rep "to amount: " to_amount
-to_account=$(cat $accounts \
- | fz --prompt="to account: " --preview="cat $past_txs")
+to_account=$(fz --prompt="to account: " --preview="cat $past_txs" <<< $accounts)
echo "to account: $to_account"
-from_account=$(cat $accounts \
- | fz --prompt="from account: " --preview="cat $past_txs")
+from_account=$(fz --prompt="from account: " --preview="cat $past_txs" <<< $accounts)
echo "from account: $from_account"
read -rep "from amount: " -i "-$to_amount" from_amount