This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
/
textmate_preferences.rb
83 lines (79 loc) · 2.53 KB
/
textmate_preferences.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
include_recipe "pivotal_workstation::textmate"
execute "set save on losing focus" do
command "defaults write ~/Library/Preferences/com.macromates.textmate OakSaveAllOnDeactivate -bool TRUE"
user WS_USER
end
execute "show line numbers" do
command "defaults write ~/Library/Preferences/com.macromates.textmate OakTextViewLineNumbersEnabled -bool TRUE"
user WS_USER
end
gem_package("plist")
plist_file = "#{ENV['HOME']}/Library/Preferences/com.macromates.textmate.plist"
ruby_block "soft tabs & tabs stop of 2" do
block do
Gem.clear_paths
require 'rubygems'
require 'plist'
require 'time'
# FIXME: if plist doesn't exist, create it.
`plutil -convert xml1 #{plist_file}`
tmate_plist = Plist::parse_xml(plist_file)
tmate_plist["OakTextViewLineNumbersEnabled"] = true
tmate_plist["OakTextViewScopedSoftTabs"] =
{ "source.catch-all" =>
{ "softTabs" => false,
"updated" => Time.parse("2011-07-14T18:59:17Z")
},
"source.plist" =>
{ "softTabs" => true,
"updated" => Time.parse("0000-12-30T00:00:00Z")
},
"source.ruby" =>
{ "softTabs" => true,
"updated" => Time.parse("0000-12-30T00:00:00Z")
},
"source.yaml" =>
{ "softTabs" => true,
"updated" => Time.parse("0000-12-30T00:00:00Z")
},
"text.catch-all" =>
{ "softTabs" => false,
"updated" => Time.parse("2011-07-14T18:59:17Z")
},
"text.plain" =>
{ "softTabs" => true,
"updated" => Time.parse("0000-12-30T00:00:00Z")
}
}
tmate_plist["OakTextViewScopedTabSize"] =
{ "source.catch-all" =>
{ "tabSize" => 4,
"updated" => Time.parse("2011-07-14T18:59:17Z")
},
"source.plist" =>
{ "tabSize" => 2,
"updated" => Time.parse("0000-12-30T00:00:00Z")
},
"source.ruby" =>
{ "tabSize" => 2,
"updated" => Time.parse("0000-12-30T00:00:00Z")
},
"source.yaml" =>
{ "tabSize" => 2,
"updated" => Time.parse("0000-12-30T00:00:00Z")
},
"text.catch-all" =>
{ "tabSize" => 4,
"updated" => Time.parse("2011-07-14T18:59:17Z")
},
"text.plain" =>
{ "tabSize" => 2,
"updated" => Time.parse("0000-12-30T00:00:00Z")
}
}
puts Plist::Emit.dump(tmate_plist["OakTextViewScopedTabSize"])
File.open(plist_file, "w") do |plist_handle|
plist_handle.puts Plist::Emit.dump(tmate_plist)
end
end
end