While I realize that there are many ways to go about this. If one is just interested in configuring environment variables for IntelliJ then you could do the following without going through a lot of hassle:
IntelliJIDEA -> Preferences -> Path Variables
Now select Add on the right and add your required variables. In my case it is the following as I used homebrew to install Maven:
Name: M2_HOME
Value: /usr/local/Cellar/maven/3.0.4
Now look under IntelliJIDEA -> Preferences -> Maven and everything should be automatically configured. Select OK and now you should be all set. Just so you guys know I use IntelliJ IDEA 11.
Be advised that the above will work only in IntelliJ. If you want this in terminal, put the required stuff in .bash_profile or throw it in /etc/launchd.conf if you want this for GUI's and the terminal. You can find more info on these methods easily doing a quick search.
plist
for loading withlaunchctl
?