Ahmad Awais

SHARE


Show Emoji in Git Log! 👌

Ahmad AwaisAhmad Awais

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! ✌

📨

TheDevTakeaway: Developers' Newsletter!

Takeaway my professional opinion about Open Source, JavaScript/Cloud, Full Stack Development, building a business, growing a family, and everything in between! Delivered to your inbox once a month. 🤣 I'm even funny some times. 👻 I hate spam! Pinky Promise!

🎩 Full-time #OpenSourcerer 🥑 JavaScript Developer Advocate 🔥 Ridiculously hard-working Full Stack Web Developer ⓦ Regular WordPress Core Developer 📣 TEDx Speaker ✌️ Spends 50-80% of his time building professional FOSS (Free & Open Source Software) used by over 218,900 Developers 🙌 Cloud Community Evangelist 🎯 JavaScript & DevOps fanboy 😂 Cracks silly jokes 💜 Loves his wife (Maedah) 🍕 Learn more about Ahmad ↣

Say 👋 on Twitter @MrAhmadAwais | Subscribe to the WordPress Takeaway!