X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tig.pl;h=e3affa8a059de0fc96096ec74fa54f58505b9226;hb=78a901d372af527c99e8860799f7655ba73a4cee;hp=85bebb6c5940bd2087374dab2fae7361e1608b1a;hpb=62446db13e52201f26c0a03d9e9e0d8b9c88e886;p=config%2Fdotfiles.git diff --git a/tig.pl b/tig.pl index 85bebb6..e3affa8 100755 --- a/tig.pl +++ b/tig.pl @@ -34,7 +34,8 @@ my $color_ref_reference = 'red bold'; my $color_author = 'magenta'; -my $format = '%h' . '%x00' # abbreviated commit hash +my $format = '%x00' # separator from --graph + . '%h' . '%x00' # abbreviated commit hash . '%at' . '%x00' # author date . '%an' . '%x00' # author name . '%s' . '%x00' # subject @@ -50,7 +51,8 @@ while (my $line = <$fh>) { } # Commit line. - $line =~ /^([ *|]+) (.+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)$/ or die; + $line =~ /^([ *|]+)\x00(.+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)$/ + or die $line; my $prefix = $1; my $hash = colored($2, $color_hash); my $date = POSIX::strftime('%Y-%m-%d', localtime($3)); @@ -61,11 +63,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",