Skip to content

Instantly share code, notes, and snippets.

@dljsjr
Created September 2, 2012 00:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dljsjr/3591788 to your computer and use it in GitHub Desktop.
Save dljsjr/3591788 to your computer and use it in GitHub Desktop.
A quick AppleScript for use with TextExpander to pull the title and URL of the frontmost Safari tab out
-- I use this snippet with Octopress to make new linklog posts.
-- I've tweaked the new_post rake task to allow me to fill in
-- the external-url: property by taking in a second argument:
-- rake new_post["Blog Title","http://some.url.com/"]
-- If the 2nd argument is the empty string, then I omit
-- that property in the yaml front matter.
-- I should note that I haven't updated my Octopress engine in a long time,
-- and when I set up the blog, link posts weren't built in. So
-- there may be a proper rake task for this now, since I think
-- the software now supports link posts natively. Tweak to your liking.
-- Doug Stephen
-- http://canadian-fury.com
tell application "Safari"
set pageTitle to name of document 1
set currentURL to URL of current tab of window 1
end tell
-- Here's how I return the information I pulled out
-- so that the script is useful as a TextExpander Snippet
return "rake new_post[\"" & pageTitle & "\",\"" & currentURL & "\"]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment