I’m interested in posting text in color when sclang is run from the command line. There was a similar question about posting in color in the post window, but this is about running sclang on its own.
I was trying to “post” commands with appropriate escape characters, e.g.:
"\x1b[32mgreen".postln;
"\\x1b[32mgreen".postln;
"\\\x\\1\\b\\[\\3\\2\\mgreen".postln;
"\"\\x1b[32m\"green".postln;
27.asAscii ++ "[32mgreen".postln;
"\\" ++ 27.asAscii ++ "[32mgreen".postln;
"^[32mgreen".postln;
"\\033[32mgreen".postln;
"\\u001[32mgreen".postln;
When running sclang with this file from the command line, none of the lines resulted in colored posting.
Posting through echo
works (e.g. "echo \"\\x1b[32mgreen\"".unixCmd;
), but this seems to break when posting hundreds of lines in close succession.
I have a workaround writing a string to a file and then piping it to echo
, but that’s not ideal. Is there really no way to “post” escape codes from sclang?
For reference: it was helpful for me to see this gist listing escape sequences in various formats.