2

When I try and trigger PHPUnit tests within MacVim, I can't see coloured outputs in my command line:

enter image description here

6
  • Vim or GVim/MacVim?
    – romainl
    Commented May 7, 2016 at 20:32
  • @romainl I'm using MacVim Commented May 7, 2016 at 20:59
  • 2
    Then you can't get colored output. Try :!phpunit --colors=auto to disable color when the terminal doesn't support it. Not "pretty" but a lot cleaner.
    – romainl
    Commented May 7, 2016 at 21:30
  • @romainl I used :!phpunit --colors=never. Is this a MacVim thing? Commented May 8, 2016 at 8:44
  • 1
    Both MacVim and GVim come with a "dumb" terminal emulator that doesn't understand color. If you do :!command in Vim in a real terminal emulator, Vim is suspended and command is executed in the host shell which (hopefully) understands color escape sequences.
    – romainl
    Commented May 8, 2016 at 9:29

2 Answers 2

1

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
4

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.

1
  • This fixed MacVim for me, thanks! Commented Jul 5, 2020 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.