LESS=RSFX: ANSI Coloring To Cmd.exe Doesn't Work

Issue #2 new
created an issue

When using LESS=RSFX in Windows, with the ansi color mode, when the output is short enough to be output on screen without the pager you end up with the ANCI color codes output into the terminal instead of interpreted as colors. Would it be possible for tpager to toggle the color mode based on the amount of output? That seems like the perfect world for a Windows user right now. If the text can't fit then use the pager with ANSI color mode and if it can fit then switch to Win32 color mode and output direct to the terminal.

(Sorry to flood you with issues... :))

Comments (4)

  1. bambams reporter

    It seems like the F flag is the only one that matters here. Apparently it tells less to quit if the text fits in one screen. Why it doesn't interpret color codes in that case, I'm not sure. A less than ideal workaround is to remove the F flag so that all commands always use the pager, but that is quite annoying when you've only got a few lines of output. Especially when you're used to how well it works with Git. :)

  2. bambams reporter

    OK, I'm not sure what the Hell is going on, but today it seems to be working as desired even with the F flag... Maybe this was a false report? I don't understand why it didn't work yesterday and is working today...

  3. Anonymous

    I've just managed to get color and pager working nicely (I think!) by installing ansicon (which makes cmd.exe grok ANSI color codes) and a Windows build of less and using the following configuration in my mercurial.ini file:

    pager =
    mode = ansi
    status.modified = magenta bold
    status.added = green bold
    status.removed = red bold
    status.deleted = cyan bold
    status.unknown = blue bold
    status.ignored = black bold
    qseries.applied = blue bold
    qseries.unapplied = blue bold
    qseries.missing = blue bold
    pager = less -FSRX

    "pager = more" also works. The various overrides for commands was needed because by default a grey blackground was used for some reason.

  4. Log in to comment