Skip to content

Commit

Permalink
Don't run OSC queries on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jan 28, 2022
1 parent 89347d6 commit 8af0187
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions termenv.go
Expand Up @@ -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
}

Expand All @@ -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{}
}

Expand All @@ -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{}
}

Expand Down

0 comments on commit 8af0187

Please sign in to comment.