Skip to content

Commit a61856e

Browse files
committed
First commit
0 parents  commit a61856e

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

Commands/Private Gist.tmCommand

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>beforeRunningCommand</key>
6+
<string>nop</string>
7+
<key>command</key>
8+
<string>#!/usr/bin/env ruby
9+
10+
require 'net/http'
11+
require 'uri'
12+
13+
file = ENV['TM_FILEPATH'].match(/^\/.*\/(\w+(?:\.\w+)*)$/)[1]
14+
login = `/usr/bin/env git config --global --get github.user`.chomp
15+
token = `/usr/bin/env git config --global --get github.token`.chomp
16+
17+
response = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'), { "files[#{file}]" =&gt; ENV['TM_SELECTED_TEXT'], "private" =&gt; true, "login" =&gt; login, "token" =&gt; token })
18+
19+
if response.body =~ /&lt;repo&gt;(\w+)&lt;\/repo&gt;/xi
20+
`osascript -e 'tell application "System Events"
21+
set xfr_clip to "https://gist.github.com/#{$1}"
22+
set the clipboard to ((xfr_clip) as text)
23+
end tell'`
24+
puts "Private Gist URL copied to clipboard" #http://gist.github.com/#{$1}
25+
else
26+
puts "Error"
27+
end</string>
28+
<key>input</key>
29+
<string>none</string>
30+
<key>keyEquivalent</key>
31+
<string>~@I</string>
32+
<key>name</key>
33+
<string>Create Private Gist</string>
34+
<key>output</key>
35+
<string>showAsTooltip</string>
36+
<key>uuid</key>
37+
<string>E637E422-3406-49BB-A772-6E42D1AA1951</string>
38+
</dict>
39+
</plist>

Commands/Public Gist.tmCommand

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>beforeRunningCommand</key>
6+
<string>nop</string>
7+
<key>command</key>
8+
<string>#!/usr/bin/env ruby
9+
10+
require 'net/http'
11+
require 'uri'
12+
13+
file = ENV['TM_FILEPATH'].match(/^\/.*\/(\w+(?:\.\w+)*)$/)[1]
14+
login = `/usr/bin/env git config --global --get github.user`.chomp
15+
token = `/usr/bin/env git config --global --get github.token`.chomp
16+
17+
response = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'), { "files[#{file}]" =&gt; ENV['TM_SELECTED_TEXT'], "login" =&gt; login, "token" =&gt; token })
18+
19+
if response.body =~ /&lt;repo&gt;(\w+)&lt;\/repo&gt;/xi
20+
`osascript -e 'tell application "System Events"
21+
set xfr_clip to "http://gist.github.com/#{$1}"
22+
set the clipboard to ((xfr_clip) as text)
23+
end tell'`
24+
puts "Public Gist URL copied to clipboard"
25+
else
26+
puts "Error"
27+
end</string>
28+
<key>input</key>
29+
<string>selection</string>
30+
<key>keyEquivalent</key>
31+
<string>~@U</string>
32+
<key>name</key>
33+
<string>Create Public Gist</string>
34+
<key>output</key>
35+
<string>showAsTooltip</string>
36+
<key>uuid</key>
37+
<string>2759C467-E0AD-488D-A37C-D8E978DEE9AB</string>
38+
</dict>
39+
</plist>

README

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
h1. TextMate Bundle to create Public/Private Gists
2+
3+
With this bundle you can simply create public and private gists. You need to have Ruby, and configured your GitHub username and token in your global config. The URL will be copied to the clipboard.
4+
5+
h2. Install
6+
<pre>
7+
mkdir -p ~/Library/Application\ Support/TextMate/Bundles/
8+
cd ~/Library/Application\ Support/TextMate/Bundles
9+
git clone git://github.com/ivanvc/gists-tmbundle.git Gists.tmbundle
10+
osascript -e 'tell app "TextMate" to reload bundles'
11+
</pre>
12+
13+
h2. That's it
14+
* Use ⌘⌥⇧I to create a private gist
15+
* Use ⌘⌥⇧P to create a public gist

info.plist

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>name</key>
6+
<string>Gist</string>
7+
<key>ordering</key>
8+
<array>
9+
<string>E637E422-3406-49BB-A772-6E42D1AA1951</string>
10+
<string>2759C467-E0AD-488D-A37C-D8E978DEE9AB</string>
11+
</array>
12+
<key>uuid</key>
13+
<string>8669948D-C9F0-4321-B1CD-BE118E88E37F</string>
14+
</dict>
15+
</plist>

0 commit comments

Comments
 (0)