Skip to content

Commit f634351

Browse files
dschorkitover
authored andcommitted
mingw: set $env:TERM=xterm-256color for newer OSes
For windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM=truecolor if unset. See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]>
1 parent 158a30d commit f634351

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

compat/mingw.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,9 +3361,20 @@ static void setup_windows_environment(void)
33613361
convert_slashes(tmp);
33623362
}
33633363

3364-
/* simulate TERM to enable auto-color (see color.c) */
3365-
if (!getenv("TERM"))
3366-
setenv("TERM", "cygwin", 1);
3364+
3365+
/*
3366+
* Make sure TERM is set up correctly to enable auto-color
3367+
* (see color.c .) Use "cygwin" for older OS releases which
3368+
* works correctly with MSYS2 utilities on older consoles.
3369+
*/
3370+
if (!getenv("TERM")) {
3371+
if ((GetVersion() >> 16) < 15063)
3372+
setenv("TERM", "cygwin", 0);
3373+
else {
3374+
setenv("TERM", "xterm-256color", 0);
3375+
setenv("COLORTERM", "truecolor", 0);
3376+
}
3377+
}
33673378

33683379
/* calculate HOME if not set */
33693380
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)