Okay, this is highly subjective, but I’m going to drop my preferences here to setting up a bash environment. I use this for OSX but also share most of it in my unix/linux environments as well.

First, you want to be IN CONTROL. So let’s get some SIMPLE understandings out of the way.

.profile

When you log in to a shell (launch new terminal window) a “profile” is run. In many places this file is called your “.profile”. At least back in the Bourne days. The new world of linux (OSX included) is dominated by “Bash Shell”. So our files are called things like “.bash_profile” instead. Same thing for the most part.

In any case, this is the file that sets up the environment for that shell session. For our purposes that means what it looks like and what commands are available.

.bash_profile .bashrc

Okay, one more diversion before we start. I use the .bashrc file for my settings. It’s a holdover of years gone by and really doesn’t matter any more. So if I say “.bashrc” and you’re putting your entries into your “.bash_profile” then you’re fine, same thing really.

Ain’t got one

If you don’t see these files or know where to find them open a shell (terminal) and that’s where you should see them. Your home directory. Try this to see everything there:

If you don’t see .bash_profile or .bashrc then you need to create them.

Now you have those files. Because I use my .bashrc file I have an off .bash_profile file. This is what is in mine:

All this says is “if you run this file, run the .bashrc file instead”. This way my bashrc always runs.

Then we’re off and racing.

Opening your file

Let’s get started. Open your .bash_profile or wherever you are adding these rules (henceforth: profile file). I won’t go into how to open these hidden files, but there are lots of ways. It depends on your editor of choice. But get your profile file opened in your favorite editor.

Command Prompt

This one is an obvious one. When we log into our shells we want to see what we need — all the time. Some people will drop the whole path in there, some just a simple > prompt. It’s personal taste. But being able to change it quickly and easily helps a lot so you can try a lot of things out.

That is a VERY simple one that will show you your location followed by a prompt. There are lots of little tricks you can do in your prompt. Maybe this resource will help: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

That happens to be the standard prompt on OSX if you want that.

Color!

The world is so much more interesting in color. Don’t skip this step. It’s not 1984 any longer. The color commands in bash are crazy looking, and I really don’t understand them. But here is a quick shortcut to getting started. As a note you should be able to open a shell and drop these commands in one at a time to see what you end up with. That should help you debug a bit.

Let’s simply change that prompt we created:

Okay, so now we have a prompt that is much cleaner if you ask me. Note though I use a dark BG to my shell windows (later) so this may look like crap to you.

So what is this mess? Well, I’ll try:

Something like this:

  • \[\0 – start color assignment
  • 33 – x-value of the color
  • [0; – basically a comma between the x and y
  • 38 – y-value
  • m\] – stop color assignment

Wow, that’s a mess. I agree. But all you care about is the 33 and the 38 in there. Honestly the format is a train wreck. but we’re just dealing with color pairs here. I also have some other stuff in the middle of my prompt to keep things succinct. Basically I end up with 3 parts:

path_in_dark_yellow    prompt_in_green    text_input_in_white

This looks great to me on a dark background shell window.

Color Code
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33

And maybe a URL: http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/

Your List (LS)

All that is fine, but you need your LS to be colored also. This is a simple one also. Add this to your profile file:

That will “enable” color ls results in your shell session. Talk about simple.

Your window

Finally, go into the settings of your terminal program and set up your favorite font choices and background colors. This helps so much you’ll love to be in Terminal!

My Settings

Here is how I’m set up:

In my .bashrc file I have this:

Then my Terminal settings are:

mbm2_terminal_settings.terminal

That’s it! Enjoy