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.
If you want to show appreciation for my efforts dear reader, you could buy me a tall hazel nut Americano ($2) via PayPal. Thanks{2 Comments below .. you can add one }
4.6.2010at 10:52
Hi.
A Snow Leopard has been successfully attached to a Windows Server 2008 Active Directory domain. Works great.
We need to give the logged user the rights to use his personnal and shared AD drivers from within the AD server. I wrote a script that works perfectly. I would like to place this script somewhere in this Snow Leopard for been used automatically by any user logged in the machine. I don’t really know Mac world, but what I’m looking for is something like an autoexec (found in the MS world). Could you help?
Thank you.