That Terminal Emoji


Sometime last week, Ruben sent me a screenshot of his screen where he’d managed to get emoji to appear in his terminal. Given that Ruben often shows me cool stuff without explaining how he managed it, I decided to find out myself as a personal challenge.

Turns it, it’s not that difficult, at least if you’re using OS X anyway. I can’t vouch for any other operating system, though it seems Ruben’s linking to a Ubuntu/similar one.

I wanted to customise the bash prompt, which Ruben switched me over to when we decided to use Hugo. This is probably your default if you don’t use the Terminal much. To add an emoji as the command line prompt, I simply need to modify the .bash_profile. Given that I have a .bashrc (again, thanks to Ruben) which the .bash_profile simply redirects to, I modified this config file instead.

First I typed in the below on a new line

PS1=" "

Then I went to the Edit menu and selected Special Characters. Finally I selected Emoji from the menu and dropped in into the line above within the quotes. I assume you could also copy and paste it from elsewhere as long as you have the emoji you want.

Like so:

PS1="🍵  $ "

Seems that it’s pretty important that you add two spaces after the emoji or anything that comes after it will stick to the emoji itself. There’s a bunch of different customisations and you can achieve the above by simply exporting PS1, but I hear the above way is a bit more permanent. Still, don’t like it? Just delete the line!

Finally, of course it’s also important to have this teacup in your scripts if you want them, and as Ruben highlighted to me it’s a good way of determining Hugo output from the echo output which was written in to track progress. I assumed I could simply copy and paste them in again, and what do you know - it worked.

echo "🍵   Process completed. Blog updated at $now."
🍵   Process completed. Blog updated at 22:41:23.

Novel, but fun.

Source: [1]