Disable colored output on a dumb terminal (#3552)

Enable colored output by default only when the TERM environment variable
is set to a value other than dumb, as git and grep do, so that users no
longer need to pass -M or set NO_COLOR on terminals that cannot display
escape sequences. Colored output is now disabled not only for TERM=dumb
but also when TERM is unset or empty. The -C option still enables colors
in all these cases. On Windows, colored output is still decided by
ANSICON and the console mode, and TERM is not checked.
This commit is contained in:
Dmitri Vereshchagin authored and GitHub committed 2026-10-16 21:50:47 +09:00
1 parent 6b53f80311
commit 633ae6058a
4 files changed
+44 -9

No files matched your search

Generated
+1 -1
View File
@@ -115,7 +115,7 @@ Output the fields of each object with the keys in sorted order\.
\fB\-\-color\-output\fR / \fB\-C\fR and \fB\-\-monochrome\-output\fR / \fB\-M\fR:
.
.IP
By default, jq outputs colored JSON if writing to a terminal\. You can force it to produce color even if writing to a pipe or a file using \fB\-C\fR, and disable color with \fB\-M\fR\. When the \fBNO_COLOR\fR environment variable is not empty, jq disables colored output by default, but you can enable it by \fB\-C\fR\.
By default, jq outputs colored JSON if writing to a terminal\. You can force it to produce color even if writing to a pipe or a file using \fB\-C\fR, and disable color with \fB\-M\fR\. When the \fBNO_COLOR\fR environment variable is not empty, or the \fBTERM\fR environment variable is unset, empty, or set to \fBdumb\fR, jq disables colored output by default, but you can enable it by \fB\-C\fR\.
.
.IP
Colors can be configured with the \fBJQ_COLORS\fR environment variable (see below)\.