Hacker News new | ask | show | jobs
by obeattie 1568 days ago
Without understanding the minutiae of this, couldn’t someone just write a program that we can pipe any output to, which strips colour commands from its input before writing it back out? Does such a program already exist? That wouldn’t require every program to add support for an environment variable.
3 comments

Great question!

There is ansi2txt (packaged as colorized-logs on debian).

https://github.com/kilobyte/colorized-logs

I also found some answers on SO with people using a sed command for this.

https://stackoverflow.com/questions/17998978/removing-colors...

Often, `cat` will do that. Many tools look at stdout to see if it's a terminal. When it isn't, they suppress color output.
By itself, less will prevent any control sequences (including colours) from actually being sent to the terminal, but most distros seem to have -R set on it by default these days. If you unset -R it'll do exactly that.