A general solution is to combine your AppleScript (Script Editor)(/System/Applications/Utilities/Script Editor.app
) with an app launcher like Alfred.
Script
tell application "Safari" to tell document 1
set the clipboard to "[#]: " & URL & " \"" & name & "\""
end tell
In this case, the result string is formatted as the second part of a Markdown reference-style link. E.g.:
[link text][1]
[1]: url "title"
Hotkey Trigger
- In your app launcher, create a hotkey workflow
- In Alfred, click
Settings > Workflows
, then click+ > Blank workflow
- Add a
Workflow Name
; other values are optional - Click
+ > Triggers > Hotekey
- In the
Hotkey Settings
tab, assign aHotkey
value. E.g.⌥C
- Leave
Action
asPass through to workflow
or your launcher's equivalent - Leave
Argument
set toNone
. - Go to the
Related Apps
tab - Verify
have focus
is the value assigned toHotkey is...active when..apps
- Click
Save
- In the
- Click
+ Actions > Run Script
- Set
Language
to/usr/bin/osascript (AS)
; leave other options set to their default values - Paste your version of the above script into the
Script
box - Click
Save
- Drag the
Hotkey
box's node and connect it to theRun Script
box
That's it! Now clicking ⌥C
in Safari lets you paste URL and title values in any app in any format with the standard Paste
keyboard shortcut — ⌘P
.
As above, you should be able to run your script as a service. You can assign a shortcut key to run the service by going to System Preferences > Keyboard > Services
.
PS: You can also download my Alfred Workflow and scripts (plain text and .scpt) from GitHub.