Skip to content

Commit 54652fa

Browse files
committed
;doc: Setting LEDGER_FILE: rewrite, new windows procedures
1 parent b67555b commit 54652fa

File tree

1 file changed

+59
-24
lines changed

1 file changed

+59
-24
lines changed

hledger/hledger.m4.md

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6858,42 +6858,77 @@ Market prices : 0 ()
68586858

68596859
## Setting LEDGER_FILE
68606860

6861-
How to set `LEDGER_FILE` permanently depends on your setup:
6861+
### Set LEDGER_FILE on unix
68626862

6863-
On unix and mac, running these commands in the terminal will work for many people; adapt as needed:
6863+
It depends on your shell, but running these commands in the terminal will work for many people;
6864+
adapt if needed:
68646865
```cli
6865-
$ echo 'export LEDGER_FILE=~/finance/2023.journal' >> ~/.profile
6866+
$ echo 'export LEDGER_FILE=~/finance/my.journal' >> ~/.profile
68666867
$ source ~/.profile
68676868
```
68686869

68696870
<!--
68706871
fish:
6871-
set -Ux LEDGER_FILE ~/finance/2023.journal
6872+
set -Ux LEDGER_FILE ~/finance/my.journal
68726873
-->
68736874

6874-
When correctly configured, in a new terminal window `env | grep LEDGER_FILE` will show your file,
6875-
and so will `hledger files`.
6875+
When correctly configured:
68766876

6877-
On mac, this additional step might be helpful for GUI applications (like Emacs started from the dock):
6878-
add an entry to `~/.MacOSX/environment.plist` like
6877+
- `env | grep LEDGER_FILE` will show your new setting
6878+
- and so should `hledger setup` and (once the file exists) `hledger files`.
68796879

6880-
```json
6881-
{
6882-
"LEDGER_FILE" : "~/finance/2023.journal"
6883-
}
6884-
```
6885-
and then run `killall Dock` in a terminal window (or restart the machine).
6880+
### Set LEDGER_FILE on mac
68866881

6887-
On Windows, see <https://www.java.com/en/download/help/path.html>,
6888-
or try running these commands in a powershell window
6889-
(let us know if it persists across a reboot, and if you need to be an Administrator):
6890-
```cli
6891-
> CD
6892-
> MKDIR finance
6893-
> SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal"
6894-
```
6895-
When correctly configured, in a new terminal window `$env:LEDGER_FILE` will show the file path,
6896-
and so will `hledger files`.
6882+
In a terminal window, follow the unix procedure above.
6883+
6884+
Also, this optional step may be helpful for GUI applications:
6885+
6886+
1. Add an entry to `~/.MacOSX/environment.plist` like
6887+
6888+
```json
6889+
{
6890+
"LEDGER_FILE" : "~/finance/my.journal"
6891+
}
6892+
```
6893+
2. Run `killall Dock` in a terminal window (or restart the machine), to complete the change.
6894+
6895+
When correctly configured for GUI applications:
6896+
6897+
- apps started from the dock or a spotlight search, such as a GUI Emacs,
6898+
will be aware of the new LEDGER_FILE setting.
6899+
6900+
### Set LEDGER_FILE on Windows
6901+
6902+
Using the gui is easiest:
6903+
6904+
1. In task bar, search for `environment variables`, and choose "Edit environment variables for your account".
6905+
2. Create or change a `LEDGER_FILE` setting in the User variables pane.
6906+
A typical value would be `C:\Users\USERNAME\finance\my.journal`.
6907+
3. Click OK to complete the change.
6908+
4. And open a new powershell window. (Existing windows won't see the change.)
6909+
6910+
Or at the command line, you can do it this way:
6911+
6912+
1. In a powershell window, run `[Environment]::SetEnvironmentVariable("LEDGER_FILE", "C:\User\USERNAME\finance\my.journal", [System.EnvironmentVariableTarget]::User)`
6913+
2. And open a new powershell window. (Existing windows won't see the change.)
6914+
6915+
Warning, doing this from the Windows command line can be tricky; other methods you may find online:
6916+
6917+
- may not affect the current window
6918+
- may not be persistent
6919+
- may not work unless you are an administrator
6920+
- may limit values to 1024 characters
6921+
- may break dynamic references to other variables
6922+
- may require a new-enough version of powershell
6923+
- or may be intended for the older command window.
6924+
- If you still have trouble, see eg
6925+
[Setting Windows PowerShell environment variables](https://stackoverflow.com/questions/714877/setting-windows-powershell-environment-variables)
6926+
or [Adding path permanently to windows using powershell doesn't appear to work](https://stackoverflow.com/questions/69236623/adding-path-permanently-to-windows-using-powershell-doesnt-appear-to-work).
6927+
6928+
When correctly configured:
6929+
6930+
- in a new powershell window, `$env:LEDGER_FILE` will show your new setting
6931+
- and so should `hledger setup` and (once the file exists) `hledger files`.
68976932

68986933
## Setting opening balances
68996934

0 commit comments

Comments
 (0)