;doc: use ``cli not ``shell for command-line examples

This commit is contained in:
Simon Michael 2023-11-26 08:30:04 -10:00
parent a1988546f1
commit 0c85b48d2c
32 changed files with 181 additions and 181 deletions

View File

@ -66,7 +66,7 @@ $ fin # list the scripts available
is a way to organise your finance-related reports and scripts using standard bash. is a way to organise your finance-related reports and scripts using standard bash.
(See also [justfile](#justfile) below.) (See also [justfile](#justfile) below.)
```shell ```cli
$ alias f=~/src/hledger/bin/ft $ alias f=~/src/hledger/bin/ft
$ f $ f
--------------------------------------------------------------------------------"; } --------------------------------------------------------------------------------"; }
@ -103,7 +103,7 @@ Add hledger options to customise reports.
[`tt`](https://github.com/simonmichael/hledger/blob/master/bin/tt) [`tt`](https://github.com/simonmichael/hledger/blob/master/bin/tt)
is a similar bash multi-script for time reports. is a similar bash multi-script for time reports.
```shell ```cli
$ alias t=~/src/hledger/bin/tt $ alias t=~/src/hledger/bin/tt
$ t $ t
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -141,7 +141,7 @@ More on [hledger and just](just.md).
Here is a [justfile](https://github.com/simonmichael/hledger/blob/master/bin/justfile) Here is a [justfile](https://github.com/simonmichael/hledger/blob/master/bin/justfile)
reimplementing the `ft` and `tt` scripts more simply: reimplementing the `ft` and `tt` scripts more simply:
```shell ```cli
$ brew install just # eg $ brew install just # eg
$ alias j=just $ alias j=just
$ cd ~/finance $ cd ~/finance
@ -268,7 +268,7 @@ The [hledger-utils python package](https://pypi.org/project/hledger-utils/) prov
a `hledger-edit` command to edit the queried transactions in your `$EDITOR` no matter what file they reside in. a `hledger-edit` command to edit the queried transactions in your `$EDITOR` no matter what file they reside in.
Install or upgrade: Install or upgrade:
```shell ```cli
$ pip install -U hledger-utils # might be slightly different on your system $ pip install -U hledger-utils # might be slightly different on your system
``` ```
@ -292,7 +292,7 @@ The [hledger-utils python package](https://pypi.org/project/hledger-utils/) prov
a `hledger-plot` command for generating charts with matplotlib. a `hledger-plot` command for generating charts with matplotlib.
Install or upgrade: Install or upgrade:
```shell ```cli
$ pip install -U hledger-utils # might be slightly different on your system $ pip install -U hledger-utils # might be slightly different on your system
``` ```
Examples: Examples:

View File

@ -15,7 +15,7 @@ This installs haskell dependencies (but not system dependencies) and rebuilds as
then runs [hledger/bench/bench.hs](https://github.com/simonmichael/hledger/blob/master/hledger/bench/bench.hs), then runs [hledger/bench/bench.hs](https://github.com/simonmichael/hledger/blob/master/hledger/bench/bench.hs),
which by default shows quick elapsed-time measurements for several operations on a standard data file: which by default shows quick elapsed-time measurements for several operations on a standard data file:
```shell ```cli
$ stack bench hledger $ stack bench hledger
NOTE: the bench command is functionally equivalent to 'build --bench' NOTE: the bench command is functionally equivalent to 'build --bench'
... ...
@ -35,7 +35,7 @@ Benchmark bench: FINISH
bench.hs has some other modes, which you can use by compiling and running it directly. bench.hs has some other modes, which you can use by compiling and running it directly.
`--criterion` reports more detailed and dependable measurements, but takes longer: `--criterion` reports more detailed and dependable measurements, but takes longer:
```shell ```cli
$ cd hledger; stack exec -- ghc -ibench bench/bench && bench/bench --criterion $ cd hledger; stack exec -- ghc -ibench bench/bench && bench/bench --criterion
... ...
Linking bench/bench ... Linking bench/bench ...
@ -80,7 +80,7 @@ variance introduced by outliers: 16% (moderately inflated)
It can also show the results for multiple h/ledger executables side by side, if you tweak the bench.hs code. It can also show the results for multiple h/ledger executables side by side, if you tweak the bench.hs code.
Unlike the other modes, it does not link with the hledger code directly, but runs the "hledger" executable found in $PATH (so ensure that's the one you intend to test). Unlike the other modes, it does not link with the hledger code directly, but runs the "hledger" executable found in $PATH (so ensure that's the one you intend to test).
```shell ```cli
$ cd hledger; stack exec -- ghc -ibench bench/bench && bench/bench --simplebench $ cd hledger; stack exec -- ghc -ibench bench/bench && bench/bench --simplebench
Benchmarking /Users/simon/.local/bin/hledger in /Users/simon/src/hledger/hledger with simplebench and shell Benchmarking /Users/simon/.local/bin/hledger in /Users/simon/src/hledger/hledger with simplebench and shell
Using bench/default.bench Using bench/default.bench
@ -107,12 +107,12 @@ simplebench.hs is a generic benchmarker of one or more executables (specified on
It has a better command-line interface than bench.hs, so you may find it more convenient It has a better command-line interface than bench.hs, so you may find it more convenient
for comparing multiple hledger versions, or hledger and ledger. Eg: for comparing multiple hledger versions, or hledger and ledger. Eg:
```shell ```cli
$ stack exec -- ghc tools/simplebench $ stack exec -- ghc tools/simplebench
[1 of 1] Compiling Main ( tools/simplebench.hs, tools/simplebench.o ) [1 of 1] Compiling Main ( tools/simplebench.hs, tools/simplebench.o )
Linking tools/simplebench ... Linking tools/simplebench ...
``` ```
```shell ```cli
$ tools/simplebench -h $ tools/simplebench -h
tools/simplebench -h tools/simplebench -h
simplebench: at least one executable needed simplebench: at least one executable needed
@ -133,7 +133,7 @@ Tips:
- tests can be commented out with # - tests can be commented out with #
- results are saved in benchresults.{html,txt} - results are saved in benchresults.{html,txt}
``` ```
```shell ```cli
cd hledger; $ ../tools/simplebench -f bench/default.bench hledger ledger cd hledger; $ ../tools/simplebench -f bench/default.bench hledger ledger
Using bench/default.bench Using bench/default.bench
Running 4 tests 2 times with 2 executables at 2015-08-24 04:24:37.257068 UTC: Running 4 tests 2 times with 2 executables at 2015-08-24 04:24:37.257068 UTC:

View File

@ -166,7 +166,7 @@ Here are some ways to run it during development:
- `yesod devel`: runs in developer mode, rebuilds automatically when config, template, static or haskell files change - `yesod devel`: runs in developer mode, rebuilds automatically when config, template, static or haskell files change
(but only files in the hledger-web package): (but only files in the hledger-web package):
```shell ```cli
$ (cd hledger-web; yesod devel) $ (cd hledger-web; yesod devel)
``` ```
@ -176,7 +176,7 @@ $ (cd hledger-web; yesod devel)
- `stack ghci`: runs the server in developer mode from GHCI. - `stack ghci`: runs the server in developer mode from GHCI.
Changes to static files like hledger.js will be visible on page reload; Changes to static files like hledger.js will be visible on page reload;
to see other changes, restart it as shown. to see other changes, restart it as shown.
```shell ```cli
$ (cd hledger-web; stack ghci hledger-web) $ (cd hledger-web; stack ghci hledger-web)
hledger-web> :main --serve # restart: ctrl-c, :r, enter, ctrl-p, ctrl-p, enter hledger-web> :main --serve # restart: ctrl-c, :r, enter, ctrl-p, ctrl-p, enter
``` ```
@ -184,7 +184,7 @@ hledger-web> :main --serve # restart: ctrl-c, :r, enter, ctrl-p, ctrl-p, enter
- `make ghci-web`: runs the server in developer mode from GHCI, also - `make ghci-web`: runs the server in developer mode from GHCI, also
interprets the hledger-lib and hledger packages so that :reload picks interprets the hledger-lib and hledger packages so that :reload picks
up changes in those packages too: up changes in those packages too:
```shell ```cli
$ make ghci-web $ make ghci-web
ghci> :main --serve ghci> :main --serve
``` ```

View File

@ -12,7 +12,7 @@ The numbers describe the number of transactions, number of accounts, and maximum
They are generated by [`tools/generatejournal.hs`](https://github.com/simonmichael/hledger/blob/master/tools/generatejournal.hs). They are generated by [`tools/generatejournal.hs`](https://github.com/simonmichael/hledger/blob/master/tools/generatejournal.hs).
They should get built automatically as needed, if not you can use `make samplejournals`: They should get built automatically as needed, if not you can use `make samplejournals`:
```shell ```cli
$ make samplejournals $ make samplejournals
ghc tools/generatejournal.hs ghc tools/generatejournal.hs
[1 of 1] Compiling Main ( tools/generatejournal.hs, tools/generatejournal.o ) [1 of 1] Compiling Main ( tools/generatejournal.hs, tools/generatejournal.o )

View File

@ -9,7 +9,7 @@ The Makefile contains a fair amount of obsolete cruft and needs cleanup. Some ta
The Makefile is self-documenting. Run `make` to see a list of the main make rules: The Makefile is self-documenting. Run `make` to see a list of the main make rules:
```shell ```cli
$ make $ make
Makefile:37: -------------------- hledger make rules -------------------- Makefile:37: -------------------- hledger make rules --------------------
Makefile:39: make [help] -- list documented rules in this makefile. make -n RULE shows more detail. Makefile:39: make [help] -- list documented rules in this makefile. make -n RULE shows more detail.
@ -23,11 +23,11 @@ Makefile:304: make hledgerdev -- quickly build the hledger executable (with ghc
To see what a make rule will do without actually doing it, use the `-n` flag: To see what a make rule will do without actually doing it, use the `-n` flag:
```shell ```cli
$ make build -n $ make build -n
stack build stack build
``` ```
```shell ```cli
$ make test -n $ make test -n
(stack test \ (stack test \
&& echo pkgtest PASSED) || echo pkgtest FAILED && echo pkgtest PASSED) || echo pkgtest FAILED

View File

@ -341,7 +341,7 @@ This is very useful when reconciling. A good workflow is to have
your bank's online register open in a browser window, for reference; your bank's online register open in a browser window, for reference;
the journal file open in an editor window; the journal file open in an editor window;
and hledger-ui in watch mode in a terminal window, eg: and hledger-ui in watch mode in a terminal window, eg:
```shell ```cli
$ hledger-ui --watch --register checking -C $ hledger-ui --watch --register checking -C
``` ```
As you mark things cleared in the editor, As you mark things cleared in the editor,

View File

@ -207,7 +207,7 @@ In addition to the web UI, hledger-web also serves a JSON API that can be
used to get data or add new transactions. used to get data or add new transactions.
If you want the JSON API only, you can use the `--serve-api` flag. Eg: If you want the JSON API only, you can use the `--serve-api` flag. Eg:
```shell ```cli
$ hledger-web -f examples/sample.journal --serve-api $ hledger-web -f examples/sample.journal --serve-api
... ...
``` ```
@ -227,7 +227,7 @@ You can get JSON data from these routes:
Eg, all account names in the journal (similar to the [accounts](hledger.html#accounts) command). Eg, all account names in the journal (similar to the [accounts](hledger.html#accounts) command).
(hledger-web's JSON does not include newlines, here we use python to prettify it): (hledger-web's JSON does not include newlines, here we use python to prettify it):
```shell ```cli
$ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool $ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool
[ [
"assets", "assets",
@ -248,7 +248,7 @@ $ curl -s http://127.0.0.1:5000/accountnames | python -m json.tool
Or all transactions: Or all transactions:
```shell ```cli
$ curl -s http://127.0.0.1:5000/transactions | python -m json.tool $ curl -s http://127.0.0.1:5000/transactions | python -m json.tool
[ [
{ {
@ -294,7 +294,7 @@ The payload must be the full, exact JSON representation of a hledger transaction
You can get sample JSON from hledger-web's `/transactions` or `/accounttransactions`, You can get sample JSON from hledger-web's `/transactions` or `/accounttransactions`,
or you can export it with hledger-lib, eg like so: or you can export it with hledger-lib, eg like so:
```shell ```cli
.../hledger$ stack ghci hledger-lib .../hledger$ stack ghci hledger-lib
>>> writeJsonFile "txn.json" (head $ jtxns samplejournal) >>> writeJsonFile "txn.json" (head $ jtxns samplejournal)
>>> :q >>> :q
@ -395,7 +395,7 @@ and related data types):
And here's how to test adding it with curl. This should add a new entry to your journal: And here's how to test adding it with curl. This should add a new entry to your journal:
```shell ```cli
$ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json $ curl http://127.0.0.1:5000/add -X PUT -H 'Content-Type: application/json' --data-binary @txn.json
``` ```

View File

@ -39,7 +39,7 @@ account name, or if none can be found, it fails with a non-zero exit code.
Examples: Examples:
```shell ```cli
$ hledger accounts $ hledger accounts
assets:bank:checking assets:bank:checking
assets:bank:saving assets:bank:saving
@ -50,7 +50,7 @@ income:gifts
income:salary income:salary
liabilities:debts liabilities:debts
``` ```
```shell ```cli
$ hledger accounts --undeclared --directives >> $LEDGER_FILE $ hledger accounts --undeclared --directives >> $LEDGER_FILE
$ hledger check accounts $ hledger check accounts
``` ```

View File

@ -9,7 +9,7 @@ counts by day, week, month or other reporting interval (by day is the
default). With query arguments, it counts only matched transactions. default). With query arguments, it counts only matched transactions.
Examples: Examples:
```shell ```cli
$ hledger activity --quarterly $ hledger activity --quarterly
2008-01-01 ** 2008-01-01 **
2008-04-01 ******* 2008-04-01 *******

View File

@ -40,7 +40,7 @@ causing it to be different from the account's real-world running balance.
An example: this shows the transactions and historical running balance An example: this shows the transactions and historical running balance
during july, in the first account whose name contains "checking": during july, in the first account whose name contains "checking":
```shell ```cli
$ hledger areg checking date:jul $ hledger areg checking date:jul
``` ```

View File

@ -96,7 +96,7 @@ if any, and then alphabetically by account name.
For instance For instance
(using [examples/sample.journal](https://github.com/simonmichael/hledger/blob/master/examples/sample.journal)): (using [examples/sample.journal](https://github.com/simonmichael/hledger/blob/master/examples/sample.journal)):
```shell ```cli
$ hledger -f examples/sample.journal bal $ hledger -f examples/sample.journal bal
$1 assets:bank:saving $1 assets:bank:saving
$-2 assets:cash $-2 assets:cash
@ -113,7 +113,7 @@ Accounts with a zero balance (and no non-zero subaccounts, in tree
mode - see below) are hidden by default. Use `-E/--empty` to show them mode - see below) are hidden by default. Use `-E/--empty` to show them
(revealing `assets:bank:checking` here): (revealing `assets:bank:checking` here):
```shell ```cli
$ hledger -f examples/sample.journal bal -E $ hledger -f examples/sample.journal bal -E
0 assets:bank:checking 0 assets:bank:checking
$1 assets:bank:saving $1 assets:bank:saving
@ -135,7 +135,7 @@ For single-period balance reports displayed in the terminal (only),
you can use `--format FMT` to customise the format and content of each you can use `--format FMT` to customise the format and content of each
line. Eg: line. Eg:
```shell ```cli
$ hledger -f examples/sample.journal balance --format "%20(account) %12(total)" $ hledger -f examples/sample.journal balance --format "%20(account) %12(total)"
assets $-1 assets $-1
bank:saving $1 bank:saving $1
@ -196,7 +196,7 @@ cleared transactions only, etc. by using [query](#queries)
arguments or [options](#report-start--end-date) to limit arguments or [options](#report-start--end-date) to limit
the postings being matched. Eg: the postings being matched. Eg:
```shell ```cli
$ hledger -f examples/sample.journal bal --cleared assets date:200806 $ hledger -f examples/sample.journal bal --cleared assets date:200806
$-2 assets:cash $-2 assets:cash
-------------------- --------------------
@ -211,7 +211,7 @@ with their full names visible, as in the examples above.
With `-t/--tree`, the account hierarchy is shown, with subaccounts' With `-t/--tree`, the account hierarchy is shown, with subaccounts'
"leaf" names indented below their parent: "leaf" names indented below their parent:
```shell ```cli
$ hledger -f examples/sample.journal balance $ hledger -f examples/sample.journal balance
$-1 assets $-1 assets
$1 bank:saving $1 bank:saving
@ -253,7 +253,7 @@ Account balances at the depth limit always include the balances from
any deeper subaccounts (even in list mode). any deeper subaccounts (even in list mode).
Eg, limiting to depth 1: Eg, limiting to depth 1:
```shell ```cli
$ hledger -f examples/sample.journal balance -1 $ hledger -f examples/sample.journal balance -1
$-1 assets $-1 assets
$2 expenses $2 expenses
@ -268,7 +268,7 @@ $ hledger -f examples/sample.journal balance -1
You can also hide one or more top-level account name parts, using `--drop NUM`. You can also hide one or more top-level account name parts, using `--drop NUM`.
This can be useful for hiding repetitive top-level account names: This can be useful for hiding repetitive top-level account names:
```shell ```cli
$ hledger -f examples/sample.journal bal expenses --drop 1 $ hledger -f examples/sample.journal bal expenses --drop 1
$1 food $1 food
$1 supplies $1 supplies
@ -314,7 +314,7 @@ Note it is not useful to calculate percentages if the amounts in a
column have mixed signs. In this case, make a separate report for each column have mixed signs. In this case, make a separate report for each
sign, eg: sign, eg:
```shell ```cli
$ hledger bal -% amt:`>0` $ hledger bal -% amt:`>0`
$ hledger bal -% amt:`<0` $ hledger bal -% amt:`<0`
``` ```
@ -323,7 +323,7 @@ Similarly, if the amounts in a column have mixed commodities, convert
them to one commodity with `-B`, `-V`, `-X` or `--value`, or make a them to one commodity with `-B`, `-V`, `-X` or `--value`, or make a
separate report for each commodity: separate report for each commodity:
```shell ```cli
$ hledger bal -% cur:\\$ $ hledger bal -% cur:\\$
$ hledger bal -% cur:€ $ hledger bal -% cur:€
``` ```
@ -335,7 +335,7 @@ With a [report interval](#report-intervals) (set by the `-D/--daily`,
`-p/--period` flag), `balance` shows a tabular report, with columns `-p/--period` flag), `balance` shows a tabular report, with columns
representing successive time periods (and a title): representing successive time periods (and a title):
```shell ```cli
$ hledger -f examples/sample.journal bal --quarterly income expenses -E $ hledger -f examples/sample.journal bal --quarterly income expenses -E
Balance changes in 2008: Balance changes in 2008:
@ -530,7 +530,7 @@ For example, you can take average monthly expenses in the common expense categor
``` ```
You can now see a monthly budget report: You can now see a monthly budget report:
```shell ```cli
$ hledger balance -M --budget $ hledger balance -M --budget
Budget performance in 2017/11/01-2017/12/31: Budget performance in 2017/11/01-2017/12/31:
@ -565,7 +565,7 @@ shown, as they have no budget amounts declared.
This can be confusing. When you need to make things clearer, use the `-E/--empty` flag, This can be confusing. When you need to make things clearer, use the `-E/--empty` flag,
which will reveal all accounts including unbudgeted ones, giving the full picture. Eg: which will reveal all accounts including unbudgeted ones, giving the full picture. Eg:
```shell ```cli
$ hledger balance -M --budget --empty $ hledger balance -M --budget --empty
Budget performance in 2017/11/01-2017/12/31: Budget performance in 2017/11/01-2017/12/31:
@ -587,7 +587,7 @@ Budget performance in 2017/11/01-2017/12/31:
You can roll over unspent budgets to next period with `--cumulative`: You can roll over unspent budgets to next period with `--cumulative`:
```shell ```cli
$ hledger balance -M --budget --cumulative $ hledger balance -M --budget --cumulative
Budget performance in 2017/11/01-2017/12/31: Budget performance in 2017/11/01-2017/12/31:
@ -639,7 +639,7 @@ day of 2020-01-15:
expenses:food $400 expenses:food $400
assets:checking assets:checking
``` ```
```shell ```cli
$ hledger bal expenses --budget $ hledger bal expenses --budget
Budget performance in 2020-01-15: Budget performance in 2020-01-15:
@ -654,7 +654,7 @@ To avoid this, specify the budget report's period, or at least the start date,
with `-b`/`-e`/`-p`/`date:`, to ensure it includes the budget goal transactions with `-b`/`-e`/`-p`/`date:`, to ensure it includes the budget goal transactions
(periodic transactions) that you want. Eg, adding `-b 2020/1/1` to the above: (periodic transactions) that you want. Eg, adding `-b 2020/1/1` to the above:
```shell ```cli
$ hledger bal expenses --budget -b 2020/1/1 $ hledger bal expenses --budget -b 2020/1/1
Budget performance in 2020-01-01..2020-01-15: Budget performance in 2020-01-01..2020-01-15:
@ -713,7 +713,7 @@ For example, let's consider these transactions:
As you can see, we have transactions in `expenses:personal:electronics:upgrades` and `expenses:personal:train tickets`, and since both of these accounts are without explicitly defined budget, As you can see, we have transactions in `expenses:personal:electronics:upgrades` and `expenses:personal:train tickets`, and since both of these accounts are without explicitly defined budget,
these transactions would be counted towards budgets of `expenses:personal:electronics` and `expenses:personal` accordingly: these transactions would be counted towards budgets of `expenses:personal:electronics` and `expenses:personal` accordingly:
```shell ```cli
$ hledger balance --budget -M $ hledger balance --budget -M
Budget performance in 2019/01: Budget performance in 2019/01:
@ -728,7 +728,7 @@ Budget performance in 2019/01:
``` ```
And with `--empty`, we can get a better picture of budget allocation and consumption: And with `--empty`, we can get a better picture of budget allocation and consumption:
```shell ```cli
$ hledger balance --budget -M --empty $ hledger balance --budget -M --empty
Budget performance in 2019/01: Budget performance in 2019/01:
@ -749,7 +749,7 @@ Budget performance in 2019/01:
The budget report evaluates periodic transaction rules to generate special "goal transactions", The budget report evaluates periodic transaction rules to generate special "goal transactions",
which generate the goal amounts for each account in each report subperiod. which generate the goal amounts for each account in each report subperiod.
When troubleshooting, you can use `print --forecast` to show these as forecasted transactions: When troubleshooting, you can use `print --forecast` to show these as forecasted transactions:
```shell ```cli
$ hledger print --forecast=BUDGETREPORTPERIOD tag:generated $ hledger print --forecast=BUDGETREPORTPERIOD tag:generated
``` ```
@ -826,7 +826,7 @@ note only CSV output supports all of them:
Examples: Examples:
- Wide layout. With many commodities, reports can be very wide: - Wide layout. With many commodities, reports can be very wide:
```shell ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -838,7 +838,7 @@ Examples:
``` ```
- Limited wide layout. A width limit reduces the width, but some commodities will be hidden: - Limited wide layout. A width limit reduces the width, but some commodities will be hidden:
```shell ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32 $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -850,7 +850,7 @@ Examples:
``` ```
- Tall layout. Each commodity gets a new line (may be different in each column), and account names are repeated: - Tall layout. Each commodity gets a new line (may be different in each column), and account names are repeated:
```shell ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -870,7 +870,7 @@ Examples:
``` ```
- Bare layout. Commodity symbols are kept in one column, each commodity gets its own report row, account names are repeated: - Bare layout. Commodity symbols are kept in one column, each commodity gets its own report row, account names are repeated:
```shell ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -891,7 +891,7 @@ Examples:
- Bare layout also affects [CSV output](#output-format), - Bare layout also affects [CSV output](#output-format),
which is useful for producing data that is easier to consume, eg for making charts: which is useful for producing data that is easier to consume, eg for making charts:
```shell ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare
"account","commodity","balance" "account","commodity","balance"
"Assets:US:ETrade","GLD","70.00" "Assets:US:ETrade","GLD","70.00"
@ -917,7 +917,7 @@ Examples:
This is the easiest kind of data for other software to consume. This is the easiest kind of data for other software to consume.
Here's how it looks: Here's how it looks:
```shell ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -Y -O csv --layout=tidy $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -Y -O csv --layout=tidy
"account","period","start_date","end_date","commodity","value" "account","period","start_date","end_date","commodity","value"
"Assets:US:ETrade","2012","2012-01-01","2012-12-31","GLD","0" "Assets:US:ETrade","2012","2012-01-01","2012-12-31","GLD","0"

View File

@ -17,7 +17,7 @@ Or if no such accounts are declared, it shows top-level accounts named
Example: Example:
```shell ```cli
$ hledger balancesheet $ hledger balancesheet
Balance Sheet Balance Sheet

View File

@ -15,7 +15,7 @@ Or if no such accounts are declared, it shows top-level accounts named
`asset`, `liability` or `equity` (case insensitive, plurals allowed) and their subaccounts. `asset`, `liability` or `equity` (case insensitive, plurals allowed) and their subaccounts.
Example: Example:
```shell ```cli
$ hledger balancesheetequity $ hledger balancesheetequity
Balance Sheet With Equity Balance Sheet With Equity

View File

@ -23,7 +23,7 @@ More precisely: all accounts matching this case insensitive regular expression:
and their subaccounts. and their subaccounts.
An example cashflow report: An example cashflow report:
```shell ```cli
$ hledger cashflow $ hledger cashflow
Cashflow Statement Cashflow Statement

View File

@ -13,7 +13,7 @@ Specify their names (or a prefix) as argument(s).
Some examples: Some examples:
```shell ```cli
hledger check # basic checks hledger check # basic checks
hledger check -s # basic + strict checks hledger check -s # basic + strict checks
hledger check ordereddates payees # basic + two other checks hledger check ordereddates payees # basic + two other checks

View File

@ -106,14 +106,14 @@ in effect splitting the multi-day transaction into two single-day transactions:
Record 2022's revenues/expenses as retained earnings on 2022-12-31, Record 2022's revenues/expenses as retained earnings on 2022-12-31,
appending the generated transaction to the journal: appending the generated transaction to the journal:
```shell ```cli
$ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal $ hledger close --retain -f 2022.journal -p 2022 >> 2022.journal
``` ```
Note 2022's income statement will now show only zeroes, Note 2022's income statement will now show only zeroes,
because revenues and expenses have been moved entirely to equity. because revenues and expenses have been moved entirely to equity.
To see them again, you could exclude the retain transaction: To see them again, you could exclude the retain transaction:
```shell ```cli
$ hledger -f 2022.journal is not:desc:'retain earnings' $ hledger -f 2022.journal is not:desc:'retain earnings'
``` ```
@ -121,7 +121,7 @@ $ hledger -f 2022.journal is not:desc:'retain earnings'
Close assets/liabilities/equity on 2022-12-31 and re-open them on 2023-01-01: Close assets/liabilities/equity on 2022-12-31 and re-open them on 2023-01-01:
```shell ```cli
$ hledger close --migrate -f 2022.journal -p 2022 $ hledger close --migrate -f 2022.journal -p 2022
# copy/paste the closing transaction to the end of 2022.journal # copy/paste the closing transaction to the end of 2022.journal
# copy/paste the opening transaction to the start of 2023.journal # copy/paste the opening transaction to the start of 2023.journal
@ -130,7 +130,7 @@ $ hledger close --migrate -f 2022.journal -p 2022
<!-- <!--
Or, you can automate more by generating one transaction at a time: Or, you can automate more by generating one transaction at a time:
```shell ```cli
$ hledger close --close -f 2022.journal -p 2022 >> 2023.journal # do this one first $ hledger close --close -f 2022.journal -p 2022 >> 2023.journal # do this one first
$ hledger close --open -f 2022.journal -p 2022 >> 2022.journal $ hledger close --open -f 2022.journal -p 2022 >> 2022.journal
``` ```
@ -139,7 +139,7 @@ $ hledger close --open -f 2022.journal -p 2022 >> 2022.journal
Now 2022's balance sheet will show only zeroes, indicating a balanced accounting equation. Now 2022's balance sheet will show only zeroes, indicating a balanced accounting equation.
([Unless](/investments.html#a-more-correct-entry) you are using @/@@ notation - in that case, try adding --infer-equity.) ([Unless](/investments.html#a-more-correct-entry) you are using @/@@ notation - in that case, try adding --infer-equity.)
To see the end-of-year balances again, you could exclude the closing transaction: To see the end-of-year balances again, you could exclude the closing transaction:
```shell ```cli
$ hledger -f 2022.journal bs not:desc:'closing balances' $ hledger -f 2022.journal bs not:desc:'closing balances'
``` ```
@ -187,12 +187,12 @@ include 2023.journal
The `clopen:` tag can exclude all but the first opening transaction. The `clopen:` tag can exclude all but the first opening transaction.
To show a clean multi-year checking register: To show a clean multi-year checking register:
```shell ```cli
$ hledger -f all.journal areg checking not:tag:clopen $ hledger -f all.journal areg checking not:tag:clopen
``` ```
And the year values allow more precision. And the year values allow more precision.
To show 2022's year-end balance sheet: To show 2022's year-end balance sheet:
```shell ```cli
$ hledger -f all.journal bs -e2023 not:tag:clopen=2023 $ hledger -f all.journal bs -e2023 not:tag:clopen=2023
``` ```

View File

@ -35,14 +35,14 @@ Examples:
Checking Checking
``` ```
```shell ```cli
$ hledger codes $ hledger codes
123 123
124 124
126 126
``` ```
```shell ```cli
$ hledger codes -E $ hledger codes -E
123 123
124 124

View File

@ -22,7 +22,7 @@ SPACE to pause/unpause, . to step forward (while paused),
CTRL-c quit. CTRL-c quit.
Examples: Examples:
```shell ```cli
$ hledger demo # list available demos $ hledger demo # list available demos
$ hledger demo 1 # play the first demo at default speed (2x) $ hledger demo 1 # play the first demo at default speed (2x)
$ hledger demo install -s4 # play the "install" demo at 4x speed $ hledger demo install -s4 # play the "install" demo at 4x speed

View File

@ -9,7 +9,7 @@ in alphabetic order.
You can add a query to select a subset of transactions. You can add a query to select a subset of transactions.
Example: Example:
```shell ```cli
$ hledger descriptions $ hledger descriptions
Store Name Store Name
Gas Station | Petrol Gas Station | Petrol

View File

@ -20,7 +20,7 @@ _FLAGS
Examples: Examples:
```shell ```cli
$ hledger diff -f $LEDGER_FILE -f bank.csv assets:bank:giro $ hledger diff -f $LEDGER_FILE -f bank.csv assets:bank:giro
These transactions are in the first file only: These transactions are in the first file only:

View File

@ -22,7 +22,7 @@ on mac you will likely have info 4.8, and should consider installing a newer ver
eg with `brew install texinfo` (#1770). eg with `brew install texinfo` (#1770).
Examples Examples
```shell ```cli
$ hledger help --help # show how the help command works $ hledger help --help # show how the help command works
$ hledger help # show the hledger manual with info, man or $PAGER $ hledger help # show the hledger manual with info, man or $PAGER
$ hledger help journal # show the journal topic in the hledger manual $ hledger help journal # show the journal topic in the hledger manual

View File

@ -73,13 +73,13 @@ to the terminal, without updating your journal or state files.
The output is valid journal format, like the print command, so you can re-parse it. The output is valid journal format, like the print command, so you can re-parse it.
Eg, to see any importable transactions which CSV rules have not categorised: Eg, to see any importable transactions which CSV rules have not categorised:
```shell ```cli
$ hledger import --dry bank.csv | hledger -f- -I print unknown $ hledger import --dry bank.csv | hledger -f- -I print unknown
``` ```
or (live updating): or (live updating):
```shell ```cli
$ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown' $ ls bank.csv* | entr bash -c 'echo ====; hledger import --dry bank.csv | hledger -f- -I print unknown'
``` ```
@ -99,7 +99,7 @@ As a result, importing entries with balance assignments
will probably generate incorrect posting amounts. will probably generate incorrect posting amounts.
To avoid this problem, use print instead of import: To avoid this problem, use print instead of import:
```shell ```cli
$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE $ hledger print IMPORTFILE [--new] >> $LEDGER_FILE
``` ```

View File

@ -16,7 +16,7 @@ Or if no such accounts are declared, it shows top-level accounts named
`revenue` or `income` or `expense` (case insensitive, plurals allowed) and their subaccounts. `revenue` or `income` or `expense` (case insensitive, plurals allowed) and their subaccounts.
Example: Example:
```shell ```cli
$ hledger incomestatement $ hledger incomestatement
Income Statement Income Statement

View File

@ -11,7 +11,7 @@ The note is the part of the transaction description after a | character
(or if there is no |, the whole description). (or if there is no |, the whole description).
Example: Example:
```shell ```cli
$ hledger notes $ hledger notes
Petrol Petrol
Snacks Snacks

View File

@ -16,7 +16,7 @@ You can add query arguments to select a subset of transactions. This implies --u
Example: Example:
```shell ```cli
$ hledger payees $ hledger payees
Store Name Store Name
Gas Station Gas Station

View File

@ -15,7 +15,7 @@ the directives and inter-transaction comments.
Eg: Eg:
```shell ```cli
$ hledger print -f examples/sample.journal date:200806 $ hledger print -f examples/sample.journal date:200806
2008/06/01 gift 2008/06/01 gift
assets:bank:checking $1 assets:bank:checking $1
@ -80,7 +80,7 @@ and you can process it again with a second hledger command.
This can be useful for certain kinds of search This can be useful for certain kinds of search
(though the same can be achieved with `expr:` queries now): (though the same can be achieved with `expr:` queries now):
```shell ```cli
# Show running total of food expenses paid from cash. # Show running total of food expenses paid from cash.
# -f- reads from stdin. -I/--ignore-assertions is sometimes needed. # -f- reads from stdin. -I/--ignore-assertions is sometimes needed.
$ hledger print assets:cash | hledger -f- -I reg expenses:food $ hledger print assets:cash | hledger -f- -I reg expenses:food
@ -140,7 +140,7 @@ Some limitations:
Here's an example of print's CSV output: Here's an example of print's CSV output:
```shell ```cli
$ hledger print -Ocsv $ hledger print -Ocsv
"txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment" "txnidx","date","date2","status","code","description","comment","account","amount","commodity","credit","debit","posting-status","posting-comment"
"1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","","" "1","2008/01/01","","","","income","","assets:bank:checking","1","$","","1","",""

View File

@ -18,7 +18,7 @@ commodity).
It is typically used with a [query](#queries) selecting a It is typically used with a [query](#queries) selecting a
particular account, to see that account's activity: particular account, to see that account's activity:
```shell ```cli
$ hledger register checking $ hledger register checking
2008/01/01 income assets:bank:checking $1 $1 2008/01/01 income assets:bank:checking $1 $1
2008/06/01 gift assets:bank:checking $1 $2 2008/06/01 gift assets:bank:checking $1 $2
@ -37,7 +37,7 @@ The `--historical`/`-H` flag adds the balance from any undisplayed
prior postings to the running total. This is useful when you want to prior postings to the running total. This is useful when you want to
see only recent activity, with a historically accurate running balance: see only recent activity, with a historically accurate running balance:
```shell ```cli
$ hledger register checking -b 2008/6 --historical $ hledger register checking -b 2008/6 --historical
2008/06/01 gift assets:bank:checking $1 $2 2008/06/01 gift assets:bank:checking $1 $2
2008/06/02 save assets:bank:checking $-1 $1 2008/06/02 save assets:bank:checking $-1 $1
@ -61,14 +61,14 @@ displayed as negative numbers.
It's also useful to show postings on the checking account together with the It's also useful to show postings on the checking account together with the
related account: related account:
```shell ```cli
$ hledger register --related --invert assets:checking $ hledger register --related --invert assets:checking
``` ```
With a [reporting interval](#reporting-interval), register shows With a [reporting interval](#reporting-interval), register shows
summary postings, one per interval, aggregating the postings to each account: summary postings, one per interval, aggregating the postings to each account:
```shell ```cli
$ hledger register --monthly income $ hledger register --monthly income
2008/01 income:salary $-1 $-1 2008/01 income:salary $-1 $-1
2008/06 income:gifts $-1 $-2 2008/06 income:gifts $-1 $-2
@ -76,7 +76,7 @@ $ hledger register --monthly income
Periods with no activity, and summary postings with a zero amount, are Periods with no activity, and summary postings with a zero amount, are
not shown by default; use the `--empty`/`-E` flag to see them: not shown by default; use the `--empty`/`-E` flag to see them:
```shell ```cli
$ hledger register --monthly income -E $ hledger register --monthly income -E
2008/01 income:salary $-1 $-1 2008/01 income:salary $-1 $-1
2008/02 0 $-1 2008/02 0 $-1
@ -95,7 +95,7 @@ $ hledger register --monthly income -E
Often, you'll want to see just one line per interval. Often, you'll want to see just one line per interval.
The `--depth` option helps with this, causing subaccounts to be aggregated: The `--depth` option helps with this, causing subaccounts to be aggregated:
```shell ```cli
$ hledger register --monthly assets --depth 1h $ hledger register --monthly assets --depth 1h
2008/01 assets $1 $1 2008/01 assets $1 $1
2008/06 assets $-1 0 2008/06 assets $-1 0
@ -129,7 +129,7 @@ date (10) description (D) account (W-41-D) amount (12) balance (12)
DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA DDDDDDDDDD dddddddddddddddddddd aaaaaaaaaaaaaaaaaaa AAAAAAAAAAAA AAAAAAAAAAAA
``` ```
and some examples: and some examples:
```shell ```cli
$ hledger reg # use terminal width (or 80 on windows) $ hledger reg # use terminal width (or 80 on windows)
$ hledger reg -w 100 # use width 100 $ hledger reg -w 100 # use width 100
$ COLUMNS=100 hledger reg # set with one-time environment variable $ COLUMNS=100 hledger reg # set with one-time environment variable

View File

@ -11,7 +11,7 @@ but adds one or more specified postings to any transactions matching QUERY.
The posting amounts can be fixed, or a multiplier of the existing transaction's first posting amount. The posting amounts can be fixed, or a multiplier of the existing transaction's first posting amount.
Examples: Examples:
```shell ```cli
$ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100' $ hledger-rewrite.hs ^income --add-posting '(liabilities:tax) *.33 ; income tax' --add-posting '(reserve:gifts) $100'
$ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"' $ hledger-rewrite.hs expenses:gifts --add-posting '(reserve:gifts) *-1"'
$ hledger-rewrite.hs -f rewrites.hledger $ hledger-rewrite.hs -f rewrites.hledger
@ -28,7 +28,7 @@ and the two spaces between account and amount.
More: More:
```shell ```cli
$ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ... $ hledger rewrite -- [QUERY] --add-posting "ACCT AMTEXPR" ...
$ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33' $ hledger rewrite -- ^income --add-posting '(liabilities:tax) *.33'
$ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"' $ hledger rewrite -- expenses:gifts --add-posting '(budget:gifts) *-1"'
@ -49,7 +49,7 @@ During the run this tool will execute so called
found in any journal it process. I.e instead of specifying this operations in found in any journal it process. I.e instead of specifying this operations in
command line you can put them in a journal file. command line you can put them in a journal file.
```shell ```cli
$ rewrite-rules.journal $ rewrite-rules.journal
``` ```
@ -68,13 +68,13 @@ Note that `'='` (equality symbol) that is used instead of date in transactions
you usually write. It indicates the query by which you want to match the you usually write. It indicates the query by which you want to match the
posting to add new ones. posting to add new ones.
```shell ```cli
$ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal $ hledger rewrite -- -f input.journal -f rewrite-rules.journal > rewritten-tidy-output.journal
``` ```
This is something similar to the commands pipeline: This is something similar to the commands pipeline:
```shell ```cli
$ hledger rewrite -- -f input.journal '^income' --add-posting '(liabilities:tax) *.33' \ $ hledger rewrite -- -f input.journal '^income' --add-posting '(liabilities:tax) *.33' \
| hledger rewrite -- -f - expenses:gifts --add-posting 'budget:gifts *-1' \ | hledger rewrite -- -f - expenses:gifts --add-posting 'budget:gifts *-1' \
--add-posting 'assets:budget *1' \ --add-posting 'assets:budget *1' \
@ -89,7 +89,7 @@ important. You can re-use result of previously added postings.
To use this tool for batch modification of your journal files you may find To use this tool for batch modification of your journal files you may find
useful output in form of unified diff. useful output in form of unified diff.
```shell ```cli
$ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33' $ hledger rewrite -- --diff -f examples/sample.journal '^income' --add-posting '(liabilities:tax) *.33'
``` ```

View File

@ -45,13 +45,13 @@ Note that `--inv` and `--pnl`'s argument is a query, and queries could have seve
To indicate that all search terms form single command-line argument, you will need to put them in quotes (see [Special characters](https://hledger.org/hledger.html#special-characters)): To indicate that all search terms form single command-line argument, you will need to put them in quotes (see [Special characters](https://hledger.org/hledger.html#special-characters)):
```shell ```cli
$ hledger roi --inv 'term1 term2 term3 ...' $ hledger roi --inv 'term1 term2 term3 ...'
``` ```
If any query terms contain spaces themselves, you will need an extra level of nested quoting, eg: If any query terms contain spaces themselves, you will need an extra level of nested quoting, eg:
```shell ```cli
$ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'" $ hledger roi --inv="'Assets:Test 1'" --pnl="'Equity:Unrealized Profit and Loss'"
``` ```

View File

@ -16,7 +16,7 @@ run time is similar to that of a single-column balance report.
Example: Example:
```shell ```cli
$ hledger stats -f examples/1000x1000x10.journal $ hledger stats -f examples/1000x1000x10.journal
Main file : /Users/simon/src/hledger/examples/1000x1000x10.journal Main file : /Users/simon/src/hledger/examples/1000x1000x10.journal
Included files : Included files :

View File

@ -16,7 +16,7 @@ as a bug!
This command also accepts tasty test runner options, written after a This command also accepts tasty test runner options, written after a
-- (double hyphen). Eg to run only the tests in Hledger.Data.Amount, -- (double hyphen). Eg to run only the tests in Hledger.Data.Amount,
with ANSI colour codes disabled: with ANSI colour codes disabled:
```shell ```cli
$ hledger test -- -pData.Amount --color=never $ hledger test -- -pData.Amount --color=never
``` ```
For help on these, see https://github.com/feuerbach/tasty#options For help on these, see https://github.com/feuerbach/tasty#options

View File

@ -98,7 +98,7 @@ in [PART 5: COMMON TASKS](#part-5-common-tasks).
hledger reads one or more data files, each time you run it. hledger reads one or more data files, each time you run it.
You can specify a file with `-f`, like so You can specify a file with `-f`, like so
```shell ```cli
$ hledger -f FILE print $ hledger -f FILE print
``` ```
@ -135,7 +135,7 @@ so as to either read successfully or to show relevant error messages.
You can also force a specific reader/format by prefixing the file path with the format and a colon. You can also force a specific reader/format by prefixing the file path with the format and a colon.
Eg, to read a .dat file as csv format: Eg, to read a .dat file as csv format:
```shell ```cli
$ hledger -f csv:/some/csv-file.dat stats $ hledger -f csv:/some/csv-file.dat stats
``` ```
@ -143,13 +143,13 @@ $ hledger -f csv:/some/csv-file.dat stats
The file name `-` means standard input: The file name `-` means standard input:
```shell ```cli
$ cat FILE | hledger -f- print $ cat FILE | hledger -f- print
``` ```
If reading non-journal data in this way, you'll need to add a file format prefix, like: If reading non-journal data in this way, you'll need to add a file format prefix, like:
```shell ```cli
$ echo 'i 2009/13/1 08:00:00' | hledger print -f timeclock:- $ echo 'i 2009/13/1 08:00:00' | hledger print -f timeclock:-
``` ```
@ -272,13 +272,13 @@ spaces, `<`, `>`, `(`, `)`, `|`, `$` and `\` - should be
enclosing them in single or double quotes, or by writing a backslash enclosing them in single or double quotes, or by writing a backslash
before them. Eg to match an account name containing a space: before them. Eg to match an account name containing a space:
```shell ```cli
$ hledger register 'credit card' $ hledger register 'credit card'
``` ```
or: or:
```shell ```cli
$ hledger register credit\ card $ hledger register credit\ card
``` ```
@ -296,13 +296,13 @@ writing backslashes before them, but since backslash is typically also
a shell metacharacter, both shell-escaping and regex-escaping will be a shell metacharacter, both shell-escaping and regex-escaping will be
needed. Eg to match a literal `$` sign while using the bash shell: needed. Eg to match a literal `$` sign while using the bash shell:
```shell ```cli
$ hledger balance cur:'\$' $ hledger balance cur:'\$'
``` ```
or: or:
```shell ```cli
$ hledger balance cur:\\$ $ hledger balance cur:\\$
``` ```
@ -314,13 +314,13 @@ arguments intended for by the add-on command, so those need an extra
level of shell-escaping. Eg to match a literal `$` sign while using level of shell-escaping. Eg to match a literal `$` sign while using
the bash shell and running an add-on command (`ui`): the bash shell and running an add-on command (`ui`):
```shell ```cli
$ hledger ui cur:'\\$' $ hledger ui cur:'\\$'
``` ```
or: or:
```shell ```cli
$ hledger ui cur:\\\\$ $ hledger ui cur:\\\\$
``` ```
@ -335,7 +335,7 @@ If you wondered why *four* backslashes, perhaps this helps:
Or, you can avoid the extra escaping by running the add-on executable directly: Or, you can avoid the extra escaping by running the add-on executable directly:
```shell ```cli
$ hledger-ui cur:\\$ $ hledger-ui cur:\\$
``` ```
@ -514,14 +514,14 @@ you would at the command prompt.
hledger commands send their output to the terminal by default. hledger commands send their output to the terminal by default.
You can of course redirect this, eg into a file, using standard shell syntax: You can of course redirect this, eg into a file, using standard shell syntax:
```shell ```cli
$ hledger print > foo.txt $ hledger print > foo.txt
``` ```
Some commands (print, register, stats, the balance commands) also Some commands (print, register, stats, the balance commands) also
provide the `-o/--output-file` option, which does the same thing provide the `-o/--output-file` option, which does the same thing
without needing the shell. Eg: without needing the shell. Eg:
```shell ```cli
$ hledger print -o foo.txt $ hledger print -o foo.txt
$ hledger print -o - # write to stdout (the default) $ hledger print -o - # write to stdout (the default)
``` ```
@ -573,17 +573,17 @@ Here are those commands and the formats currently supported:
--> -->
The output format is selected by the `-O/--output-format=FMT` option: The output format is selected by the `-O/--output-format=FMT` option:
```shell ```cli
$ hledger print -O csv # print CSV on stdout $ hledger print -O csv # print CSV on stdout
``` ```
or by the filename extension of an output file specified with the `-o/--output-file=FILE.FMT` option: or by the filename extension of an output file specified with the `-o/--output-file=FILE.FMT` option:
```shell ```cli
$ hledger balancesheet -o foo.csv # write CSV to foo.csv $ hledger balancesheet -o foo.csv # write CSV to foo.csv
``` ```
The `-O` option can be combined with `-o` to override the file extension, if needed: The `-O` option can be combined with `-o` to override the file extension, if needed:
```shell ```cli
$ hledger balancesheet -o foo.txt -O csv # write CSV to foo.txt $ hledger balancesheet -o foo.txt -O csv # write CSV to foo.txt
``` ```
@ -658,7 +658,7 @@ by the [`print`](#print) command, which are always displayed with all
decimal digits). decimal digits).
For example, the following will force dollar amounts to be displayed as shown: For example, the following will force dollar amounts to be displayed as shown:
```shell ```cli
$ hledger print -c '$1.000,0' $ hledger print -c '$1.000,0'
``` ```
@ -710,7 +710,7 @@ Typically you would start with 1 and increase until you are seeing enough.
Debug output goes to stderr, and is not affected by `-o/--output-file` (unless you redirect stderr to stdout, eg: `2>&1`). Debug output goes to stderr, and is not affected by `-o/--output-file` (unless you redirect stderr to stdout, eg: `2>&1`).
It will be interleaved with normal output, which can help reveal when parts of the code are evaluated. It will be interleaved with normal output, which can help reveal when parts of the code are evaluated.
To capture debug output in a log file instead, you can usually redirect stderr, eg: To capture debug output in a log file instead, you can usually redirect stderr, eg:
```shell ```cli
hledger bal --debug=3 2>hledger.log hledger bal --debug=3 2>hledger.log
``` ```
@ -982,12 +982,12 @@ be reported on 6/1 for easy bank reconciliation:
assets:checking ; bank cleared it on monday, date:6/1 assets:checking ; bank cleared it on monday, date:6/1
``` ```
```shell ```cli
$ hledger -f t.j register food $ hledger -f t.j register food
2015-05-30 expenses:food $10 $10 2015-05-30 expenses:food $10 $10
``` ```
```shell ```cli
$ hledger -f t.j register checking $ hledger -f t.j register checking
2015-06-01 assets:checking $-10 $-10 2015-06-01 assets:checking $-10 $-10
``` ```
@ -1785,7 +1785,7 @@ account expenses
``` ```
those accounts will be displayed in declaration order: those accounts will be displayed in declaration order:
```shell ```cli
$ hledger accounts -1 $ hledger accounts -1
assets assets
liabilities liabilities
@ -1994,7 +1994,7 @@ In case of trouble, adding `--debug=6` to the command line will show which alias
As explained at [Directives and multiple files](#directives-and-multiple-files), As explained at [Directives and multiple files](#directives-and-multiple-files),
`alias` directives do not affect parent or sibling files. Eg in this command, `alias` directives do not affect parent or sibling files. Eg in this command,
```shell ```cli
hledger -f a.aliases -f b.journal hledger -f a.aliases -f b.journal
``` ```
account aliases defined in a.aliases will not affect b.journal. account aliases defined in a.aliases will not affect b.journal.
@ -2040,7 +2040,7 @@ For example, you could erase all account names:
a:aa 1 a:aa 1
b b
``` ```
```shell ```cli
$ hledger print --alias '/.*/=' $ hledger print --alias '/.*/='
2021-01-01 2021-01-01
1 1
@ -2056,7 +2056,7 @@ that would give a different journal when reparsed:
old 1 old 1
other other
``` ```
```shell ```cli
$ hledger print --alias old="new USD" | hledger -f- print $ hledger print --alias old="new USD" | hledger -f- print
2021-01-01 2021-01-01
new USD 1 new USD 1
@ -2087,7 +2087,7 @@ it tries and fails to infer a type for "foo".
If you are using account aliases and the [`type:` query](#queries) is not matching accounts as you expect, If you are using account aliases and the [`type:` query](#queries) is not matching accounts as you expect,
try troubleshooting with the accounts command, eg something like: try troubleshooting with the accounts command, eg something like:
```shell ```cli
$ hledger accounts --alias assets=bassetts type:a $ hledger accounts --alias assets=bassetts type:a
``` ```
@ -2420,7 +2420,7 @@ Some examples:
expenses:gifts $20 expenses:gifts $20
assets:checking assets:checking
``` ```
```shell ```cli
$ hledger print --auto $ hledger print --auto
2017-12-01 2017-12-01
expenses:food $10 expenses:food $10
@ -2800,7 +2800,7 @@ skip 1
fields date, description, , amount fields date, description, , amount
date-format %d/%m/%Y date-format %d/%m/%Y
``` ```
```shell ```cli
$ hledger print -f basic.csv $ hledger print -f basic.csv
2019-11-12 Foo 2019-11-12 Foo
expenses:unknown 10.23 expenses:unknown 10.23
@ -2955,7 +2955,7 @@ In either of these cases, hledger will do a time-zone-aware conversion,
localising the CSV date-times to your current system time zone. localising the CSV date-times to your current system time zone.
If you prefer to localise to some other time zone, eg for reproducibility, If you prefer to localise to some other time zone, eg for reproducibility,
you can (on unix at least) set the output timezone with the TZ environment variable, eg: you can (on unix at least) set the output timezone with the TZ environment variable, eg:
```shell ```cli
$ TZ=-1000 hledger print -f foo.csv # or TZ=-1000 hledger import foo.csv $ TZ=-1000 hledger print -f foo.csv # or TZ=-1000 hledger import foo.csv
``` ```
@ -3448,7 +3448,7 @@ Some tips:
It's a good idea to get rapid feedback while creating/troubleshooting CSV rules. It's a good idea to get rapid feedback while creating/troubleshooting CSV rules.
Here's a good way, using entr from [eradman.com/entrproject](https://eradman.com/entrproject): Here's a good way, using entr from [eradman.com/entrproject](https://eradman.com/entrproject):
```shell ```cli
$ ls foo.csv* | entr bash -c 'echo ----; hledger -f foo.csv print desc:SOMEDESC' $ ls foo.csv* | entr bash -c 'echo ----; hledger -f foo.csv print desc:SOMEDESC'
``` ```
A desc: query (eg) is used to select just one, or a few, transactions of interest. A desc: query (eg) is used to select just one, or a few, transactions of interest.
@ -3480,7 +3480,7 @@ filename extension.
When reading files with the "wrong" extension, you can ensure the CSV reader When reading files with the "wrong" extension, you can ensure the CSV reader
(and the default field separator) by prefixing the file path with `csv:`, `ssv:` or `tsv:`: (and the default field separator) by prefixing the file path with `csv:`, `ssv:` or `tsv:`:
Eg: Eg:
```shell ```cli
$ hledger -f ssv:foo.dat print $ hledger -f ssv:foo.dat print
``` ```
@ -3538,7 +3538,7 @@ There is one exception: balance assertions, if you have generated
them, will not be checked, since normally these will work only when them, will not be checked, since normally these will work only when
the CSV data is part of the main journal. If you do need to check the CSV data is part of the main journal. If you do need to check
balance assertions generated from CSV right away, pipe into another hledger: balance assertions generated from CSV right away, pipe into another hledger:
```shell ```cli
$ hledger -f file.csv print | hledger -f- print $ hledger -f file.csv print | hledger -f- print
``` ```
@ -3554,7 +3554,7 @@ journal. It is idempotent, so you don't have to remember how many
times you ran it or with which version of the CSV. times you ran it or with which version of the CSV.
(It keeps state in a hidden `.latest.FILE.csv` file.) (It keeps state in a hidden `.latest.FILE.csv` file.)
This is the easiest way to import CSV data. Eg: This is the easiest way to import CSV data. Eg:
```shell ```cli
# download the latest CSV files, then run this command. # download the latest CSV files, then run this command.
# Note, no -f flags needed here. # Note, no -f flags needed here.
$ hledger import *.csv [--dry] $ hledger import *.csv [--dry]
@ -3833,7 +3833,7 @@ currency EUR
# set the base account for all txns # set the base account for all txns
account1 assets:bank:boi:checking account1 assets:bank:boi:checking
``` ```
```shell ```cli
$ hledger -f bankofireland-checking.csv print $ hledger -f bankofireland-checking.csv print
2012-12-07 LODGMENT 529898 2012-12-07 LODGMENT 529898
assets:bank:boi:checking EUR10.0 = EUR131.2 assets:bank:boi:checking EUR10.0 = EUR131.2
@ -3866,7 +3866,7 @@ description %Notes
account1 assets:coinbase:cc account1 assets:coinbase:cc
amount %Quantity_Transacted %Asset @ %Spot_Price_at_Transaction %Spot_Price_Currency amount %Quantity_Transacted %Asset @ %Spot_Price_at_Transaction %Spot_Price_Currency
``` ```
```shell ```cli
$ hledger print -f coinbase.csv $ hledger print -f coinbase.csv
2021-12-30 Received 100.00 USDC from an external account 2021-12-30 Received 100.00 USDC from an external account
assets:coinbase:cc 100 USDC @ 0.740000 GBP assets:coinbase:cc 100 USDC @ 0.740000 GBP
@ -3920,7 +3920,7 @@ if %fees [1-9]
account3 expenses:fees account3 expenses:fees
amount3 %fees amount3 %fees
``` ```
```shell ```cli
$ hledger -f amazon-orders.csv print $ hledger -f amazon-orders.csv print
2012-07-29 (16000000000000DGLNJPI1P9B8DKPVHL) To Foo. ; status:Completed 2012-07-29 (16000000000000DGLNJPI1P9B8DKPVHL) To Foo. ; status:Completed
assets:amazon assets:amazon
@ -4059,7 +4059,7 @@ if Google
``` ```
```shell ```cli
$ hledger -f paypal-custom.csv print $ hledger -f paypal-custom.csv print
2019-10-01 (60P57143A8206782E) Calm Radio MONTHLY - $1 for the first 2 Months: Me - Order 99309. Item total: $1.00 USD first 2 months, then $6.99 / Month ; itemid:, fromemail:simon@joyful.com, toemail:memberships@calmradio.com, time:03:46:20, type:Subscription Payment, status:Completed 2019-10-01 (60P57143A8206782E) Calm Radio MONTHLY - $1 for the first 2 Months: Me - Order 99309. Item total: $1.00 USD first 2 months, then $6.99 / Month ; itemid:, fromemail:simon@joyful.com, toemail:memberships@calmradio.com, time:03:46:20, type:Subscription Payment, status:Completed
assets:online:paypal $-6.99 = $-6.99 assets:online:paypal $-6.99 = $-6.99
@ -4137,7 +4137,7 @@ Here is a
[sample.timeclock](https://raw.github.com/simonmichael/hledger/master/examples/sample.timeclock) to [sample.timeclock](https://raw.github.com/simonmichael/hledger/master/examples/sample.timeclock) to
download and some queries to try: download and some queries to try:
```shell ```cli
$ hledger -f sample.timeclock balance # current time balances $ hledger -f sample.timeclock balance # current time balances
$ hledger -f sample.timeclock register -p 2009/3 # sessions in march 2009 $ hledger -f sample.timeclock register -p 2009/3 # sessions in march 2009
$ hledger -f sample.timeclock register -p weekly --depth 1 --empty # time summary by week $ hledger -f sample.timeclock register -p weekly --depth 1 --empty # time summary by week
@ -4181,7 +4181,7 @@ hledger reads this as a transaction on this day with three
No commodity symbol is assumed, but we typically interpret it as hours. No commodity symbol is assumed, but we typically interpret it as hours.
```shell ```cli
$ hledger -f a.timedot print # .timedot file extension (or timedot: prefix) is required $ hledger -f a.timedot print # .timedot file extension (or timedot: prefix) is required
2023-05-01 * 2023-05-01 *
(hom:errands) 2.00 ; two hours (hom:errands) 2.00 ; two hours
@ -4263,7 +4263,7 @@ biz:research .
inc:client1 .... .... inc:client1 .... ....
biz:research . biz:research .
``` ```
```shell ```cli
$ hledger -f a.timedot print date:2016/2/2 $ hledger -f a.timedot print date:2016/2/2
2016-02-02 * 2016-02-02 *
(inc:client1) 2.00 (inc:client1) 2.00
@ -4271,7 +4271,7 @@ $ hledger -f a.timedot print date:2016/2/2
2016-02-02 * 2016-02-02 *
(biz:research) 0.25 (biz:research) 0.25
``` ```
```shell ```cli
$ hledger -f a.timedot bal --daily --tree $ hledger -f a.timedot bal --daily --tree
Balance changes in 2016-02-01-2016-02-03: Balance changes in 2016-02-01-2016-02-03:
@ -4304,13 +4304,13 @@ $ hledger -f a.timedot print
(work:adm) 0.25 ; t:s (work:adm) 0.25 ; t:s
``` ```
```shell ```cli
$ hledger -f a.timedot bal $ hledger -f a.timedot bal
1.75 work:adm 1.75 work:adm
-------------------- --------------------
1.75 1.75
``` ```
```shell ```cli
$ hledger -f a.timedot bal --pivot t $ hledger -f a.timedot bal --pivot t
1.00 c 1.00 c
0.50 e 0.50 e
@ -4347,7 +4347,7 @@ Using `.` as account name separator:
fos.hledger.timedot 4h fos.hledger.timedot 4h
fos.ledger .. fos.ledger ..
``` ```
```shell ```cli
$ hledger -f a.timedot --alias '/\./=:' bal -t $ hledger -f a.timedot --alias '/\./=:' bal -t
4.50 fos 4.50 fos
4.00 hledger:timedot 4.00 hledger:timedot
@ -4359,7 +4359,7 @@ $ hledger -f a.timedot --alias '/\./=:' bal -t
<!-- <!--
Another sample, download from Another sample, download from
https://raw.github.com/simonmichael/hledger/master/examples/sample.timedot and try: https://raw.github.com/simonmichael/hledger/master/examples/sample.timedot and try:
```shell ```cli
$ hledger -f sample.timedot balance # current time balances $ hledger -f sample.timedot balance # current time balances
$ hledger -f sample.timedot register -p 2009/3 # sessions in march 2009 $ hledger -f sample.timedot register -p 2009/3 # sessions in march 2009
$ hledger -f sample.timedot register -p weekly --depth 1 --empty # time summary by week $ hledger -f sample.timedot register -p weekly --depth 1 --empty # time summary by week
@ -4404,7 +4404,7 @@ commodity A 1,000.00
(a) A 1000 (a) A 1000
``` ```
```shell ```cli
$ hledger print $ hledger print
2023-01-02 2023-01-02
(a) A 1,000. (a) A 1,000.
@ -4414,7 +4414,7 @@ $ hledger print
If this is a problem (eg when exporting to [Ledger](/ledger.md#ledger-to-ledger)), If this is a problem (eg when exporting to [Ledger](/ledger.md#ledger-to-ledger)),
you can avoid it by disabling digit group marks, eg with you can avoid it by disabling digit group marks, eg with
[-c/--commodity](#commodity-styles): [-c/--commodity](#commodity-styles):
```shell ```cli
$ hledger print -c 'A 1000.00' $ hledger print -c 'A 1000.00'
2023-01-02 2023-01-02
(a) A 1000 (a) A 1000
@ -4423,7 +4423,7 @@ $ hledger print -c 'A 1000.00'
or by forcing print to show decimal digits in all amounts, eg with or by forcing print to show decimal digits in all amounts, eg with
[--round](#print-amount-style): [--round](#print-amount-style):
```shell ```cli
$ hledger print --round=soft $ hledger print --round=soft
2023-01-02 2023-01-02
(a) A 1,000.00 (a) A 1,000.00
@ -4696,13 +4696,13 @@ Examples:
Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always): Show historical balances at end of the 15th day of each month (N is an end date, exclusive as always):
```shell ```cli
$ hledger balance -H -p "every 16th day" $ hledger balance -H -p "every 16th day"
``` ```
Group postings from the start of wednesday to end of the following tuesday (N is both (inclusive) start date and (exclusive) end date): Group postings from the start of wednesday to end of the following tuesday (N is both (inclusive) start date and (exclusive) end date):
```shell ```cli
$ hledger register checking -p "every 3rd day of week" $ hledger register checking -p "every 3rd day of week"
``` ```
@ -4940,7 +4940,7 @@ Some examples:
income:dues -2 EUR ; member: John Doe, kind: Lifetime income:dues -2 EUR ; member: John Doe, kind: Lifetime
``` ```
Normal balance report showing account names: Normal balance report showing account names:
```shell ```cli
$ hledger balance $ hledger balance
2 EUR assets:bank account 2 EUR assets:bank account
-2 EUR income:dues -2 EUR income:dues
@ -4948,7 +4948,7 @@ $ hledger balance
0 0
``` ```
Pivoted balance report, using member: tag values instead: Pivoted balance report, using member: tag values instead:
```shell ```cli
$ hledger balance --pivot member $ hledger balance --pivot member
2 EUR 2 EUR
-2 EUR John Doe -2 EUR John Doe
@ -4956,21 +4956,21 @@ $ hledger balance --pivot member
0 0
``` ```
One way to show only amounts with a member: value (using a [query](#queries)): One way to show only amounts with a member: value (using a [query](#queries)):
```shell ```cli
$ hledger balance --pivot member tag:member=. $ hledger balance --pivot member tag:member=.
-2 EUR John Doe -2 EUR John Doe
-------------------- --------------------
-2 EUR -2 EUR
``` ```
Another way (the acct: query matches against the pivoted "account name"): Another way (the acct: query matches against the pivoted "account name"):
```shell ```cli
$ hledger balance --pivot member acct:. $ hledger balance --pivot member acct:.
-2 EUR John Doe -2 EUR John Doe
-------------------- --------------------
-2 EUR -2 EUR
``` ```
Hierarchical reports can be generated with multiple pivots: Hierarchical reports can be generated with multiple pivots:
```shell ```cli
$ hledger balance Income:Dues --pivot kind:member $ hledger balance Income:Dues --pivot kind:member
-2 EUR Lifetime:John Doe -2 EUR Lifetime:John Doe
-------------------- --------------------
@ -5247,7 +5247,7 @@ and `hledger bse`'s total will not be disrupted.
And, hledger can still infer the cost for cost reporting, And, hledger can still infer the cost for cost reporting,
but it's not done by default - you must add the `--infer-costs` flag like so: but it's not done by default - you must add the `--infer-costs` flag like so:
```shell ```cli
$ hledger print --infer-costs $ hledger print --infer-costs
2022-01-01 one hundred euros purchased at $1.35 each 2022-01-01 one hundred euros purchased at $1.35 each
assets:dollars $-135 @@ €100 assets:dollars $-135 @@ €100
@ -5256,7 +5256,7 @@ $ hledger print --infer-costs
equity:conversion €-100 equity:conversion €-100
``` ```
```shell ```cli
$ hledger bal --infer-costs -B $ hledger bal --infer-costs -B
€-100 assets:dollars €-100 assets:dollars
€100 assets:euros €100 assets:euros
@ -5286,7 +5286,7 @@ Eg:
assets:euros €100 @ $1.35 assets:euros €100 @ $1.35
``` ```
```shell ```cli
$ hledger print --infer-equity $ hledger print --infer-equity
2022-01-01 2022-01-01
assets:dollars $-135 assets:dollars $-135
@ -5316,7 +5316,7 @@ revealing the per-unit cost basis, and providing more flexibility in how you wri
``` ```
All the other variants above can (usually) be rewritten to this final form with: All the other variants above can (usually) be rewritten to this final form with:
```shell ```cli
$ hledger print -x --infer-costs --infer-equity $ hledger print -x --infer-costs --infer-equity
``` ```
@ -5507,7 +5507,7 @@ For reference, here is the current behaviour, since hledger 1.25.
All of the transactions above are considered balanced (and on each day, the two transactions are considered equivalent). All of the transactions above are considered balanced (and on each day, the two transactions are considered equivalent).
Here are the market prices inferred for B: Here are the market prices inferred for B:
```shell ```cli
$ hledger -f- --infer-market-prices prices $ hledger -f- --infer-market-prices prices
P 2022-01-01 B A 1 P 2022-01-01 B A 1
P 2022-01-01 B A 1.0 P 2022-01-01 B A 1.0
@ -5565,17 +5565,17 @@ P 2016/11/01 € $1.10
P 2016/12/21 € $1.03 P 2016/12/21 € $1.03
``` ```
How many euros do I have ? How many euros do I have ?
```shell ```cli
$ hledger -f t.j bal -N euros $ hledger -f t.j bal -N euros
€100 assets:euros €100 assets:euros
``` ```
What are they worth at end of nov 3 ? What are they worth at end of nov 3 ?
```shell ```cli
$ hledger -f t.j bal -N euros -V -e 2016/11/4 $ hledger -f t.j bal -N euros -V -e 2016/11/4
$110.00 assets:euros $110.00 assets:euros
``` ```
What are they worth after 2016/12/21 ? (no report end date specified, defaults to today) What are they worth after 2016/12/21 ? (no report end date specified, defaults to today)
```shell ```cli
$ hledger -f t.j bal -N euros -V $ hledger -f t.j bal -N euros -V
$103.00 assets:euros $103.00 assets:euros
``` ```
@ -5637,7 +5637,7 @@ P 2000-04-01 A 4 B
``` ```
Show the cost of each posting: Show the cost of each posting:
```shell ```cli
$ hledger -f- print --cost $ hledger -f- print --cost
2000-01-01 2000-01-01
(a) 5 B (a) 5 B
@ -5651,7 +5651,7 @@ $ hledger -f- print --cost
``` ```
Show the value as of the last day of the report period (2000-02-29): Show the value as of the last day of the report period (2000-02-29):
```shell ```cli
$ hledger -f- print --value=end date:2000/01-2000/03 $ hledger -f- print --value=end date:2000/01-2000/03
2000-01-01 2000-01-01
(a) 2 B (a) 2 B
@ -5662,7 +5662,7 @@ $ hledger -f- print --value=end date:2000/01-2000/03
``` ```
With no report period specified, that shows the value as of the last day of the journal (2000-03-01): With no report period specified, that shows the value as of the last day of the journal (2000-03-01):
```shell ```cli
$ hledger -f- print --value=end $ hledger -f- print --value=end
2000-01-01 2000-01-01
(a) 3 B (a) 3 B
@ -5676,7 +5676,7 @@ $ hledger -f- print --value=end
``` ```
Show the current value (the 2000-04-01 price is still in effect today): Show the current value (the 2000-04-01 price is still in effect today):
```shell ```cli
$ hledger -f- print --value=now $ hledger -f- print --value=now
2000-01-01 2000-01-01
(a) 4 B (a) 4 B
@ -5690,7 +5690,7 @@ $ hledger -f- print --value=now
``` ```
Show the value on 2000/01/15: Show the value on 2000/01/15:
```shell ```cli
$ hledger -f- print --value=2000-01-15 $ hledger -f- print --value=2000-01-15
2000-01-01 2000-01-01
(a) 1 B (a) 1 B
@ -5881,7 +5881,7 @@ Here are some quick examples of how to do some basic tasks with hledger.
Here's how to list commands and view options and command docs: Here's how to list commands and view options and command docs:
```shell ```cli
$ hledger # show available commands $ hledger # show available commands
$ hledger --help # show common options $ hledger --help # show common options
$ hledger CMD --help # show CMD's options, common options and CMD's documentation $ hledger CMD --help # show CMD's options, common options and CMD's documentation
@ -5889,7 +5889,7 @@ $ hledger CMD --help # show CMD's options, common options and CMD's document
You can also view your hledger version's manual in several formats You can also view your hledger version's manual in several formats
by using the [help command](#help). Eg: by using the [help command](#help). Eg:
```shell ```cli
$ hledger help # show the hledger manual with info, man or $PAGER (best available) $ hledger help # show the hledger manual with info, man or $PAGER (best available)
$ hledger help journal # show the journal topic in the hledger manual $ hledger help journal # show the journal topic in the hledger manual
$ hledger help --help # find out more about the help command $ hledger help --help # find out more about the help command
@ -5914,7 +5914,7 @@ here are some tips that might help:
## Starting a journal file ## Starting a journal file
hledger looks for your accounting data in a journal file, `$HOME/.hledger.journal` by default: hledger looks for your accounting data in a journal file, `$HOME/.hledger.journal` by default:
```shell ```cli
$ hledger stats $ hledger stats
The hledger journal file "/Users/simon/.hledger.journal" was not found. The hledger journal file "/Users/simon/.hledger.journal" was not found.
Please create it first, eg with "hledger add" or a text editor. Please create it first, eg with "hledger add" or a text editor.
@ -5924,7 +5924,7 @@ Or, specify an existing journal file with -f or LEDGER_FILE.
You can override this by setting the `LEDGER_FILE` environment variable (see below). You can override this by setting the `LEDGER_FILE` environment variable (see below).
It's a good practice to keep this important file under version control, It's a good practice to keep this important file under version control,
and to start a new file each year. So you could do something like this: and to start a new file each year. So you could do something like this:
```shell ```cli
$ mkdir ~/finance $ mkdir ~/finance
$ cd ~/finance $ cd ~/finance
$ git init $ git init
@ -5951,7 +5951,7 @@ Market prices : 0 ()
How to set `LEDGER_FILE` permanently depends on your setup: How to set `LEDGER_FILE` permanently depends on your setup:
On unix and mac, running these commands in the terminal will work for many people; adapt as needed: On unix and mac, running these commands in the terminal will work for many people; adapt as needed:
```shell ```cli
$ echo 'export LEDGER_FILE=~/finance/2023.journal' >> ~/.profile $ echo 'export LEDGER_FILE=~/finance/2023.journal' >> ~/.profile
$ source ~/.profile $ source ~/.profile
``` ```
@ -5972,7 +5972,7 @@ and then run `killall Dock` in a terminal window (or restart the machine).
On Windows, see <https://www.java.com/en/download/help/path.html>, On Windows, see <https://www.java.com/en/download/help/path.html>,
or try running these commands in a powershell window or try running these commands in a powershell window
(let us know if it persists across a reboot, and if you need to be an Administrator): (let us know if it persists across a reboot, and if you need to be an Administrator):
```shell ```cli
> CD > CD
> MKDIR finance > MKDIR finance
> SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal" > SETX LEDGER_FILE "C:\Users\USERNAME\finance\2023.journal"
@ -6013,7 +6013,7 @@ balances on this date. Here are two ways to do it:
The = amounts are optional balance assertions, providing extra error checking. The = amounts are optional balance assertions, providing extra error checking.
- The second way: run `hledger add` and follow the prompts to record a similar transaction: - The second way: run `hledger add` and follow the prompts to record a similar transaction:
```shell ```cli
$ hledger add $ hledger add
Adding transactions to journal file /Users/simon/finance/2023.journal Adding transactions to journal file /Users/simon/finance/2023.journal
Any command line arguments will be used as defaults. Any command line arguments will be used as defaults.
@ -6050,7 +6050,7 @@ balances on this date. Here are two ways to do it:
``` ```
If you're using version control, this could be a good time to commit the journal. Eg: If you're using version control, this could be a good time to commit the journal. Eg:
```shell ```cli
$ git commit -m 'initial balances' 2023.journal $ git commit -m 'initial balances' 2023.journal
``` ```
@ -6126,7 +6126,7 @@ that, by adding the `*` marker.
Eg in the paycheck transaction above, insert `*` between `2023-01-15` and `paycheck` Eg in the paycheck transaction above, insert `*` between `2023-01-15` and `paycheck`
If you're using version control, this can be another good time to commit: If you're using version control, this can be another good time to commit:
```shell ```cli
$ git commit -m 'txns' 2023.journal $ git commit -m 'txns' 2023.journal
``` ```
@ -6135,7 +6135,7 @@ $ git commit -m 'txns' 2023.journal
Here are some basic reports. Here are some basic reports.
Show all transactions: Show all transactions:
```shell ```cli
$ hledger print $ hledger print
2023-01-01 * opening balances 2023-01-01 * opening balances
assets:bank:checking $1000 assets:bank:checking $1000
@ -6163,7 +6163,7 @@ $ hledger print
``` ```
Show account names, and their hierarchy: Show account names, and their hierarchy:
```shell ```cli
$ hledger accounts --tree $ hledger accounts --tree
assets assets
bank bank
@ -6183,7 +6183,7 @@ liabilities
``` ```
Show all account totals: Show all account totals:
```shell ```cli
$ hledger balance $ hledger balance
$4105 assets $4105 assets
$4000 bank $4000 bank
@ -6203,7 +6203,7 @@ $ hledger balance
``` ```
Show only asset and liability balances, as a flat list, limited to depth 2: Show only asset and liability balances, as a flat list, limited to depth 2:
```shell ```cli
$ hledger bal assets liabilities -2 $ hledger bal assets liabilities -2
$4000 assets:bank $4000 assets:bank
$105 assets:cash $105 assets:cash
@ -6213,7 +6213,7 @@ $ hledger bal assets liabilities -2
``` ```
Show the same thing without negative numbers, formatted as a simple balance sheet: Show the same thing without negative numbers, formatted as a simple balance sheet:
```shell ```cli
$ hledger bs -2 $ hledger bs -2
Balance Sheet 2023-01-16 Balance Sheet 2023-01-16
@ -6238,7 +6238,7 @@ The final total is your "net worth" on the end date.
(Or use `bse` for a full balance sheet with equity.) (Or use `bse` for a full balance sheet with equity.)
Show income and expense totals, formatted as an income statement: Show income and expense totals, formatted as an income statement:
```shell ```cli
hledger is hledger is
Income Statement 2023-01-01-2023-01-16 Income Statement 2023-01-01-2023-01-16
@ -6263,7 +6263,7 @@ Income Statement 2023-01-01-2023-01-16
The final total is your net income during this period. The final total is your net income during this period.
Show transactions affecting your wallet, with running total: Show transactions affecting your wallet, with running total:
```shell ```cli
$ hledger register cash $ hledger register cash
2023-01-01 opening balances assets:cash $100 $100 2023-01-01 opening balances assets:cash $100 $100
2023-01-10 gift received assets:cash $20 $120 2023-01-10 gift received assets:cash $20 $120
@ -6272,7 +6272,7 @@ $ hledger register cash
``` ```
Show weekly posting counts as a bar chart: Show weekly posting counts as a bar chart:
```shell ```cli
$ hledger activity -W $ hledger activity -W
2019-12-30 ***** 2019-12-30 *****
2023-01-06 **** 2023-01-06 ****
@ -6343,13 +6343,13 @@ Then select it by setting the `LANG` environment variable.
Note, exact spelling and capitalisation of the locale name may be important: Note, exact spelling and capitalisation of the locale name may be important:
Here's one common way to configure this permanently for your shell: Here's one common way to configure this permanently for your shell:
```shell ```cli
$ echo "export LANG=en_US.utf8" >>~/.profile $ echo "export LANG=en_US.utf8" >>~/.profile
# close and re-open terminal window # close and re-open terminal window
``` ```
If you are using Nix (not NixOS) for GHC and Hledger, you might need to set the `LOCALE_ARCHIVE` variable: If you are using Nix (not NixOS) for GHC and Hledger, you might need to set the `LOCALE_ARCHIVE` variable:
```shell ```cli
$ echo "export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive" >>~/.profile $ echo "export LOCALE_ARCHIVE=${glibcLocales}/lib/locale/locale-archive" >>~/.profile
# close and re-open terminal window # close and re-open terminal window
``` ```