├── .github
└── FUNDING.yml
├── Solarized Dark.bbcolors
├── Solarized Light.bbcolors
├── README.mkd
└── bbcolors
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [rcarmo]
2 |
--------------------------------------------------------------------------------
/Solarized Dark.bbcolors:
--------------------------------------------------------------------------------
1 | "Color:Background" = "rgb(1044,8292,10466)";
2 | "Color:Comment" = "rgb(28873,33399,33872)";
3 | "Color:Foreground" = "rgb(60037,58327,52285)";
4 | "Color:HTMLAnchor" = "rgb(48611,13976,4819)";
5 | "Color:HTMLAttributeName" = "rgb(8359,30320,51269)";
6 | "Color:HTMLAttributeValue" = "rgb(9620,37409,34407)";
7 | "Color:HTMLImage" = "rgb(50946,7079,28519)";
8 | "Color:HTMLTag" = "rgb(28873,33399,33872)";
9 | "Color:InsertionPointLineHighlightColor" = "rgb(2581,10493,12998)";
10 | "Color:Invisibles:Other" = "rgb(2581,10493,12998)";
11 | "Color:Invisibles:Spaces" = "rgb(2581,10493,12998)";
12 | "Color:Keywords" = "rgb(8359,30320,51269)";
13 | "Color:NumericConstant" = "rgb(8359,30320,51269)";
14 | "Color:PredefinedName" = "rgb(48611,13976,4819)";
15 | "Color:PrimaryHighlight" = "rgb(21257,26684,28737)";
16 | "Color:SecondaryHighlight" = "rgb(2581,10493,12998)";
17 | "Color:String" = "rgb(9620,37409,34407)";
18 | "Color:UseCustomHighlight" = 1;
19 | "Color:XMLProcessingInstruction" = "rgb(42432,30639,1539)";
20 |
--------------------------------------------------------------------------------
/Solarized Light.bbcolors:
--------------------------------------------------------------------------------
1 | "Color:Background" = "rgb(64843,62779,56626)";
2 | "Color:Comment" = "rgb(28873,33399,33872)";
3 | "Color:Foreground" = "rgb(1044,8292,10466)";
4 | "Color:HTMLAnchor" = "rgb(48611,13976,4819)";
5 | "Color:HTMLAttributeName" = "rgb(8359,30320,51269)";
6 | "Color:HTMLAttributeValue" = "rgb(9620,37409,34407)";
7 | "Color:HTMLImage" = "rgb(50946,7079,28519)";
8 | "Color:HTMLTag" = "rgb(28873,33399,33872)";
9 | "Color:InsertionPointLineHighlightColor" = "rgb(60037,58327,52285)";
10 | "Color:Invisibles:Other" = "rgb(60037,58327,52285)";
11 | "Color:Invisibles:Spaces" = "rgb(60037,58327,52285)";
12 | "Color:Keywords" = "rgb(8359,30320,51269)";
13 | "Color:NumericConstant" = "rgb(8359,30320,51269)";
14 | "Color:PredefinedName" = "rgb(48611,13976,4819)";
15 | "Color:PrimaryHighlight" = "rgb(33160,37018,36938)";
16 | "Color:SecondaryHighlight" = "rgb(60037,58327,52285)";
17 | "Color:String" = "rgb(9620,37409,34407)";
18 | "Color:UseCustomHighlight" = 1;
19 | "Color:XMLProcessingInstruction" = "rgb(42432,30639,1539)";
20 |
--------------------------------------------------------------------------------
/README.mkd:
--------------------------------------------------------------------------------
1 | ---
2 | Title: Solarized Colorscheme for BBEdit and TextWrangler
3 | Description: Precision colors for machines and people
4 | Author: Rui Carmo
5 | Created: 2011 Apr 07
6 | Modified: 2011 Apr 16
7 | ---
8 |
9 | Solarized Colorscheme for BBEdit and TextWrangler
10 | =================================================
11 |
12 | Developed by [Rui Carmo](http://the.taoofmac.com), contributions by [Andreas Fuchs](https://github.com/antifuchs) and [Michael Josephson](https://github.com/mikej).
13 |
14 | If you have come across this colorscheme via the [repository] on
15 | github, visit the [Solarized homepage] or visit the main
16 | [Solarized repository].
17 |
18 | [repository]: https://github.com/rcarmo/textwrangler-bbedit-solarized
19 | [Solarized homepage]: http://ethanschoonover.com/solarized
20 | [Solarized repository]: https://github.com/altercation/solarized
21 |
22 | Installation
23 | ------------
24 |
25 | Starting in BBEdit 10.0 and TextWrangler 4.0, you can use the .bbcolors files without using any command-line tools.
26 |
27 | All you need to do is drop the .bbcolor files into your personal `Library` folder:
28 |
29 | * `~/Library/Application Support/BBEdit/Color Schemes/` (for BBEdit)
30 | * `~/Library/Application Support/TextWrangler/Color Schemes` (for TextWrangler).
31 |
32 | If you're a command-line person, copy/paste:
33 |
34 | cp *.bbcolors ~/Library/Application\ Support/BBEdit/Color\ Schemes/
35 |
36 | or, for TextWrangler:
37 |
38 | cp *.bbcolors ~/Library/Application\ Support/TextWrangler/Color\ Schemes/
39 |
40 | ...and then go to BBEdit/TextWrangler preferences and pick the color scheme in "Text Colors".
41 |
42 | Since TextWrangler (older than to 4.0) and BBEdit (older than version 10) don't allow you to save theme files separately, these `.bbcolor` files are generated by John Gruber's [BBColors][b] utility (bundled for your convenience), which manipulates their preferences file directly.
43 |
44 | To install these, place the files in `~/Library/Application\ Support/BBColors` and, with TextWrangler/BBEdit *closed*, invoke [BBColors][b] thusly:
45 |
46 | 1. For BBEdit (< version 10):
47 |
48 | ./bbcolors -load "Solarized Dark"
49 |
50 | 2. For TextWrangler (< version 4):
51 |
52 | ./bbcolors -load "Solarized Light" -tw
53 |
54 | [b]:http://daringfireball.net/projects/bbcolors/
55 |
56 | License
57 | -------
58 | Copyright (c) 2011 Rui Carmo
59 |
60 | Permission is hereby granted, free of charge, to any person obtaining a copy
61 | of this software and associated documentation files (the "Software"), to deal
62 | in the Software without restriction, including without limitation the rights
63 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
64 | copies of the Software, and to permit persons to whom the Software is
65 | furnished to do so, subject to the following conditions:
66 |
67 | The above copyright notice and this permission notice shall be included in
68 | all copies or substantial portions of the Software.
69 |
70 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
73 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
75 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
76 | THE SOFTWARE.
77 |
--------------------------------------------------------------------------------
/bbcolors:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | #
3 | # bbcolors -- A text color scheme manager for BBEdit and TextWrangler.
4 | #
5 | # Copyright (c) 2006 John Gruber
6 | #
7 | #
8 | # This program is free software; you may redistribute it and/or
9 | # modify it under the same terms as Perl itself.
10 | #
11 |
12 |
13 | use warnings;
14 | use strict;
15 | use Getopt::Long;
16 | use Pod::Usage;
17 | use encoding 'utf8';
18 | use utf8;
19 |
20 | use vars qw($VERSION);
21 | $VERSION = '1.0.1';
22 | # Sun 15 Oct 2006
23 |
24 | my $delete_setname;
25 | my $load_setname;
26 | my $save_setname;
27 | my $language;
28 | my $bbopen = 0; # If set, open a disk browser window showing the current saved color sets.
29 | my $reckless = 0; # If set, apply defaults changes even if app is running.
30 | my $zap = 0; # If set, clear all existing text color prefs, resetting to BBEdit defaults.
31 | my %app = (
32 | name => "BBEdit",
33 | bundle => "com.barebones.bbedit",
34 | creator => "R*ch",
35 | tool => "bbedit",
36 | );
37 |
38 | # This should work even on systems not using English; the true names aren't localized:
39 | my $bbcolors_support_folder = "$ENV{HOME}/Library/Application Support/BBColors";
40 | unless (-d $bbcolors_support_folder) {
41 | mkdir $bbcolors_support_folder
42 | or die "Can't create application support folder: $!";
43 | }
44 |
45 | GetOptions (
46 | "delete=s" => \$delete_setname,
47 | "list" => \&list_color_sets,
48 | "load=s" => \$load_setname,
49 | "save=s" => \$save_setname,
50 | "reckless" => \$reckless,
51 | "language=s" => \$language,
52 | "bbedit" => , # Do nothing; uses BBEdit by default
53 | "textwrangler|tw" => sub {%app = (
54 | name => "TextWrangler",
55 | bundle => "com.barebones.textwrangler",
56 | creator => "!Rch",
57 | tool => "edit",
58 | )},
59 | "open" => \&open_sets_folder_in_finder,
60 | "bbopen" => \$bbopen,
61 | "zap" => \$zap,
62 | 'help|?' => sub { pod2usage(1); },
63 | 'man' => sub { pod2usage(-verbose => 2); },
64 | "version" => sub { print "Version $VERSION\n"; exit 0; },
65 | ) or pod2usage(2);
66 |
67 |
68 | # Save first:
69 | if ($save_setname) {
70 | open (SETFILE, '>:utf8', "$bbcolors_support_folder/$save_setname.bbcolors")
71 | or die "Can't open file for writing: $!";
72 |
73 | my @lines = qx(defaults read $app{bundle} | egrep \\"Color:);
74 |
75 | if ($language) {
76 | # Only save color prefs for the language "$language"
77 | $language = quotemeta $language;
78 | @lines = grep(/"Color:.+:$language/, @lines);
79 | }
80 |
81 | my $len = 0; # Longest key string
82 | foreach (@lines) {
83 | if (m{^\s*(.+?) = (.+);\s*$}ms) {
84 | my $key = $1; # Should already have quotes around it
85 | my $val = $2;
86 | $key = unescape_plist_string($key);
87 | $len = length $key if (length $key > $len);
88 | $_ = "$key = $val;";
89 | }
90 | }
91 |
92 | # Loop through again to print; I can't figure out a way to do this
93 | # in one loop and still get the pretty-printed alignment.
94 | foreach (@lines) {
95 | if (m{^\s*(.+?) = (.+);\s*$}ms) {
96 | my $key = $1; # Should already have quotes around it
97 | my $val = $2;
98 | $val = " " . $val unless $val =~ m/^"/; # Looks better with a space before non-string values.
99 | printf SETFILE ("%-${len}s = %s;\n", $key, $val);
100 | }
101 | }
102 |
103 | close SETFILE;
104 | }
105 |
106 |
107 | # Then Zap:
108 | if ($zap) {
109 | if ( is_editor_running($app{name}) and ! $reckless ) {
110 | print "Won't zap prefs while $app{name} is running.\n";
111 | exit 0;
112 | }
113 | else {
114 | my @lines = qx(defaults read $app{bundle} | egrep \\"Color:);
115 |
116 | if ($language) {
117 | # Only zap color prefs for the language "$language"
118 | $language = quotemeta $language;
119 | @lines = grep(/"Color:[^"]+:$language/, @lines);
120 | }
121 |
122 | foreach (@lines) {
123 | if (m{^\s*(.+?) = (.+);\s*$}ms) {
124 | my $key = $1; # Should already have quotes around it
125 | $key = unescape_plist_string($key);
126 | my $res = qx(defaults delete $app{bundle} $key );
127 | }
128 | else {
129 | print STDERR "Can't parse line: «$_»\n";
130 | }
131 | }
132 | }
133 | }
134 |
135 |
136 | # Then load:
137 | if ($load_setname) {
138 | if ( is_editor_running($app{name}) and ! $reckless ) {
139 | print "Won't load prefs while $app{name} is running.\n";
140 | exit 0;
141 | }
142 | else {
143 | open (SETFILE, '<:utf8', "$bbcolors_support_folder/$load_setname.bbcolors")
144 | or do {print "No such scheme: '$load_setname'\nTry 'bbcolors -list' to see available schemes.\n"; exit;};
145 | while () {
146 | #
147 | # These lines should look like:
148 | # "Color:CTagsIdentifier" = "rgb(39321,0,26214)";
149 | # "Color:ColorAttributesSeparately" = 1;
150 | #
151 |
152 | next if m{^[ \t]*//}ms; # Treat // lines as comments.
153 |
154 | if (m{^\s*(.+?)[ \t]*=[ \t]*(.+);\s*$}ms) {
155 | my $key = $1; # These two captures keep the quotes around the key...
156 | my $val = $2; # ...and value.
157 | my $type = "-string";
158 | if ($val =~ m{^\d+$}) {
159 | # If the value is nothing but digits, treat it as an integer.
160 | # This seems to work even if it's actually a boolean. (I.e.
161 | # there's no need to guess whether 1 and 0 are bools or ints.)
162 | $type = "-integer";
163 | }
164 |
165 | if ($language) {
166 | my $quoted = quotemeta $language;
167 | next if ($key !~ m/$quoted"$/);
168 | }
169 |
170 | my $res = qx(defaults write $app{bundle} $key $type $val );
171 | }
172 | else {
173 | # Do nothing with lines that don't match.
174 | }
175 | }
176 | }
177 | }
178 |
179 |
180 | # Then delete:
181 | if ($delete_setname) {
182 | if (-f "$bbcolors_support_folder/$delete_setname.bbcolors") {
183 | unlink "$bbcolors_support_folder/$delete_setname.bbcolors"
184 | or die "Unable to delete $bbcolors_support_folder/$delete_setname.bbcolors: $!";
185 | }
186 | else {
187 | print "Color scheme '$delete_setname' does not exist.\n";
188 | }
189 | }
190 |
191 |
192 | # bbopen last; that way it won't fire up your editor before you diddle with the prefs
193 | if ($bbopen) {
194 | system($app{tool}, $bbcolors_support_folder);
195 | }
196 |
197 |
198 |
199 | #### End of main script. ####
200 |
201 | sub unescape_plist_string {
202 | my $str = shift;
203 |
204 | # Un-double backslashes
205 | $str =~ s{\\\\}{\\}g;
206 | # Unescape Unicode chars:
207 | $str =~ s{ \\U([[:xdigit:]]{4}) }{ chr(hex($1)) }egx;
208 |
209 | return $str;
210 | }
211 |
212 |
213 | sub escape_plist_string {
214 | my $str = shift;
215 |
216 | # Encode Unicode chars into plist \U hex escapes;
217 | # e.g. "Langüage" -> "Lang\U00fcage"
218 | $str =~ s{ (\P{IsASCII}) }{ sprintf("\\U%04x", ord($1)) }egx;
219 | # Double all backslashes:
220 | $str =~ s{\\}{\\\\}g;
221 |
222 | return $str;
223 | }
224 |
225 |
226 | sub is_editor_running {
227 | my $app_name = shift;
228 | my @processes = qx( ps -xc -o command );
229 | chomp @processes;
230 | my $count = grep { $_ eq $app_name } @processes;
231 | return $count;
232 | }
233 |
234 |
235 | sub list_color_sets {
236 | my $count = 0;
237 | opendir(FOLDER, $bbcolors_support_folder)
238 | or die "Can't open $bbcolors_support_folder: $!";
239 | while( my $file = readdir FOLDER ) {
240 | if (-T "$bbcolors_support_folder/$file" and $file =~ m/[.]bbcolors$/) {
241 | $count++;
242 | $file =~ s/[.]bbcolors$//; # trim the extension
243 | print "$file\n";
244 | }
245 | }
246 | print "No color sets available in $bbcolors_support_folder\n" unless $count;
247 | closedir(FOLDER);
248 | }
249 |
250 |
251 | sub open_sets_folder_in_finder {
252 | system("open", $bbcolors_support_folder);
253 | }
254 |
255 |
256 |
257 | __END__
258 |
259 | =head1 NAME
260 |
261 | bbcolors - Save and load text color sets for BBEdit.
262 |
263 |
264 | =head1 SYNOPSIS
265 |
266 | bbcolors -save "scheme name"
267 | bbcolors -load "scheme name"
268 | bbcolors -man
269 |
270 |
271 | =head1 DESCRIPTION
272 |
273 | B saves and loads "sets" of text color preferences for BBEdit.
274 |
275 |
276 | =head1 OPTIONS
277 |
278 | =over 8
279 |
280 | =item B<-delete> F
281 |
282 | Delete the saved bbcolors scheme named 'setname'. Does not effect current BBEdit preferences.
283 |
284 |
285 | =item B<-list>
286 |
287 | List all color sets.
288 |
289 |
290 | =item B<-load> F
291 |
292 | Replace current BBEdit text colors with scheme named "setname".
293 |
294 |
295 | =item B<-save> F
296 |
297 | Save current BBEdit text colors to scheme named "setname', overwriting any existing scheme with that name.
298 |
299 |
300 | =item B<-zap>
301 |
302 | Deletes all current BBEdit (or TextWrangler) color settings, including those keyed to specific languages. For example, if you set custom colors for the Perl language in BBEdit, and then use bbcolors to load a new colorset that does not contain Perl-specific colors, your previously-set custom colors for Perl will remain in place. If you use the B<-zap> option when loading the new scheme, however, your custom color settings will be deleted, and your Perl files will be displayed using the default colors of the just-loaded color scheme.
303 |
304 | =item B<-lang> F<"language name">
305 |
306 | Target a specific language when saving, loading, or zapping.
307 |
308 | =over 4
309 |
310 | =item *
311 |
312 | If saving, only save those colors set for the specified language. (The <-save> command normally saves all colors.)
313 |
314 | =item *
315 |
316 | If loading, only load those colors from the named scheme which are keyed to the specified language.
317 |
318 | =item *
319 |
320 | If zapping, only zap the preferences keyed to the specified language.
321 |
322 | =back
323 |
324 | =item B<-open>
325 |
326 | Open the ~/Library/Application Support/BBColors/ folder in the Finder. If the folder doesn't exist, it will be created.
327 |
328 |
329 | =item B<-bbopen>
330 |
331 | Open the ~/Library/Application Support/BBColors/ folder in a new disk browser window using BBEdit (or TextWrangler, if used in conjunction with the B<-tw> option). If the folder doesn't exist, it will be created.
332 |
333 |
334 | =item B<-bbedit>
335 |
336 | Explicitly use with BBEdit (as opposed to TextWrangler). This option is on by default.
337 |
338 |
339 | =item B<-textwrangler>
340 |
341 | =item B<-tw>
342 |
343 | Use TextWrangler instead of BBEdit.
344 |
345 |
346 | =item B<-help>
347 |
348 | Print a brief help message and exit.
349 |
350 |
351 | =item B<-man>
352 |
353 | Print the full bbcolors manual page.
354 |
355 |
356 | =item B<-version>
357 |
358 | Print the current bbcolors version number.
359 |
360 |
361 | =back
362 |
363 |
364 | =head1 A NOTE ON TEXT ENCODING
365 |
366 | B should work just fine with languages modules and saved color sets whose names contain non-ASCII characters. The only provision is that all input and output is assumed to be UTF-8.
367 |
368 |
369 | =head1 VERSION HISTORY
370 |
371 | =over 8
372 |
373 | =item 1.0.1 - Sun 15 Oct 2006
374 |
375 | Switched to a more efficient method of testing whether BBEdit and TextWrangler are currently running. Cleaned up the documentation slightly, replacing several instances of "color set" with "color scheme".
376 |
377 |
378 | =back
379 |
380 | =head1 COPYRIGHT AND LICENSE
381 |
382 | Copyright (c) 2006 John Gruber.
383 |
384 | This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
385 |
386 | =cut
387 |
--------------------------------------------------------------------------------