Skip to content

Commit 4e38a61

Browse files
rkitoverGit for Windows Build Agent
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 git-for-windows#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 <rkitover@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent e2e73f3 commit 4e38a61

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

compat/mingw.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,9 +3169,20 @@ static void setup_windows_environment(void)
31693169
convert_slashes(tmp);
31703170
}
31713171

3172-
/* simulate TERM to enable auto-color (see color.c) */
3173-
if (!getenv("TERM"))
3174-
setenv("TERM", "cygwin", 1);
3172+
3173+
/*
3174+
* Make sure TERM is set up correctly to enable auto-color
3175+
* (see color.c .) Use "cygwin" for older OS releases which
3176+
* works correctly with MSYS2 utilities on older consoles.
3177+
*/
3178+
if (!getenv("TERM")) {
3179+
if ((GetVersion() >> 16) < 15063)
3180+
setenv("TERM", "cygwin", 0);
3181+
else {
3182+
setenv("TERM", "xterm-256color", 0);
3183+
setenv("COLORTERM", "truecolor", 0);
3184+
}
3185+
}
31753186

31763187
/* calculate HOME if not set */
31773188
if (!getenv("HOME")) {

0 commit comments

Comments
 (0)