Amazing Open in Chrome LaunchBar Script
This morning I read a tweet that is going to make my life a little bit easier - and my appreciation of LaunchBar that much greater:
it's all about this Gist:
-- | |
-- open currently open URL in Safari in Chrome | |
-- forked from https://gist.github.com/3151932 | |
-- | |
property theURL : "" | |
tell application "Safari" | |
set theURL to URL of current tab of window 1 | |
end tell | |
if appIsRunning("Google Chrome") then | |
tell application "Google Chrome" | |
if (count of (every window where visible is true)) is greater than 0 then | |
-- running with a visible window, ready for new tab | |
else | |
-- running but no visible window, so create one | |
make new window | |
end if | |
end tell | |
else | |
tell application "Google Chrome" | |
-- chrome app not running, so start it | |
do shell script "open -a \"Google Chrome\"" | |
end tell | |
end if | |
-- now that we have made sure chrome is running and has a visible | |
-- window create a new tab in that window | |
-- and activate it to bring to the front | |
tell application "Google Chrome" | |
tell front window | |
make new tab with properties {URL:theURL} | |
end tell | |
activate | |
end tell | |
on appIsRunning(appName) | |
tell application "System Events" to (name of processes) contains appName | |
end appIsRunning |
If you have the Gist Vim plugin, it's easy - load it up and save it as ~/Library/Application Support/LaunchBar/Actions/Open in Chrome.scpt and then open LaunchBar and use the OIL short-hand and hit enter, and it's done -- the front page in Safari is opened up in Chrome!
This is just amazing to me! I've been using LaunchBar for years but I've only really been scratching the surface. This kind of automation is so simple, but so incredibly powerful. Gotta love great software!
[7/24] UPDATE: the gist has been updated with a few fixes for some cases when Chrome wasn't open, etc. It worked for me because I already had it open, and, like the developer, didn't need the extra work. But now it'll work even better, and that's great too.