Customize the Command Line by Adding Emoji Icons to the Bash Prompt
A very unique and amusing way to customize the bash prompt appearance is to add one of Mac OS X’s Emoji icons to transform the appearance of the prompt itself.
This isn’t going to be the most practical tweak in the world on it’s own, but it is entertaining and because it’s using traditional methods of customizing the bash prompt you can make it as useful or useless as you want.
How to Add Emoji to Bash Prompt in Mac OS Terminal
Here’s how to add an emoji icon as the command line prompt:
- Open Terminal app and use your preferred command line text editor to modify the .bash_profile file:
- Add a new line like the following:
- Now pull down the “Edit” menu and choose “Special Characters”, then select “Emoji” from the special character menu
- Find the Emoji you want to use in the shell prompt and drag & drop it into the PS1=” ” line so that it’s contained within the quotes
nano .bash_profile
PS1=" "
- Depending on terminal settings, nothing may be visible after using drag & drop, but put two spaces after the blank space where the emoji was dropped, it will end up looking something like this: PS1=” “
- Save the .bash_profile change with Control+O (for nano) then exit out of nano with Control+X
- Open a new Terminal window to see the emoji as the prompt
With only an Emoji set in there, the new bash prompt will look like this:
The emoji tends to look best as a prompt when the Terminal font size is fairly large, perhaps larger than you’re accustomed to. This is particularly the case with complex emoji icons, but for basic icons like stars, shamrocks, and thumbs up the smaller fonts still look ok.
This is more fun than anything else, and if you’re an avid terminal user you probably will find this more ridiculous than functional depending on how you’ve customized the bash prompt outside off this, though you can still apply the typical formatting customizations alongside the Emoji as well. One common and particularly useful customization is to show the current working directory, that can be added by changing the PS1=” ” command to the following:
PS1="(drop emoji here) \W "
Or reversed:
PS1="\W (drop emoji here) "
And, getting increasingly useful with a username @ hostname visible with the emoji and PWD as well:
PS1="\u@\h (drop emoji icon) \W "
Remember to add a space (if not two) to after the Emoji or else it will be cramped against the command prompt.
If this is a bit too outrageous for you, check out a guide to improve the overall Terminal appearance and another excellent trick to make it more readable by adding a separator between commands that have been executed.
Heads up to Torrez for the funny tip idea by way of DaringFireball
`export PS1=$(echo $PS1 | sed ‘s/\(.*\)\$/\1 πΉ $/’)` – one liner to tweak an existing `$PS1` which you can comment out.
Cool!
Useless, but so Groovy, Thanks
Is there any way to get alpha channel support for the emojis inside the terminal window?
Mine is set to semi-transparent black, but the emojis don’t seem to support it, which means a square completely transparent box shows around them. Just looks ugly that way, that’s all.
Nice tip though, thanks.
I think is better open .bash_profile with textedit with “open -e .bash_profile” and than write the PS1″ ”
mine is this:
export PS1=”\[33[36m\]\u\[33[m\]@\[33[32m\]\h (drop emoji here)(space):\[33[33;1m\]\w\[33[m\]\$”
thanks for the trick!
I think it’s actually very useful! If you select the right icon (colour-wise) it might help to see differentiate the prompt (as well as entered commands) from the cmd output.
Wojtek, I bet your favourite colour is Beige. Have a little fun sometime.
Yes, but the question is: why? Terminal is supposed to be useful and having an icon isn’t going to help that. Why not post some tips on how to actually make it work for the benefit of the user?
Debbie downer over here.
I think it’s funny. Not for me, but I’m not going to pull a Woktej on ya.
Mostly because it can be fun to customize things.
We do have a lengthy category archive of tons of useful command line tips that directly benefit the user though.
https://osxdaily.com/category/command-line/
It’s actually a very easy and useful way to make it easy to see past command boundaries when you’re scrolling backwards. Like if you run a big compile and want to see the very first error that was generated.