Skip to content

Commit 75c11a4

Browse files
committed
Merge pull request #3751 from rkitover/native-term
mingw: set $env:TERM=xterm-256color for newer OSes
2 parents 98b1e6b + 5d37758 commit 75c11a4

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
@@ -2918,9 +2918,20 @@ static void setup_windows_environment(void)
29182918
convert_slashes(tmp);
29192919
}
29202920

2921-
/* simulate TERM to enable auto-color (see color.c) */
2922-
if (!getenv("TERM"))
2923-
setenv("TERM", "cygwin", 1);
2921+
2922+
/*
2923+
* Make sure TERM is set up correctly to enable auto-color
2924+
* (see color.c .) Use "cygwin" for older OS releases which
2925+
* works correctly with MSYS2 utilities on older consoles.
2926+
*/
2927+
if (!getenv("TERM")) {
2928+
if ((GetVersion() >> 16) < 15063)
2929+
setenv("TERM", "cygwin", 0);
2930+
else {
2931+
setenv("TERM", "xterm-256color", 0);
2932+
setenv("COLORTERM", "truecolor", 0);
2933+
}
2934+
}
29242935

29252936
/* calculate HOME if not set */
29262937
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)