From a0eda916735aefcd88da9d89481e421da762ffd5 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Sat, 16 Nov 2019 19:50:27 +0100 Subject: [PATCH] allow more editors, add dependencies --- local/bin/ladd | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/local/bin/ladd b/local/bin/ladd index 7921986..9b44913 100755 --- a/local/bin/ladd +++ b/local/bin/ladd @@ -3,10 +3,15 @@ # # 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. +# set to the current date. Finally, it opens the end of the file in +# $EDITOR. # # Bonus over `hledger add`: interactive matching it easier, and # transaction formatting is retained because it's just a copy. +# +# Depends on: +# - fzf (https://github.com/junegunn/fzf) +# - ed ledger="${1:-$LEDGER_FILE}" @@ -35,7 +40,11 @@ x wq HERE -# review change: open end of the file -vi +\$ "$ledger" +# review change: open end of the file (if I know how) +case "$EDITOR" in +vi*) "$EDITOR" +\$ "$ledger" ;; +emacs) "$EDITOR" "$ledger" -f end-of-buffer ;; +*) "$EDITOR" "$ledger" ;; +esac clear