Skip to content

Commit a4f5d84

Browse files
committed
Merge pull request #3751 from rkitover/native-term
mingw: set $env:TERM=xterm-256color for newer OSes
2 parents 985f614 + b72b0f7 commit a4f5d84

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

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

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

0 commit comments

Comments
 (0)