Created
May 31, 2016 09:29
-
-
Save gdsmith/a87f38ee40e09de6e5a71afa487403a6 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby18 -wKU | |
line = ENV['TM_CURRENT_LINE'] || ENV['TM_SELECTED_TEXT'] | |
color = '' | |
line.scan(/(#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})(?=[^0-9A-Fa-f])|rgba{0,1}\([0-9]{1,3}[, ]+?[0-9]{1,3}[, ]+?[0-9]{1,3}[, 0-9\.]*?\))/) { |c| | |
color = color+"<div style='font-size:8px;display:inline-block;height:3em;margin:0;padding:0 0.5em 0 0;height:3em;background:#{c[0]}'><span style='background:#000;color:#FFF'>#{c[0]}</span></div>" | |
} | |
color = '<div style=\\"background:\\#000;color:\\#FFF;padding:2px\\">No color found</div>' unless color.length > 0 | |
%x{ \"$DIALOG\" tooltip --transparent --html \"#{color}\" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment