Skip to content

Instantly share code, notes, and snippets.

@bomberstudios
Created September 28, 2008 19:22
Show Gist options
  • Save bomberstudios/13490 to your computer and use it in GitHub Desktop.
Save bomberstudios/13490 to your computer and use it in GitHub Desktop.
"Twit This" service for Mac OS X
#!/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