From ed0d7cbad149a0bb1573aca5e911695449257976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Plagborg=20Bak=20S=C3=B8rensen?= Date: Mon, 6 Jul 2026 16:20:29 +0200 Subject: [PATCH] Respect $NO_COLOR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NO_COLOR is somewhat of a standard defined in https://no-color.org/. Signed-off-by: Kristoffer Plagborg Bak Sørensen --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index e7acbe2..a317548 100644 --- a/main.go +++ b/main.go @@ -63,7 +63,10 @@ func main() { case "never": shouldColor = false case "auto": - shouldColor = isatty.IsTerminal(out.Fd()) + noColorValue, noColorEnvVarSet := os.LookupEnv("NO_COLOR") + noColor := noColorEnvVarSet && noColorValue != "" + + shouldColor = isatty.IsTerminal(out.Fd()) && !noColor default: log.Err(fmt.Errorf("invalid --color %q", *colorMode)).Msg("") }