Skip to content

Commit

Permalink
mingw: set $env:TERM=xterm-256color for newer OSes
Browse files Browse the repository at this point in the history
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.

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 <rkitover@gmail.com>
  • Loading branch information
dscho authored and rkitover committed Mar 25, 2022
1 parent 158a30d commit f634351
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3361,9 +3361,20 @@ static void setup_windows_environment(void)
convert_slashes(tmp);
}

/* simulate TERM to enable auto-color (see color.c) */
if (!getenv("TERM"))
setenv("TERM", "cygwin", 1);

/*
* Make sure TERM is set up correctly to enable auto-color
* (see color.c .) Use "cygwin" for older OS releases which
* works correctly with MSYS2 utilities on older consoles.
*/
if (!getenv("TERM")) {
if ((GetVersion() >> 16) < 15063)
setenv("TERM", "cygwin", 0);
else {
setenv("TERM", "xterm-256color", 0);
setenv("COLORTERM", "truecolor", 0);
}
}

/* calculate HOME if not set */
if (!getenv("HOME")) {
Expand Down

0 comments on commit f634351

Please sign in to comment.