8000 [Console] Fix color support · symfony/symfony@f1287da · GitHub
[go: up one dir, main page]

Skip to content

Commit f1287da

Browse files
committed
[Console] Fix color support
1 parent e111a54 commit f1287da

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Console\Exception\InvalidArgumentException;
1515
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
16+
use function str_ends_with;
1617

1718
/**
1819
* StreamOutput writes the output to a given stream.
@@ -106,10 +107,18 @@ protected function hasColorSupport()
106107
return true;
107108
}
108109

109-
return 'Hyper' === getenv('TERM_PROGRAM')
110+
if ('Hyper' === getenv('TERM_PROGRAM')
111+
|| false !== getenv('COLORTERM')
110112
|| false !== getenv('ANSICON')
111113
|| 'ON' === getenv('ConEmuANSI')
112-
|| str_starts_with((string) getenv('TERM'), 'xterm');
114+
) {
115+
return true;
116+
}
117+
118+
$term = (string) getenv('TERM');
119+
120+
return str_ends_with($term, 'screen')
121+
|| str_ends_with($term, 'xterm');
113122
}
114123

115124
/**

0 commit comments

Comments
 (0)
0