Skip to content

Instantly share code, notes, and snippets.

@keithamus
Created December 10, 2010 13:58
Show Gist options
  • Save keithamus/736220 to your computer and use it in GitHub Desktop.
Save keithamus/736220 to your computer and use it in GitHub Desktop.
Add this to your ~/.nanorc and when running "git commit" (if your editor is nano) you'll have syntax highlighting in your commit message. Includes support for "git commit -v" too!
syntax "gitcommit" "COMMIT_EDITMSG$"
color white "#.*"
color green "#.(modified|deleted).*"
color yellow start="# Changes.*" end="# Changed.*"
color cyan start="# Untracked.*" end="diff"
color cyan start="# Untracked.*" end="$$"
color brightred "^deleted file mode .*"
color brightgreen "^\+.*"
color brightred "^-.*"
color brightyellow "^(diff|index|---|\+\+\+).*"
color brightmagenta "@@.*@@"
color white "# (Change[ds]|Untracked) .*"
color white "#.*\(use .*"
color white "^#"
@jacklorusso
Copy link

Legend cheers mate

@dacdave
Copy link

dacdave commented Dec 5, 2016

Will this work for .vimrc as well?

@dos1
Copy link

dos1 commented Sep 22, 2017

Thanks <3

@ob-ivan
Copy link

ob-ivan commented Feb 21, 2019

Great highlighting! My life has just become so much better!

Some ideas to add to this:

  • Put this into a separate file (I use .config/nano/gitcommit.nanorc) and then reference to it from your .nanorc with an include line as described here: http://milianw.de/code-snippets/git-commit-message-highlighting-in-nano
  • Use different colors for comments and the message itself. E.g. cyan for the comments.
  • Special highlighting for the "cut" line with ---- >8 ----.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment