Where to create a .profile on Mac OS X

10

3

I'm using Mac OS X Snow Leopard. Which folder do I create my .profile file in?

I like to create a path for /usr/local/mysql/bin – any tips on how to export this path? I only know how to type it for .bash_profile.

nicole

Posted 2011-07-21T14:38:56.517

Reputation: 509

Answers

21

You create .profile in the same folder as .bash_profile, namely in /Users/your-user-name/ also available under ~ or $HOME.

You can add the line using a text editor or command line editor of your choice (like vim, emacs or nano), but you can also do it with Text Edit:

open -a TextEdit ~/.bash_profile

Where to put the export command?

One important thing: If you already have a .bash_profile, your .profile will not be loaded automatically. From bash's manual:

it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Because of that, when you already have a ~/.bash_profile file and create a ~/.profile, the latter will never be read by bash automatically. You can add the appropriate export command in your ~/.bash_profile and it will work just fine if you always use bash:

export PATH=/usr/local/mysql/bin/:$PATH

Source .profile from .bash_profile

If you want to have a separate .profile, you need to manually include it from ~/.bash_profile. Put the following in ~/.bash_profile:

source ~/.profile

slhck

Posted 2011-07-21T14:38:56.517

Reputation: 182 472

0

In Terminal:

open .profile

If that doesn't work, go to your home directory:

sudo nano .profile

and add:

export PATH=$PATH:/usr/local/mysql/bin/

nicole

Posted 2011-07-21T14:38:56.517

Reputation: 509

3Shouldn't need sudo to edit .profile in your home directory. – fideli – 2011-07-21T17:22:31.833

In addition it might be better to have your custom path in front of $PATH, so that your local MySQL binary always comes first. – slhck – 2011-07-22T09:16:24.877