Skip to content

Commit b72b0f7

Browse files
rkitoverdscho
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]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9028643 commit b72b0f7

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
@@ -2794,9 +2794,20 @@ static void setup_windows_environment(void)
27942794
convert_slashes(tmp);
27952795
}
27962796

2797-
/* simulate TERM to enable auto-color (see color.c) */
2798-
if (!getenv("TERM"))
2799-
setenv("TERM", "cygwin", 1);
2797+
2798+
/*
2799+
* Make sure TERM is set up correctly to enable auto-color
2800+
* (see color.c .) Use "cygwin" for older OS releases which
2801+
* works correctly with MSYS2 utilities on older consoles.
2802+
*/
2803+
if (!getenv("TERM")) {
2804+
if ((GetVersion() >> 16) < 15063)
2805+
setenv("TERM", "cygwin", 0);
2806+
else {
2807+
setenv("TERM", "xterm-256color", 0);
2808+
setenv("COLORTERM", "truecolor", 0);
2809+
}
2810+
}
28002811

28012812
/* calculate HOME if not set */
28022813
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)