Syntax highlighting your code outputted from the git pager.

by abargnesi
GNU/Linux ◆ rxvt-unicode-256color ◆ bash 1813 views

If you use git on the command line then you’ll see code at some point dumped to the pager. By default the output is not colorized as it’s just text to git.

We can change that by setting the GIT_PAGER environment variable to a pager command and combining a syntax highlighting with less.

Example using python’s pygments library:

GIT_PAGER=”pygmentize -l ruby | less -FRX” git show HEAD~2:lib/bel/parsers/ast/node.rb

Enjoy!