Customize Terminal Prompt in OS X Yosemite with Emoji Icons

2015-04-24 OS X

One of the reasons why I felt in love with Macs and OS X is the combination of interface beauty and power of Unix. Although I do like Debian and Ubuntu in terms of doing my development stuff, both systems are extremely ugly and don’t give much visual pleasure. But let’s focus on OS X.

If you work for most of your time in Terminal, it would be nice to customize the prompt to suit your needs. In this article I will demonstrate how to customize your prompt and convert it into a fancy one. It’s going to be fun since we’ll deal with some Emoji icons.

Type

⌘ Space

and then Terminal to open it.

Prompt can contain your custom text as well as some defined values assigned to particular letters preceded by a backslash sign.

  • \d – current date
  • \t – current time
  • \u – user name
  • \h – host name
  • \W – working directory
  • \w – full path to current working directory
  • \n – new line

I assume that you use Bash. Go to your home directory

cd ~

and open .bash_profile in an editor you preffer

mcedit .bash_profile

OS X Terminal Prompt

Are you curious how the hell I inserted those icons? ;) It’s extremely easy. Take a look.

From the Menu Bar go to Edit and click on Emoji & Symbols.

OS X Terminal Prompt - Emoji

Feel free to put any icon(s) you want. I like green color so I had to put some plants and palm trees. ;)

Here’s the syntax to export PS1 (Prompt String 1)

export PS1=" "

Anything between quotation marks is your content.

Mine is

export PS1="[\t] (emoji) (emoji) \n[Hi \u!] (emoji) (emoji) (emoji) (emoji) (emoji) \w (emoji) "

OS X Terminal Prompt - Final work

Do NOT follow this link or you will be banned from the site!