How to define ESC char in git?

纵然是瞬间 提交于 2019-12-22 05:23:34

问题


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

git log --decorate --color

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.

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


回答1:


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.

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.)



来源:https://stackoverflow.com/questions/4959498/how-to-define-esc-char-in-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!