When I try and trigger PHPUnit tests within MacVim, I can't see coloured outputs in my command line:
2 Answers
The GUI version of Vim (MacVim on Mac OS X, GVim everywhere else) comes with a "dumb" terminal emulator that doesn't understand color at all.
If you want to run command-line programs without the ugly escape codes you'll need to either configure those programs to not use color when not possible or call them with dedicated options.
In your case:
:!vendor/bin/phpunit --colors=never ...
Since we are at it:
Git
The default value has been auto
for a while but if you use an old release:
$ git config --global color.ui auto
Npm
This is a bit extreme but npm
expects a boolean, here:
$ npm config set color=false
I was facing same problem with gvim
on Linux.
Put following in your ~/.gvimrc
set guioptions+=!
Explanation from :help guioptions
:
'!' External commands are executed in a terminal window. Without this flag the MS-Windows GUI will open a console window to execute the command. The Unix GUI will simulate a dumb terminal to list the command output. The terminal window will be positioned at the bottom, and grow upwards as needed.
:!phpunit --colors=auto
to disable color when the terminal doesn't support it. Not "pretty" but a lot cleaner.:!phpunit --colors=never
. Is this a MacVim thing?:!command
in Vim in a real terminal emulator, Vim is suspended andcommand
is executed in the host shell which (hopefully) understands color escape sequences.