ANSI color in git is not displayed correctly

前端 未结 8 1023
一向
一向 2020-12-12 18:00

Recently, I switched to SLES 11. I found a problem for git command. All the ANSI color could not be rendered. Instead, it shows the ANSI code like this:

*ESC

相关标签:
8条回答
  • 2020-12-12 18:36

    I had the same problem. But why I need to configure a git in one machine and no need on another? I want to fix the source of the problem because

    git config --global core.pager "less -R"

    looks like a workaround for me.

    0 讨论(0)
  • 2020-12-12 18:42

    Try setting your LESS environment variable to include the -R option:

    LESS=-R git grep ...
    

    If this works, add export LESS=-R to your ~/.bashrc or ~/.profile or similar shell startup file.

       -R or --RAW-CONTROL-CHARS
              Like -r, but only ANSI "color" escape sequences are
              output in "raw" form.  Unlike -r, the screen
              appearance is maintained correctly in most cases.
              ANSI "color" escape sequences are sequences of the
              form:
    
                   ESC [ ... m
    
              where the "..." is zero or more color specification
              characters
    
    0 讨论(0)
提交回复
热议问题