Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"more" command alternative that does support colors? [closed]

This is in my top 10 list of tiny annoying things in Linux. I love colored output in terminals: it's nice to see and useful when reading.

The first thing I do on a new system is to set aliases for both ls and grep to show colored output, and the second is to install vim and htop.

I use both Gentoo and Ubuntu, and I see that emerge, the package manager of Gentoo, has a higher readability than apt-get/aptitude just because it uses way much more color output than the latter.

So, whenever I have to pipe an emerge command with more, all the color is lost and I have to focus my attention on every line to avoid missing anything important.

I can understand that a basic command such as more shouldn't depend on ncurses (someone could argue that we also have less, so one of the two could be even color-friendly), but why there isn't a famous alternative to more that supports colors, as there is for vi/vim, top/htop etc.?

Thanks for any hint.

like image 871
Avio Avatar asked May 27 '12 20:05

Avio


People also ask

What ls option enables colorized output on Linux?

By default, on most Linux distributions these days has ls colors enabled. If your Linux distribution is an exception to this default setting, then you may run ls with –color option to enable colored output.

How do you change the color of text in CMD?

To set the default Command Prompt window color, select the upper-left corner of the Command Prompt window, select Defaults, select the Colors tab, and then select the colors that you want to use for the Screen Text and Screen Background.

How do you make a terminal colorful in Linux?

The -F option controls the frequency of the rainbow effect. The -t option enables 24-bit color, while -f forces color output (the options are case-sensitive, like in many other Linux commands). The -i option will invert the foreground and background colors, giving a rainbow background to your terminal text.


1 Answers

Most commands that can output color have an option to choose between:

  • ON: Always output color
  • OFF: Never output color
  • AUTO: Show color if and only if the output is a terminal

Many commands work automatically in color AUTO mode. That is the case for emerge. And that is why you do not have color when you pipe the output: the pioe is not a terminal.

The solution is to tell emerge to output the colors unconditionally. And tell less not to filter them, of course.

Try:

emerge --color y | less -R
like image 108
rodrigo Avatar answered Sep 27 '22 18:09

rodrigo