Skip to content

Instantly share code, notes, and snippets.

@base10
Created September 9, 2012 00:13
Show Gist options
  • Save base10/3681456 to your computer and use it in GitHub Desktop.
Save base10/3681456 to your computer and use it in GitHub Desktop.
Simple script to list the urls of all open Safari tabs in a datestamped YAML file
#!/usr/bin/env ruby
require 'appscript'
require 'yaml'
include Appscript
safari = app 'Safari'
url_list = safari.windows.tabs.URL.get
url_list.flatten!
dt = DateTime.now
date_format = dt.strftime("%F_%H%M")
list_path = "#{ENV['HOME']}/saved_urls_#{date_format}.yml"
File.open(list_path, "w") do |f|
f.puts(url_list.to_yaml)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment