Skip to content

Instantly share code, notes, and snippets.

@ptbrowne ptbrowne/README.md
Last active Nov 1, 2018

Embed
What would you like to do?
Automatically add emojis to your commits

To automatically add emojis to your commits, you can use the commit-msg hook.

$ git init
$ ln -s commit-msg-emoji .git/hooks/commit-msg
#!/bin/sh
# the file where the commit message is written
filepath="$1"
tmp_file=$(mktemp /tmp/emoji-commitzen.XXXX)
replacements=(
's/^feat/✨ feat/'
's/^fix/🐝 fix/'
's/^doc/📚 doc/'
's/^style/🎨 style/'
's/^refactor/🔨 refactor/'
's/^perf/🚀 perf/'
's/^chore/🔧 chore/'
's/^lint/💄 lint/'
's/^test/🚨 test/'
's/^first/🐣 first/'
)
# join replacements by ; to have sed perform multiple replace
sed_command=$(printf "%s;" "${replacements[@]}")
# perform replacements in temp file
cat $filepath | sed "$sed_command" > $tmp_file
# replace commit file
mv $tmp_file $filepath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.