Improved Prompt
Posted on May 20, 2012When spending a lot of time in a shell, it's crucial to have a good prompt (PS1). By default, Mac OS X's Bash prompt is pretty bland. The entire prompt is in a single color and has, in my opinion, akward formatting.

Luckily, it's quite easy to change around your prompt for it to be more suitable. By editing your .bash_profile located in your user's home directory, you can style your prompt to your liking. Even making the smallest changes can dramatically improve quick redability while in a shell.
Take a look at my prompt. It states the logged in user, followed by the machine name, and lastly the current directory. By having simple differences with color, I can quickly glance to see where I am.

To use my PS1, add the following to your .bash_profile
PS1='\[\e[0;32m\]\u@\h\[\e[m\] \[\e[1;34m\]\W\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'
If you're interested in exploring other available colors for your prompt, take a look at the wonder Arch Linux wiki. In a future post, we'll explore some helpful scripts to further extend your prompt.