PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/sync-vars.rb

https://github.com/devender/clean-mail
Ruby | 19 lines | 16 code | 2 blank | 1 comment | 0 complexity | 41cbc02ccf175f0e6d15eadef9430b66 MD5 | raw file
  1. username = 'devender'
  2. #all the variables you want to be copied/sync
  3. to_copy = ['PATH', 'HOME', 'LOGNAME']
  4. props = Hash.new
  5. to_copy.each { |name| props[name] = ENV[name] }
  6. File.open("/Users/#{username}/.MacOSX/environment.plist", "w") do |file|
  7. file.puts "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  8. file.puts "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
  9. file.puts "<plist version=\"1.0\">"
  10. file.puts "<dict>"
  11. props.each do |key,value|
  12. file.puts " <key>#{key}</key>"
  13. file.puts " <string>#{value}</string>"
  14. end
  15. file.puts "</dict>"
  16. file.puts "</plist>"
  17. end