Sublime Forum

Ansi color codes in build output

#1

I’ve been playing around with Elixir package and when I run my tests via Cmd+B the output is colored, which works in terminal, but not in the sublime buffer (Sublime Text 2)

Is there a way to fix this? I only found some solutions for the RubyTest package, but it doesn’t work. I’m also getting a little different output in Sublime Text 3, is there a way to supress those lines at the end?

0 Likes

Ansi color codes are still appearing on the output panel
#2

Is there any update for this?

0 Likes

#3

I’m also looking to get this to work and haven’t found anything useful yet. Please post back if you figure something out.

0 Likes

#4

It’d be pretty damn rad if this worked.

0 Likes

#5

Hint: recently found out that build systems support setting the syntax of the output panel.

0 Likes

#6

Anyone ever get this to work in any useful way?

0 Likes

#7

It looks like Sublime Text simply doesn’t support ANSI color codes.

What I did was to download ansifilter from andre-simon.de/doku/ansifilt … filter.php and modify the build output to filter the sequences.

This is an example for Bash Build System

[code]{
“cmd” : “bash”, “$file”],
“selector” : “source.shell”,

"windows": {
    "path"  : "$path;\\program files\\tools\\ansifilter",
    "cmd"   : "bash", "$file", "|",  "ansifilter"],
    "shell" : true
}

}[/code]

By the way: ansifilter needs two Mingw DLLs that are not included

0 Likes

#8

I just setup my Sublime Text 2 with build settings for both CasperJS and CasperJS test and was able to specify --no-colors options.

Here are the details: gist.github.com/morozgrafix/9626928

0 Likes

#9

Ansi colors in the build console would be REALLY helpful!

0 Likes

#10

the consoel output is highlighted by an specified tmLanguage so you could create one which has token eg

<dict> <key>begin</key> <string>esc[31M</string> <key>beginCaptures</key> <dict> <key>1</key> <dict> <key>name</key> <string>hide</string> </dict> </dict> <key>end</key> <string>(?=esc\[)</string> <key>name</key> <string>red</string> </dict>

0 Likes

#11

[quote=“valerij_”]the consoel output is highlighted by an specified tmLanguage so you could create one which has token eg

<dict> <key>begin</key> <string>esc[31M</string> <key>beginCaptures</key> <dict> <key>1</key> <dict> <key>name</key> <string>hide</string> </dict> </dict> <key>end</key> <string>(?=esc\[)</string> <key>name</key> <string>red</string> </dict> [/quote]

How do we use this? I’ve tried creating an ansi.tmLanguage file and then setting “syntax”: “ansi” in my build system but it just says Error loading syntax file ansi.

The unofficial docs unfortunately don’t show an example of how to use the syntax field.

0 Likes

#12

I was able to display ANSI colors using the ANSIescape plugin, see some more details in this issue

0 Likes

#13

I know this thread is old, but in case anyone is wondering, installing the ANSIEsacpe via PAckage Control as suggested by a previous poster didn’t help with build output, but the issue he pointed me to did. After installing the ANSIEscape plugin via Package Control I went to the GitHub repo for ANSISublime (appears to be same as ANSIEscape). I perused the files and I noticed the ansi.py version on the GitHub repo includes the AnsiColorBuild command entry and the one installed via Package Control does not. To fix:

  • I downloaded the master branch zip file from ANSISublime GitHub

  • extracted it’s contents to a local folder

  • re-zipped the contents of the extracted main folder (excluding the folder itself)

  • renamed it to ANSIescape.sublime-package

  • copied it over top the existing one in the ST3 installed packages folder

  • edited my custom Grunt.sublime-build
    file with the following lines

"target": "ansi_color_build",
"syntax": "Packages/ANSIescape/ANSI.tmLanguage",

and now I can see the color coded output in my ST3 build console.

0 Likes

#14

@davehibshman I’ve created an account just to thank you :smile:

Worked pretty well for me too, got gulp colored output now !

0 Likes

#15

Sorry guys, I guess it was my fault. I merged the pull request a while ago but forgot to tag the release and PM only installs tagged releases.
It should be fixed now.

0 Likes

#16

Sublime Text 3 on my computer can’t work properly even when I just want a file containing ANSI escape code to be colored by ANSIescape plugin…
When I switched the syntax to ANSI, the file indeed became read-only, but still not colored, displaying garbage like ESC.
I have totally no idea about how to fix this… I have only installed it from package control so far and just want a text file to display in colors…
Did I miss something fundamental to install before using this plugin?
Please help… THANKS!

0 Likes

#17

You need to add to your build system.

0 Likes