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.
git log
, whenever you need to.This guide expects you to write commit messages like these.
docs: Update README.md
fix: Rename variable
Then weβll use a command to turn the above into this:
π docs: Update README.md
π fix: Rename variable
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:
sed
call that uses newlines to separate rules. Or you can do it in one line using semicolons.ci:
means if ci
appears not as a prefix but in the middle of your message, it wonβt get affectd.chore
prefix is not actually in the Angular Convention.build:
as a prefix like I do.π·<200d>
for build and β‘<fe0f>
for perf. The command output still looks correct.ci
emojis.chore
, as it depends on the context.
π§½
for general cleaning chore. Or π§Ή
could work too.π₯
for Remove code or files.
π§
for Add or update configuration files.
.π
for Move or rename resources (e.g.: files, paths, routes).
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
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.
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