Skip to content

Commit f8248ab

Browse files
dschorkitover
authored andcommitted
mingw: $env:TERM="xterm-256color" for newer OSes
For Windows builds >= 15063 set $env:TERM to "xterm-256color" instead of "cygwin" because they have a more capable console system that supports this. Also set $env:COLORTERM="truecolor" if unset. $env:TERM is initialized so that ANSI colors in color.c work, see 29a3963 (Win32: patch Windows environment on startup, 2012-01-15). See #3629 regarding problems caused by always setting $env:TERM="cygwin". This is the same heuristic used by the Cygwin runtime. Signed-off-by: Rafael Kitover <[email protected]>
1 parent fa8edb8 commit f8248ab

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)