Color Extension

This extension is distributed with Mercurial

Author: Kevin Christen

Source: hgext/color.py

This extension is obsolete. Color is built in to the Mercurial UI now.

To disable color universally, add to your .hgrc file:

[ui]
color = off

Overview

This extension modifies the status command to add color to its output to reflect file status, the qseries command to add color to reflect patch status (applied, unapplied, missing), and to diff-related commands to highlight additions, removals, diff headers, and trailing whitespace.

Other effects in addition to color, like bold and underlined text, are also available. Effects are rendered with the ECMA-48 SGR control function (aka ANSI escape codes). This module also provides the render_text function, which can be used to add effects to any text.

Configuration

Configure your .hgrc to enable the extension by adding the following lines:

[extensions]
color =

The color extension supports both ANSI consoles and Windows consoles. It will use Windows console mode automatically on Windows platforms unless it finds TERM defined in the environment, in which case it assumes you are using an ANSI shell on Windows. If this auto-detection fails, you can explicitly set the mode by:

[color]
# valid modes are win32, ansi, auto, off
mode = win32

Default effects may be overriden from the .hgrc file:

[color]
status.modified = blue bold underline red_background
status.added = green bold
status.removed = red bold blue_background
status.deleted = cyan bold underline
status.unknown = magenta bold underline
status.ignored = black bold

'none' turns off all effects:

status.clean = none
status.copied = none

qseries can be customized in a similar way:

qseries.applied = blue bold underline
qseries.unapplied = black bold
qseries.missing = red bold

as can diff, and any commands that output diffs:

diff.diffline = bold
diff.extended = cyan bold
diff.file_a = red bold
diff.file_b = green bold
diff.hunk = magenta
diff.deleted = red
diff.inserted = green
diff.changed = white
diff.trailingwhitespace = bold red_background

Discussion

The default colors are a bit painful to read for me, so I modified them to the following:

[color]
status.modified = magenta bold
status.added = green bold
status.removed = red bold
status.deleted = cyan bold
status.unknown = blue bold
status.ignored = black bold

Mainly I removed the color backgrounds and made the info which is most important for me stand out the most:

  1. modified
  2. deleted
  3. removed

I normally have temporary files in my dirs, so "unknown" shouldn't stand out for me (as it does in magenta), I don't know if that applies to most people.

Besides: "black bold" is in grey for me (which is good).


CategoryBundledExtension

ColorExtension (last edited 2017-07-04 04:31:40 by AntonShestakov)