How to get Colored Build Output from Make in Sublime Text 3?

Recent versions of ST3's Makefile build system (as described in the Make.sublime-build file) already contain a syntax definition which produces colorized output.

If you're not happy with that, here's what you can do as an alternative and generally working approach if you have a build system which produces ANSI colors in a terminal and you want to have them show in the build output panel of Sublime Text 3.

This is how I did it in my Sublime Text 3 installation for RSpec, but I think it is perfectly applicable in any case with a tool producing color in a regular console/TTY:

1. Force your build system to output colors even if it's not outputting to a TTY.

This depends on the build system. For example, for Ruby and RSpec, you might create an .rspec file in your project with the following contents:

--color --tty

In your case, you already have a build system which produces output with ANSI color escape sequences.

2. Install the ANSIescape (SublimeANSI) package

It's recommended to install it via Package Control. See the repo of the package for installation and configuration instructions.

3. Create a new build system definition in Sublime Text and configure it to recognize ANSI colors

For example, here is the contents of my Colorized RSpec.sublime-build build system:

{
    "cmd": ["rspec", "-I ${file_path}", "$file"],
    "file_regex": "# ([A-Za-z:0-9_./ ]+rb):([0-9]+)",
    "working_dir": "${project_path:${folder:${file_path}}}",
    "selector": "source.ruby.rspec",
    // Recognize ANSI colors in the output
    "target": "ansi_color_build",
    "syntax": "Packages/ANSIescape/ANSI.tmLanguage"
}

The last two configuration options are taken from SublimeANSI's readme. You can apply this to your build system for Make. You can base it on the current version of the Make.sublime-build file from Sublime Text 3's packages.

4. Build your file/project using the newly created build system.

Use the "Build with..." menu to pick the new build system. On OS X this is Cmd + Shift + B. Subsequent builds with Cmd + B will use this last picked build system.

Here's how it looks:

enter image description here


There's currently no way to make the ST3 console parse colors that I have found. This would need to be discussed with the author. I have noticed before that the console always has monochromatic output. ST3 currently only uses the colors that are provided with the theme that you have applied to it.

Only way to get rid of the escape sequences would be to filter them out before the output hits Sublime.