There’s been a lot of talk lately about those cool colours that Paul Irish uses in his videos. If you don’t know who Paul Irish is and you dabble in a bit of web design … well … shame on you! 😉 The things referenced in this article, including the prompt, can be found in Paul’s YouTube video entitled "The Build Script of HTML5 Boilerplate: An Introduction". Anyway, I think the prompt colours are pretty useful, especially if you’re speedy at navigating your way around the CLI/shell in Linux or OS X and want to see where you are very quickly.. They help identify where you are in the file system, whether or not your current working directory is a git branch and, depending on what options you set, whether or not there are untracked files present etc.
Here’s what Paul’s prompt looks like (screenshot from the video linked above).
I believe Paul is using iTerm, as am I. Combined with the stuff below, my iTerm configuration looks like this:
Pimp my prompt!
Ok, so you want your prompt to look like that? It’s not that hard, actually. You have to grant me a little latitude, though, as I’m guessing what Paul uses the various CLI prefix symbols for. In this example I’m using an "o" to indicate a working outside a git branch and a + to indicate that the current working directory is a git branch.
This only works if you’re running an OS X or Linux shell – I’m sure you can do it with Windows but I’m not going to cover that here.
If you haven’t got one already, open or create a file called .bash_profile in your home (~) folder. You might be asking why not use .bashrc? We want the command we’re adding to apply to interactive login shells – .bashrc only applies to interactive non-login shells. There is an exception to this if you’re using OS X (like me) – .bash_profile is run for each new Terminal.app window, by default.
If a file with that name already exists, make sure you don’t remove anything from it that you want to keep. From here I’m going to explain what each part of my .bash_profile does. The complete file will be shown at the end, including a couple of extra bits.
Note: If you’re going to include the git parts, you’ll need to download the git source and put the file .git-completion somewhere (mine is in my home directory).