public
Description: Random Stuff
Homepage:
Clone URL: git://github.com/devender/devender-sandbox.git
devender-sandbox / sync-vars.rb
100644 20 lines (17 sloc) 0.67 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
username = 'devender'
#all the variables you want to be copied/sync
to_copy = ['PATH', 'HOME', 'LOGNAME']
 
props = Hash.new
to_copy.each { |name| props[name] = ENV[name] }
 
File.open("/Users/#{username}/.MacOSX/environment.plist", "w") do |file|
  file.puts "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
  file.puts "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
  file.puts "<plist version=\"1.0\">"
  file.puts "<dict>"
  props.each do |key,value|
    file.puts " <key>#{key}</key>"
    file.puts " <string>#{value}</string>"
  end
  file.puts "</dict>"
  file.puts "</plist>"
end