Git and Mercurial console output customization

Recently with a lot of help from guys from Polidea, we have created few useful output customization for our version control systems(for those who use terminal). So let’s start with mercurial, here is part of the .hgrc file (Mercurial.ini on Windows, however some commands might not work):

# extension for paging mercurial output
pager = LESS='FSRX' less
attend = annotate, cat, diff, export, glog, log, qdiff, hist

# extension do display log in graphical way
graphlog =
pager =

# alias for pretty printing mercurial log
hist = glog --template "\033[31m{node|short}\033[0m \033[1;34m<{author|person}>\033[0m \033[32m({date|age})\033[0m \n\t\t{desc}\n"


We first enable and configure pager extension which basically allows you to scroll through the command output, it works pretty much like hg <your command> | less. Then we enable graphlog extension, that makes hg log to print nicely formated graph of branches, merges, commits, etc. Finally to additionally color log output we do some magic, and define our own hg log with custom template. Final result of running hg hist looks like this:

The same can be done for git. Here is equivalent .gitconfig (thanks to Wojciech Erbetowski for this):

	hist = log --pretty=format:'%Cred%h%Creset %C(bold blue)<%an>%Creset%C(yellow)%d%Creset %Cgreen(%cr)%Creset%n%w(80,8,8)%s' --graph


Happy coding!

Leave a Reply


1 comment

  1. Git ‘hist’ alias can be extended as ‘histfull’ which also includes changed files:

    histfull = log –pretty=format:’%Cred%h%Creset %C(bold blue)%Creset%C(yellow)%d%Creset %Cgreen(%cr)%Creset%n%w(80,8,8)%s%n’ –graph –name-status

    Bless Git :)