Saturday 1 December 2018

macos - Where does $PATH get set in OS X 10.6 Snow Leopard?


I type echo $PATH on the command line and get


/opt/local/bin:/opt/local/sbin:/Users/andrew/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/pear/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin


I'm wondering where this is getting set since my .bash_login file is empty.


I'm particularly concerned that, after installing MacPorts, it installed a bunch of junk in /opt. I don't think that directory even exists in a normal Mac OS X install.


Update: Thanks to jtimberman for correcting my echo $PATH statement



Answer



When bash starts it reads the following files every time you login. For the purposes of OS X, this means every time you open a new Terminal window.


/etc/profile
~/.bash_profile
~/.bash_login (if .bash_profile does not exist)
~/.profile (if .bash_login does not exist)

When you start a new shell by typing bash on the command line, it reads .bashrc


OS X also uses ~/.MacOSX/environment.plist to set more environment variables, including paths if necessary.


Finally, /etc/paths and /etc/paths.d are read by the shell too.




/opt/local/bin etc. are added in ~/.tcshrc by MacPorts. Also be sure to look in ~/.cshrc.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...