8000 Detect Mintty for color support on Windows by stof · Pull Request #15915 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Detect Mintty for color support on Windows #15915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Detect Mintty for color support on Windows
Mintty is now the default terminal in GitBash, and it supports ANSI
colors without the need of ANSICON (it even supports 256 colors rather
than the 16 colors supported by ANSICON).
  • Loading branch information
stof committed Sep 26, 2015
commit dbd50c806e8d7c541d7ee07e500a8e66785ea696
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static function register($mode = false)
private static function hasColorSupport()
{
if ('\\' === DIRECTORY_SEPARATOR) {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}

return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ protected function doWrite($message, $newline)
*
* Colorization is disabled if not supported by the stream:
*
* - Windows without Ansicon and ConEmu
* - Windows without Ansicon, ConEmu or Mintty
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
*/
protected function hasColorSupport()
{
if (DIRECTORY_SEPARATOR === '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}

return function_exists('posix_isatty') && @posix_isatty($this->stream);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Dumper/CliDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ protected function supportsColors()
}

if ('\\' === DIRECTORY_SEPARATOR) {
static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'));
static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'));
} elseif (function_exists('posix_isatty')) {
$h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);
$h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'wb') : $this->outputStream;
Expand Down
0