Created
August 1, 2023 11:48
-
-
Save nathanpc/6f5f4aeddf5a220ba45c02892fae7e96 to your computer and use it in GitHub Desktop.
Converts an iTerm2 color profile made for newer versions of iTerm to work in iTerm2 version 2.0 for OS X Leopard.
This file contains 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 characters
#!/usr/bin/env perl | |
### fix-itermcolors.pl | |
### Converts an iTerm2 color profile made for newer versions of iTerm to work | |
### in iTerm2 version 2.0 for OS X Leopard. | |
### | |
### Author: Nathan Campos <[email protected]> | |
use strict; | |
use warnings; | |
use autodie; | |
# Slurps the file. | |
sub slurp { | |
my ($fname) = @_; | |
open my $fh, '<', $fname; | |
local $/ = undef; | |
my $data = <$fh>; | |
close $fh; | |
return $data; | |
} | |
# Read the iTerm color profile. | |
my $plist = slurp($ARGV[0]); | |
# Strip out invalid keys. | |
$plist =~ s/\s+<key>Alpha Component<\/key>[^\/]+.+//g; | |
$plist =~ s/\s+<key>Color Space<\/key>[^\/]+.+//g; | |
# Remove invalid dictionaries. | |
$plist =~ s/\s+<key>Badge Color<\/key>((?!<\/dict>)[\s\S])*<\/dict>\s?//gs; | |
$plist =~ s/\s+<key>Cursor Guide Color<\/key>((?!<\/dict>)[\s\S])*<\/dict>\s?//gs; | |
$plist =~ s/\s+<key>Link Color<\/key>((?!<\/dict>)[\s\S])*<\/dict>\s?//gs; | |
$plist =~ s/\s+<key>Tab Color<\/key>((?!<\/dict>)[\s\S])*<\/dict>\s?//gs; | |
# Print it out. | |
print $plist; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment