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

Re: [PATCH] git-status: colorize status output

From
Jeff King <peff@peff.net>
Date
Aug 5, 2006, 03:21 UTC
Message-ID
<20060805032135.GA11244@coredump.intra.peff.net>
In-Reply-To
<20060805031418.GA11102@coredump.intra.peff.net>
On Fri, Aug 04, 2006 at 11:14:19PM -0400, Jeff King wrote:
> The idea is that red things indicate a potential mistake on the part of the
> user (e.g., forgetting to update a file, forgetting to git-add a file).

I actually wanted to do this because I started syntax-highlighting the git-commit message in vim. I found myself catching simple mistakes in commits, like the ones I mentioned above, before committing, saving me from doing an --amend. Then I got so hooked on it I wanted the colorization everytime I ran git-status.

If anyone is interested in the vim syntax highlighting, it is below.
Copy the file to $HOME/.vim/syntax/gitcommit.vim and add the following
line to your .vimrc:
  autocmd BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
-Peff

-- >8 -- syn region gitLine start=/^#/ end=/$/ syn region gitCommit start=/^# Updated but not checked in:$/ end=/^#$/ contains=gitHead,gitCommitFile syn region gitHead contained start=/^# (.*)/ end=/^#$/ syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile

syn match gitCommitFile contained /^#\t.*/hs=s+2 syn match gitChangedFile contained /^#\t.*/hs=s+2 syn match gitUntrackedFile contained /^#\t.*/hs=s+2

hi def link gitLine Comment hi def link gitCommit Comment hi def link gitChanged Comment hi def link gitHead Comment hi def link gitUntracked Comment hi def link gitCommitFile Type hi def link gitChangedFile Constant hi def link gitUntrackedFile Constant

Previous: Jeff KingNext: Greg KH
Message 2 of 21 in “git-status: colorize status output”
  1. git-status: colorize status outputJeff King, Aug 5, 2006
  2. Jeff KingAug 5, 2006
  3. Greg KHAug 5, 2006
  4. Junio C HamanoAug 5, 2006
  5. Jeff KingAug 5, 2006
  6. Jeff KingAug 5, 2006
  7. Matthias LederhoferAug 5, 2006
  8. Junio C HamanoAug 5, 2006
  9. Junio C HamanoAug 5, 2006
  10. Matthias LederhoferAug 5, 2006
  11. Junio C HamanoAug 5, 2006
  12. Matthias LederhoferAug 5, 2006
  13. Jeff KingAug 5, 2006
  14. Matthias LederhoferAug 5, 2006
  15. Jeff KingAug 5, 2006
  16. Jeff KingAug 5, 2006
  17. Sam RavnborgAug 7, 2006
  18. Jeff KingAug 5, 2006
  19. Matthias LederhoferAug 5, 2006
  20. Joel BeckerAug 6, 2006
  21. Jeff KingAug 6, 2006

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.