Skip to content

Commit 04c635b

Browse files
committed
mingw: set $env:TERM=xterm-256color for newer OSes
For windows builds >= 15063 set $env:TERM to xterm-256color because they have a more capable console system that supports this. Also set $env:COLORTERM=truecolor if unset. 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 1c1ff4d commit 04c635b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

compat/mingw.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,9 +3401,22 @@ static void setup_windows_environment(void)
34013401
convert_slashes(tmp);
34023402
}
34033403

3404-
/* simulate TERM to enable auto-color (see color.c) */
3405-
if (!getenv("TERM"))
3406-
setenv("TERM", "cygwin", 1);
3404+
3405+
/*
3406+
* Make sure TERM is set up correctly to enable auto-color
3407+
* (see color.c .) Use "cygwin" for older OS releases which
3408+
* works correctly with MSYS2 utilities on older consoles.
3409+
*/
3410+
if (!getenv("TERM")) {
3411+
if (windows_build() >= 15063) {
3412+
setenv("TERM", "xterm-256color", 1);
3413+
3414+
if (!getenv("COLORTERM"))
3415+
setenv("COLORTERM", "truecolor", 1);
3416+
}
3417+
else
3418+
setenv("TERM", "cygwin", 1);
3419+
}
34073420

34083421
/* calculate HOME if not set */
34093422
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)