Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: