-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an alignment/width option for hledger add
#2008
Comments
0branch
added
the
A-WISH
Some kind of improvement request, hare-brained proposal, or plea.
label
Feb 25, 2023
Oh, my apologies for overlooking those. And: thanks for hledger! |
No problem. Glad you're enjoying it! |
My current workaround is to process journals with awk #!/bin/bash
# Right-align the amounts in an hledger journal
# [Ed Morton's answer](https://stackoverflow.com/a/74765525/5266640)
# Usage:
# Check it: ./align-journal.sh myjournal.j | less
# Output: ./align-journal.sh myjournal.j > myjournal.aligned.j
awk '
# Find lines with amounts to be aligned
match($0,/^( {2,4}[^ ]+) +([^;]+\y)?( *;.*)?/,a) {
# Righ-align to column 60. 42 + 16 + 2
$0 = sprintf("%-42s %16s%s", a[1], a[2], a[3])
}
{ print }
' "$@"
Should make
... all neat
Although currently this script fails to align everything. The following are left untouched:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been keeping my journal entries aligned using vim-ledger's
LedgerAlign
command, which aligns transactions on the decimal separator at a preconfigured column (default: 60).When adding transactions with
add
, however,hledger
uses the max account width for calculating alignment, meaning that entries added by the wizard are aligned internally but (typically) misaligned with prior entries.Feature request: please provide
--width=Int
/-w Int
option or something similar so that I can request that transactions are aligned consistently. If an account width exceeds this specification, its width can be used instead.The text was updated successfully, but these errors were encountered: