File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,22 @@ protected function hasColorSupport(): bool
108108 return true ;
109109 }
110110
111- return 'Hyper ' === getenv ('TERM_PROGRAM ' )
111+ if ('Hyper ' === getenv ('TERM_PROGRAM ' )
112+ || false !== getenv ('COLORTERM ' )
112113 || false !== getenv ('ANSICON ' )
113114 || 'ON ' === getenv ('ConEmuANSI ' )
114- || str_starts_with ((string ) getenv ('TERM ' ), 'xterm ' );
115+ ) {
116+ return true ;
117+ }
118+
119+ $ term = (string ) getenv ('TERM ' );
120+
121+ if ('dumb ' === $ term ) {
122+ return false ;
123+ }
124+
125+ // See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
126+ return 1 === @preg_match ('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/ ' , $ term );
115127 }
116128
117129 /**
You can’t perform that action at this time.
0 commit comments