Jeroen De Dauw
Jeroen De Dauw

Reputation: 10918

PHPUnit color output by default IF supported

By default PHPUnit does not use colour output. One can add the --colors flag to the phpunit command or add colors="true" to the config file.

I'd like to have colors by default and hence have the setting in my config file. This is nice since I can then run phpunit rather than phpunit --colors most of the time. However I do have one place where the terminal does not support color output. When colors are enabled there, it makes the output less readable.

Is it possible to keep colors on by default and disable it for this specific terminal? There appears to be no --no-colors flag or similar. And ideally I'd not have to specify this anywhere to begin with, and be able to specify something like colors="auto", which then detects if the terminal supports ANSI colors or not.

Upvotes: 1

Views: 1531

Answers (1)

clami219
clami219

Reputation: 3038

If you are working under a unix like terminal you could add the following to your .bash_profile

alias phpunitc='phpunit --colors'

In this way you could have colors calling phpunitc, and no colors calling phpunit (this would require that you remove the colors="true" setting from the configuration file).

Upvotes: 3

Related Questions