Share your tips, tricks & snippets!

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. :sweat_smile: 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.)