Bash startup script in OSX
If you’re coming from Linux, and you’re looking for .bashrc in OSX, you’re not gonna find it–at the time I wrote this, the OSX is version 10.5.7 (Leopard)–you can find the bash initialization files in 2 places; in ~/.profile and /etc/profile.
- ~/.profile-the tilde (~) is a shortcut to /Users/yourloginname, so you will find this file exactly right under your home directory. This initialization file is executed everytime you open a shell session, such as when you open a Terminal window or executed xterm. This file only affects your profile and not anybody elses–I dont’ think that you’re sharing your Mac with anybody else anyway, but just in case you work in an environment where some other people use the Mac, if you’d like to customize bash, this is the place to do it. You can define environment variables to be exported here or set the CLASSPATH of Java or maybe set PATH to include jython executables etc.
- /etc/profile-pretty much does what ~/.profile does, the slight difference is the scope. This initialization file is executed for every account in the Mac, so this is quite global. This is handy for system administrators of Mac, if there are variables or CLASSPATH or PATH information that is to be enforced for every one who logs in the Mac, this is the place to do the edits
Sample .profile
# test -r /sw/bin/init.sh && . /sw/bin/init.sh export TOMCAT_HOME=~/progtools/apache-tomcat-6.0.18 export CATALINA_HOME=$TOMCAT_HOME export JYTHON_HOME=~/jython2.5.0 export PATH=$PATH:$TOMCAT_HOME/bin:$JYTHON_HOME:. export PS1="_$ " # this is how to comment on bash
This is my .profile file, it’s got some definitions where to find tomcat and jython executables. It also has some instructions on how to change the shell prompt, I don’t like very long shell prompts, I’d like to see just the dollar sign.
Leave a comment