On Jan 8, 2007, at 3:03 PM, Dave Land wrote:

Happily, Apple provided a utility that handles it for you:

   defaults read "${HOME}/.MacOSX/environment"

Actually, making this work in bash (or other shell) requires a little more than just reading the file... Here's the relevant chunk from my .bashrc:

# Get environment variables from ~/.MacOSX/environment.plist
# (This avoids the sin of duplicating data here and in that file)
if [[ `uname` == 'Darwin' ]] ; then
defaults read ~/.MacOSX/environment | grep -v '[{}]' | tr '"' "'" | awk '{ print "declare -x",$1"="$3 }' | while read -r OneLine; do eval $OneLine; done;
fi

To give credit where it's due, this came from a comment on macosxhints.com.

The conditional (if [[ `uname` == "Darwin' ]]) is because I use this same .bashrc across several hosts, including Solaris, Linux, and Mac OS X.

Dave

Reply via email to