Skip to content

Commit c852a21

Browse files
rkitoverGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
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]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f446da5 commit c852a21

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

compat/mingw.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -2820,9 +2820,20 @@ static void setup_windows_environment(void)
28202820
convert_slashes(tmp);
28212821
}
28222822

2823-
/* simulate TERM to enable auto-color (see color.c) */
2824-
if (!getenv("TERM"))
2825-
setenv("TERM", "cygwin", 1);
2823+
2824+
/*
2825+
* Make sure TERM is set up correctly to enable auto-color
2826+
* (see color.c .) Use "cygwin" for older OS releases which
2827+
* works correctly with MSYS2 utilities on older consoles.
2828+
*/
2829+
if (!getenv("TERM")) {
2830+
if ((GetVersion() >> 16) < 15063)
2831+
setenv("TERM", "cygwin", 0);
2832+
else {
2833+
setenv("TERM", "xterm-256color", 0);
2834+
setenv("COLORTERM", "truecolor", 0);
2835+
}
2836+
}
28262837

28272838
/* calculate HOME if not set */
28282839
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)