Disable color when not in a terminal or when the user requests it#2801
Merged
Disable color when not in a terminal or when the user requests it#2801
Conversation
Disable color output automatically when the environment indicates it is not appropriate. Previously, Console.Color was hardcoded to true regardless of context. Color is now disabled when any of the following are true: - NO_COLOR env var is set (per https://no-color.org/) - COG_NO_COLOR env var is set - TERM=dumb - stderr is not an interactive terminal (TTY) The TTY check is on stderr specifically, since that is where cog writes all its colored log output. Refs: https://clig.dev/#output, https://no-color.org/
374fc95 to
1baf057
Compare
Add a persistent --no-color flag that forces color off for all subcommands. This complements the automatic environment detection (NO_COLOR, COG_NO_COLOR, TERM=dumb, non-TTY stderr) added in the previous commit, giving users an explicit CLI escape hatch. Refs: https://clig.dev/#output, https://no-color.org/
1baf057 to
054c332
Compare
markphelps
approved these changes
Mar 4, 2026
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.
Summary
NO_COLORis set,COG_NO_COLORis set, orTERM=dumb--no-colorpersistent flag as an explicit CLI escape hatchPreviously
Console.Colorwas hardcoded totruewith no way to disable it. TheSetColor()function existed but was never called.A responsible follow-up to #2793.
What disables color
NO_COLORenv var (non-empty)COG_NO_COLORenv var (non-empty)TERM=dumb--no-colorflagThe TTY check is on stderr specifically, since that is where cog writes all its colored log output. This means piping stdout to another program still preserves colors on stderr.
References