From 8af018736dcd6a02b767e7cb5f89759b94dc5072 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 28 Jan 2022 15:12:13 +0100 Subject: [PATCH] Don't run OSC queries on CI --- termenv.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/termenv.go b/termenv.go index 4677856..e51d129 100644 --- a/termenv.go +++ b/termenv.go @@ -22,10 +22,19 @@ const ( TrueColor ) +func isTTY(fd uintptr) bool { + ci := os.Getenv("CI") + if len(ci) > 0 { + return false + } + + return isatty.IsTerminal(fd) +} + // ColorProfile returns the supported color profile: // Ascii, ANSI, ANSI256, or TrueColor. func ColorProfile() Profile { - if !isatty.IsTerminal(os.Stdout.Fd()) { + if !isTTY(os.Stdout.Fd()) { return Ascii } @@ -34,7 +43,7 @@ func ColorProfile() Profile { // ForegroundColor returns the terminal's default foreground color. func ForegroundColor() Color { - if !isatty.IsTerminal(os.Stdout.Fd()) { + if !isTTY(os.Stdout.Fd()) { return NoColor{} } @@ -43,7 +52,7 @@ func ForegroundColor() Color { // BackgroundColor returns the terminal's default background color. func BackgroundColor() Color { - if !isatty.IsTerminal(os.Stdout.Fd()) { + if !isTTY(os.Stdout.Fd()) { return NoColor{} }