* Colorized git log
@ 2005-04-21 21:12 Sean
2005-04-21 22:42 ` Petr Baudis
0 siblings, 1 reply; 6+ messages in thread
From: Sean @ 2005-04-21 21:12 UTC (permalink / raw)
To: GIT Mailing Lists
On the off chance that someone else might like it, here is a pager script
for the git log that adds a splash of color:
#!/bin/sh
git log "$@" | sed -re '
/.*signed-off-by.*/Is//\x1b[34m&\x1b[0m/
/^--*$/Is//\x1b[31m&\x1b[0m/
/^(commit|tree|parent) .*/Is//\x1b[32m&\x1b[0m/
/^author .*/Is//\x1b[36m&\x1b[0m/
/^committer .*/Is//\x1b[35m&\x1b[0m/' | less -R
Sean
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Colorized git log 2005-04-21 21:12 Colorized git log Sean @ 2005-04-21 22:42 ` Petr Baudis 2005-04-22 0:46 ` [PATCH] " Daniel Serpell 0 siblings, 1 reply; 6+ messages in thread From: Petr Baudis @ 2005-04-21 22:42 UTC (permalink / raw) To: Sean; +Cc: GIT Mailing Lists Dear diary, on Thu, Apr 21, 2005 at 11:12:45PM CEST, I got a letter where Sean <seanlkml@sympatico.ca> told me that... > On the off chance that someone else might like it, here is a pager script > for the git log that adds a splash of color: Actually, I would've never expected that I would like it, but we all sometimes surprise ourselves. I made git log colorized if you pass it -c in current git-pasky. Thanks. -- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Colorized git log 2005-04-21 22:42 ` Petr Baudis @ 2005-04-22 0:46 ` Daniel Serpell 2005-04-22 0:54 ` Petr Baudis 0 siblings, 1 reply; 6+ messages in thread From: Daniel Serpell @ 2005-04-22 0:46 UTC (permalink / raw) To: GIT Mailing Lists; +Cc: Petr Baudis Hi! On 4/21/05, Petr Baudis <pasky@ucw.cz> wrote: > > I made git log colorized if you pass it -c in current git-pasky. > This has two problems, solved in two patches: * A space is added in front of header lines when you use color. * It does not work in my (Debian) xterm. This is because here "setterm" only works with TERM=linux. ------------------------- Strip space in front of colorized header lines. gitlog.sh: 6d24d857fb6c2f7e810954adaca1990599906f07 --- a/gitlog.sh +++ 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. 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)" + colauthor="$(tput setaf 6)" + colcommitter="$(tput setaf 5)" + colsignoff="$(tput setaf 3)" + coldefault="$(tput op)" else colheader= colauthor= ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Colorized git log 2005-04-22 0:46 ` [PATCH] " Daniel Serpell @ 2005-04-22 0:54 ` Petr Baudis 2005-04-22 1:04 ` Daniel Serpell 2005-04-22 1:04 ` Steven Cole 0 siblings, 2 replies; 6+ messages in thread From: Petr Baudis @ 2005-04-22 0:54 UTC (permalink / raw) To: Daniel Serpell; +Cc: GIT Mailing Lists 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... > Hi! Hi, > On 4/21/05, Petr Baudis <pasky@ucw.cz> wrote: > > > > I made git log colorized if you pass it -c in current git-pasky. > > > > This has two problems, solved in two patches: could you please sign them off? > * A space is added in front of header lines when you use color. Oh, good catch, thanks. > * It does not work in my (Debian) xterm. This is because here > "setterm" only works with TERM=linux. Duh. And they say "Where possible terminfo is consulted to find the string to use." in their manual page. :/ > 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)" > + colauthor="$(tput setaf 6)" > + colcommitter="$(tput setaf 5)" > + colsignoff="$(tput setaf 3)" > + coldefault="$(tput op)" > else > colheader= > colauthor= Please at least stick the colors in comments after the assignment. Not everyone knows ANSI color codes off-hand (the last thing I've memorized were BIOS color codes in the distant DOS days). -- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Colorized git log 2005-04-22 0:54 ` Petr Baudis @ 2005-04-22 1:04 ` Daniel Serpell 2005-04-22 1:04 ` Steven Cole 1 sibling, 0 replies; 6+ messages in thread From: Daniel Serpell @ 2005-04-22 1:04 UTC (permalink / raw) To: GIT Mailing Lists; +Cc: Petr Baudis Hi! On 4/21/05, Petr Baudis <pasky@ucw.cz> wrote: > 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= ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Colorized git log 2005-04-22 0:54 ` Petr Baudis 2005-04-22 1:04 ` Daniel Serpell @ 2005-04-22 1:04 ` Steven Cole 1 sibling, 0 replies; 6+ messages in thread From: Steven Cole @ 2005-04-22 1:04 UTC (permalink / raw) To: Petr Baudis; +Cc: Daniel Serpell, GIT Mailing Lists On Thursday 21 April 2005 06:54 pm, Petr Baudis wrote: > Duh. And they say "Where possible terminfo is consulted to find the > string to use." in their manual page. :/ > > > 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)" > > + colauthor="$(tput setaf 6)" > > + colcommitter="$(tput setaf 5)" > > + colsignoff="$(tput setaf 3)" > > + coldefault="$(tput op)" > > else > > colheader= > > colauthor= > > Please at least stick the colors in comments after the assignment. > Not everyone knows ANSI color codes off-hand (the last thing I've > memorized were BIOS color codes in the distant DOS days). > I like the color idea, but since many people have their own idea of what colors are appropriate, etc (I use a dark background, and the magenta is painful), perhaps we could have a LOG_COLORS file, similar in concept (but more readable) to the /etc/DIR_COLORS file. Great work ! Steven ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-04-22 1:04 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-04-21 21:12 Colorized git log Sean 2005-04-21 22:42 ` Petr Baudis 2005-04-22 0:46 ` [PATCH] " Daniel Serpell 2005-04-22 0:54 ` Petr Baudis 2005-04-22 1:04 ` Daniel Serpell 2005-04-22 1:04 ` Steven Cole
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.