Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
917 views
in Technique[技术] by (71.8m points)

bash - ANSI color in git is not displayed correctly

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[33m*commit 0a02124a0fd85c1f0094bcdf15bac1645e3c8630ESC[m

note: the ansi color in 'ls' works very well.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...