Maxime P
Maxime P

Reputation: 775

How to have the Sublime Text console showing color instead of the color codes

I have a build system output in the console. However it is showing color code instead of the actual colorized text.

[37;46;1mTest file: static/tests/casperjs/login/test.js

How can I apply a color theme to the console output?

Thanks!

Upvotes: 3

Views: 1222

Answers (1)

unohoo
unohoo

Reputation: 388

Unfortunately sublime doesn't support this. I ended up writing a plugin that parses the output and converts it into a colored version (for a subset of colors, ones we use in our testing framework).

If you would like to look into that, or if anyone stumbles upon this in future here are some tips..

I detect output in the plugin with an on_modified event listener and a view with no name (view.name()). This does not uniquely identify the output pane so you'll have to do a bit more than that, I found no other easy way (unless you want to hook into your build plugin and act directly on the view it generates). To make the color changes, I remove the color codes (view.erase()) and add color to the regions marked by those codes with view.add_regions(). The colors I add are ones I manually insert into a custom theme, as again there seems to be no other way. Also, for some reason it seems you can't add a color with the exact background of the active theme (it inverts it or something), so I set the color's backgrounds to something just different.

As you can tell, it's a hacky, ad hoc solution, otherwise I would release it on Github.

You can also check out SublimeREPL, it does console text coloring

Upvotes: 1

Related Questions