Boost Productivity by Fanfare on Code Commit

Working on an exciting project is like a great adventure! Every code commit is a victory towards to the battle of new features. Why not celebrate with musical flourish? Uplifting fanfare will inspire you to fight the next combat!

This is a tutorial of how to play your favorite short music from Youtube on Git code commit.

Requirement

Mplayer and mpv are two popular media players on Linux. We choose mpv because mplayer requires extra setup to accept https protocol (open-ssl).

Installation

On Mac

brew install mpv  

On Ubuntu

sudo add-apt-repository ppa:mc3man/mpv-tests  
sudo apt-get install mpv  

Quick Setup

If you don't have any git hook yet, go to Full Setup section. To play short music from Youtube, simply add one line of code in <repository>/.git/hooks/post-commit file.

#!/bin/sh

# Play fanfare on commit
mpv --no-video <Youtube URL> &> /dev/null

# Add other post-commit hooks

Options:

  • --no-vedio audio only, required for no UI popup
  • --start=<time> start from given position (sec)
  • --end=<time> end at given position (sec)

Full Setup

You can create a global git commit hook. And pass hook setup to desired existing repository.

Enable git templates

git config --global init.templatedir '~/.git-templates'  
mkdir -p ~/.git-templates/hooks  

Write hooks in ~/.git-templates/hooks. For playing music when git commit completed, edit post-commit hook in ~/.git-templates/hooks/post-commit. Same step as in Quick Setup.

#!/bin/sh

# Play fanfare on commit
mpv --no-video <Youtube URL> &> /dev/null  

And make the hook executable

chmod a+x ~/.git-templates/hooks/post-commit  

For any repository you would like to enable the hook we just created, re-initialize git in existing repository.

cd <repository path>  
git init  

Demo

I love the classic victory fanfare from Final Fantasy series . Here it goes with Final Fantasy XV version!

Reference

Create a global git commit hook

You might enjoy:

Next post No more posts

Comments

comments powered by Disqus