File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ enum class control { // Behaviour of rang function calls
113
113
Force = 2 // force ansi color output to non terminal streams
114
114
};
115
115
// Use rang::setControlMode to set rang control mode
116
+ // The default can be set by environment variables: https://bixense.com/clicolors/
117
+ // NO_COLOR to disable color output, CLICOLOR_FORCE to force color output
116
118
117
119
enum class winTerm { // Windows Terminal Mode
118
120
Auto = 0 , // (Default) automatically detects wheter Ansi or Native API
@@ -126,7 +128,16 @@ namespace rang_implementation {
126
128
127
129
inline std::atomic<control> &controlMode () noexcept
128
130
{
129
- static std::atomic<control> value (control::Auto);
131
+ static std::atomic<control> value = [] {
132
+ // https://bixense.com/clicolors/
133
+ if (std::getenv (" NO_COLOR" ) != nullptr ) {
134
+ return control::Off;
135
+ }
136
+ if (std::getenv (" CLICOLOR_FORCE" ) != nullptr ) {
137
+ return control::Force;
138
+ }
139
+ return control::Auto;
140
+ }();
130
141
return value;
131
142
}
132
143
You can’t perform that action at this time.
0 commit comments