Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 71eb2cf

Browse files
committedApr 8, 2015
Dracula + iterm importer
1 parent b8518eb commit 71eb2cf

File tree

9 files changed

+140
-0
lines changed

9 files changed

+140
-0
lines changed
 

‎README.mkd

+19
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ color theme].
88
Colorschemes
99
------------
1010

11+
[Dracula][dracula]:
12+
13+
![Dracula](/screenshots/dracula.png?raw=true "Dracula")
14+
1115
[Gotham][vim-gotham]:
1216

1317
![Gotham](/screenshots/gotham.png?raw=true "Gotham")
@@ -84,6 +88,19 @@ Each theme has is own folder in the `colors` dir. It contains 5 files:
8488
No additional configuration is needed to add a theme, the installation script
8589
just list at launch the children folders in the `colors` dir.
8690

91+
Importing iTerm themes
92+
----------------------
93+
94+
It's possible to import an iTerm colorscheme to a gnome-terminal one. Use the
95+
script `tools/import_from_iterm.rb`.
96+
97+
Prerequisites: a working ruby installation with the `nokogiri-plist` ruby gem
98+
(`gem install nokogiri-plist`).
99+
100+
Example call:
101+
102+
`tools/import_from_iterm.rb my_iterm_colorscheme.itermcolors my_iterm_colorscheme`
103+
87104
Contributors
88105
------------
89106

@@ -101,6 +118,7 @@ Colorscheme authors
101118
* [Solarized][Solarized homepage]: Ethan Schoonover
102119
* [Gotham][vim-gotham]: Andrea Leopardi
103120
* [Hemisu][vim-hemisu]: Noah Frederick
121+
* [Dracula][dracula]: Zeno Rocha
104122

105123
Solarized
106124
===
@@ -152,3 +170,4 @@ readme.
152170
[Gotham]
153171
[vim-gotham]: https://github.com/whatyouhide/vim-gotham
154172
[vim-hemisu]: https://github.com/noahfrederick/vim-hemisu
173+
[dracula]: https://github.com/zenorocha/dracula-theme

‎colors/dracula/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Colorscheme dracula - imported from iterm on 2015-04-08 10:33:45 +0200

‎colors/dracula/bd_color

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#ffffffffffff

‎colors/dracula/bg_color

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#1e1f1f4528e7

‎colors/dracula/fg_color

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#f8f8f8f8f2f2

‎colors/dracula/palette_dconf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
'#000000000000', '#ffff55555555', '#5050fafa7b7b', '#f1f1fafa8c8c', '#bdbd9393f9f9', '#ffff7979c6c6', '#8b8be9e9fdfd', '#bbbbbbbbbbbb', '#555555555555', '#ffff55555555', '#5050fafa7b7b', '#f1f1fafa8c8c', '#bdbd9393f9f9', '#ffff7979c6c6', '#8b8be9e9fdfd', '#ffffffffffff'

‎colors/dracula/palette_gconf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#000000000000:#ffff55555555:#5050fafa7b7b:#f1f1fafa8c8c:#bdbd9393f9f9:#ffff7979c6c6:#8b8be9e9fdfd:#bbbbbbbbbbbb:#555555555555:#ffff55555555:#5050fafa7b7b:#f1f1fafa8c8c:#bdbd9393f9f9:#ffff7979c6c6:#8b8be9e9fdfd:#ffffffffffff

‎screenshots/dracula.png

48.6 KB
Loading

‎tools/import_from_iterm.rb

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env ruby
2+
3+
# imports an iTerm color profile to gnome terminal
4+
# syntax: import_from_iterm.rb <path_to_profile> <profile_name>
5+
6+
require 'nokogiri'
7+
require 'nokogiri-plist'
8+
9+
class Color
10+
attr_accessor :red
11+
attr_accessor :green
12+
attr_accessor :blue
13+
14+
def initialize(args={})
15+
args.each_pair do |k, v|
16+
self.send("#{k}=", v)
17+
end
18+
end
19+
20+
def to_48bit_hex
21+
red_part = sprintf("%04x", (red.to_f * 65535).round)
22+
green_part = sprintf("%04x", (green.to_f * 65535).round)
23+
blue_part = sprintf("%04x", (blue.to_f * 65535).round)
24+
"##{red_part}#{green_part}#{blue_part}"
25+
end
26+
end
27+
28+
file_path = ARGV[0]
29+
profile_name = ARGV[1]
30+
31+
unless file_path && profile_name
32+
puts "Syntax: import_from_iterm.rb <path_to_profile> <profile_name>"
33+
exit(-1)
34+
end
35+
36+
if Dir.exists?("colors/#{profile_name}")
37+
puts "Color #{profile_name} already exists, delete it or choose a different name"
38+
exit(-1)
39+
end
40+
41+
input = File.open(file_path)
42+
plist = Nokogiri::PList(input)
43+
input.close
44+
45+
# First of all, we need to collect values for each ansi color
46+
# Label inside plist file is like "Ansi 0 Color"
47+
48+
colors = {}
49+
(0).upto(15) do |count|
50+
label = "Ansi #{count} Color"
51+
data = plist[label]
52+
colors[label] = Color.new(
53+
red: data['Red Component'],
54+
green: data['Green Component'],
55+
blue: data['Blue Component'],
56+
)
57+
end
58+
59+
# Now, we need to collect other data: background color, foreground color, and bold color
60+
61+
['Background Color', 'Foreground Color', 'Bold Color'].each do |label|
62+
data = plist[label]
63+
colors[label] = Color.new(
64+
red: data['Red Component'],
65+
green: data['Green Component'],
66+
blue: data['Blue Component'],
67+
)
68+
end
69+
70+
# Very good. Now we have all we need to generate the Gnome Terminal color profile.
71+
72+
# Let's start creating a directory
73+
74+
Dir.mkdir("colors/#{profile_name}")
75+
76+
# now, the palettes. Let's build it first
77+
78+
palette = []
79+
(0).upto(15) do |count|
80+
label = "Ansi #{count} Color"
81+
color_code_48_bit = colors[label].to_48bit_hex
82+
palette << color_code_48_bit
83+
end
84+
85+
# now let's write the dconf palette
86+
File.open("colors/#{profile_name}/palette_dconf", "w") do |f|
87+
f.puts palette.map { |color| "'#{color}'"}.join(", ")
88+
end
89+
90+
# and the gconf palette
91+
File.open("colors/#{profile_name}/palette_gconf", "w") do |f|
92+
f.puts palette.join(":")
93+
end
94+
95+
# bold color
96+
File.open("colors/#{profile_name}/bd_color", "w") do |f|
97+
f.puts colors['Bold Color'].to_48bit_hex
98+
end
99+
100+
# background color
101+
File.open("colors/#{profile_name}/bg_color", "w") do |f|
102+
f.puts colors['Background Color'].to_48bit_hex
103+
end
104+
105+
# Foreground color
106+
File.open("colors/#{profile_name}/fg_color", "w") do |f|
107+
f.puts colors['Foreground Color'].to_48bit_hex
108+
end
109+
110+
# A little README.md file
111+
File.open("colors/#{profile_name}/README.md", "w") do |f|
112+
f.puts "Colorscheme #{profile_name} - imported from iterm on #{Time.now}"
113+
end
114+
115+
puts "Done!"

0 commit comments

Comments
 (0)
Please sign in to comment.