It’s just really cool 🤘 to see every commit linked with your current animated mood. But it can be a hassle to setup, especially when using external git GUI’s like Tower.
Now let’s setup a commit hook for our project in git. But first let me explain to you what this does. A
post-commit hook is a script that triggers after every commit (hence the name post). This way we can automate some post-commit actions.
In our case we want to run the
lolcommits command with some options.
Add the following file to your git repository on this location
.git/hooks/post-commitwith the content below:
#!/usr/bin/env bash# We only execute the script when not merging or rebasing.
if [ ! -d "$GIT_DIR/rebase-merge" ]; then
# Set the correct language.
# Add homebrew to the PATH.
# When using Rbenv we need to add the shims directory to the PATH.
export PATH="~/.rbenv/shims:$PATH"# Define the directory where the gif will be placed.
export LOLCOMMITS_DIR=/Users/fousa/Dropbox/Lolcommits# Generate the gif.
lolcommits --capture \
--device='FaceTime HD Camera' >/dev/null 2>&1 &
Now you just have to make sure the post-hook is executable.
chmod +x .git/hooks/post-commit
A few extra words about the script:
- You can fetch the device name by running
lolcommits --devicesin the command line. I prefer to use my MacBook’s camera.
delaythe execution of the script because the camera needs some time to start. Otherwise the gif has a black initial frame which is a bit fugly. 😣
More configuration options available here.
But what about existing projects? We’ll create a git template so you don’t always have to create the post commit hook.
Now let’s copy the post-commit hook here:
~/.git_template/hooks/post-commit. Next, set the template directory in your .
gitconfig file like this:
templatedir = ~/.git_template
Then this hook will be automagically added to your project every time you run
You can even just re-run
git init in the root of your project. This will copy the post-commit configuration from the template to your repository. When a hook is already present, you’ll have to remove it to get it copied on
git init. (or you can just add the required code to the
Automation is awesome! 🤘