commit message Syndicate content

warning: Creating default object from empty value in /www/htdocs/w0065fc9/milianw/modules/taxonomy/taxonomy.pages.inc on line 33.

» Git commit message highlighting in nano

Sat, 11/24/2012 - 16:07

For those who use nano as their CLI editor of choice: Here’s a syntax highlighting file for Git commit messages which also supports the special KDE commit hook keywords.

  1. ## syntax highlighting for git commit messages of KDE projects
  2. syntax "patch" ".git/COMMIT_EDITMSG$"
  3.  
  4. # overlong lines
  5. color brightred "^.{70,}.+$"
  6.  
  7. # KDE commit hook keywords, see: http://community.kde.org/Sysadmin/GitKdeOrgManual#Commit_hook_keywords
  8. color yellow "^(FEATURE|BUG|CCBUG|FIXED-IN|CCMAIL|REVIEW|GUI|DIGEST):.*$"
  9. color yellow "(SVN_SILENT|GIT_SILENT|SVN_MERGE)"
  10.  
  11. # comment
  12. color blue "^#.*$"
  13.  
  14. # special comment lines
  15. color green "^# Changes to be committed:"
  16. color red "^# Changes not staged for commit:"
  17. color brightblue "^# Untracked files:"
  18. color brightblue "^# On branch .+$"
  19. color brightblue "^# Your branch is ahead of .+$"
  20.  
  21. # diff files
  22. # meh - cannot match against \t ... should be: ^#\t.*$
  23. color cyan "^#[^ a-zA-Z0-9][^ ].*$"

Just put this file as gitcommit.nanorc or similar somewhere on your disk and load it from your .nanorc or even /etc/nanorc like this:

  1. include "/path/to/gitcommit.nanorc"
Screenshot of highlighted git commit message
Screenshot of highlighted git commit message