emoji-resources

Git log emoji

View your Conventional Commit log messages with emojis added

This page is about alias I came up with to prettify your commit log view to show emojis, without needing the commit messages to actually contain emojis or editing messages.

Features

Resources

Commit message style

Write conventianl commits

This guide expects you to write commit messages like these.

docs: Update README.md
fix: Rename variable

Add emojis

Then we’ll use a command to turn the above into this:

πŸ“ docs: Update README.md
πŸ› fix: Rename variable

The command to run

For Bash or Linux, using sed to find and replace.

Here is a long multi-line command you can copy and paste. Prevent going through the entire git log, I’ve limited to the most recent 20 commits.

git lol -20 | sed 's/feat:/✨ feat:/g
s/fix:/πŸ› fix:/g
s/build:/πŸ‘·β€β™‚οΈ build:/g
s/chore:/🧽 chore:/g
s/ci:/πŸ”§ ci:/g
s/docs:/πŸ“ docs:/g
s/refactor:/♻️ refactor:/g
s/perf:/⚑️ perf:/g
s/style:/🎨 style:/g
s/test:/βœ… test:/g
s/tag:/πŸ”– tag:/g
s/Initial commit$/πŸŽ‰ Initial commit/g'

Example output with emojis inserted:

* a15457b Update development.md
* 00e49b0 Create development.md
* a400c64 ✨ feat: Update link layout
* bb96ef5 (πŸ”– tag: v0.2.0) ✨ feat: Add to homepage
* 715c4bd πŸ“ docs: Add to README.md
* 3670bfb ✨ feat: Change theme to dark
* 9720c96 πŸŽ‰ Initial commit

Notes:

If you want to test that without git:

$ echo 'perf: abc' | sed 's/feat:/✨ feat:/g ; s/perf:/⚑ perf:/g'
✨ feat: abc
$ echo 'perf: abc' | sed 's/feat:/✨ feat:/g ; s/perf:/⚑ perf:/g'
⚑️ perf: abc

Set up an alias

Configure

To make is easier to use the command above any time, you can add it to your git aliases in ~/.gitconfig.

Add to your git config under [alias] section.

This shows a commit message in a single line and adds a tree flow for use with branches. No emojis yet.

  lol = "log --graph --decorate --oneline"

Now set the emoji command as an alias too. This will use call lol as defined above and then do the replacement. We use a TOML heredoc (multi-line string), which involves both escaping line breaks (which allows wrapping but also flattens everything to one line) and adding in semicolons to split out replacement rules.

[alias]
    emoji = """! git lol -20 | sed 's/feat:/✨ feat:/g ; \
		s/fix:/πŸ› fix:/g ; \
		s/build:/πŸ‘·β€β™‚οΈ build:/g ; \
		s/chore:/🧽 chore:/g ; \
		s/ci:/πŸ”§ ci:/g ; \
		s/docs:/πŸ“ docs:/g ; \
		s/refactor:/♻️ refactor:/g ; \
		s/perf:/⚑️ perf:/g ; \
		s/style:/🎨 style:/g ; \
		s/test:/βœ… test:/g ; \
		s/tag:/πŸ”– tag:/g ; \
		s/Initial commit$/πŸŽ‰ Initial commit/g' \
	"""

Save the config.

Use alias

Now you can use it anywhere in a git repo. You don’t need to restart your terminal.

$ git emoji
* a15457b Update development.md
* 00e49b0 Create development.md
* a400c64 ✨ feat: Update link layout
* bb96ef5 (πŸ”– tag: v0.2.0) ✨ feat: Add to homepage
* 715c4bd πŸ“ docs: Add to README.md
* 3670bfb ✨ feat: Change theme to dark
* 9720c96 πŸŽ‰ Initial commit