Search code examples
mercurial

How do I remove escape sequences (ESC[0;33m) from hg's output?


I'm trying out Mercurial. When I run hg log in the terminal, I see this output, paged through a pager, probably less:

ESC[0;33mchangeset:   1:82e55d328c8cESC[0m
tag:         tip
user:        [email protected]
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

ESC[0;33mchangeset:   0:0a04b987be5aESC[0m
user:        [email protected]
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program

How do I configure Mercurial so that I don't see escape and control sequences like ESC[0;33m and ESC[0m


Solution

  • These sequences are meant to enable colour output in the terminal. You can disable colour by adding --color=never, like this:

    hg log --color=never
    

    Even better, you can change the pager to enable recognising these colour sequences. For example, you can use less -R on systems that have less. Modify ~/.config/hg/hgrc or ~/.hgrc to include this section:

    [pager]
    pager = less -R