|
|
|
New Version for both Bash and Tcsh
Err, ignore that comment on lines 10 and 11 of the new script. If the script can't determine the shell, it exits right away and doesn't default to bash...
New Version for both Bash and Tcsh
Hey folks,
Apple provided us with the "defaults" command to deal with property lists. So, to read all key/value pairs in a very simple and effective way, you simply need defaults read "${HOME}/.MacOSX/environment"That said, the bash way suitable for 99 percent of all cases to include directly into .bashrc would read as follows (on a single line): defaults read "${HOME}/.MacOSX/environment" | tr -d "{" | tr -d "}" | sed 's{\ =\ {={g' | tr ";" "\n" | grep "=" | while read -r OneLine; do eval export $OneLine; doneCheers, Thomas
New Version for both Bash and Tcsh
Two small additions:
> the bash way suitable for 99 percent of all cases That means, this will work unless key or value contain "{", "}", or ";" because they will be converted while parsing the property list. > tr ";" "n"Should read "\n". The backslash character "\" has been eaten by the form submission, so once again:
|
SearchFrom our Sponsor...Latest Lion HintsWhat's New:Hints1 new Hints in the last 24 hoursComments last 2 days
Links last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2013 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Powered by Geeklog Created this page in 0.09 seconds |
|