This post is inspired and credited in large part to @yechielk. He posted this tweet last night and I, like everyone else, also wanted to add emojis that reacted to the success of my commands!
This guide can likely be adapted for other setups, but in this case I'm running zsh
, specifically oh-my-zsh
so the instructions are based on that.
1 - Navigate to themes folder
oh-my-zsh
uses themes to define the visual display of the terminal window. So we'll start by navigating to the folder where the themes are.
cd ~/oh-my-zsh/themes
2 - Figure out what theme you're running
There are a ton of themes in that folder, but we only want to edit the one we're running. So let's find out what that is.
echo $ZSH_THEME
3 - Navigate into that theme file
I'm running alanpeabody
which I've customized over the years. So let's open that file.
Yes, I use
nano
! It works for me. You can usevim
or whatever else works for you.
nano alanpeabody.zsh-theme
4 - Create a variable that will set the emoji
This is the heart of what we're doing and I didn't write it. I lifted it from @yechielk dotfiles and made some modifications. Work smarter, not harder folks!
Note that you can replace these faces with whatever emoji, or even text, that you want.
local emoji="${debian_chroot:+($debian_chroot)}\$(if [ \$? == 0 ]; then echo đ$; else echo đ; fi) â
5 - Add variable to prompt
The final step is to find where in the theme your prompt is declared. Mine was at the bottom of the file and appropriately named PROMPT
. Prepend the definition with the emoji variable using the appropriate syntax and we're off to the races.
PROMPT="${emoji}${user} ${pwd}$ "
Note that spaces in this string are taken into account. I have one at the end so my typed commands are spaced out from my prompt, but I removed the one between emoji and my user since it takes up unnecessary space beyond the emoji visual buffer.
Complete!
And that's it. Remember to restart your terminal so that these changes can take effect. Have fun!
Top comments (13)
Thanks! BTW, I use the built-in
fino
theme that uses emojis to show if the git working tree is dirty or not.Awesome! Added random status emojis to my Bash prompt:
Yay!!! đ
You can use emoji in
bash-it
, too!Awesome!! Very excited to see this post out! đđđ
OK going to try this.
Love some terminal candy! Setting this up asap, thanks for the detailed write-up. đđ
For an example of this in Bash: github.com/sukima/dotfiles/blob/ma...
Love the dates theming! So fun.
â¤ď¸ Epic! đđ
đ¤Żđđâ
Haha, can we expect a screenshot of your updated terminal soon?!
Nice!
A little difference, in macos, default themes folder is here (hidden)
cd ~/.oh-my-zsh/themes