Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9a568e7826
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (46 sloc) 1.371 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 42 43 44 45 46 47 48 49 50
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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>command</key>
<string>#!/usr/bin/env ruby -wKU
require "pp"

def indent(text)
text.split(/\n/).collect { |str| $&amp; if str =~ /^\s*/ }.reject { |e| e == "" }.min { |a, b| a.length &lt;=&gt; b.length }
end

def tab
ENV['TM_SOFT_TABS'] == 'YES' ? ' ' * ENV['TM_TAB_SIZE'].to_i : "\t"
end

code = STDIN.read

if code =~ /\n/ &amp;&amp; ENV['TM_INPUT_START_LINE_INDEX'].to_i == 0 then
  STDOUT &lt;&lt; indent(code) &lt;&lt; "{\n"
  STDOUT &lt;&lt; code.gsub(/^(?=.)/, "#{tab}")
  STDOUT &lt;&lt; indent(code) &lt;&lt; "}\n"
else
  STDOUT &lt;&lt; "{#{code}}"
end
</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>{</string>
<key>name</key>
<string>Wrap in Braces</string>
<key>outputCaret</key>
<string>heuristic</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>replaceInput</string>
<key>scope</key>
<string>source &amp; dyn.selection &amp; -dyn.caret.mixed</string>
<key>uuid</key>
<string>52DA9EF9-6D1A-4E55-BFB9-BCB85C250715</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
Something went wrong with that request. Please try again.