Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  [Console] Fix color support
  • Loading branch information
fabpot committed Feb 3, 2024
2 parents 019186b + ec17108 commit 2900969
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,22 @@ protected function hasColorSupport(): bool
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');

if ('dumb' === $term) {
return false;
}

// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
return 1 === @preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
}

/**
Expand Down

0 comments on commit 2900969

Please sign in to comment.