Created
January 14, 2011 08:06
-
-
Save scragz/779348 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
# java -jar ~/Library/jEdit/jars/ruby.jar -S gem install -i ~/.gem/jruby/1.8 gist | |
require 'rubygems' | |
require 'gist' | |
def gistBufferOrSelection(view) | |
textarea, buffer = view.getTextArea, view.getBuffer | |
if textarea.getSelectionCount > 0 | |
text = textarea.getSelectedText | |
else | |
text = textarea.getText | |
end | |
path = buffer.getPath | |
gist_file = | |
{:extension => File.extname(path), :filename => File.basename(path), :input => text} | |
begin | |
url = Gist.write([gist_file]) | |
puts url | |
`open #{url}` | |
rescue Exception => e | |
puts e.message | |
end | |
end | |
gistBufferOrSelection($view) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment