如何在git中定义ESC char? [英] How to define ESC char in git?

查看:177
本文介绍了如何在git中定义ESC char?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在git输出中使用着色,例如:

I want to use coloring in git output, e.g.:

git log --decorate --color

当我发出这个命令时,我得到的输出像 ESC [1; 32m 其中 ESC 是相反的颜色。

这看起来像一个有效的转义序列,除了必须发送\\ 033 ,而不是字符 E S C

当我发出 ls 命令时,我会根据权限着色文件。
这样的功能没有什么问题。

When I issue this command I get output looking like ESC[1;32m where ESC is in reversed color.
This looks to me as a valid escape sequence, except that the \033 must be sent and not the characters E, S and C.
When I issue an ls command, I get coloring of the files according to the rights. So nothing wrong with the capabilities.

有没有环境变量必须设置为ESC字符的值?
或者我看错了方向?

我正在运行openSUSE 11.1

Is there an environment variable that must be set to the value of the ESC char? Or am I looking in the wrong direction?
I am running openSUSE 11.1

推荐答案

看起来像您的终端(或任何处理输出的程序)不明白这一点,并显示 ESC 作为 \033 。如果您使用显示输出,则需要 -R 参数。

Looks like your terminal (or any program handling the output) did not understand this, and showed ESC as a placeholder for the \033. If you are using less to show the output, then it needs the -R parameter.

我正在使用配置 core.pager = less -XRMSI ,它在这里工作得很好(也是一个openSUSE,虽然我是不知道哪个版本)。 (更改之前,请使用 git config -l <​​/ code>查找当前配置,并记住旧值。另外,您可能想要阅读 less 关于可用开关的文档。)

I'm using the configuration core.pager=less -XRMSI, and it works fine here (also an openSUSE, though I'm not sure which version). (Before changing, look up your current configuration with git config -l, and remember the old value. Also you may want to read the less documentation about the usable switches.)

这篇关于如何在git中定义ESC char?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆