I am forever going back and forth in Terminal from my local machine (Mac Pro) to an ssh session on my Ubuntu Server. Terminal is not the easiest on the eyes to begin with but I’m particularly bothered by OS X’s default shell prompt, especially after spending time in Ubuntu’s shell.
This is what the default Mac shell prompt looks like:
And this is what my Ubuntu shell prompt looks like:
A little splash of color goes a long way on tired eyes. But even the Ubuntu layout is better… on a Mac the prompt reads like this:
as opposed to this on Ubuntu:
At first look the difference seems negligible, but consider drilling deep into the file structure with cd… again, on a Mac:
and on Ubuntu:
Tell me in each example, at a glance, a) who’s session it is and b) what folder you’re currently in. On the Mac, one might be inclined to think we’re in the “user” folder and “host” is the session user. In Ubuntu there is no doubt, the prompt starts by identifying the user and the host, and ends with the current folder.
So what can we do about it?
## Adding color ##
You may or may not already have a `~/.profile` or `~/.bash_profile` on your Mac–if you do, that’s great. If not, make one (using vim, nano, TextMate or your editor of choice).
For a default Mac prompt, add this line:
For this outcome:
Here is what it all means…
* `PS1` — the initial prompt string
* `[e[34m]h` — will be a blue `host`
* `[e[00m]:` — will be a white colon
* `[e[32m]w ` — will be green directories followed by a space
* `[e[34m]u` — will be the user in blue
* `[e[00m]$` — will be a white `$`
Here is a chart to help you with the colors and their corresponding numbers (courtesy of [IBM][a_110613211618]):
## Making it easier to read ##
If you’re like me and you want to be able to read the prompt logically, then you can rearrange the prompt like this:
For this outcome:
I hope that helps make your stay in Terminal a little easier.