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.
这是我在Linux中排名前十的烦人事物。我喜欢终端的彩色输出:阅读时看起来很有用,也很有用。
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
.
我在新系统上做的第一件事是为ls和grep设置别名以显示彩色输出,第二个是安装vim和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.
我同时使用Gentoo和Ubuntu,我看到gentoo的包管理器emerge比apt-get / aptitude具有更高的可读性,因为它使用了比后者更多的颜色输出。
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.?
我可以理解,更多的基本命令不应该依赖于ncurses(有人可能会说我们也有更少,所以两者中的一个甚至可能是颜色友好的),但为什么没有一个着名的替代品更多支持颜色,如vi / vim,top / htop等?
Thanks for any hint.
谢谢你的任何提示。
1 个解决方案
#1
15
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
ON:始终输出颜色
OFF:不输出颜色
AUTO:当且仅当输出是终端时才显示颜色
Many commands work automatically in color AUTO mode. That is the case for emege
. And that is why you do not have color when you pipe the output: the pioe is not a terminal.
许多命令在彩色AUTO模式下自动工作。这就是emege的情况。这就是为什么管道输出时没有颜色的原因:pioe不是终端。
The solution is to tell emerge
to output the colors unconditionally. And tell less
not to filter them, of course.
解决方案是告诉emerge无条件输出颜色。当然,告诉你不要过滤它们。
Try:
emerge --color y | less -R
#1
15
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
ON:始终输出颜色
OFF:不输出颜色
AUTO:当且仅当输出是终端时才显示颜色
Many commands work automatically in color AUTO mode. That is the case for emege
. And that is why you do not have color when you pipe the output: the pioe is not a terminal.
许多命令在彩色AUTO模式下自动工作。这就是emege的情况。这就是为什么管道输出时没有颜色的原因:pioe不是终端。
The solution is to tell emerge
to output the colors unconditionally. And tell less
not to filter them, of course.
解决方案是告诉emerge无条件输出颜色。当然,告诉你不要过滤它们。
Try:
emerge --color y | less -R