Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure git commit editor colors

Tags:

git

vim

What is the parameter to configure the color of the first line (and the body text) of the commit message editor of git? (In case that matters, I am using vim as an editor).

I have found many related resources, but none of them gave the option to specify this color. (For the records, the most relevant hits were the following:

  • https://gist.github.com/rab/4067067
  • Git - Do colours mean something in the editor that opens when I commit?
  • https://unix.stackexchange.com/questions/44266)

I am beginning to suspect that this option has to be configured somewhere else (e.g. in bash or in vim)...

like image 777
Attilio Avatar asked Oct 03 '16 08:10

Attilio


2 Answers

To change the color of the title when you are editing the commit message in vim, add following code to ~/.vimrc

au FileType gitcommit
 \ hi gitcommitSummary ctermfg=yellow ctermbg=red

other highlight option can be found by typing :hi in vim command, or from following url

https://github.com/vim/vim/blob/master/runtime/syntax/gitcommit.vim

like image 189
ymonad Avatar answered Sep 19 '22 17:09

ymonad


As the syntax script for the gitcommit filetype properly uses :hi def link, you can simply overwrite any of its highlightings in your ~/.vimrc:

:hi gitcommitSummary ctermfg=yellow ctermbg=red

No :au FileType gitcommit (as in @ymonad's answer) is necessary.

like image 23
Ingo Karkat Avatar answered Sep 21 '22 17:09

Ingo Karkat