A User's view of Hledger

Learning about hledger

Making life easier with LEDGER_FILE

There is an old saying: “If you want to learn something well, teach it.”

This column recently had the same effect. Specifically, a couple of weeks ago, the “sponsor” of my blog was the -f flag. In the ad, I wanted to explain the benefits of using the flag as compared with the alternative for the default file. As I was really vague on the options for the default file, I turned to the hledger manual. As a result, I ran across the option to set LEDGER_FILE. I learned enough to explain the alternative to the -f flag.

Later I thought, why not try setting the LEDGER_FILE environment variable for the file I most often work with?

Via an internet search, I found the information regarding setting the LEDGER_FILE environment variable on a Mac. Specifically, the instructions were:

Add the line

export LEDGER_FILE=~[path and file name go here]

to .zshrc file in home directory.

Following the instructions, I went to the command line and ran:

source ~/.zshrc

The reason for the line above is to make the changes take effect immediately. At least, that’s what the instructions said.

In any case, the instructions worked for my Mac, and my hledger commands no longer need to reference my file name with the -f flag for the file with my current hledger transactions.

Today’s blog post is brought to you by the LEDGER_FILE environment variable

First, please note that sponsors to this blog do not influence my opinions about them. Also, I have a strict policy of of only accepting sponsors whose hledger commands, flags, environment variables or whatever I either actually use or probably should use but I haven’t gotten around to it yet.

Now, on to the message from this week’s sponsor.

Do you want to look cool? Real cool? Then don’t be caught typing out the file name after every hledger command. Cool kids don’t do that. They use the LEDGER_FILE environment variable. So, get with the in crowd and set your LEDGER_FILE environment variable today.