Skip to content

Instantly share code, notes, and snippets.

@gdsmith
Created May 31, 2016 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdsmith/a87f38ee40e09de6e5a71afa487403a6 to your computer and use it in GitHub Desktop.
Save gdsmith/a87f38ee40e09de6e5a71afa487403a6 to your computer and use it in GitHub Desktop.
#!/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