+static void get_env_opts(Settings &args)
+{
+ // CLICOLOR is a de-facto standard option for colors <https://bixense.com/clicolors/>
+ // CLICOLOR != 0: ANSI colors are supported (auto-detection, this is the default)
+ // CLICOLOR == 0: ANSI colors are NOT supported
+ const char *clicolor = std::getenv(ENV_CLICOLOR);
+ if (clicolor && std::string(clicolor) == "0") {
+ args.set("color", "never");
+ }
+ // NO_COLOR only specifies that no color is allowed.
+ // Implemented according to <http://no-color.org/>
+ const char *no_color = std::getenv(ENV_NO_COLOR);
+ if (no_color && no_color[0]) {
+ args.set("color", "never");
+ }
+ // CLICOLOR_FORCE is another option, which should turn on colors "no matter what".
+ const char *clicolor_force = std::getenv(ENV_CLICOLOR_FORCE);
+ if (clicolor_force && std::string(clicolor_force) != "0") {
+ // should ALWAYS have colors, so we ignore tty (no "auto")
+ args.set("color", "always");
+ }
+}
+