Minimal example code:
cols = ToExpression @ ReadString @ "!tput cols";(*valid for linux && macos*)
badline = StringRepeat["-",cols];
goodline = StringRepeat["-",cols-1];
redline = StringJoin["\033[31m",goodline,"\033[0m"];
Print @ goodline;
Print @ badline;
Print @ redline;
If you run this code in any other way than in the interactive REPL, all lines print as one line, but within the REPL, the last two lines get split. Not sure why 'badline' gets split. 'redline' gets split because the ANSI codes get counted in the string length, so the interface mistakes it as going over the available columns.
Changing option FormatType of \$Output to any form given by \$OutputForms does not work.
How to prevent the unnecessary line splitting?
SetOptions[$Output, PageWidth -> Infinity]and see if it makes any difference. You could also trySetOptions[EvaluationNotebook[], LineBreakWithin -> False]that I saw which might make difference.? $\endgroup$