-
-
Save muralisc/22c591fae9ac436765a02de3235a23e2 to your computer and use it in GitHub Desktop.
Revisions
-
timothy revised this gist
Oct 8, 2012 . 1 changed file with 3 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,6 @@ use strict; print <<eof; <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> @@ -39,13 +35,11 @@ print "</dict>\n</plist>"; sub do_color { my $i = 0; my $ret = ''; for (shift =~ m/.{2}/gs) { $ret .= "\t\t<key>$cols{$i} Component</key>\n\t\t<real>"; $ret .= sprintf("%.16f", hex($_)/255); $ret .= "</real>\n"; $i++; } -
timothy revised this gist
Oct 8, 2012 . 1 changed file with 7 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,8 @@ #!/usr/bin/perl -w # Convert .Xdefaults or similar terminal colors to iTerm2 scheme # Only supports simple hex colors, no funny stuff use strict; use Color::Rgb; @@ -21,23 +25,18 @@ while (<>) { if(/^[^!]*color(\d+):\s+#(\w{6})/) { print "\t<key>Ansi $1 Color</key>\n\t<dict>\n"; print &do_color($2); print "\t</dict>\n"; } elsif(/^[^!]*(fore|back)ground:\s+#(\w{6})/) { my $fb = $1; $fb =~ tr/fb/FB/; print "\t<key>" . $fb . "ground Color</key>\n\t<dict>\n"; print &do_color($2); print "\t</dict>\n"; } } print "</dict>\n</plist>"; sub do_color { my $color = shift; -
timothy created this gist
Oct 8, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ #!/usr/bin/perl -w use strict; use Color::Rgb; my $rgb = new Color::Rgb(rgb_txt=>"rgb.txt"); print <<eof; <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> eof my %cols = ( 2 => "Blue", 1 => "Green", 0 => "Red", ); while (<>) { if(/^[^!]*color(\d+):\s+#(\w{6})/) { print "\t<key>Ansi $1 Color</key>\n\t<dict>\n"; my $out = &do_color($2); print $out; print "\t</dict>\n"; } elsif(/^[^!]*(fore|back)ground:\s+#(\w{6})/) { my $fb = $1; $fb =~ tr/fb/FB/; print "\t<key>" . $fb . "ground Color</key>\n\t<dict>\n"; my $out = &do_color($2); print $out; print "\t</dict>\n"; } } print <<eof; </dict> </plist> eof sub do_color { my $color = shift; my $ret = ""; my @colors = $rgb->hex2rgb("#$2"); my $i = 0; for(@colors) { $ret .= "\t\t<key>$cols{$i} Component</key>\n\t\t<real>"; $ret .= sprintf("%.16f", $colors[$i]/255); $ret .= "</real>\n"; $i++; } return $ret; }