Created
February 18, 2014 18:52
-
-
Save takuya/9077302 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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