pub fn colors_enabled() -> boolExpand description
Does the caller want colour at all?
Only when stdout — where every sign and highlighted fragment goes — is a
terminal (decisions ADR-0021, cli.output.no-color-off-terminal): escape
codes in a CI log, a file, or a string an agent captured are noise the
reader has to strip. Under a git hook stdout is git’s stderr, which is the
terminal when a person commits. The cursor-moving region on stderr has its
own gate, live::watching.
NO_COLOR per no-color.org: present and NON-EMPTY disables it, whatever the
value. TERM=dumb is a terminal that cannot render SGR. FORCE_COLOR
(non-empty, not 0 or false) turns colour on through a pipe, for a
caller that will render it; NO_COLOR and TERM=dumb still win.
Read once — a hook is a short-lived process and its environment does not change underneath it.