Last active
January 2, 2016 09:39
-
-
Save shadowbq/8285016 to your computer and use it in GitHub Desktop.
Theme changer iterm.color to gnome-terminal
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 characters
# https://github.com/caseyhoward/nokogiri-plist | |
require 'nokogiri-plist' | |
# /apps/gnome-terminal/profiles/Default | |
# -> background_color | |
# -> bold_color | |
# -> foreground_color | |
# -> palette | |
def convert_to_key(real_color) | |
return "%02X" % (real_color * 255) | |
end | |
def gconf2_command(gconf_key, gconf_type, gconf_value) | |
return "gconftool-2 --set /apps/gnome-terminal/profiles/Default/#{gconf_key} --type #{gconf_type} \"#{gconf_value}\"" | |
end | |
def get_rgb(doc_hash) | |
red = convert_to_key(doc_hash["Red Component"]) | |
green = convert_to_key(doc_hash["Green Component"]) | |
blue = convert_to_key(doc_hash["Blue Component"]) | |
return "##{red}#{green}#{blue}" | |
end | |
ARGV.each do |iterm_theme| | |
f = open(iterm_theme) | |
doc = Nokogiri::PList(f) | |
keys_to_export = Hash.new | |
keys_to_export["palette"] = Array.new(16) | |
doc.keys.each do |doc_key| | |
if doc_key =~ /Ansi \d+ Color/ | |
slot = doc_key.scan(/Ansi (\d+) Color/)[0][0].to_i | |
hex = get_rgb(doc[doc_key]) | |
keys_to_export["palette"][slot] = hex | |
end | |
if doc_key =~ /Background Color/ | |
# This goes directly to background_color | |
hex = get_rgb(doc[doc_key]) | |
keys_to_export["background_color"] = hex | |
end | |
if doc_key =~ /Foreground Color/ | |
# This goes directly to foreground_color | |
hex = get_rgb(doc[doc_key]) | |
keys_to_export["foreground_color"] = hex | |
end | |
if doc_key =~ /Bold Color/ | |
# This goes directly to bold color | |
hex = get_rgb(doc[doc_key]) | |
keys_to_export["bold_color"] = hex | |
end | |
end | |
puts "# " + iterm_theme | |
puts gconf2_command("foreground_color", "string", keys_to_export["foreground_color"]) | |
puts gconf2_command("background_color", "string", keys_to_export["background_color"]) | |
puts gconf2_command("bold_color", "string", keys_to_export["bold_color"]) | |
puts gconf2_command("palette", "string", keys_to_export["palette"].join(':')) | |
end |
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 characters
ruby iterm2gnome.rb Zenburn.itermcolors | |
# Zenburn.itermcolors | |
gconftool-2 --set /apps/gnome-terminal/profiles/Default/foreground_color --type string "#DCDCCC" | |
gconftool-2 --set /apps/gnome-terminal/profiles/Default/background_color --type string "#1F1F1F" | |
gconftool-2 --set /apps/gnome-terminal/profiles/Default/bold_color --type string "#FFCFAF" | |
gconftool-2 --set /apps/gnome-terminal/profiles/Default/palette --type string "#000B13:#E89393:#9ECE9E:#F0DFAF:#8CD0D3:#C0BED1:#DFAF8F:#EFEFEF:#000B13:#E89393:#9ECE9E:#F0DFAF:#8CD0D3:#C0BED1:#DFAF8F:#FFFFFF" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
recovered from
https://web.archive.org/web/20120809035624/http://www.sharms.org/blog/2012/08/using-iterm-2-themes-with-gnome-terminal/