Apple - How can I add a path to the PATH environment variable?
OSX reads the following files in order when a terminal opens :
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
So place your path addition into one of these. I normally put additions into ~/.bash_profile
echo 'export PATH=/my/path:$PATH' >> ~/.bash_profile
should do the trick!
If you used echo 'export PATH=/my/path:$PATH' > ~/.bash_profile
, or any such variation, you would be overwriting the contents of your profile!
In addition to the places mentioned by @RobZolkos, the login shell also looks in /etc/paths
and the files inside /etc/paths.d/
. One path entry per line in these files.
See /etc/profile
and the manual page for path_helper
.