fix: use /dev/tty for width autodetect; default config width: 0 - #966
Open
HeikoSchlittermann wants to merge 1 commit into
Open
fix: use /dev/tty for width autodetect; default config width: 0#966HeikoSchlittermann wants to merge 1 commit into
HeikoSchlittermann wants to merge 1 commit into
Conversation
Author
HeikoSchlittermann
force-pushed
the
detect-tty-width
branch
from
May 30, 2026 13:06
2389263 to
5520a54
Compare
HeikoSchlittermann
force-pushed
the
detect-tty-width
branch
from
May 30, 2026 13:06
5520a54 to
ec374d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related width-autodetect fixes.
1. Prefer
/dev/ttyoveros.Stdoutfor terminal-size detection.term.GetSize(os.Stdout.Fd())fails whenever stdout isn't a TTY — e.g.glow x.md | less,glow x.md > out, or someglow <x.mdsetups — and glow silently falls back to 80 columns./dev/ttyrefers to the controlling terminal regardless of how the standard fds are wired, so it works in all those cases. Falls back to the originalterm.GetSize(os.Stdout.Fd())path when/dev/ttycan't be opened, so behaviour is a strict superset.2. Default config now ships
width: 0instead ofwidth: 80.glow configwrites a hard-coded YAML template on first run withwidth: 80, which silently overrides the documented0 = autodetectdefault (viper.SetDefault("width", 0)in main.go). The auto-generated config is therefore strictly more restrictive than no config at all. Aligning the template withSetDefaultrestores the documented behaviour.Existing users with the old config still get 80 until they edit it once; new users get autodetect out of the box.