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


Click here to return to the 'Copy variables from GUI to CLI' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Copy variables from GUI to CLI
Authored by: sco08y on Jul 26, '04 11:26:00AM
Another approach would be to modify your startup scripts to read the environment.plist file, going backwards. IMHO, it would be much simpler than constantly running an update script on your XML file! Personally, I don't have so many environment variables that I've needed to do this, but this might work: First, grab Mac::PropertyList:
sudo cpan install Mac::PropertyList
Then add this line to the appropriate rc file: (I added newlines to avoid page widening)
eval `perl -MMac::PropertyList -e 'while(($k, $v) = each 
%{parse_plist(<>)->value()}) { print "$k=$v\n"; }' 
< ~/.MacOSX/environment.plist`
That would work in sh and bash, csh probably needs to change "$k=$v" to "set $k=$v" or something. Also, this doesn't handle odd characters, which you'd want to put before the print statement. The nice thing is that you can edit your environment easily by dropping environment.plist in your Dock.

[ Reply to This | # ]
Copy variables from GUI to CLI
Authored by: sco08y on Jul 26, '04 11:28:04AM

oh, wait, bash and sh need "export $k=$v".

Note that if you want a script to have _temporary_ access to an easily configured .plist file, don't use export.



[ Reply to This | # ]