I would like to know how to share url and webpage title by doing the following step.

  1. Select URL in Safari
  2. Right click and choose Share via Email
  3. Automator will open the email program, put the title of a web page as a subject, and put the URL in the message body.
link|improve this question
feedback

1 Answer

require 'cgi'

url = STDIN.read.strip
curl = `curl -s -L #{url}`
title = CGI.unescapeHTML(curl.scan(/<title>(.*?)<\/title>/m)[0][0].strip)
mail = "mailto:?subject=#{CGI.escapeHTML(title)}&body=#{CGI.escapeHTML(url)}"
system("open", mail)
  1. Open Automator and choose the Service template
  2. Add a Run Shell Script action, and select /usr/bin/ruby in the Shell dropdown
  3. Paste the script and save
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.