| 1 |
repl |
| 2 |
|
| 3 |
Start an interactive prompt, where you can run any of hledger's |
| 4 |
commands. Data files are parsed just once, so the commands run faster. |
| 5 |
|
| 6 |
Flags: |
| 7 |
no command-specific flags |
| 8 |
|
| 9 |
This command is experimental and could change in the future. |
| 10 |
|
| 11 |
hledger repl starts a read-eval-print loop (REPL) where you can enter |
| 12 |
commands interactively. As with the run command, each input file (or |
| 13 |
each input file/input options combination) is parsed just once, so |
| 14 |
commands will run more quickly than if you ran them individually at the |
| 15 |
command line. |
| 16 |
|
| 17 |
Also like run, the input file(s) specified for the repl command will be |
| 18 |
the default input for all interactive commands. You can override this |
| 19 |
temporarily by specifying an -f option in particular commands. But note |
| 20 |
that commands will not see any changes made to input files (eg by add) |
| 21 |
until you exit and restart the REPL. |
| 22 |
|
| 23 |
The command syntax is the same as with run: |
| 24 |
|
| 25 |
- enter one hledger command at a time, without the usual hledger first |
| 26 |
word |
| 27 |
- empty lines and comment text from # to end of line are ignored |
| 28 |
- use single or double quotes to quote arguments when needed |
| 29 |
- type exit or quit or control-D to exit the REPL. |
| 30 |
|
| 31 |
While it is running, the REPL remembers your command history, and you |
| 32 |
can navigate in the usual ways: |
| 33 |
|
| 34 |
- Keypad or Emacs navigation keys to edit the current command line |
| 35 |
- UP/DOWN or control-P/control-N to step back/forward through history |
| 36 |
- control-R to search for a past command |
| 37 |
- TAB to complete file paths. |
| 38 |
|
| 39 |
Generally repl command lines should feel much like the normal hledger |
| 40 |
CLI, but you may find differences. repl is a little stricter; eg it |
| 41 |
requires full command names or official abbreviations (as seen in the |
| 42 |
commands list). |
| 43 |
|
| 44 |
The commands and help commands, and the command help flags (CMD --tldr, |
| 45 |
CMD -h/--help, CMD --info, CMD --man), can be useful. |
| 46 |
|
| 47 |
You can type control-C to cancel a long-running command (but only once; |
| 48 |
typing it a second time will exit the REPL). |
| 49 |
|
| 50 |
And in most shells you can type control-Z to temporarily exit to the |
| 51 |
shell (and then fg to return to the REPL). |
| 52 |
|
| 53 |
Examples |
| 54 |
|
| 55 |
Start the REPL and enter some commands: |
| 56 |
|
| 57 |
$ hledger repl |
| 58 |
Enter hledger commands. To exit, enter 'quit' or 'exit', or send EOF. |
| 59 |
% stats |
| 60 |
Main file : .../2025.journal |
| 61 |
... |
| 62 |
% stats -f 2024/2024.journal |
| 63 |
Main file : .../2024.journal |
| 64 |
... |
| 65 |
% stats |
| 66 |
Main file : .../2025.journal |
| 67 |
... |
| 68 |
|
| 69 |
or: |
| 70 |
|
| 71 |
$ hledger repl -f some.journal |
| 72 |
Enter hledger commands. To exit, enter 'quit' or 'exit', or send EOF. |
| 73 |
% bs |
| 74 |
... |
| 75 |
% print -b 'last week' |
| 76 |
... |
| 77 |
% bs -f other.journal |
| 78 |
... |