diff --git a/README.md b/README.md index 1c4e3b3f4..3f9da0653 100644 --- a/README.md +++ b/README.md @@ -592,6 +592,8 @@ In addition, uv respects the following environment variables: - `MACOSX_DEPLOYMENT_TARGET`: Used with `--python-platform macos` and related variants to set the deployment target (i.e., the minimum supported macOS version). Defaults to `12.0`, the least-recent non-EOL macOS version at time of writing. +- `NO_COLOR`: Disable colors. Takes precedence over `FORCE_COLOR`. See [no-color.org](https://no-color.org). +- `FORCE_COLOR`: Enforce colors regardless of TTY support. See [force-color.org](https://force-color.org). ## Versioning diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 23aaf7f10..45363735a 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -46,8 +46,20 @@ impl GlobalSettings { Self { quiet: args.quiet, verbose: args.verbose, - color: if args.no_color { + color: if args.no_color + || std::env::var_os("NO_COLOR") + .filter(|v| !v.is_empty()) + .is_some() + { ColorChoice::Never + } else if std::env::var_os("FORCE_COLOR") + .filter(|v| !v.is_empty()) + .is_some() + || std::env::var_os("CLICOLOR_FORCE") + .filter(|v| !v.is_empty()) + .is_some() + { + ColorChoice::Always } else { args.color },