Creating a .bash_profile file in OS X and adding PATH directories

If you’re starting out with a fresh install of OS X (10.9 in my example) and are using any development tools, at some point I’m sure you’ll want to add some directories to your system PATH. In short: this allows you to use an application in a specific directory from any other directory – commonly when you’re running commands in Terminal.

To start, we’ll utilize a text editor – in my case I’m using TextMate – but any plain text editor should do. Let’s get to it:

  1. bash_1Let’s first make sure you don’t already have a .bash_profile. In TextMate, go to File > Open. Browse to your home folder (with the house icon) and click “Show Hidden Files”. In your home folder you shouldn’t already see a .bash_profile file. (If you do, then you don’t need to create a new file and can open your file, make changes and skip to step 5.)
  2. bash_2So cancel the open dialog and enter some text into the untitled file currently open. You’re usually entering something like: export PATH=${PATH}:/somedirectory/asubdirectory:/anotherdirectory
  3. bash_3Now let’s save our new .bash_profile. Go to File > Save As. Browse to your home folder (with the little house icon again). Enter the filename as “.bash_profile” (without quotes).
  4. bash_4If you get a message saying “names that begin with a dot are reserved for the system” chose “Use ‘.’
  5. bash_5That’s it. Now if you already have a terminal open run source ~/.bash_profile (this just give you access to the updated PATH).
Creating a .bash_profile file in OS X and adding PATH directories

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s