-
Notifications
You must be signed in to change notification settings - Fork 5
/
texshop-colorizer.rb
150 lines (141 loc) · 3.37 KB
/
texshop-colorizer.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# encoding: utf-8
module Colors
def colorize(text, color_code)
"\033[#{color_code}m#{text}\033[0m"
end
{ :black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:magenta => 35,
:cyan => 36,
:white => 37
}.each do |key, color_code|
define_method key do |text|
colorize(text, color_code)
end
end
def solarized_light
[
'background_R 0.99',
'background_G 0.96',
'background_B 0.89',
'commandred 0.86',
'commandgreen 0.196',
'commandblue 0.184',
'commentred 0.58',
'commentgreen 0.63',
'commentblue 0.63',
'foreground_R 0.40',
'foreground_G 0.48',
'foreground_B 0.51',
'indexred 0.83',
'indexgreen 0.21',
'indexblue 0.51',
'markerred 0.165',
'markergreen 0.63',
'markerblue 0.596',
'insertionpoint_R 0.40',
'insertionpoint_G 0.48',
'insertionpoint_B 0.51',
].each do |setting|
`defaults write TeXShop #{setting}`
end
end
def solarized_dark
[
'background_R 0.00',
'background_G 0.169',
'background_B 0.212',
'commandred 0.86',
'commandgreen 0.196',
'commandblue 0.184',
'commentred 0.345',
'commentgreen 0.431',
'commentblue 0.459',
'foreground_R 0.514',
'foreground_G 0.580',
'foreground_B 0.589',
'indexred 0.83',
'indexgreen 0.21',
'indexblue 0.51',
'markerred 0.165',
'markergreen 0.63',
'markerblue 0.596',
'insertionpoint_R 0.514',
'insertionpoint_G 0.580',
'insertionpoint_B 0.589',
].each do |setting|
`defaults write TeXShop #{setting}`
end
end
def default_colors
[
'background_R 1.0',
'background_G 1.0',
'background_B 1.0',
'commandred 0.0',
'commandgreen 0.0',
'commandblue 1.0',
'commentred 1.0',
'commentgreen 0.0',
'commentblue 0.0',
'foreground_R 0.00',
'foreground_G 0.00',
'foreground_B 0.00',
'indexred 1.00',
'indexgreen 1.00',
'indexblue 0.00',
'insertionpoint_R 0.00',
'insertionpoint_G 0.00',
'insertionpoint_B 0.00',
'markerred 0.02',
'markergreen 0.51',
'markerblue 0.13'
].each do |setting|
`defaults write TeXShop #{setting}`
end
end
def custom_colors
[
'background_R 0.00',
'background_G 0.169',
'background_B 0.212',
'commentred 0.4',
'commentgreen 0.4',
'commentblue 0.4',
'commandred 0.1',
'commandgreen 0.3',
'commandblue 0.9',
'foreground_R 0.9',
'foreground_G 0.9',
'foreground_B 0.9',
'indexred 0.83',
'indexgreen 0.21',
'indexblue 0.51',
'insertionpoint_R 1.00',
'insertionpoint_G 0.00',
'insertionpoint_B 0.00',
'markerred 0.02',
'markergreen 1.0',
'markerblue 0.13'
].each do |setting|
`defaults write TeXShop #{setting}`
end
end
end
include Colors
puts green("Type 'light', 'dark' or 'custom' for solarized color scheme (everything else will restore the default colors):")
STDOUT.flush
user_input = STDIN.gets.chomp
if user_input == 'light'
solarized_light
elsif user_input == 'dark'
solarized_dark
elsif user_input == 'custom'
custom_colors
else
puts red("restoring default color scheme")
default_colors
end