Skip to content

Instantly share code, notes, and snippets.

@kch
Created February 2, 2012 23:30
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 kch/1726439 to your computer and use it in GitHub Desktop.
Save kch/1726439 to your computer and use it in GitHub Desktop.
Copy the URLs for the selected messages in Mail to the clipboard.
#!/usr/bin/env ruby
# encoding: UTF-8
require 'appscript'
require 'cgi'
###################################################################
# Copy the URLs for the selected messages in Mail to the clipboard.
###################################################################
mail = Appscript::app("Mail")
urls = mail.selection.get.map { |msg| "message://" + CGI.escape("<#{msg.message_id.get}>") }
open('|pbcopy', 'w') { |io| io.write urls.join("\n") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment