]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - tig.pl
tig.pl: Color refs.
[config/dotfiles.git] / tig.pl
diff --git a/tig.pl b/tig.pl
index 85bebb6c5940bd2087374dab2fae7361e1608b1a..f753408bba21d20eb89af891c55b82e19578349f 100755 (executable)
--- 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",