LinuxCommandLibrary

hledger-add

Add transactions to an hledger journal file

TLDR

Record new transactions, saving to the default journal file

$ hledger add
copy

Add transactions to 2024.journal, but also load 2023.journal for completions
$ hledger add [[-f|--file]] [path/to/2024.journal] [[-f|--file]] [path/to/2023.journal]
copy

Provide answers for the first four prompts
$ hledger add [today] '[best buy]' [expenses:supplies] '[$20]'
copy

Show add's options and documentation with $PAGER
$ hledger add [[-h|--help]]
copy

Show add's documentation with info or man if available
$ hledger help add
copy

SYNOPSIS

hledger add [OPTIONS] [DATEFMT]

PARAMETERS

-f, --file FILE
    use a different journal file

--account-lengths=N
    truncate or pad account names to N columns in prompts (default 0)

--alias=ACCT1=ACCT2
    define account alias for matching (repeatable)

--auto
    match accounts by similar name (substring/wildcard)

--today
    start with today's date as default

-h, --help
    show general help

--version
    show version info

DATEFMT
    strptime-compatible date format string for input prompts

DESCRIPTION

hledger-add is a command-line interactive tool for adding transactions to hledger plain text journals. It provides a guided, step-by-step prompt interface ideal for quick daily data entry from a terminal.

Usage begins with prompts for posting date (default today, supports period strings like '2w ago'), optional effective date, description, then one or more postings specifying payee-like description, account name(s), amounts, and optional tags/prices/balance assertions. Tab-completion suggests accounts from your journal history. Enter a blank description line to finish postings and commit, or 'x' to abort.

Supports multi-posting transactions, multiple commodities, historical prices, and complex balance checks like Assets:Checking $50 or Assets:Checking $50 @ €45. Options customize prompts, such as padding account names for alignment or using aliases/auto-matching for easier input. Integrates seamlessly with hledger's ecosystem for immediate balance checks post-entry.

Perfect for users maintaining personal or project finances in plain text, ensuring data integrity without spreadsheets. Requires a terminal supporting readline for best experience.

CAVEATS

Interactive only; no batch/script mode. Assumes QWERTY keyboard and readline support. Balance assertions must be exact or transaction fails.

PROMPT SEQUENCE

1. Posting date
2. Effective date (optional)
3. Description
4. Account & amount (repeat until blank)
5. Commit (Enter) or abort ('x')

TIPS

Use Tab for account completion. Blank account=previous. Add tags with ; or |. Check balances with hledger bal after.

HISTORY

Developed by Simon Michael as part of hledger (initial release 2008), inspired by Ledger's add command. Evolved with hledger versions, adding features like auto-completion (v0.20+), balance assertions (v1.0+), and alias support.

SEE ALSO

Copied to clipboard