ls(1): Enable colors with COLORTERM is set in the environment
COLORTERM is the de facto standard, while CLICOLOR is generally specific to FreeBSD and ls(1). PR: 230101 Submitted by: D Green <dfrg@xsmail.com> (with manpage additions by myself) Reviewed by: cem ("LGTM" in PR; pre-manpage changes) MFC after: 1 week
This commit is contained in:
+12
-2
@@ -32,7 +32,7 @@
|
|||||||
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
|
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd January 17, 2018
|
.Dd August 8, 2018
|
||||||
.Dt LS 1
|
.Dt LS 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -132,6 +132,8 @@ after each that is a
|
|||||||
Enable colorized output.
|
Enable colorized output.
|
||||||
This option is equivalent to defining
|
This option is equivalent to defining
|
||||||
.Ev CLICOLOR
|
.Ev CLICOLOR
|
||||||
|
or
|
||||||
|
.Ev COLORTERM
|
||||||
in the environment.
|
in the environment.
|
||||||
(See below.)
|
(See below.)
|
||||||
This functionality can be compiled out by removing the definition of
|
This functionality can be compiled out by removing the definition of
|
||||||
@@ -628,6 +630,10 @@ The
|
|||||||
variable still needs to reference a color capable terminal however
|
variable still needs to reference a color capable terminal however
|
||||||
otherwise it is not possible to determine which color sequences to
|
otherwise it is not possible to determine which color sequences to
|
||||||
use.
|
use.
|
||||||
|
.It Ev COLORTERM
|
||||||
|
See description for
|
||||||
|
.Ev CLICOLOR
|
||||||
|
above.
|
||||||
.It Ev COLUMNS
|
.It Ev COLUMNS
|
||||||
If this variable contains a string representing a
|
If this variable contains a string representing a
|
||||||
decimal integer, it is used as the
|
decimal integer, it is used as the
|
||||||
@@ -652,7 +658,9 @@ for more information.
|
|||||||
.It Ev LSCOLORS
|
.It Ev LSCOLORS
|
||||||
The value of this variable describes what color to use for which
|
The value of this variable describes what color to use for which
|
||||||
attribute when colors are enabled with
|
attribute when colors are enabled with
|
||||||
.Ev CLICOLOR .
|
.Ev CLICOLOR
|
||||||
|
or
|
||||||
|
.Ev COLORTERM .
|
||||||
This string is a concatenation of pairs of the format
|
This string is a concatenation of pairs of the format
|
||||||
.Ar f Ns Ar b ,
|
.Ar f Ns Ar b ,
|
||||||
where
|
where
|
||||||
@@ -759,6 +767,8 @@ option for more details.
|
|||||||
.It Ev TERM
|
.It Ev TERM
|
||||||
The
|
The
|
||||||
.Ev CLICOLOR
|
.Ev CLICOLOR
|
||||||
|
and
|
||||||
|
.Ev COLORTERM
|
||||||
functionality depends on a terminal type with color capabilities.
|
functionality depends on a terminal type with color capabilities.
|
||||||
.It Ev TZ
|
.It Ev TZ
|
||||||
The timezone to use when displaying dates.
|
The timezone to use when displaying dates.
|
||||||
|
|||||||
+1
-1
@@ -368,7 +368,7 @@ main(int argc, char *argv[])
|
|||||||
f_listdot = 1;
|
f_listdot = 1;
|
||||||
|
|
||||||
/* Enabling of colours is conditional on the environment. */
|
/* Enabling of colours is conditional on the environment. */
|
||||||
if (getenv("CLICOLOR") &&
|
if ((getenv("CLICOLOR") || getenv("COLORTERM")) &&
|
||||||
(isatty(STDOUT_FILENO) || getenv("CLICOLOR_FORCE")))
|
(isatty(STDOUT_FILENO) || getenv("CLICOLOR_FORCE")))
|
||||||
#ifdef COLORLS
|
#ifdef COLORLS
|
||||||
if (tgetent(termcapbuf, getenv("TERM")) == 1) {
|
if (tgetent(termcapbuf, getenv("TERM")) == 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user