5 ms·
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 be
by obeattie 5y 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.
- alex_smart 5y agoGreat question! There is ansi2txt (packaged as colorized-logs on debian). https://github.com/kilobyte/colorized-logs 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-from-output https://stackoverflow.com/questions/17998978/removing-colors...
- tgv 5y agoOften, `cat` will do that. Many tools look at stdout to see if it's a terminal. When it isn't, they suppress color output.
- lexicality 5y agoBy 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.