Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct paging and coloured output using Git for Windows via Cygwin

Tags:

git

cygwin

Title says it all: is it possible to get Git for Windows to pipe its output through cygwin's less so that it shows up correctly in a mintty window? There have been a number of questions asked about this, but still no definitive answer.

Arguably this kind of setup is a little esoteric, but
- I need cygwin because I'm using a build system that requires it;
- I don't want to use the git client that comes with cygwin because it is an order of magnitude slower when applying patches or rebasing, which is something I often need to do;
- I am aware that manually typing git show <whatever> --color=always | less -R works, but I'm finding it hard to believe that the only working solution is to set up aliases like this for every git command I want paged and coloured output from.

like image 782
laszlok Avatar asked Aug 08 '16 17:08

laszlok


1 Answers

It turned out to be surprisingly easy:
git config --global core.pager 'C:/cygwin/bin/less.exe'
or
git config --global core.pager 'C:\\cygwin\\bin\\less.exe'
will both do the trick. (With the path adjusted to wherever your installation of cygwin lies.) I didn't find this at first because of the need for double backslashes within the quote; but forward slashes work fine too.

like image 136
laszlok Avatar answered Oct 19 '22 08:10

laszlok