Skip to content

Instantly share code, notes, and snippets.

@takuya
Created February 18, 2014 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya/9077302 to your computer and use it in GitHub Desktop.
Save takuya/9077302 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'optparse'
require 'open3'
text , image,url,video = nil
opt = OptionParser.new
opt.on("-i [image]", "--image", "Set Image to tweet ") { |e| image = e }
opt.on("-u [url]", "--url", "Set URL to tweet ") { |e| url = e }
opt.on("-v [video]", "--video", "Set video to tweet ") { |e| video = e }
opt.parse!(ARGV)
text = ARGV.shift
cmd = "terminal-share -service twitter -text '#{text}' "
cmd += " -image '#{image}'" if image
cmd += " -video '#{video}'" if video
cmd += " -url '#{url}'" if url
Open3.popen3(cmd){|stdin,stdout,stderr|
stdin.close
stdout_thread = Thread.start{
stdout.each_line{ |line|
puts line
}
}
stdout_thread.join
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment