You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no standard way to detect which color level is supported.
881
-
The most common way to detect color support is to check the `TERM` and `COLORTERM` environment variables.
882
-
CI systems can be detected by checking for the existence of the `CI` and other specifically environment variables.
883
-
Combine that with the knowledge about which operating system the program is running on, and we have a decent enough way to detect colors.
876
+
There is no standard way to detect terminal color support.
877
+
The most common method is to check the `TERM` and `COLORTERM` environment variables, which often indicate the supported color level.
878
+
879
+
Most standard CI systems can be identified by the presence of the `CI` environment variable.
880
+
While some CI uses their own specific environment variables, they are inconsistent and not widely adopted.
881
+
882
+
883
+
Ansis provides basic support for standard CI environments by checking the commonly used `CI` environment variable.
884
+
In such cases, Ansis assumes support for at least 16 colors.
885
+
If your code uses 256-color or truecolor, Ansis automatically [fallback](#fallback) to 16 colors, or to black and white if no color support is detected.
886
+
887
+
> Ansis explicitly detects `GitHub Actions` as supporting `truecolor`, as most Ansis users rely on GitHub CI.
888
+
889
+
Combined with information about the operating system, this approach provides a practical and lightweight method for detecting color support in most environments.
0 commit comments