AppleScripts

Here are some AppleScripts I’ve made and use on a daily basis.

Note: Please actually look at the code before running, none of these are destructive, but I’m not taking any blame. Also, “Safari” can usually be swapped for “Google Chrome.”

Generate a UUID to the clipboard (Download)

set the clipboard to (do shell script "uuidgen")

Grab the current Safari tab to clipboard formatted in Markdown (Download)

tell application "Safari"
	set tabURL to the URL of the current tab of window 1
	set tabName to the name of the current tab of window 1
	set the clipboard to "[" & tabName & "](" & tabURL & ")"
end tell

Dump Tabs (Download)

I’m often catching myself feeling overwhelmed with open windows and multiple tabs. This will grab every tab title and url in every open Safari window and generate a Markdown document in ~/Safari Tab Dumps/ as YYYYMMDDTHHMMSS.markdown. It then closes all the open windows and opens a clean Safari session.

Copy current Spotify track to clipboard (Download)

I don’t use Spotify any more, but at the time, I was surprised to find that it is scriptable. This was used often when playing music in the office. I eventually converted it to a Service and bound it to a keyboard shortcut.

tell application "Spotify"
	set spotifyURL to the spotify url of current track
	set the clipboard to spotifyURL
end tell