DEV Community

Cover image for emocli is a command-line interface for emoji selection with gitmoji support
Doug Elkin
Doug Elkin

Posted on • Updated on

emocli is a command-line interface for emoji selection with gitmoji support

I've recently gotten into the habit of using gitmoji in my commit messages, and I've decided that I really like having visual cues in my commit logs. I think the added visual image helps with quickly associating each commit with the type of work that was done. Now that I'm hooked on this practice, my brain really doesn't want me to go back.

While there is gitmoji-cli, there are times when I just want to use another emoji that has not been incorporated into the gitmoji project. For example, I may use a cookie (๐Ÿช) when writing a commit message related to work on HTTP cookies, or a vomiting face (๐Ÿคฎ) for a commit which adds a lot of debug statements.

For these other emoji characters, one would typically need to turn to a helper application like the KDE Emoji Picker, the Gnome Emoji Selector, or a web browser with Emojipedia. There are also extensions for the rofi utility (rofi-emoji and rofimoji) which allow a lightweight solution for those not in full desktop environments.

I created emocli to provide a command-line interface for searching and selecting emoji characters from a combined dataset that uses information from Unicode, Inc. and also the gitmoji project.

How to Install Emocli

Arch Linux users can install the AUR package.

paru -S emocli
# or
yay -S emocli
Enter fullscreen mode Exit fullscreen mode

Users with rustup installed can install the crate using cargo.

cargo install emocli
Enter fullscreen mode Exit fullscreen mode

Usage

Usage:  emocli [OPTIONS] <search>

OPTIONS:
-h | --help     print this help
-l | --list     list all emoji characters
-i | --info     include info
-n | --name     match name exactly
Enter fullscreen mode Exit fullscreen mode

Examples

list all emoji characters with their name, categories, keywords, and gitmoji description (if available)

emocli -li
Enter fullscreen mode Exit fullscreen mode

search for an emoji using keywords

emocli -i dog
# output
๐Ÿถ dog face | Animals & Nature / animal-mammal | dog,face,pet
๐Ÿ• dog | Animals & Nature / animal-mammal | dog,pet
๐Ÿฆฎ guide dog | Animals & Nature / animal-mammal | accessibility,blind,guide,guide dog
๐Ÿ•โ€๐Ÿฆบ service dog | Animals & Nature / animal-mammal | accessibility,assistance,dog,service
๐Ÿฉ poodle | Animals & Nature / animal-mammal | dog,poodle
๐ŸŒญ hot dog | Food & Drink / food-prepared | frankfurter,hot dog,hotdog,sausage
Enter fullscreen mode Exit fullscreen mode

print a specific emoji by name

if the name is more than one word, it should be enclosed in quotes

emocli -n 'guide dog'
# output
๐Ÿฆฎ
Enter fullscreen mode Exit fullscreen mode

use in a commit message

git commit -m "$(emocli -n rocket) production launch"
Enter fullscreen mode Exit fullscreen mode

use with rofi and xclip

The following script provides similar functionality to the rofi extensions mentioned above (using rofi and xclip).

# put this somewhere as a script in your PATH, shell alias, or keyboard shortcut
emocli -li | rofi -dmenu -window-title emoji | cut -d' ' -f1 | tr -d '\n' | xclip -selection clipboard
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

my terminal is not displaying all emoji characters

Your mileage may vary on terminal support for displaying emoji consisting of 2 or more characters joined by a zero-width joiner character (U+200D). The "service dog" emoji (๐Ÿ•โ€๐Ÿฆบ) is one such example. Even with a proper font config, it will appear on many terminals as a dog next to a safety vest.
๐Ÿ•๐Ÿฆบ

Currently, the best configuration tested with emocli -li is the wezterm terminal with the Noto Color Emoji font installed and configured.

Top comments (1)

Collapse
 
duhdugg profile image
Doug Elkin

For the 2-3 people interested, I've rewritten this in Rust and deprecated the NPM package. This article has been updated.