From 057f0180cb8a22b279e7ebbb24ddd50dc1881750 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 11 Mar 2013 15:06:08 +0100 Subject: [PATCH] tig.pl: Color refs. --- tig.pl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tig.pl b/tig.pl index 85bebb6..f753408 100755 --- a/tig.pl +++ b/tig.pl @@ -61,11 +61,28 @@ while (my $line = <$fh>) { # Color "graph". $prefix =~ s/\|/colored($&, $color_graph)/ge; - # Strip leading whitespace. + # Strip leading whitespace and braces. $refs =~ s/^\s+//; + $refs =~ tr/()//d; + + # Color refs. + $refs = join colored(', ', $color_ref_sep), map { + my $color; + if ($_ eq 'HEAD') { + $color = $color_ref_head; + } elsif (m{/}) { + $color = $color_ref_reference; + } else { + $color = $color_ref_branch; + } + colored($_, $color); + } split /, /, $refs; if ($refs ne '') { - $refs = ' ' . $refs; + $refs = ' ' + . colored('(', $color_ref_sep) + . $refs + . colored(')', $color_ref_sep); } printf "%s %s %s %s%s %s\n", -- 2.45.2