Something Someone Somewhere Uses... Sometimes
Tags: vscode, git, emoji, gitmoji
Published: 2018-12-21 14:07:55

---
title: Something Someone Somewhere Uses... Sometimes
published: true
description: Small Victories in Software
tags: vscode,git,emoji,gitmoji
cover_image: https://thepracticaldev.s3.amazonaws.com/i/r53t0uy9sq44kqa05oqy.png
---


🌌 Recently I found myself coding in a team and it was decided that all commit messages would begin with an emoji. [Gitmoji](https://gitmoji.carloscuesta.me/) defines what each emoji means. ✨ or `:sparkles:` is for a new feature and 💩 or `:hanky:` is for bad code that needs improvement...you get the idea. Turns out there are tons of these - I just counted 62. I admit, it adds an element of fun and repos look more stylish. Gitmoji says:

> **Using emojis** on **commit messages** provides an easy way of **identifying the purpose or intention of a commit** with only looking at the emojis used.

|Normal|Gitmoji|
|:-:|:-:|
|<img src="https://thepracticaldev.s3.amazonaws.com/i/bcey6sbuulhmgmcgpt0k.png" width="300" />|<img src="https://thepracticaldev.s3.amazonaws.com/i/7uv72m8y5tl044dyktgl.png" width="300" />|

So coding begins on this project and the time comes to start making commits. I cruise over to **Gitmoji** and scroll around trying to find the best available emoji. This ends up taking a while as I learn the system. I also have a problem when I use the Windows 10 emoji tool (`windows button + ;`) to insert the emoji into the terminal. When the commit message gets to **GitHub**, the emoji looks like &#2186; aka nothing. So this is becoming a giant waste of time, seriously disturbing my flow, yo.

> I was also unaware of [gitmoji-cli](https://gitmoji.carloscuesta.me/about) at this time

Instead of running `npm i -g gitmoji-cli`, which I still haven't done, I spent the rest of the day making a **VS Code** extension and not working on my project. I had no idea what I was doing, but **VSC** is pretty amazing and has a tool to help scaffold an extension. 

```
npm install -g yo generator-code
yo code
```

The `yo` installs [Yeoman](https://yeoman.io/) and `generator-code` is the **VSC** tool that generates all the files needed for an extension, ➕ a Hello World.

In any event, I found the docs and the api to be user friendly. Another 🤙 radical feature dude, is that **VSC** will automatically know that the workspace is for extension development (I believe this is based on `~.vscode/launch.json` file the code generator makes). Instead of running an npm script or something, just press `F5` and a whole new window opens along with a debugger. I feel like a theme is developing of me worshiping my code editor...idk...we spend a lot of time together.

After a few hours I had built a solution to my problem, integrated right into my favorite code editor. It works by having a big list of all the emojis and their definitions available in the command palette. **VS Code's** api is such that I didn't even have to write the logic for the search, only process the result. Less work, how great is that. Anyways, after an emoji is selected the prompt wants the commit message. All I really do is match the user's selected emoji to the list and roll it all together with a string literal....Then finally everything pops out in the integrated terminal (or creates one). 

```
// pseudo code
const choice = '🚀 Deploying stuff'

const gitmoji = () => {
...
   if(choice.match('🚀')) return ':rocket:'
...
}
const commitText = 'Deploy app to Heroku'

send.to.terminal(`git commit -m ${gitmoji} ${commitText}`)
```

So the final string in the terminal might be something like:

```
 git commit -m ':rocket: Deploy app to Heroku'
```
Then you Hit enter.

Here is a gif that explains it better than I do:

![Gitmoji Commit in action](https://thepracticaldev.s3.amazonaws.com/i/74aa7j8srvdnroofskn0.gif)

The next step was publishing the extension to the marketplace. Not a big deal. There is a command for that. And 💥, my extension is available to the entire community. After a week or so its been installed 30 something times, not earth shattering, but for where I am at in my career I count anyone using anything I had a hand in as a success. I can only imagine what it feels like to work on a big app with millions of users. My brain would blow a gasket.

At the end of the day providing value to the user is the true purpose of writing software. Though most of the time I just enjoy coming up with ideas and solving problems, lost in my own little world. 

So if u feel like giving it a try just search `gitmoji commit` in extensions.

Pro Tip - instead of going to the palette and selecting the `Gitmoji Commit` command, map the command straight to a keybinding. I use `Ctl/Cmd + K G`. 

{% github benjaminadk/emojigit %}