~soywod/pimalaya#68: 
Content is too narrow when piping stdout

Piping stdout to anything that's not the terminal, e.g.:

himalaya list --page-size=200 | tac

Prints a table that is not as wide as the terminal, but a fixed width:

(a few random examples):

200 │ ⚑ │Een … │De Uithof │24/01/2023 10:28 198 │ │Nept… │Steam │24/01/2023 18:17 164 │ │PAW … │Events │17/02/2023 09:10 134 │ │[Git… │GitHub │28/02/2023 08:20

My terminal is about 50% wider so can fit more content right now. If I don't pipe, the width is calculated automatically. Maybe --max-width=auto could be available here? I want to pipe the above command to fzf.

This issue is kind of aggravated by the fact that the FROM column is made wide enough to fit the widest sender -- even if it means leaving just four characters for the subject. I think it makes sense to split the width 50/50 between those columns, unless one of both fits in less than that.

-- Hugo

Status
RESOLVED WONT_FIX
Submitter
~whynothugo
Assigned to
No-one
Submitted
1 year, 2 months ago
Updated
1 year, 25 days ago
Labels
0:bug 2:himalaya 3:cli

~soywod 1 year, 2 months ago*

My terminal is about 50% wider so can fit more content right now. If I don't pipe, the width is calculated automatically. Maybe --max-width=auto could be available here? I want to pipe the above command to fzf.

I checked back the code and I found it a bit confusing, I refactor is needed. Regarding the API, introducing a special auto value makes sense!

This issue is kind of aggravated by the fact that the FROM column is made wide enough to fit the widest sender -- even if it means leaving just four characters for the subject. I think it makes sense to split the width 50/50 between those columns, unless one of both fits in less than that.

This is related to https://todo.sr.ht/~soywod/pimalaya/28.

~whynothugo 1 year, 2 months ago

I checked back the code and I found it a bit confusing, I refactor is needed. Regarding the API, introducing a special auto value makes sense!

Yeah, I think the current default when not-piping is already auto, so maybe modelling it that way helps keep in simple.

~soywod REPORTED WONT_FIX 1 year, 25 days ago

I dug a bit this issue, it turns out that the problem comes from the crate terminal_size. This crate returns the size of the current terminal ONLY if the current terminal is a TTY. When piping the result like in himalaya list | tac we are not in a TTY, which defaults the terminal size to 80 (hence the shrink). The auto has just no impact outside of a TTY since we cannot get information about the current terminal size. The workaround is to add a giant max width --max-width 9999 so that the content does not shrink.

Register here or Log in to comment, or comment via email.