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

[PATCH] Colored log on any ANSI capable terminal

From
PRPavel Roskin <proski@gnu.org>
Date
Apr 22, 2005, 01:42 UTC
Message-ID
<1114134137.12771.7.camel@dv>
Hello!

setterm only works on Linux terminal. It should be safe to use raw ANSI sequences -they work on most terminals, including xterm. Nobody forces you to use the "-c" option to "git log" on those stone-age terminals that neither support nor ignore ANSI color codes.

I'm aware of $'...' but it may not work in bash 1.x.
Signed-off-by: Pavel Roskin <proski@gnu.org>
--- a/gitlog.sh
+++ b/gitlog.sh
@@ -12,11 +12,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=$(echo -ne '\e[32m')
+	colauthor=$(echo -ne '\e[36m')
+	colcommitter=$(echo -ne '\e[35m')
+	colsignoff=$(echo -ne '\e[33m')
+	coldefault=$(echo -ne '\e[39m')
 else
 	colheader=
 	colauthor=
-- 
Regards,
Pavel Roskin
Message 1 of 1 in “Colored log on any ANSI capable terminal”
  1. Colored log on any ANSI capable terminalPavel Roskin, Apr 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.