When running on Windows, I have changed my default terminal in the IntelliJ IDE from default Windows cmd to bash (I am using the one installed with Git, located at C:\Program Files\Git\bin\bash.exe). It works very well, the only trouble is that when running sbt from the terminal, some strange characters are shown (I assume they are some control characters intended to format the output).
This does not happen when I run sbt directly from the bash launched in the Windows as a standalone window.
Is there some setting (an environment variable or a config file) for any of the three components involved (sbt, IntelliJ, bash) I could change so that I do not see those formatting characters misinterpreted? If they would work and affect the formatting it would be a nice bonus, but that is less important to me.
IntelliJ:

Standalone:

sbt by default colors the console output, which does not work on Windows, but perhaps the launcher script doesn't disable the codes in the IntelliJ terminal script.
You can disable colors by passing the -Dsbt.log.noformat=true to sbt
You can preserve the colours and formatting if you add the following to your .bashrc file:
sbt() {
/c/progra~2/sbt/bin/sbt.bat "$@"
}
export -f sbt
.bashrc can be found (or created) in your %USERPROFILE% directory, e.g. C:\Users\{username}\.bashrc.
Substitute a different path to sbt.bat if necessary, but it needs to be without spaces.
Restart your terminal afterwards, or run source ~/.bashrc.
This exports a bash function that causes "sbt" to run the sbt batch file launcher instead of the shell script launcher that it would otherwise. The batch launcher clearly does a better job of processing the output on Windows. (I also use this for gcloud and gsutil commands that fall over in other ways when invoked from Bash.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With