Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'From a hint submission...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
From a hint submission...
Authored by: robg on Aug 02, '04 09:17:32AM
By 'anonymous' as a new hint, but designed to go here:
Sometimes it's more practical to maintain the environment.plist file as the central piece of information and 'import' it into your .(t)cshrc file, so that the GUI environment gets reflected in the commandline environment.

To do this one can just copy the attached AWK script to ~/.MacOSX/ (or to some other reasonable place) and use it in a .(t)cshrc as follows:
# Parse ~/.MacOSX/environment.plist
eval `awk -f ~/.MacOSX/environment.awk ~/.MacOSX/environment.plist`
-- AWK SCRIPT BEGIN --

# ###################################
# SIMPLE AWK SCRIPT TO PARSE ENVIRONMENT.PLIST
# 2004, Erik Abele. No rights reserved.
# ###################################

/<key>.*<\/key>/ {
s = index($0, "<key>") + 5
e = index($0, "</key>")
key = substr($0, s, e-s)
next
}
/<string>.*<\/string>/ {
s = index($0, "<string>") + 8
e = index($0, "</string>")
string = substr($0, s, e-s)
printf "setenv %s \"%s\";", key, string
next
}

-- AWK SCRIPT END --
Well, it should be pretty simple to adapt this to other shells (bash, zsh, ...).
-rob.

[ Reply to This | # ]