seaofclouds / sass-textmate-bundle

enjoy the splendor of textmate bundles and sass.

This URL has Read+Write access

sass-textmate-bundle / Commands / Insert Color….tmCommand
100644 41 lines (37 sloc) 1.14 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundleUUID</key>
<string>4675F24E-6227-11D9-BFB1-000D93589AF6</string>
<key>command</key>
<string>#!/usr/bin/env ruby
 
prefix, def_col = '#', ''
if STDIN.read =~ /(#?)([0-9A-Fa-f]{6})/ then
  prefix = $1
  rgb = $2.scan(/../).map { |i| i.hex * 257 }
  def_col = ' default color {' + rgb.join(",") + '}'
end
 
col = `osascript 2&gt;/dev/null -e 'tell app "TextMate" to choose color#{def_col}'`
exit 200 if col == ""
 
col = col.split(",").map { |i| i.to_i / 257 }
printf '%s%02X%02X%02X', prefix, *col
</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>@C</string>
<key>name</key>
<string>Insert Color…</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>scope</key>
<string>source.sass</string>
<key>uuid</key>
<string>15DB6DEF-1236-4781-AC58-D5D7B8A76727</string>
</dict>
</plist>