Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.
share|improve this question
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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