Changing pager settings for Git.

It seems that on FreeBSD, the default pager is more. For Git commands involving the pager, this has the effect of displaying ANSI color escape sequences as ‘ESC[ …’ rather than coloring the text:

$ git diff
ESC[1mdiff --git a/mininet/link.py b/mininet/link.pyESC[m
ESC[1mindex 9703ce7..559b5da 100644ESC[m
ESC[1m--- a/mininet/link.pyESC[m
ESC[1m+++ b/mininet/link.pyESC[m
ESC[36m@@ -25,7 +25,7 @@ESC[m
 """ESC[m
 ESC[m
 from mininet.log import info, error, debugESC[m
ESC[31m-from mininet.util import makeIntfPairESC[m
ESC[32m+ESC[mESC[32mfrom mininet.util import makeIntfPair, quietRun
...

A quick search of the man pages for more (which actually leads to less(1)) shows that the -R flag would allow the raw (ANSI) control characters to be displayed properly:

       -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 cor-
              rectly  in  most  cases.   ANSI  "color"  escape  sequences  are
              sequences of the form:

                   ESC [ ... m

Setting the PAGER environment variable to ‘more -R’ is a solution, but one way to only affect Git’s behavior is to set its configurations using git config:

$ git config --global core.pager 'more -R'

References:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s