iterm2mintty 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b11b14ef3736ef26f77b1d35db3bcc862a7a4aa
4
+ data.tar.gz: e5648092e45252376f28f0edf7d7ce17d7b33cc0
5
+ SHA512:
6
+ metadata.gz: 90b8a0deef95b6445dc7a89165ade2fa146b2ef2dc8c36f307eb9c91e6b1440531e48fd830aab979fef0552201a0a8eb734a1607a24b5c7b5d2203033993ca5b
7
+ data.tar.gz: d9fb454bec29664579562e5224e086c725073995aab190ba9081036f0936b1658e6c074ad14f9f7cbf960c352b80e3439358cd30c72c7340dbcbd0307748cf68
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iterm2mintty.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Brian Field
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Iterm2mintty
2
+
3
+ Still very very very much a work in progress. Converts existing iterm2 colorscheme into a mintty
4
+ compatible one.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'iterm2mintty'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install iterm2mintty
21
+
22
+ ## Usage
23
+
24
+ ```
25
+ iterm2mintty somecolorscheme.itermcolors
26
+ ```
27
+
28
+ Should output a .minttyrc file in whatever directory you ran it in.
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/[my-github-username]/iterm2mintty/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ end
7
+
8
+ desc "Run tests"
9
+ task default: :test
data/bin/iterm2mintty ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ Signal.trap("INT") { exit 1 }
7
+
8
+ require "iterm2mintty"
9
+ require "pathname"
10
+
11
+ file = Pathname.new(ARGV[0])
12
+
13
+ File.open("./.minttyrc", "w") do |f|
14
+ f.write Iterm2mintty.new(pathname: file).convert
15
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'iterm2mintty/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iterm2mintty"
8
+ spec.version = Iterm2mintty::VERSION
9
+ spec.authors = ["Brian Field"]
10
+ spec.email = ["brian@madsalty.com"]
11
+ spec.summary = %q{Tool for converting terminal themes from iTerm2 to mintty}
12
+ spec.description = %q{}
13
+ spec.homepage = "http://www.github.com/bobcats/iterm2mintty"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ["iterm2mintty"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_runtime_dependency "plist"
25
+ end
@@ -0,0 +1,137 @@
1
+ require "iterm2mintty/version"
2
+ require "plist"
3
+ require "pry"
4
+
5
+ class Iterm2mintty
6
+ attr_reader :pathname, :ansi_colors
7
+
8
+ def initialize(pathname:)
9
+ @pathname = pathname
10
+ end
11
+
12
+ def convert
13
+ ansi_colors.map do |color|
14
+ color.to_mintty + "\n"
15
+ end.join
16
+ end
17
+
18
+ def ansi_colors
19
+ @ansi_colors ||=
20
+ parsed_theme.map do |k, v|
21
+ red = Integer(v["Red Component"] * 255)
22
+ green = Integer(v["Green Component"] * 255)
23
+ blue = Integer(v["Blue Component"] * 255)
24
+ color = Color.new(red, green, blue)
25
+
26
+ case k
27
+ when /Ansi/
28
+ number = Integer(k.match(/\d+/)[0])
29
+ ANSIColor.new(number: number, color: color)
30
+ when "Background Color"
31
+ BGColor.new(color: color)
32
+ when "Foreground Color"
33
+ FGColor.new(color: color)
34
+ when "Cursor Color"
35
+ CursorColor.new(color: color)
36
+ end
37
+ end.compact
38
+ end
39
+
40
+ def parsed_theme
41
+ @parsed_theme ||= Plist.parse_xml(pathname)
42
+ end
43
+ end
44
+
45
+ class Iterm2mintty::Mintty
46
+ def self.rc_build(colors)
47
+ puts colors.map do |color|
48
+ color.to_mintty
49
+ end
50
+ end
51
+ end
52
+
53
+ module Iterm2mintty::MinttyColor
54
+ def to_mintty
55
+ "#{name}= #{red}, #{green}, #{blue}"
56
+ end
57
+ end
58
+
59
+ module Iterm2mintty::Colorable
60
+ def red
61
+ color.r
62
+ end
63
+
64
+ def green
65
+ color.g
66
+ end
67
+
68
+ def blue
69
+ color.b
70
+ end
71
+ end
72
+
73
+ class Iterm2mintty::ANSIColor
74
+ include Iterm2mintty::MinttyColor
75
+ include Iterm2mintty::Colorable
76
+
77
+ attr_reader :number, :color
78
+
79
+ NAMES = %w(
80
+ Black Red Green Yellow Blue Magenta Cyan White
81
+ BoldBlack BoldRed BoldGreen BoldYellow BoldBlue BoldMagenta BoldCyan BoldWhite
82
+ )
83
+
84
+ def initialize(number:, color:)
85
+ @number = number
86
+ @color = color
87
+ end
88
+
89
+ def name
90
+ NAMES[number]
91
+ end
92
+ end
93
+
94
+ class Iterm2mintty::FGColor
95
+ include Iterm2mintty::MinttyColor
96
+ include Iterm2mintty::Colorable
97
+ attr_reader :color
98
+
99
+ def initialize(color:)
100
+ @color = color
101
+ end
102
+
103
+ def name
104
+ "ForegroundColour"
105
+ end
106
+ end
107
+
108
+ class Iterm2mintty::BGColor
109
+ include Iterm2mintty::MinttyColor
110
+ include Iterm2mintty::Colorable
111
+ attr_reader :color
112
+
113
+ def initialize(color:)
114
+ @color = color
115
+ end
116
+
117
+ def name
118
+ "BackgroundColour"
119
+ end
120
+ end
121
+
122
+ class Iterm2mintty::CursorColor
123
+ include Iterm2mintty::MinttyColor
124
+ include Iterm2mintty::Colorable
125
+ attr_reader :color
126
+
127
+ def initialize(color:)
128
+ @color = color
129
+ end
130
+
131
+ def name
132
+ "CursorColour"
133
+ end
134
+ end
135
+
136
+ class Iterm2mintty::Color < Struct.new(:r, :g, :b)
137
+ end
@@ -0,0 +1,3 @@
1
+ class Iterm2mintty
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,213 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>Ansi 0 Color</key>
6
+ <dict>
7
+ <key>Blue Component</key>
8
+ <real>0.20179691910743713</real>
9
+ <key>Green Component</key>
10
+ <real>0.1818026602268219</real>
11
+ <key>Red Component</key>
12
+ <real>0.1665644645690918</real>
13
+ </dict>
14
+ <key>Ansi 1 Color</key>
15
+ <dict>
16
+ <key>Blue Component</key>
17
+ <real>0.31569483879999999</real>
18
+ <key>Green Component</key>
19
+ <real>0.30211547020000001</real>
20
+ <key>Red Component</key>
21
+ <real>0.72003227469999997</real>
22
+ </dict>
23
+ <key>Ansi 10 Color</key>
24
+ <dict>
25
+ <key>Blue Component</key>
26
+ <real>0.1934914291</real>
27
+ <key>Green Component</key>
28
+ <real>0.51726025340000004</real>
29
+ <key>Red Component</key>
30
+ <real>0.47279784079999998</real>
31
+ </dict>
32
+ <key>Ansi 11 Color</key>
33
+ <dict>
34
+ <key>Blue Component</key>
35
+ <real>0.31311613319999998</real>
36
+ <key>Green Component</key>
37
+ <real>0.53968650100000004</real>
38
+ <key>Red Component</key>
39
+ <real>0.8995583653</real>
40
+ </dict>
41
+ <key>Ansi 12 Color</key>
42
+ <dict>
43
+ <key>Blue Component</key>
44
+ <real>0.53338390588760376</real>
45
+ <key>Green Component</key>
46
+ <real>0.420734703540802</real>
47
+ <key>Red Component</key>
48
+ <real>0.29605811834335327</real>
49
+ </dict>
50
+ <key>Ansi 13 Color</key>
51
+ <dict>
52
+ <key>Blue Component</key>
53
+ <real>0.47512847185134888</real>
54
+ <key>Green Component</key>
55
+ <real>0.31322062015533447</real>
56
+ <key>Red Component</key>
57
+ <real>0.43185719847679138</real>
58
+ </dict>
59
+ <key>Ansi 14 Color</key>
60
+ <dict>
61
+ <key>Blue Component</key>
62
+ <real>0.45474731922149658</real>
63
+ <key>Green Component</key>
64
+ <real>0.48341637849807739</real>
65
+ <key>Red Component</key>
66
+ <real>0.30198413133621216</real>
67
+ </dict>
68
+ <key>Ansi 15 Color</key>
69
+ <dict>
70
+ <key>Blue Component</key>
71
+ <real>0.41454979777336121</real>
72
+ <key>Green Component</key>
73
+ <real>0.38266518712043762</real>
74
+ <key>Red Component</key>
75
+ <real>0.35304740071296692</real>
76
+ </dict>
77
+ <key>Ansi 2 Color</key>
78
+ <dict>
79
+ <key>Blue Component</key>
80
+ <real>0.35396462680000002</real>
81
+ <key>Green Component</key>
82
+ <real>0.74809849260000005</real>
83
+ <key>Red Component</key>
84
+ <real>0.70226675270000005</real>
85
+ </dict>
86
+ <key>Ansi 3 Color</key>
87
+ <dict>
88
+ <key>Blue Component</key>
89
+ <real>0.36974489688873291</real>
90
+ <key>Green Component</key>
91
+ <real>0.71015834808349609</real>
92
+ <key>Red Component</key>
93
+ <real>0.89336264133453369</real>
94
+ </dict>
95
+ <key>Ansi 4 Color</key>
96
+ <dict>
97
+ <key>Blue Component</key>
98
+ <real>0.69103837013244629</real>
99
+ <key>Green Component</key>
100
+ <real>0.56596899032592773</real>
101
+ <key>Red Component</key>
102
+ <real>0.43031883239746094</real>
103
+ </dict>
104
+ <key>Ansi 5 Color</key>
105
+ <dict>
106
+ <key>Blue Component</key>
107
+ <real>0.67327117919921875</real>
108
+ <key>Green Component</key>
109
+ <real>0.49495330452919006</real>
110
+ <key>Red Component</key>
111
+ <real>0.63015031814575195</real>
112
+ </dict>
113
+ <key>Ansi 6 Color</key>
114
+ <dict>
115
+ <key>Blue Component</key>
116
+ <real>0.70492839813232422</real>
117
+ <key>Green Component</key>
118
+ <real>0.74725800752639771</real>
119
+ <key>Red Component</key>
120
+ <real>0.49952495098114014</real>
121
+ </dict>
122
+ <key>Ansi 7 Color</key>
123
+ <dict>
124
+ <key>Blue Component</key>
125
+ <real>0.71428978443145752</real>
126
+ <key>Green Component</key>
127
+ <real>0.72398024797439575</real>
128
+ <key>Red Component</key>
129
+ <real>0.7101062536239624</real>
130
+ </dict>
131
+ <key>Ansi 8 Color</key>
132
+ <dict>
133
+ <key>Blue Component</key>
134
+ <real>0.13228283822536469</real>
135
+ <key>Green Component</key>
136
+ <real>0.12020024657249451</real>
137
+ <key>Red Component</key>
138
+ <real>0.11482735723257065</real>
139
+ </dict>
140
+ <key>Ansi 9 Color</key>
141
+ <dict>
142
+ <key>Blue Component</key>
143
+ <real>0.19629062712192535</real>
144
+ <key>Green Component</key>
145
+ <real>0.17900724709033966</real>
146
+ <key>Red Component</key>
147
+ <real>0.5527348518371582</real>
148
+ </dict>
149
+ <key>Background Color</key>
150
+ <dict>
151
+ <key>Blue Component</key>
152
+ <real>0.097707755863666534</real>
153
+ <key>Green Component</key>
154
+ <real>0.092142701148986816</real>
155
+ <key>Red Component</key>
156
+ <real>0.086937598884105682</real>
157
+ </dict>
158
+ <key>Bold Color</key>
159
+ <dict>
160
+ <key>Blue Component</key>
161
+ <real>0.72798359394073486</real>
162
+ <key>Green Component</key>
163
+ <real>0.73781722784042358</real>
164
+ <key>Red Component</key>
165
+ <real>0.71933764219284058</real>
166
+ </dict>
167
+ <key>Cursor Color</key>
168
+ <dict>
169
+ <key>Blue Component</key>
170
+ <real>0.72798359394073486</real>
171
+ <key>Green Component</key>
172
+ <real>0.73781722784042358</real>
173
+ <key>Red Component</key>
174
+ <real>0.71933764219284058</real>
175
+ </dict>
176
+ <key>Cursor Text Color</key>
177
+ <dict>
178
+ <key>Blue Component</key>
179
+ <real>0.13528014719486237</real>
180
+ <key>Green Component</key>
181
+ <real>0.12312769144773483</real>
182
+ <key>Red Component</key>
183
+ <real>0.11772145330905914</real>
184
+ </dict>
185
+ <key>Foreground Color</key>
186
+ <dict>
187
+ <key>Blue Component</key>
188
+ <real>0.72798359394073486</real>
189
+ <key>Green Component</key>
190
+ <real>0.73781722784042358</real>
191
+ <key>Red Component</key>
192
+ <real>0.71933764219284058</real>
193
+ </dict>
194
+ <key>Selected Text Color</key>
195
+ <dict>
196
+ <key>Blue Component</key>
197
+ <real>0.72798359394073486</real>
198
+ <key>Green Component</key>
199
+ <real>0.73781722784042358</real>
200
+ <key>Red Component</key>
201
+ <real>0.71933764219284058</real>
202
+ </dict>
203
+ <key>Selection Color</key>
204
+ <dict>
205
+ <key>Blue Component</key>
206
+ <real>0.13528014719486237</real>
207
+ <key>Green Component</key>
208
+ <real>0.12312769144773483</real>
209
+ <key>Red Component</key>
210
+ <real>0.11772145330905914</real>
211
+ </dict>
212
+ </dict>
213
+ </plist>
@@ -0,0 +1,54 @@
1
+ require "minitest/autorun"
2
+ require "iterm2mintty"
3
+ require "pathname"
4
+
5
+ class Iterm2minttyTest < MiniTest::Test
6
+ def setup
7
+ @i22m = Iterm2mintty.new(
8
+ pathname: Pathname.new("test/Hybrid.itermcolors")
9
+ )
10
+ end
11
+
12
+ def test_convert
13
+ minttyrc =
14
+ <<-MINTTYRC
15
+ Black= 42, 46, 51
16
+ Red= 183, 77, 80
17
+ BoldGreen= 120, 131, 49
18
+ BoldYellow= 229, 137, 79
19
+ BoldBlue= 75, 107, 136
20
+ BoldMagenta= 110, 79, 121
21
+ BoldCyan= 77, 123, 115
22
+ BoldWhite= 90, 97, 105
23
+ Green= 179, 190, 90
24
+ Yellow= 227, 181, 94
25
+ Blue= 109, 144, 176
26
+ Magenta= 160, 126, 171
27
+ Cyan= 127, 190, 179
28
+ White= 181, 184, 182
29
+ BoldBlack= 29, 30, 33
30
+ BoldRed= 140, 45, 50
31
+ BackgroundColour= 22, 23, 24
32
+ CursorColour= 183, 188, 185
33
+ ForegroundColour= 183, 188, 185
34
+ MINTTYRC
35
+
36
+ assert_equal minttyrc, @i22m.convert
37
+ end
38
+ end
39
+
40
+ class Iterm2mintty
41
+ class ANSIColorTest < MiniTest::Test
42
+ def setup
43
+ @black = ANSIColor.new(number: 0, color: Color.new(0, 0, 0))
44
+ end
45
+
46
+ def test_name
47
+ assert_equal "Black", @black.name
48
+ end
49
+
50
+ def test_to_mintty
51
+ assert_equal "Black= 0, 0, 0", @black.to_mintty
52
+ end
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iterm2mintty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Field
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: plist
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: ''
56
+ email:
57
+ - brian@madsalty.com
58
+ executables:
59
+ - iterm2mintty
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/iterm2mintty
69
+ - iterm2mintty.gemspec
70
+ - lib/iterm2mintty.rb
71
+ - lib/iterm2mintty/version.rb
72
+ - test/Hybrid.itermcolors
73
+ - test/test_iterm2mintty.rb
74
+ homepage: http://www.github.com/bobcats/iterm2mintty
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Tool for converting terminal themes from iTerm2 to mintty
98
+ test_files:
99
+ - test/Hybrid.itermcolors
100
+ - test/test_iterm2mintty.rb