Skip to content

Commit 68365c8

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 2c4d077 commit 68365c8

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
@@ -2639,9 +2639,20 @@ static void setup_windows_environment(void)
26392639
convert_slashes(tmp);
26402640
}
26412641

2642-
/* simulate TERM to enable auto-color (see color.c) */
2643-
if (!getenv("TERM"))
2644-
setenv("TERM", "cygwin", 1);
2642+
2643+
/*
2644+
* Make sure TERM is set up correctly to enable auto-color
2645+
* (see color.c .) Use "cygwin" for older OS releases which
2646+
* works correctly with MSYS2 utilities on older consoles.
2647+
*/
2648+
if (!getenv("TERM")) {
2649+
if ((GetVersion() >> 16) < 15063)
2650+
setenv("TERM", "cygwin", 0);
2651+
else {
2652+
setenv("TERM", "xterm-256color", 0);
2653+
setenv("COLORTERM", "truecolor", 0);
2654+
}
2655+
}
26452656

26462657
/* calculate HOME if not set */
26472658
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)