git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Colorized git log

From
DSDaniel Serpell <daniel.serpell@gmail.com>
Date
Apr 22, 2005, 01:04 UTC
Message-ID
<f0796bb7050421180433eeeb8@mail.gmail.com>
In-Reply-To
<20050422005452.GZ7443@pasky.ji.cz>
Hi!
On 4/21/05, Petr Baudis <pasky@ucw.cz> wrote:
Show 6 quoted lines
> Dear diary, on Fri, Apr 22, 2005 at 02:46:19AM CEST, I got a letter
> where Daniel Serpell <daniel.serpell@gmail.com> told me that...
> >
> > This has two problems, solved in two patches:
> 
> could you please sign them off?

Ok, here are, resent (I suppose it's ok tho put all in one e-mail), and with the comments added.

-------------- Strip space in front of colorized header lines.

Signed-off-by:  Daniel Serpell <daniel.serpell@gmail.com>
+++ b/gitlog.sh
@@ -27,7 +27,7 @@ fi
 base=$(gitXnormid.sh -c $1) || exit 1
 
 rev-tree $base | sort -rn | while read time commit parents; do
-	echo $colheader commit ${commit%:*} $coldefault;
+	echo $colheader""commit ${commit%:*} $coldefault;
 	cat-file commit $commit | \
 		while read key rest; do
 			case "$key" in
@@ -43,10 +43,10 @@ rev-tree $base | sort -rn | while read t
 				dtz=${tz/+/+ }; dtz=${dtz/-/- }
 				pdate="$(date -Rud "1970-01-01 UTC + $sec sec $dtz" 2>/dev/null)"
 				if [ "$pdate" ]; then
-					echo -n $color $key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/"
+					echo -n $color$key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/"
 					echo $coldefault
 				else
-					echo $color $key $rest $coldefault
+					echo $color$key $rest $coldefault
 				fi
 				;;
 			"")
@@ -56,7 +56,7 @@ rev-tree $base | sort -rn | while read t
 				'
 				;;
 			*)
-				echo $colheader $key $rest $coldefault
+				echo $colheader$key $rest $coldefault
 				;;
 			esac
 
--------------
Uses tput instead of setterm to set colors, seems to work with more
terminals.

Signed-off-by:  Daniel Serpell <daniel.serpell@gmail.com>

gitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07
--- a/gitlog.sh
+++ b/gitlog.sh
@@ -11,11 +11,11 @@
 
 if [ "$1" = "-c" ]; then
 	shift
-	colheader=$(setterm -foreground green)
-	colauthor=$(setterm -foreground cyan)
-	colcommitter=$(setterm -foreground magenta)
-	colsignoff=$(setterm -foreground yellow)
-	coldefault=$(setterm -foreground default)
+	colheader="$(tput setaf 2)" # Green, see terminfo(5), "Color Handling"
+	colauthor="$(tput setaf 6)" # Cyan
+	colcommitter="$(tput setaf 5)" # Magenta
+	colsignoff="$(tput setaf 3)" # Yellow
+	coldefault="$(tput op)" # Restore default
 else
 	colheader=
 	colauthor=
Previous: Petr BaudisNext: Steven Cole
Message 5 of 6 in “Colorized git log”
  1. SeanApr 21, 2005
  2. Petr BaudisApr 21, 2005
  3. Colorized git logDaniel Serpell, Apr 22, 2005
  4. Petr BaudisApr 22, 2005
  5. Daniel SerpellApr 22, 2005
  6. Steven ColeApr 22, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.