Earlier quoted context omitted.
This is the problem with people trying to be clever. Now you output escape sequences regardless of terminal setting. Using a library which handles that (an a thousand other quirks) makes much more sense
There is no cleverness involved. The escape sequences are decades old and universally supported as a de facto standard. In this case the escape sequences are assigned to variables that are attached to other strings. This is as clever as using an operator. These escape sequences are even supported by Chromes dev tools console directly in the browser. The real issue is invented here syndrome . People irrationally defer…
It's easy to solve though, simply assign empty strings to escape code variables when the output is not an interactive shell.