Skip to content

Commit 5f7c8b5

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

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
@@ -3092,9 +3092,20 @@ static void setup_windows_environment(void)
30923092
convert_slashes(tmp);
30933093
}
30943094

3095-
/* simulate TERM to enable auto-color (see color.c) */
3096-
if (!getenv("TERM"))
3097-
setenv("TERM", "cygwin", 1);
3095+
3096+
/*
3097+
* Make sure TERM is set up correctly to enable auto-color
3098+
* (see color.c .) Use "cygwin" for older OS releases which
3099+
* works correctly with MSYS2 utilities on older consoles.
3100+
*/
3101+
if (!getenv("TERM")) {
3102+
if ((GetVersion() >> 16) < 15063)
3103+
setenv("TERM", "cygwin", 0);
3104+
else {
3105+
setenv("TERM", "xterm-256color", 0);
3106+
setenv("COLORTERM", "truecolor", 0);
3107+
}
3108+
}
30983109

30993110
/* calculate HOME if not set */
31003111
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)