Skip to content

Commit

Permalink
[Console] Fix color support
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Jan 31, 2024
1 parent e111a54 commit f1287da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Symfony/Component/Console/Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use function str_ends_with;

/**
* StreamOutput writes the output to a given stream.
Expand Down Expand Up @@ -106,10 +107,18 @@ protected function hasColorSupport()
return true;
}

return 'Hyper' === getenv('TERM_PROGRAM')
if ('Hyper' === getenv('TERM_PROGRAM')
|| false !== getenv('COLORTERM')
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| str_starts_with((string) getenv('TERM'), 'xterm');
) {
return true;
}

$term = (string) getenv('TERM');

return str_ends_with($term, 'screen')
|| str_ends_with($term, 'xterm');
}

/**
Expand Down

0 comments on commit f1287da

Please sign in to comment.