What we need to do since it's a fresh Snow Leopard install is create a .bash_profile file in our home directory with the additional paths we'd like to add. If you're not working with a new install you can check if there's a .bash_profile file that already exists by navigating to your home directory and using the 'ls -a' command to display hidden files. If one already exists you would edit this file with the directory paths you would like to add to the environment. Just add additional 'PATH=/path/you/want/to/add/:' statements after the export statement but before the final ':$PATH'.
An alternative to the .bash_profile is to edit the file 'paths' in the /etc directory with the directory paths you'd like to add however this seems less intuitive to me, especially if you have multiple users on your system and don't want them to have access to particular commands from Terminal.
In my case, the .bash_profile file didn't exist in my home directory in Snow Leopard since I'd performed a clean install so opened a new Terminal session(opens in your home directory) and ran the following command:
echo 'export PATH=/path/you/want/to/add/to/env:$PATH' >> ~/.bash_profile
Running this command creates the file '.bash_profile' and adds your new path along with the current directory paths that reside in the $PATH variable. For example, if I wanted to include subversion commands like svn, svnadmin, svndumpfilter, etc. located (in my case) in the /opt/subversion/bin directory, I'd simply issue the following command:
echo 'export PATH=/opt/subversion/bin/:$PATH' >> ~/.bash_profile
You can test if this works by opening up a new terminal window, typing the 'env' command and looking for the newly added directory values in the output.
6 comments:
That worked great. Thank you!
You're welcome Rob, glad I could help you out!
John, do you know how to set up the .bash_profile such that the directories, executable files, shell scripts and text files show up in different colors when a "ls" is done on the iterm ?
Also, when I open a fortran program using the "VI" editor on a regular UNIX box, I can see the commands, keywords, commented sentences all in different colors - however, on the iterm on MAX OS X (10.6.4), everything is in black. Do u know how to set that up? Any help will be much appreciated! Thanks - Falguni
alias ls="ls -G"
You can also add to the path by creating files in the directory /etc/paths.d
You can use something like the following:
echo "/some/other/path" >> /etc/paths.d/SomeFileName
or, you can simply create a file and put it directly in that folder. Either way, the path item you place in the file will be appended to the end of the main path.
I name the files after the app requiring the path item - X11 or WireShark, for example.
If the path item needs to go to the front (MacPorts' path, for example), you would have to use the method suggested here or an equivalent (updating the /etc/paths file, for instance).
For the person asking about colorizing their 'ls' command: use the -G option in 'ls'. For example:
ls -G
-- or --
ls -lG
Thanks!
Post a Comment