@@ -14,11 +14,18 @@ internal object TerminalDetection {
14
14
): TerminalInfo {
15
15
// intellij console is interactive, even though isatty returns false
16
16
val ij = isIntellijRunActionConsole()
17
- val inputInteractive = interactive ? : (ij || stdinInteractive())
18
- val outputInteractive = interactive ? : (ij || stdoutInteractive())
17
+
18
+ // https://github.com/mintty/mintty/issues/482
19
+ val mintty = isMinttyTerminal()
20
+
21
+ val inputInteractive = interactive ? : (ij || mintty || stdinInteractive())
22
+ val outputInteractive = interactive ? : (ij || mintty || stdoutInteractive())
23
+
19
24
val level = ansiLevel ? : ansiLevel(outputInteractive)
20
25
val ansiHyperLinks = hyperlinks ? : (outputInteractive && level != NONE && ansiHyperLinks())
26
+
21
27
val (w, h) = detectInitialSize()
28
+
22
29
return TerminalInfo (
23
30
width = width ? : w,
24
31
height = height ? : h,
@@ -45,6 +52,7 @@ internal object TerminalDetection {
45
52
return forcedColor() != NONE && (isWindowsTerminal() || when (getTermProgram()) {
46
53
" hyper" , " wezterm" -> true
47
54
" iterm.app" -> iTermVersionSupportsTruecolor()
55
+ " mintty" -> minttyVersionSupportsHyperlinks()
48
56
else -> when (getTerm()) {
49
57
" xterm-kitty" , " alacritty" -> true
50
58
else -> false
@@ -82,6 +90,7 @@ internal object TerminalDetection {
82
90
" hyper" -> return TRUECOLOR
83
91
" apple_terminal" -> return ANSI256
84
92
" iterm.app" -> return if (iTermVersionSupportsTruecolor()) TRUECOLOR else ANSI256
93
+ " mintty" -> return TRUECOLOR
85
94
" wezterm" -> return TRUECOLOR
86
95
}
87
96
@@ -161,6 +170,14 @@ internal object TerminalDetection {
161
170
return ver != null && ver >= 3
162
171
}
163
172
173
+ private fun minttyVersionSupportsHyperlinks (): Boolean {
174
+ val ver = getEnv(" TERM_PROGRAM_VERSION" )?.split(" ." )?.mapNotNull { it.toIntOrNull() }
175
+ if (ver == null || ver.size != 3 ) return false
176
+
177
+ // https://github.com/mintty/mintty/issues/823#issuecomment-473096464
178
+ return (ver[0 ] > 2 ) || (ver[0 ] == 2 && ver[1 ] > 9 ) || (ver[0 ] == 2 && ver[1 ] == 9 && ver[2 ] > 6 )
179
+ }
180
+
164
181
private fun isCI (): Boolean {
165
182
return getEnv(" CI" ) != null
166
183
}
@@ -182,4 +199,8 @@ internal object TerminalDetection {
182
199
// their terminal tab. In the latter case, the JediTerm envvar is set, in the former it's missing.
183
200
return ! isJediTerm() && runningInIdeaJavaAgent()
184
201
}
202
+
203
+ private fun isMinttyTerminal (): Boolean {
204
+ return getEnv(" TERM_PROGRAM" ) == " mintty"
205
+ }
185
206
}
0 commit comments