Skip to content

add NO_COLOR env variable to avoid ansi escape codes#40

Merged
sinclairtarget merged 1 commit into
sinclairtarget:masterfrom
kaffarell:master
Sep 17, 2025
Merged

add NO_COLOR env variable to avoid ansi escape codes#40
sinclairtarget merged 1 commit into
sinclairtarget:masterfrom
kaffarell:master

Conversation

@kaffarell

@kaffarell kaffarell commented Sep 12, 2025

Copy link
Copy Markdown
Contributor

Sometimes ansi escape codes cannot be rendered (e.g. when executing
inside of vim with :!git who -l), so add a evironment flag which
doesn't print ansi escape codes. Also add the --color flag to override
the environment variable.

@sinclairtarget

Copy link
Copy Markdown
Owner

Hi kaffarell, I noticed your fork and created this issue: #39

Thanks for opening the PR and for pushing for this change. I think it's a good idea. My only suggestion is that we should follow the spec linked in the issue. NO_COLOR=1 should turn off color, and instead of having a --no-color flag we'd have a --color flag to enable color.

@kaffarell kaffarell changed the title add -no-color flag to avoid ansi escape codes add NO_COLOR env variable to avoid ansi escape codes Sep 16, 2025
@kaffarell

Copy link
Copy Markdown
Contributor Author

Thanks for looking at it, updated the PR.

@sinclairtarget

sinclairtarget commented Sep 16, 2025

Copy link
Copy Markdown
Owner

Thank you! This is looking great.

One last thing: According to the spec, if NO_COLOR is set to the empty string then it looks like it's supposed to count as not being set. I observe that same behavior using bat:

$ NO_COLOR="" bat foo.go
<output is colored>

Sometimes ansi escape codes cannot be rendered (e.g. when executing
inside of vim with `:!git who -l`), so add a evironment flag which
doesn't print ansi escape codes. Also add the --color flag to override
the environment variable.
@kaffarell

Copy link
Copy Markdown
Contributor Author

Done!

@sinclairtarget

Copy link
Copy Markdown
Owner

Nice! Thank you very much for your work on this.

I may wait to push out another release until there have been a few more changes. But I'm excited to get this out eventually!

@sinclairtarget sinclairtarget merged commit aa656b0 into sinclairtarget:master Sep 17, 2025
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