@@ -61,7 +61,7 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen
61
61
}
62
62
63
63
String os = System .getProperty ("os.name" );
64
- if ( os .startsWith ("Windows" ) ) {
64
+ if ( os .startsWith ("Windows" ) && ! isCygwin () ) {
65
65
66
66
// On windows we know the console does not interpret ANSI codes..
67
67
try {
@@ -75,15 +75,15 @@ public static OutputStream wrapOutputStream(final OutputStream stream, int filen
75
75
return new AnsiOutputStream (stream );
76
76
}
77
77
78
- // We must be on some unix variant..
78
+ // We must be on some Unix variant, including Cygwin or MSYS(2) on Windows. ..
79
79
try {
80
80
// If the jansi.force property is set, then we force to output
81
81
// the ansi escapes for piping it into ansi color aware commands (e.g. less -r)
82
82
boolean forceColored = Boolean .getBoolean ("jansi.force" );
83
83
// If we can detect that stdout is not a tty.. then setup
84
84
// to strip the ANSI sequences..
85
85
int rc = isatty (fileno );
86
- if ( !forceColored && rc == 0 ) {
86
+ if ( !isCygwin () && ! forceColored && rc == 0 ) {
87
87
return new AnsiOutputStream (stream );
88
88
}
89
89
@@ -105,6 +105,11 @@ public void close() throws IOException {
105
105
};
106
106
}
107
107
108
+ private static boolean isCygwin () {
109
+ String term = System .getenv ("TERM" );
110
+ return term != null && term .equals ("xterm" );
111
+ }
112
+
108
113
/**
109
114
* If the standard out natively supports ANSI escape codes, then this just
110
115
* returns System.out, otherwise it will provide an ANSI aware PrintStream
0 commit comments