I want to distinguish feature/stage/release branches by color. I have a branch naming convention.
Is there a way to color branch names in the output of hg branches
according to some regexp-based rules?
Is there a better way to do this other than writing a custom script and creating an alias for it?
By the way, there is a question and a great answer on how to do this in git
By default, Mercurial's standard color extension only allows colorization based on branch status. E.g.:
(Taken from
hg help color
.)In order to specify colors based on regular expressions, you'll need a script and (for convenience) an alias. The following is in Ruby, because Ruby's case statement makes it fairly easy to do selection by regular expression.
You can also use the
colorize
gem if you already have it installed.You can then add this as an alias to your
.hgrc
. For example, if the above script resides in/path/to/color-branches.rb
, do: