formatting in ledger, trying to get display_total in a straight line.

68 views
Skip to first unread message

James

unread,
Jul 20, 2020, 2:00:16 PM7/20/20
to Ledger
Hi,

I am struggling with ledger formatting. I am trying to get the total amount in a straight line.

--format "\ %((depth_spacer)+(partial_account))\  %(display_total)\n%/"


I am not very good with the formatting and would appreciate if someone could help with the above so that the display_total is indented (and in a straight line).

Thanks !

Sam Tetruashvili

unread,
Jul 20, 2020, 2:25:50 PM7/20/20
to ledge...@googlegroups.com
Can you provide an example of your desired output?

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/655787e0-e603-4413-8691-71133e21a84co%40googlegroups.com.

James

unread,
Jul 20, 2020, 2:48:16 PM7/20/20
to Ledger
Yes. Absolutely,
The desired output is like in the Ledger manual example:-


When I try doing this on my machine the display totals(and percent values) are messy. They are not straight but rather squiggly. I think it has to do something with the formatting commands.

Current Output :

 Food 10.00 USD
 
Water 5.00 USD
 
Egg 2.00 USD
 
Cheese 3.00 USD



Desired Output :

 Food           10.00 USD
 
Water          5.00 USD
 
Egg              2.00 USD
 
Cheese       3.00 USD

Sam Tetruashvili

unread,
Jul 20, 2020, 5:32:23 PM7/20/20
to ledge...@googlegroups.com
I've had a similar problem and added the following to my .ledgerrc

--balance-format %(justify(scrub(display_total), 20, -1, true, color)) %(!options.flat ? depth_spacer : '')%-(ansify_if(partial_account(options.flat), cyan if color))\n%/%$1\n%/--------------------\n

The only difference here is that I print out the value of each account before the name of each account (I did this because I have some long account names). You could probably start with this and edit it to suit your needs. The justify command is how I align the display_total values printed to the terminal. Also, if you don't like the cyan color feel free to swap it with any other terminal text color (I used cyan because the default dark blue text for the account names doesn't provide enough contrast on a black terminal).



Reply all
Reply to author
Forward
0 new messages