Skip to content

Instantly share code, notes, and snippets.

@swdyh
Created April 21, 2011 03:28
Show Gist options
  • Save swdyh/933656 to your computer and use it in GitHub Desktop.
Save swdyh/933656 to your computer and use it in GitHub Desktop.
cmd :gyast, '', 'post screencapture' do
now = Time.now.to_i
file_jpg = "/tmp/#{now}.jpg"
system "screencapture -i -t jpg \"#{file_jpg}\""
unless File.exist? file_jpg
exit
end
begin
url = @g.create file_jpg
rescue Gisty::InvalidFileException => e
puts "Error: invalid file"
rescue Exception => e
puts "Error: #{e}"
else
id = url.split('/').last
system "open https://gist.github.com/raw/#{id}/#{now}.jpg" if /darwin/ === RUBY_PLATFORM
end
File.delete file_jpg
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment