I miss small utility ansi2txt. That is a filter that removes ANSI colors from output. In Ubuntu, it is included in the package colorized-logs (not installed by default)…
Why? Some programs print colored text to the console and there could be reason to remove colors and see only black/white (plain) text.
Example, pakfire list prints packages in green and red color. When used with grep, it corrupts console, try this: pakfire list | grep ipfire. It is easy to fix console, just execute command reset.
Is there a better way? Yes, use ansi2txt!
pakfire list | ansi2txt | grep ipfire doesn’t corrupt console…
ansi2txt is useful when output from a program, output full of colors, has to be copied to an issue or a plain text file.
Workaround (the good old way):
pakfire list | sed -e 's/\x1b\[[0-9;]*m//g' | grep ipfire
[root@ipfire ~] # pakfire --help
Usage: pakfire <install|remove> [options] <pak(s)>
<update> - Contacts the servers for new lists of paks.
<upgrade> - Installs the latest version of all paks.
<list> [installed/notinstalled/upgrade] - Outputs a list with all, installed, available or upgradeable paks.
<info> <pak> [<pak> ...] - Output pak metadata.
<status> - Outputs a summary about available core upgrades, updates and a required reboot
Global options:
--non-interactive --> Enables the non-interactive mode.
You won't see any question here.
-y --> Short for --non-interactive.
--no-colors --> Turns off the wonderful colors.
[root@ipfire ~] #
OK, I assume it works. But no all programs have an option to disable colors. ansi2txt is a filter that works for any program… pakfire was my example as I know it has output with colors and I do not like it…
For the most part this is not an issue for me so I don’t have a good solution.
Since the support & build queues are very busy I’d suggest using this as an opportunity to learn how to build an IPFire add-on. It always helps to have a first project that you are passionate about. And this one seems to be it!
There are people within the Community that can help (and are willing to help!)