Skip to content

Commit d77d995

Browse files
committed
Merge pull request #3751 from rkitover/native-term
mingw: set $env:TERM=xterm-256color for newer OSes
2 parents 9ca8b56 + f8248ab commit d77d995

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
@@ -3378,9 +3378,20 @@ static void setup_windows_environment(void)
33783378
convert_slashes(tmp);
33793379
}
33803380

3381-
/* simulate TERM to enable auto-color (see color.c) */
3382-
if (!getenv("TERM"))
3383-
setenv("TERM", "cygwin", 1);
3381+
3382+
/*
3383+
* Make sure TERM is set up correctly to enable auto-color
3384+
* (see color.c .) Use "cygwin" for older OS releases which
3385+
* works correctly with MSYS2 utilities on older consoles.
3386+
*/
3387+
if (!getenv("TERM")) {
3388+
if ((GetVersion() >> 16) < 15063)
3389+
setenv("TERM", "cygwin", 0);
3390+
else {
3391+
setenv("TERM", "xterm-256color", 0);
3392+
setenv("COLORTERM", "truecolor", 0);
3393+
}
3394+
}
33843395

33853396
/* calculate HOME if not set */
33863397
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)