Archive for December, 2015

color diff to pdf

7 December, 2015

Sometimes you want to explain changes you did to a text in (La)TeX, or perhaps to source code, as a coloured diff produced by your favourite VCS, such as git in my case, by attaching it to an email. The net is full of various scripts to do so, with various degree of success; however, all you need is an installation of enscript, something that is standard on most Linux systems, or at least used to be so.

enscript understands a lot of different programming languages, and can highlight them, and not only them, but also various diff files, e.g., something that git normally produces, unified diffs. Now if your diff is saved in a file blah.diff, you can do

enscript -o blah.ps --color -Ediffu blah.diff

to create Postscript file blah.ps with nicely coloured diff. (And you can also produce HTML instead, or convert Postscript to PDF.)

Advertisements