Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get git log with color and paging on cygwin?

I'd like to have colored git logs with paging on cygwin.

I managed to get colored logs with

git log --color=always

If I do

git log --color=always | less

I get paging, but the color commands are printed instead of interpreded

ESC[33mcommit b4dbe28f459adf0df1784d3a597628cc27abf836ESC[m
Author: Ernst Pluess <[email protected]>
Date:   Thu Apr 18 13:23:07 2013 +0200

    Changed to UTF-8

On my OSX box colors and paging is the default behaviour for git log on the shell. How can I get the same for cygwin on Windows.

like image 632
BetaRide Avatar asked Apr 18 '13 12:04

BetaRide


2 Answers

I was able to configure git globally (on cygwin at least) by running

git config --global core.pager 'C:/cygwin64/bin/less.exe'

This way running git log shows a paged and colorized output.

like image 183
picheto Avatar answered Sep 28 '22 10:09

picheto


Use

less -R

instead of just less to pass color ANSI control characters through to the terminal.

You can also set the LESS environment variable to

LESS=-R

to make this default behaviour.

like image 30
rtytgat Avatar answered Sep 28 '22 09:09

rtytgat