Skip to content

Commit 2ab1fac

Browse files
committed
Merge pull request #3751 from rkitover/native-term
mingw: set $env:TERM=xterm-256color for newer OSes
2 parents 213e3c2 + a1762b7 commit 2ab1fac

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
@@ -2942,9 +2942,20 @@ static void setup_windows_environment(void)
29422942
convert_slashes(tmp);
29432943
}
29442944

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

29492960
/* calculate HOME if not set */
29502961
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)