Skip to content

Conversation

@smemsh
Copy link
Contributor

@smemsh smemsh commented Jan 28, 2026

This patch attempts to let the user override the "not/unknown terminal" width using a standard environment variable. When stdin is not a tty, we'll default to $COLUMNS, rather than the hardcoded 80, if atoi() works on the value. If not sane or not present, defaults to 80 columns as before. This is likely to work correctly in most scenarios and not change existing behavior, because $COLUMNS would usually only be set for a terminal, and the termios determination will override the environment there.

Use case: a keybind for timew summary :day in window manager to display in a transient window. Bound action executes in a fork of the wm, which doesn't have a tty, and its stdin/out/err are /dev/null. After the recent #566, the summary output is now always 80 columns therein. So this patch gives a workaround and should have good behavior for everyone.

Please apply, thanks.

this lets the user give the terminal width instead of always defaulting
to 80 just because no terminal is detected, and should work with
terminals because termios are used first as before and 80 are fallback
if $COLUMNS no set.

Signed-off-by: Scott Mcdermott <[email protected]>
@smemsh
Copy link
Contributor Author

smemsh commented Jan 28, 2026

the opensuse build error doesn't look like mine... some packaging thing

Copy link
Member

@lauft lauft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
I will try to fix the CI issue.

@lauft lauft added this to the Next Release milestone Feb 1, 2026
@lauft lauft merged commit e41291b into GothenburgBitFactory:develop Feb 1, 2026
31 of 33 checks passed
@lauft lauft changed the title allow $COLUMNS before defaulting 80 when no tty read $COLUMNS before defaulting width 80 when no tty Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants