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.:
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.
Unfortunately this is not working for the .unixCmd although when I "\\abc".postln it does show the escape char. Any other alternatives on how to solve it?
If you have the full path in a variable or array, such as you’d obtain from .pathMatch, you can quote or escape characters when building the command string:
p = "C:/Users/username/Downloads/*.MOV".pathMatch; // or however you want to get the paths
// play a random one
"FFplay -i \"%\"".format(p.choose).unixCmd;
// or, if you're sure spaces are the only problem
"FFplay -i %".format(p.choose.escapeChar($ )).unixCmd;
I wasn’t expecting to solve @MarcinP problem, but serendipity sometimes come out of the fast and light particles inside the supercollider. (I hope it also works on the terminal).