fatih / color

Color package for Go (golang)
https://pkg.go.dev/github.com/fatih/color
MIT License
7.26k stars 615 forks source link

Respect $TERM #50

Closed robnagler closed 7 years ago

robnagler commented 7 years ago

It would be wonderful if you could turn off color like @mjibson did in cortesi/termlog#3. I don't develop with go, but it seems like his change is a good compromise to respect $TERM without breaking backwards compatibility:

var NoColor = !isatty.IsTerminal(os.Stdout.Fd()) || os.Getenv("TERM") == "dumb"

Anybody who sets TERM=dumb is actively trying to communicate with programs that the output is not a terminal which seems in line with the IsTerminal() test.

Please tell others about how to respect $TERM, thanks!

fatih commented 7 years ago

I think this wouldn't break anything. If you open a PR I'm happy to merge it. Thanks.