Skip to content

Commit e1865fe

Browse files
authored
feat: support FORCE_COLOR environment variable (#671)
https://force-color.org, covers NO_COLOR too. FORCE_COLOR takes precedence over NO_COLOR, as in the standard's example implementation.
1 parent ba23891 commit e1865fe

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Unconditionally enable colors if the [FORCE_COLOR](https://force-color.org) environment variable is set to a non-empty value.
13+
1014
## [3.28.0] - 2026-01-14
1115

1216
### Added

internal/core/core.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ func BuildRootCmd(conf *config.Config) cobra.Command {
3636
return err
3737
}
3838

39-
// detect desired colour output
39+
// detect desired colour output, respect https://force-color.org (FORCE_COLOR, NO_COLOR)
4040
switch {
41-
case conf.GlobalFlags.ForceColours == config.True:
41+
case conf.GlobalFlags.ForceColours == config.True || os.Getenv("FORCE_COLOR") != "":
4242
text.EnableColors()
43-
// Environment variable with US spelling to support https://no-color.org
4443
case conf.GlobalFlags.NoColours == config.True || os.Getenv("NO_COLOR") != "":
4544
text.DisableColors()
4645
case conf.GlobalFlags.OutputFormat != config.ValueOutputHuman:

0 commit comments

Comments
 (0)