In this week's hledger fan blog posting, I show one of my favorite tricks for saving time at the command line. Read about it at https://hledgerfan.com/one-favorite-hledger-shortcut/
I just make just commands for things that I use periodically. just + hledger =
This isn't hledger specific though. I do this in ledger as well
Even better, you can use regex for those three letter combos. The most popular are ^start_match
and end_match$
; but nothing stops you from using other detailed regex — see this example from the Ledger docs
Another thing I find quite useful is shell aliases for common commands, like (for hledger):
alias hl='hledger'
alias acc='hledger accounts'
alias accounts='hledger accounts'
alias act='hledger activity'
alias add='hledger add'
alias areg='hledger aregister'
alias bal='hledger balance'
alias bs='hledger bs'
alias bse='hledger bse'
alias budget='hledger bal --budget'
alias cf='hledger cashflow'
alias check='hledger check'
alias close='hledger close'
alias comm='hledger commodities'
alias desc='hledger descriptions'
alias files='hledger files'
alias iadd='hledger-iadd'
alias is='hledger is'
alias notes='hledger notes'
alias payees='hledger payees'
alias prices='hledger prices'
alias print='hledger print'
alias reg='hledger register'
alias stats='hledger stats'
alias tags='hledger tags'
alias all='hledger -f $FINDIR/all.journal'
alias 2020='hledger -f $FINDIR/2020/2020.journal'
alias 2021='hledger -f $FINDIR/2021/2021.journal'
alias 2022='hledger -f $FINDIR/2022/2022.journal'
alias 2023='hledger -f $FINDIR/2023/2023.journal'
alias 2024='hledger -f $FINDIR/2024/2024.journal'
See https://github.com/simonmichael/hledger/blob/321cdca918307e8398d90bc28d4531be68b11f57/bin/bashrc
The "just" commands are new to me. Can you give an example or two of what one of these commands would look like with your favorite plain text accounting tool?
Yes, regular expressions can be powerful and timesaving. I always feel that I need to learn more about them.
Very helpful examples, and as I was following your link, I also came across the justfile examples in https://github.com/simonmichael/hledger/blob/321cdca918307e8398d90bc28d4531be68b11f57/bin/Justfile. Worth noting for me in case I want to start using "just" commands.
Related: hledger and just - hledger
Wow, just
looks like a great program. I'll have to check it out. At first look, I thought it was like pet
, but pet
's more general-use. I've saved hedger commands there before, but I'll give just
a try.