Ahmad Awais



Show Emoji in Git Log! πŸ‘Œ

Ahmad AwaisAhmad Awais

πŸ†• Check out Emoji Log and 🌟star it on GitHub here β†’

I like emoji. I like ’em a lot. Programming, code, geeks/nerds, open source, all of that is inherently dull and sometimes boring. Emoji (which is, in fact, the plural of emoji) helps me add colors and emotions to the mix. Nothing bad if you want to add emotions to this 2D flat text-based world of code.

But the problem is that on MacOS the $ git log command is a little emoji-racist (yes, it’s a term that I coined and I have a post that I am writing about it). Apparently, if you run $ git log in your terminal it doesn’t display emoji.

$ git log
commit f60fd4a63be2c42588249a6db036b62c4ca2c0c8
Author: Ahmad Awais <[email protected]>
Date: 1 min ago
<U+1F4E6> Test Samples!

But if you add the argument --no-pager to it, that does work.

$ git log --no-pager
commit f60fd4a63be2c42588249a6db036b62c4ca2c0c8
Author: Ahmad Awais <[email protected]>
Date: 1 min ago
πŸ“¦ Test Samples!

So, after searching a bit, I found out that Git’s pager defaults to less. So, my next attempt was to try and print an emoji with less. Didn’t work. Now, I knew what was causing this issue. It was definitely less.

Less Emoji

After trying to disable less on recommendations from several answers over there at StackOverflow, I almost gave up, as none of that worked.

Finally, I thought about updating less as MacOS comes with a pretty old version of less, I think it was 458, whereas the current version of less is 530. (If MacOS was open source, I’d have found myself pushing a PR to update less β€” Apple, did you hear that?!).

So, our old friend Homebrew came to rescue. Instead of going through the trouble of downloading and compiling the latest source of less I just ran the following command.

brew install homebrew/core/less

Since less which used to be a part of homebrew/dupes was migrated to homebrew/core. And guess what, this is what fixed my git log.

git log


Make your git log even better! I use the following alias in my ZSH/Bash rc files. It saves lots of space and gives me more human readable info.

alias lg="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(red)%h%C(r) β€”β€” %C(bold blue)%an%C(r): %C(white)%s%C(r) %C(dim white) %C(bold green)(%ar)%C(r) %C(bold yellow)%d%C(r)' --all"

And I end up with this:

better git log alias

Peace! ✌

I help businesses understand developers πŸ“Ÿ Launching Node.js CLI Automation Course πŸ‘¨β€πŸ« Edutainer at VSCode.pro 🎩 An award-winning open-source engineer and developer advocate 🦊 Google Developers Expert for web 🌳 Node.js foundation Community Committee member ✌️ Author of various open-source dev-tools and software libraries used by millions of developers worldwide ⓦ WordPress Core Developer πŸ“£ TEDx Speaker πŸ™Œ Leading developers and publishing technical content for over a decade πŸ˜‚ Self-confessed tech comedian working with the JavaScript web and cloud communities πŸ’œ Loves his wife (Maedah) ❯ Learn more about Awais ↣

Say πŸ‘‹ on Twitter @MrAhmadAwais | Subscribe to the Developers Takeaway!


Developers Takeaway

Takeaway my professional opinion on open-source, developer relations, growing your business with family, and everything in between! Delivered to your inbox a couple of times every year. I'm even funny at times. I hate spam β€” pinky-promise!

πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’» 115,834 Developers Already Subscribed