Skip to content

Instantly share code, notes, and snippets.

@scragz
Created January 14, 2011 08:06
Show Gist options
  • Save scragz/779348 to your computer and use it in GitHub Desktop.
Save scragz/779348 to your computer and use it in GitHub Desktop.
# 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