| less or more don't display colors

Martin Geisler martin at geisler.net
Mon Feb 1 19:29:38 UTC 2016


On Mon, Feb 1, 2016 at 7:28 PM, Uwe Brauer <oub at mat.ucm.es> wrote:

> Hello
>
> I have the following alias (found somewhere on the web)
> lg = log --template "{label('custom.rev',
> rev)}\t{label('custom.phase',phase)}\t{label('custom.tag',tags)}\t{desc|firstline}
> {label('custom.age', date|age)} {label('custom.user', author|user)}\n"
>
> That produces a very nice colored output.
>
> However, since the output is very large,  I run
>
>  hg lg | more
>
> But then  the colors are not displayed (using less the same occurs)
>
> Is there any possibility to display colors in this stetting?
>

The color extension turns off the colors by default when it detects that
stdout doesn't go to the terminal.

You can force colors by adding --color=always to the command line in your
alias.

Alternatively, I would suggest using the pager extension (
https://www.mercurial-scm.org/wiki/PagerExtension). That allows you to make
certain commands always use a pager and color will then be shown as well. I
use this configuration for pager:

[pager]
pager = less -RFSX

Read the man page for less and adjust the flags as necessary -- the '-R'
flag is what makes less pass ANSI color codes through.


-- 
Martin Geisler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20160201/ffa5bdbb/attachment-0002.html>


More information about the Mercurial mailing list