如何使most
寻呼机正确显示从标准输入接收的文本中的颜色?
注意:我不确定它是否是most
.
我没有遇到与less
and相同的问题more
,只有 with most
,否则它作为man
.
我不是发布图片,而是邀请人们尝试此操作(仅当您已most
安装时):
$ command apropos zip | command grep --color=always zip | command less
$ command apropos zip | command grep --color=always zip | command more
$ command apropos zip | command grep --color=always zip | command most
Run Code Online (Sandbox Code Playgroud)
less
并more
正确显示颜色,同时most
显示带有额外“垃圾”^[[K
包裹所有彩色文本区域的颜色。
令人惊讶的是,这是可以的:
$ (export PAGER=most; command man zip)
Run Code Online (Sandbox Code Playgroud)
我是否遗漏了什么(手册页most
没有帮助),滥用命令还是我应该将其报告为错误?
less
(更新)的说明:正如 Sparhawk 在评论中提到的那样,less
如果没有提供选项-R
(or --RAW-CONTROL-CHARS
) 或-r
(or --raw-control-chars
) (也可以在LESS
环境变量中设置),则它也不起作用。
事实上,我首先搜索了一个类似的选项most
(但没有找到)。
所有人都有彩色 UTF?8 编码文本的问题,而不仅仅是most
. 就我而言,终端没问题,所以那不是终端。相同的无色 UTF?8 文本适用于所有三个寻呼机,因此这不是字符编码。
man grep 2>/dev/null |
GREP_COLORS=$(man grep 2>/dev/null |
grep '^ *ms=01;31' -m1):ne \
grep '^ *GREP_COLORS *$\|^ *ne ' -A9 --color=always |
most
Run Code Online (Sandbox Code Playgroud)
对我有用。顺便说一句,我只是most
为了解决这个问题而安装的,我喜欢它。谢谢。
GREP_COLORS
Specifies the colors and other attributes
used to highlight various parts of the
output. Its value is a colon-separated list
of capabilities that defaults to
ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36
with the rv and ne boolean capabilities
omitted (i.e., false). Supported
capabilities are as follows.
ne Boolean value that prevents clearing
to the end of line using Erase in
Line (EL) to Right (\33[K) each time
a colorized item ends. This is
needed on terminals on which EL is
not supported. It is otherwise
useful on terminals for which the
back_color_erase (bce) boolean
terminfo capability does not apply,
when the chosen highlight colors do
...
Run Code Online (Sandbox Code Playgroud)