Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress display of escape sequences in diff

Tags:

git

When I run git diff to see what was changed in a modified file, diff displays many highlighted escape sequences. For example:

ESC[1mindex a7671ab..c228e2c 100644ESC[m
ESC[1m--- a/core/bp-nav-horizontal.phpESC[m
ESC[1m+++ b/core/bp-nav-horizontal.phpESC[m
ESC[36m@@ -77,7 +77,7 @@ESC[m
 <!-- Contact Us -->ESC[m
   <ul>ESC[m
       <li>ESC[m

How can I suppress these ESC[xxx characters. They make it very hard to read the text.

Amended 15 Aug 2014

This is not really about git diff. Displays of git log also show the ESC... characters. This seems like a configuration problem, but I don't know where it is. Where should I look?

like image 494
Lewy Avatar asked Aug 15 '14 19:08

Lewy


People also ask

How do you ignore an escape sequence in Python?

Python escape sequence ignore To ignore all the escape sequences in the string, we have to make a string as a raw string using 'r' before the string. After that escape sequence will also be considered normal characters.

Which statement prevent the escape sequence interpretation?

The correct option is col1\tcol2\tcol3\tOpen() for execution.


2 Answers

The problem is with the pager used by GIT to print diffs and logs. Adding -R to the configuration for less solved the problem for me. I used

git config --global core.pager "less -R"
like image 82
Lewy Avatar answered Oct 14 '22 15:10

Lewy


You might have set color.ui=always (or auto and the terminal detection does not work). You can turn it off with never (if it is always try auto first).

You can configure all commands with config.ui or specific for git-diff with color.diff.

git config --global color.ui never

Use

git config --local -l
git config --global -l
git config --system -l

To list the current settings for the project, user and machine. To switch it temporarily on/off you can use the --color=always argument at each command. For example:

git log --color=never

See also: http://git-scm.com/book/en/Customizing-Git-Git-Configuration

like image 21
2 revs Avatar answered Oct 14 '22 15:10

2 revs