Skip to content

Instantly share code, notes, and snippets.

@masnick
Created June 25, 2015 14:45
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 masnick/56389a686c2a3dacbb08 to your computer and use it in GitHub Desktop.
Save masnick/56389a686c2a3dacbb08 to your computer and use it in GitHub Desktop.
LaunchBar 6 Action for posting to iDoneThis
#!/Users/max/.rbenv/versions/2.1.3/bin/ruby
# ^^^ Note that this is custom to my computer.
# Necessary for loading from Gemfile without `bundle exec`
# Use `bundle install --standalone` to get this file
# Won't work if there are spaces in the path to the folder with the Gemfile?
# I had to copy the Gemfile to my desktop and run this there.
require File.join(File.expand_path('..', __FILE__), 'bundle/bundler/setup')
require 'json'
require 'idonethis'
client = IDoneThis::Client.new("api-key-here")
done = client.done(ARGV.join(" "), 'team-short-name-here')
if done.has_key? 'errors'
error_for_applescript = done['errors'].to_json.gsub(/\\/, '\\').gsub('"', '\"')
`osascript -e 'tell application "LaunchBar" to display alert "Could not post to iDoneThis" message "Error: #{error_for_applescript}"'`
else
puts [{"title" => "Posted!", "url" => done['permalink']}].to_json
end
source "https://rubygems.org"
gem 'json'
gem 'idonethis'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment