#!/bin/sh # Copies a previous transaction to today. # # Select a previous transaction by fuzzy matching on the titles. This # transaction is then copied to the end of the journal, uncleared and # set to the current date. Finally, it opens the end of the file in vi. # # Bonus over `hledger add`: interactive matching it easier, and # transaction formatting is retained because it's just a copy. ledger="${1:-$LEDGER_FILE}" # fuzzy select a transaction title selection="$(sed -n 's/....-..-..\( [*!]\)\? //p' "$ledger" | sort | uniq | fzf)" [ -z "$selection" ] && clear && exit 0 # quit if escaped cat <