Skip to content

Commit

Permalink
fix: detect if running from vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
gkampitakis committed Nov 4, 2023
1 parent 875f35a commit 6da74e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/colors/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ var NOCOLOR = isNoColor()

func isNoColor() bool {
// https://no-color.org (with any value)
_, ok := os.LookupEnv("NO_COLOR")
return ok
_, noColor := os.LookupEnv("NO_COLOR")
// hacky way but should be good enough to support diff on vscode output panel
term := strings.ToLower(os.Getenv("_"))
return noColor || strings.Contains(term, "visual") || strings.Contains(term, "code")
}

func Sprint(color, s string) string {
Expand Down

0 comments on commit 6da74e0

Please sign in to comment.