Skip to content

Commit f208221

Browse files
committed
Merge pull request #3751 from rkitover/native-term
mingw: set $env:TERM=xterm-256color for newer OSes
2 parents d6d6824 + 68365c8 commit f208221

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
@@ -2936,9 +2936,20 @@ static void setup_windows_environment(void)
29362936
convert_slashes(tmp);
29372937
}
29382938

2939-
/* simulate TERM to enable auto-color (see color.c) */
2940-
if (!getenv("TERM"))
2941-
setenv("TERM", "cygwin", 1);
2939+
2940+
/*
2941+
* Make sure TERM is set up correctly to enable auto-color
2942+
* (see color.c .) Use "cygwin" for older OS releases which
2943+
* works correctly with MSYS2 utilities on older consoles.
2944+
*/
2945+
if (!getenv("TERM")) {
2946+
if ((GetVersion() >> 16) < 15063)
2947+
setenv("TERM", "cygwin", 0);
2948+
else {
2949+
setenv("TERM", "xterm-256color", 0);
2950+
setenv("COLORTERM", "truecolor", 0);
2951+
}
2952+
}
29422953

29432954
/* calculate HOME if not set */
29442955
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)