🎨 See a lovely color swatch in your terminal every time you author a commit.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
templates
.gitignore
README.md
demo.gif
index.js
package-lock.json
package.json
single-line.png

README.md

Commit Colors

See a lovely color swatch in your terminal every time you author a commit. Here's what it looks like:

animated gif demonstrating commit colors

The hexadecimal color comes from the first six characters in your commit hash.

Installing

  1. Install the package globally

    npm install -g @sparkbox/commit-colors
  2. Copy/paste the following text into a post-commit hook:

    #!/bin/bash
    SHA=$(git rev-parse HEAD)
    SHA6=${SHA:0:6}
    commit-colors $SHA6
    

    In other words, put the above code in a file named post-commit at the location .git/hooks/post-commit in your git project of choice. Make sure this file is executable. If you want this hook to run an all your repos, see how to do that here.

Options

You can change the appearance of the message by using a different template, like the "single line" template below:

a screenshot of the message using the "single line" template

To use a different template, pass the template path as the second argument to commit-colors in your shell script:

commit-colors $SHA6 './templates/single-line'

This could also be a path to your own custom template.

commit-colors $SHA6 '~/my-stuff/my-color-template'

Todo

  • Make it easier to install the commit hook.
  • Ensure it is cross-platform.
  • Support more color names.
  • ???