14 January 2010

Colourizing mercurial output when piping to less

Filed under: Uncategorized — Tags: — bookweevil @ 10:43 am

From at least version 1.3.1 onwards, it looks like mercurial will colourize the output of commands like “hg diff” (for instance), making them much easier to read on-screen.

However, when it detects that output is going to a pipe rather than a terminal, it normally turns colourization off.

You can turn it back on using the “–color=always” argument; and if you’re piping to “less”, then “less -R” will cause it to recognize ANSI colour escape sequences. For example:

  hg diff --color=always | less -R

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

%d bloggers like this: