AppleScript to get Google search URL

In Safari 6, with the new combined URL and search field, if you type search terms into the field, then press return, you’ll get a Google page with the results, but you won’t get a search URL in the address field. Some people want to save searches at times. Macworld’s Dan Frakes tweeted an AppleScript which does just that and Many Tricks developer Peter Maurer improved on it. Run the script and it will get the URL for the frontmost tab then send it to the clipboard, from which you can paste it where you want.

tell application "Safari"
	set the clipboard to URL of current tab of window 1 as string
end tell

Add to digg
Add to Reddit
Add to Slashdot
Email this Article
Add to StumbleUpon