Created
September 28, 2008 19:22
-
-
Save bomberstudios/13490 to your computer and use it in GitHub Desktop.
"Twit This" service for Mac OS X
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
#!/usr/bin/env ruby | |
# Get ThisService from http://wafflesoftware.net/thisservice/ | |
# Use this .rb file with Type: "Acts on Input" and click "Create Service" | |
# From now on, you can twit the selected text in *any* Cocoa application by | |
# selecting Application menu » Services » Twit This | |
# | |
# The first time you use it you'll be prompted for authorisation to use your | |
# saved user and password from Keychain.app | |
input = STDIN.gets nil | |
data = `security find-internet-password -s twitter.com -g 2>&1` | |
if data =~ /^password: "(.*)"$/ | |
password = $1 | |
end | |
if data =~ /"acct"<blob>="(\w+)"/ | |
user = $1 | |
end | |
%x(curl -d 'status=#{input}' -u #{user}:#{password} http://twitter.com/statuses/update.atom) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment