Let's start a thread where people share their favorite command-line snippets, tips, and tricks!
I'll kick things off with my personal favorite:
hledger reg -D expenses -O csv | sed "s/.00 KRW//g" > expenses.csv
This command exports my expenses from hledger to CSV, removes the '.00 KRW' suffix, and saves the result. It's a quick and easy way to prepare data for visualization in LibreOffice Calc or similar spreadsheet software.
2 Likes
Great thread! Could be a good recurring topic. I have so many of these I risk becoming a bore.
Here's a favourite:
Turn any report into a live-updating one using a file watcher tool, such as watchexec (one of the best). Typically you can just prepend watchexec --
to any command line. Eg
watchexec -- hledger bs
watchexec -- hledger import --dry
watchexec -- ledger reg checking
2 Likes
I agree that this is a great topic. This tip is more for beginners, which is that the hledger commands can be shortened. So, for example, I use areg instead of aregister and reg instead of register.
A second way to see live updates is using hledger-ui:
hledger-ui --watch
hledger-ui -w --register checking -C
(--watch
mightn't work on your platform - let us know details)
A third way to see live updates, of errors at least, is using flycheck-hledger in Emacs.
(though flycheck-hledger has bitrotted and won't handle all errors; needs some love.)
If you want the output for the commands like payee
or tags
to use columns:
$ hledger payee
Payee1
Payee10
Payee2
Payee3
Payee4
Payee5
Payee6
Payee7
Payee8
Payee9
$ hledger payee | git column --mode=column --padding=5
Payee1 Payee2 Payee4 Payee6 Payee8
Payee10 Payee3 Payee5 Payee7 Payee9
git column
can help you.
edit: Just use column
.
$ hledger payee | column