How to define ESC char in git?

2019-04-27 17:47发布

问题:

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