[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dircolors: consider COLORTERM sufficient for color
From: |
Arsen Arsenović |
Subject: |
[PATCH] dircolors: consider COLORTERM sufficient for color |
Date: |
Sat, 12 Feb 2022 22:54:07 +0100 |
COLORTERM is an environment used usually to expose truecolor support in
terminal emulators. If a terminal emulator supports truecolor, it is
surely reasonable to assume it also supports 8/16/256 colors.
This implicitly supports foot, alacritty and any other truecolor
terminal emulator with unmatched $TERM.
---
Good evening,
I've noticed dircolors does not work in foot and alacritty, and on previously
raised patches about adding a TERM entry for them the concern of a nongeneric
solution was brought up. This is a valid concern, and as many terminals
(including these two) export COLORTERM to advertise 24-bit color support, it'd
appear to be a good way to pick up on color support.
src/dircolors.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/dircolors.c b/src/dircolors.c
index b8cd203..2d20486 100644
--- a/src/dircolors.c
+++ b/src/dircolors.c
@@ -243,6 +243,7 @@ dc_parse_stream (FILE *fp, char const *filename)
size_t input_line_size = 0;
char const *line;
char const *term;
+ char const *colorterm;
bool ok = true;
/* State for the parser. */
@@ -253,6 +254,14 @@ dc_parse_stream (FILE *fp, char const *filename)
if (term == NULL || *term == '\0')
term = "none";
+ /* Check for $COLORTERM */
+ colorterm = getenv ("COLORTERM");
+ if (colorterm == NULL)
+ colorterm = "";
+
+ if (*colorterm != '\0')
+ state = ST_TERMSURE;
+
while (true)
{
char *keywd, *arg;
--
2.34.1
- [PATCH] dircolors: consider COLORTERM sufficient for color,
Arsen Arsenović <=