[英]'watch' is not interpreting the implicit 'reset' color code `^[m`
It appears that watch
is not interpret the implicit 'reset' color code ^[m
.看来
watch
没有解释隐含的“重置”颜色代码^[m
。 It does interpret the explicit code ^[0m
.它确实解释了显式代码
^[0m
。
Does anyone know how to fix this?有谁知道如何解决这一问题? Or does it sound like a bug and I need to contact the maintainers of
watch
?或者这听起来像一个错误,我需要联系
watch
的维护者?
I'm using watch
with git log
, and git log
uses implicit resets ^[m
.我将
watch
与git log
一起使用,而git log
使用隐式重置^[m
。
Example:例子:
$ watch -c git log --oneline --decorate --source --graph --color=always
What it should look like is:它应该是什么样子:
$ git log --oneline --decorate --source --graph --color=always
If we don't include the -c
( --color
) option on watch
, we can see that the ANSI escape codes are there:如果我们不在
watch
包含-c
( --color
) 选项,我们可以看到 ANSI 转义码在那里:
Every 2.0s: git log --oneline --decorate --source --graph --color=always Fri Sep 28 08:17:42 2018
* ^[33m9db218b^[m HEAD^[33m (^[m^[1;36mHEAD^[m^[33m -> ^[m^[1;32mmaster^[m^[33m, ^[m^[1;33mtag: v0.8.0b5^[m^[33m, ^[m^[1;31morigin/master^[m^[33m, ^[m^[1;31morigin/HEAD^[m^[33m)^[m Doc updates for v0.8.0b5 release
* ^[33mfd342d9^[m HEAD Update changelog [ci skip]
* ^[33md1af865^[m HEAD Update changelog
* ^[33m70889fa^[m HEAD Merge branch 'testing-updates' into 'master'
There's a lot going on in the above example - let's simplify it:上面的例子中发生了很多事情——让我们简化一下:
$ echo -e "\033[33myellow\033[mnormal"
watch
watch
Note: the -e
arg on echo
is not parsed because we're quoting things.注意:
echo
上的-e
arg 未被解析,因为我们正在引用内容。 watch
now handles the color codes. watch
现在处理颜色代码。
$ watch -c 'echo -e "\033[33myellow\033[mnormal"'
-c
flag from watch
watch
删除-c
标志$ watch 'echo -e "\033[33myellow\033[mnormal"'
Every 2.0s: echo -e "\033[33myellow\033[mnormal" Fri Sep 28 08:29:26 2018
-e ^[33myellow^[mnormal
This looks as expected.这看起来像预期的那样。
^[0m
reset code works^[0m
重置代码有效$ watch -c 'echo -e "\033[33myellow\033[0mnormal"'
Primarily tested under WSL: Window 10 Pro, v1803, build 17134.286主要在 WSL 下测试:Window 10 Pro, v1803, build 17134.286
$ watch -v
watch from procps-ng 3.3.10
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
$ uname -a
Linux redacted-hostname 4.4.0-17134-Microsoft #285-Microsoft Thu Aug 30 17:31:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
$ git --version
git version 2.7.4
Also tested using PuTTY to a linux machine.还在 Linux 机器上使用 PuTTY 进行了测试。 Same version information as above, just not using WSL.
与上面相同的版本信息,只是不使用 WSL。
Looks like it was fixed in version 3.3.12 of procps
, which contains watch
:看起来它已在
procps
3.3.12 版中procps
,其中包含watch
:
https://gitlab.com/procps-ng/procps/issues/12 https://gitlab.com/procps-ng/procps/issues/12
https://gitlab.com/procps-ng/procps/commit/6fcb690099bd681930946492e8a93c61e82249d8 https://gitlab.com/procps-ng/procps/commit/6fcb690099bd681930946492e8a93c61e82249d8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.