MacOS – How to prevent CodeRunner from prefixing its console output with [00m[00m[00m[00m[00m

command lineconsolemacosterminal

There seems to be a connection between CodeRunner's console output and your actual terminal prompt script, that is, if such prompt code is sourced from e.g. ~/.bash_profile (which CodeRunner reads by default).

I have a pretty fancy (read: great) terminal prompt (screenshot|code) that seems to mess up CodeRunner's console output, leading to garbled [00m[00m[00m[00m[00m characters at the start everytime I run some code, even though it's error-free and regardless of language). I'm reluctant to change my prompt for the sake of getting rid of these annoying characters.

If I turn off Invoke bash in login mode when running code in CodeRunner's Advanced prefs, I'm seeing bash: source: No such file or directory instead…

So I'm stuck between a rock and a hard place, trying to get a clean console in CodeRunner…

How can this be fixed? (I've tried contacting the developer about this but I'm receiving no answer.)

Best Answer

The culprit probably is line 88 in your prompt.sh:

trap 'echo -ne "\033[00m"' DEBUG

This will output an ANSI escape code to reset the colors and style before the output of every command.

From examining your bash script, this line seems to be unnecessary, because you are resetting the formatting at the end of your prompt here on line 76:

PS1="$status_style"'$fill \t\n'"$BY\$(__name_and_server)$Y\w$G\$(__git_prompt)$RESET$ "

I suggest you just remove line 88 and try it like that.

Somewhat unrelated to this problem, but I also suggest editing line 73 to the following:

local RESET="\[\033[0m\]"

This way you are truly resetting the ANSI styling, whereas before you were setting it to white.