March 1, 2017

Emoji on the Command Line

In today's environment, Developers and QA engineers quite often have to log in to a remote AWS server that has virtual servers to perform tasks. Sometimes they are busy and may forget which server they are monitoring. One way to fix this is to use the emoji name in the Macintosh prompt. This way you know that your back on your computer and not on any production AWS server.

You will need to use Apple's Terminal app to add Emoji to the prompt, as iTerm doesn't really have good emoji support. This isn't an issue since your not going to be using emoji all the time.

Enable Emoji at the Command Line

Open Terminal app and use nano to modify the .bash_profile file:

nano .bash_profile

Tech Note: This will not work using BBEdit. This functionality appears to be an exclusive functionality of the Terminal app.

Add a new line like the following:

PS1=" "

PS1 is the Bash variable for Prompt.

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, I would suggest an Apple or the House. Then drag & drop it into the PS1=" " line so that it's contained within the quotes.

Save the .bash_profile change with Control+O then exit out of nano with Control+X

Open a new Terminal window to see the emoji as the prompt

Bash Login

What is Nano?

nano is a small, free and friendly editor which aims to replace Pico, the default editor included in the non-free Pine package. Rather than just copying Pico's look and feel, nano also implements some missing (or disabled by default) features in Pico, such as "search and replace" and "go to line and column number".

Bash Generator

If you want more out of your Bash Prompt, check out the Bash Generator where you can create a productive Bash Prompt.

Comments

Add your Comments

Feel free to leave a comment about this post.

- Feel Free to add HTML to your comment!