{"thread":{"id":"231","subject":"Colorized git log","startedAt":"2005-04-21T21:12:45Z","lastAt":"2005-04-22T01:04:18Z","messageCount":6,"participants":["Sean","Petr Baudis","Daniel Serpell","Steven Cole"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"1205","messageId":"3536.10.10.10.24.1114117965.squirrel@linux1","threadId":"231","inReplyTo":null,"subject":"Colorized git log","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2005-04-21T21:12:45Z","receivedAt":"2005-04-21T21:12:45Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"\nOn the off chance that someone else might like it, here is a pager script\nfor the git log that adds a splash of color:\n\n#!/bin/sh\ngit log \"$@\" | sed -re '\n     /.*signed-off-by.*/Is//\\x1b[34m&\\x1b[0m/\n     /^--*$/Is//\\x1b[31m&\\x1b[0m/\n     /^(commit|tree|parent) .*/Is//\\x1b[32m&\\x1b[0m/\n     /^author .*/Is//\\x1b[36m&\\x1b[0m/\n     /^committer .*/Is//\\x1b[35m&\\x1b[0m/'  | less -R\n\n\nSean\n\n\n"},{"id":"1208","messageId":"20050421224229.GR7443@pasky.ji.cz","threadId":"231","inReplyTo":"3536.10.10.10.24.1114117965.squirrel@linux1","subject":"Re: Colorized git log","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-21T22:42:29Z","receivedAt":"2005-04-21T22:42:29Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, Apr 21, 2005 at 11:12:45PM CEST, I got a letter\nwhere Sean <seanlkml@sympatico.ca> told me that...\n> On the off chance that someone else might like it, here is a pager script\n> for the git log that adds a splash of color:\n\nActually, I would've never expected that I would like it, but we all\nsometimes surprise ourselves.\n\nI made git log colorized if you pass it -c in current git-pasky. Thanks.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1224","messageId":"f0796bb7050421174647943f0c@mail.gmail.com","threadId":"231","inReplyTo":"20050421224229.GR7443@pasky.ji.cz","subject":"[PATCH] Colorized git log","fromName":"Daniel Serpell","fromEmail":"daniel.serpell@gmail.com","sentAt":"2005-04-22T00:46:19Z","receivedAt":"2005-04-22T00:46:19Z","isPatch":true,"sender":{"key":"daniel.serpell@gmail.com","avatar":null},"body":"Hi!\n\nOn 4/21/05, Petr Baudis <pasky@ucw.cz> wrote:\n> \n> I made git log colorized if you pass it -c in current git-pasky. \n> \n\nThis has two problems, solved in two patches:\n* A space is added in front of  header lines when you use color.\n* It does not  work in my (Debian) xterm. This is because here \n  \"setterm\" only works with TERM=linux.\n\n-------------------------\nStrip space in front of colorized header lines.\n\ngitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07\n--- a/gitlog.sh\n+++ b/gitlog.sh\n@@ -27,7 +27,7 @@ fi\n base=$(gitXnormid.sh -c $1) || exit 1\n \n rev-tree $base | sort -rn | while read time commit parents; do\n-\techo $colheader commit ${commit%:*} $coldefault;\n+\techo $colheader\"\"commit ${commit%:*} $coldefault;\n \tcat-file commit $commit | \\\n \t\twhile read key rest; do\n \t\t\tcase \"$key\" in\n@@ -43,10 +43,10 @@ rev-tree $base | sort -rn | while read t\n \t\t\t\tdtz=${tz/+/+ }; dtz=${dtz/-/- }\n \t\t\t\tpdate=\"$(date -Rud \"1970-01-01 UTC + $sec sec $dtz\" 2>/dev/null)\"\n \t\t\t\tif [ \"$pdate\" ]; then\n-\t\t\t\t\techo -n $color $key $rest | sed \"s/>.*/> ${pdate/+0000/$tz}/\"\n+\t\t\t\t\techo -n $color$key $rest | sed \"s/>.*/> ${pdate/+0000/$tz}/\"\n \t\t\t\t\techo $coldefault\n \t\t\t\telse\n-\t\t\t\t\techo $color $key $rest $coldefault\n+\t\t\t\t\techo $color$key $rest $coldefault\n \t\t\t\tfi\n \t\t\t\t;;\n \t\t\t\"\")\n@@ -56,7 +56,7 @@ rev-tree $base | sort -rn | while read t\n \t\t\t\t'\n \t\t\t\t;;\n \t\t\t*)\n-\t\t\t\techo $colheader $key $rest $coldefault\n+\t\t\t\techo $colheader$key $rest $coldefault\n \t\t\t\t;;\n \t\t\tesac\n \n\n-------------------------\nUses tput instead of setterm to set colors, seems to work with more\nterminals.\n\ngitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07\n--- a/gitlog.sh\n+++ b/gitlog.sh\n@@ -11,11 +11,11 @@\n \n if [ \"$1\" = \"-c\" ]; then\n \tshift\n-\tcolheader=$(setterm -foreground green)\n-\tcolauthor=$(setterm -foreground cyan)\n-\tcolcommitter=$(setterm -foreground magenta)\n-\tcolsignoff=$(setterm -foreground yellow)\n-\tcoldefault=$(setterm -foreground default)\n+\tcolheader=\"$(tput setaf 2)\"\n+\tcolauthor=\"$(tput setaf 6)\"\n+\tcolcommitter=\"$(tput setaf 5)\"\n+\tcolsignoff=\"$(tput setaf 3)\"\n+\tcoldefault=\"$(tput op)\"\n else\n \tcolheader=\n \tcolauthor=\n"},{"id":"1225","messageId":"20050422005452.GZ7443@pasky.ji.cz","threadId":"231","inReplyTo":"f0796bb7050421174647943f0c@mail.gmail.com","subject":"Re: [PATCH] Colorized git log","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-22T00:54:52Z","receivedAt":"2005-04-22T00:54:52Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Apr 22, 2005 at 02:46:19AM CEST, I got a letter\nwhere Daniel Serpell <daniel.serpell@gmail.com> told me that...\n> Hi!\n\nHi,\n\n> On 4/21/05, Petr Baudis <pasky@ucw.cz> wrote:\n> > \n> > I made git log colorized if you pass it -c in current git-pasky. \n> > \n> \n> This has two problems, solved in two patches:\n\ncould you please sign them off?\n\n> * A space is added in front of  header lines when you use color.\n\nOh, good catch, thanks.\n\n> * It does not  work in my (Debian) xterm. This is because here \n>   \"setterm\" only works with TERM=linux.\n\nDuh. And they say \"Where possible terminfo is consulted to find the\nstring to use.\" in their manual page. :/\n\n> gitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07\n> --- a/gitlog.sh\n> +++ b/gitlog.sh\n> @@ -11,11 +11,11 @@\n>  \n>  if [ \"$1\" = \"-c\" ]; then\n>  \tshift\n> -\tcolheader=$(setterm -foreground green)\n> -\tcolauthor=$(setterm -foreground cyan)\n> -\tcolcommitter=$(setterm -foreground magenta)\n> -\tcolsignoff=$(setterm -foreground yellow)\n> -\tcoldefault=$(setterm -foreground default)\n> +\tcolheader=\"$(tput setaf 2)\"\n> +\tcolauthor=\"$(tput setaf 6)\"\n> +\tcolcommitter=\"$(tput setaf 5)\"\n> +\tcolsignoff=\"$(tput setaf 3)\"\n> +\tcoldefault=\"$(tput op)\"\n>  else\n>  \tcolheader=\n>  \tcolauthor=\n\nPlease at least stick the colors in comments after the assignment.\nNot everyone knows ANSI color codes off-hand (the last thing I've\nmemorized were BIOS color codes in the distant DOS days).\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1226","messageId":"f0796bb7050421180433eeeb8@mail.gmail.com","threadId":"231","inReplyTo":"20050422005452.GZ7443@pasky.ji.cz","subject":"Re: [PATCH] Colorized git log","fromName":"Daniel Serpell","fromEmail":"daniel.serpell@gmail.com","sentAt":"2005-04-22T01:04:16Z","receivedAt":"2005-04-22T01:04:16Z","isPatch":true,"sender":{"key":"daniel.serpell@gmail.com","avatar":null},"body":"Hi!\n\nOn 4/21/05, Petr Baudis <pasky@ucw.cz> wrote:\n> Dear diary, on Fri, Apr 22, 2005 at 02:46:19AM CEST, I got a letter\n> where Daniel Serpell <daniel.serpell@gmail.com> told me that...\n> >\n> > This has two problems, solved in two patches:\n> \n> could you please sign them off?\n\nOk, here are, resent (I suppose it's ok tho put all in one e-mail),\nand with the comments added.\n\n--------------\nStrip space in front of colorized header lines.\n\nSigned-off-by:  Daniel Serpell <daniel.serpell@gmail.com>\n\n+++ b/gitlog.sh\n@@ -27,7 +27,7 @@ fi\n base=$(gitXnormid.sh -c $1) || exit 1\n \n rev-tree $base | sort -rn | while read time commit parents; do\n-\techo $colheader commit ${commit%:*} $coldefault;\n+\techo $colheader\"\"commit ${commit%:*} $coldefault;\n \tcat-file commit $commit | \\\n \t\twhile read key rest; do\n \t\t\tcase \"$key\" in\n@@ -43,10 +43,10 @@ rev-tree $base | sort -rn | while read t\n \t\t\t\tdtz=${tz/+/+ }; dtz=${dtz/-/- }\n \t\t\t\tpdate=\"$(date -Rud \"1970-01-01 UTC + $sec sec $dtz\" 2>/dev/null)\"\n \t\t\t\tif [ \"$pdate\" ]; then\n-\t\t\t\t\techo -n $color $key $rest | sed \"s/>.*/> ${pdate/+0000/$tz}/\"\n+\t\t\t\t\techo -n $color$key $rest | sed \"s/>.*/> ${pdate/+0000/$tz}/\"\n \t\t\t\t\techo $coldefault\n \t\t\t\telse\n-\t\t\t\t\techo $color $key $rest $coldefault\n+\t\t\t\t\techo $color$key $rest $coldefault\n \t\t\t\tfi\n \t\t\t\t;;\n \t\t\t\"\")\n@@ -56,7 +56,7 @@ rev-tree $base | sort -rn | while read t\n \t\t\t\t'\n \t\t\t\t;;\n \t\t\t*)\n-\t\t\t\techo $colheader $key $rest $coldefault\n+\t\t\t\techo $colheader$key $rest $coldefault\n \t\t\t\t;;\n \t\t\tesac\n \n--------------\nUses tput instead of setterm to set colors, seems to work with more\nterminals.\n\nSigned-off-by:  Daniel Serpell <daniel.serpell@gmail.com>\n\ngitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07\n--- a/gitlog.sh\n+++ b/gitlog.sh\n@@ -11,11 +11,11 @@\n \n if [ \"$1\" = \"-c\" ]; then\n \tshift\n-\tcolheader=$(setterm -foreground green)\n-\tcolauthor=$(setterm -foreground cyan)\n-\tcolcommitter=$(setterm -foreground magenta)\n-\tcolsignoff=$(setterm -foreground yellow)\n-\tcoldefault=$(setterm -foreground default)\n+\tcolheader=\"$(tput setaf 2)\" # Green, see terminfo(5), \"Color Handling\"\n+\tcolauthor=\"$(tput setaf 6)\" # Cyan\n+\tcolcommitter=\"$(tput setaf 5)\" # Magenta\n+\tcolsignoff=\"$(tput setaf 3)\" # Yellow\n+\tcoldefault=\"$(tput op)\" # Restore default\n else\n \tcolheader=\n \tcolauthor=\n"},{"id":"1227","messageId":"200504211904.18283.elenstev@mesatop.com","threadId":"231","inReplyTo":"20050422005452.GZ7443@pasky.ji.cz","subject":"Re: [PATCH] Colorized git log","fromName":"Steven Cole","fromEmail":"elenstev@mesatop.com","sentAt":"2005-04-22T01:04:18Z","receivedAt":"2005-04-22T01:04:18Z","isPatch":true,"sender":{"key":"elenstev@mesatop.com","avatar":null},"body":"On Thursday 21 April 2005 06:54 pm, Petr Baudis wrote:\n\n> Duh. And they say \"Where possible terminfo is consulted to find the\n> string to use.\" in their manual page. :/\n> \n> > gitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07\n> > --- a/gitlog.sh\n> > +++ b/gitlog.sh\n> > @@ -11,11 +11,11 @@\n> >  \n> >  if [ \"$1\" = \"-c\" ]; then\n> >  \tshift\n> > -\tcolheader=$(setterm -foreground green)\n> > -\tcolauthor=$(setterm -foreground cyan)\n> > -\tcolcommitter=$(setterm -foreground magenta)\n> > -\tcolsignoff=$(setterm -foreground yellow)\n> > -\tcoldefault=$(setterm -foreground default)\n> > +\tcolheader=\"$(tput setaf 2)\"\n> > +\tcolauthor=\"$(tput setaf 6)\"\n> > +\tcolcommitter=\"$(tput setaf 5)\"\n> > +\tcolsignoff=\"$(tput setaf 3)\"\n> > +\tcoldefault=\"$(tput op)\"\n> >  else\n> >  \tcolheader=\n> >  \tcolauthor=\n> \n> Please at least stick the colors in comments after the assignment.\n> Not everyone knows ANSI color codes off-hand (the last thing I've\n> memorized were BIOS color codes in the distant DOS days).\n> \n\nI like the color idea, but since many people have their own idea\nof what colors are appropriate, etc (I use a dark background, and\nthe magenta is painful), perhaps we could have a LOG_COLORS\nfile, similar in concept (but more readable) to the /etc/DIR_COLORS\nfile.  Great work !\n\nSteven\n"}]}