iterm2xrdb: allow extra keys in itermcolors files
https://github.com/mbadolato/iTerm2-Color-Schemes/issues/37
This commit is contained in:
parent
6f501c2c4d
commit
b4c816f218
1 changed files with 8 additions and 9 deletions
|
|
@ -1,17 +1,16 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Converts iTerm2 color schemes into xrdb(1) format, as a set of `#define`s,
|
||||
# and prints the result to STDOUT. Reads STDIN if no input files are given.
|
||||
#
|
||||
# Usage: iterm2xrdb FILE...
|
||||
# Usage: cat FILE... | iterm2xrdb
|
||||
# Usage: iterm2xrdb < INPUT
|
||||
#
|
||||
#--
|
||||
# Converts iTerm2 color schemes into xrdb(1) format, as a set of `#define`s,
|
||||
# and prints the result to STDOUT. Reads STDIN if no input files are given.
|
||||
#
|
||||
# Written in 2013 by Suraj N. Kurapati <https://github.com/sunaku>
|
||||
|
||||
ARGF.read.scan(%r{>(.+?)</}).flatten(1).each_slice(7) do |color, *components|
|
||||
puts "#define #{ color.gsub(/\W/, ?_) } #" + Hash[*components].
|
||||
values_at('Red Component', 'Green Component', 'Blue Component').
|
||||
map {|intensity| sprintf '%02x', (intensity.to_f * 255).round }.join
|
||||
end
|
||||
puts ARGF.read.scan(%r{>(.+?)</}).flatten(1).slice_before(/\bColor$/).map {
|
||||
|color, *pairs| "#define #{ color.gsub(/\W/, ?_) } #" + Hash[*pairs].
|
||||
values_at('Red Component', 'Green Component', 'Blue Component').
|
||||
map { |intensity| sprintf '%02x', (intensity.to_f * 255).round }.join
|
||||
}.to_a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue