Last active
December 11, 2015 03:59
-
-
Save tamalw/4542230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework "ScriptingBridge" | |
unless `ps aux | grep Safari.ap[p]` == "" | |
safari ||= SBApplication.applicationWithBundleIdentifier("com.apple.Safari") | |
if ARGV.empty? | |
safari.windows.each do |window| | |
puts "Window #{window.index}:" | |
window.tabs.each do |tab| | |
puts "\t#{tab.name}" | |
end | |
end | |
else | |
safari.windows.each do |window| | |
window.tabs.each do |tab| | |
if tab.name.downcase.include? ARGV.first.downcase | |
safari.activate unless safari.frontmost | |
window.index = 1 | |
window.currentTab = tab | |
end | |
end | |
end | |
end | |
else | |
puts "Safari is not running." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment