John Lindquist: 0:00 Create a blank workflow in Alfred. We'll call this md-link and pick a Bundle ID. I'll just call mine mdlink, hit Create, and right click and pick a Trigger of hotkey.
0:13 We'll choose the hotkey of Command M, which I'll just type on my keyboard and the argument from the drop down should be selection in macOS. This will allow us to pass the currently selected text into the workflow. Hit Save here, then our output will be a copy to clipboard, and we'll show it pasting that same text three times.
0:36 You'll also want to check automatically paste the frontmost app, click save here, and then connect these together by clicking and dragging. Now, when I hit Command M, it should copy and paste three times.
0:48 I'll switch over to a text editor, I'll type something, select it, hit Command M. You'll see the result is type something three times which was the selection in Mac OS. Then Alfred copied it and pasted it three times.
1:05 Now, what we want is access to the current URL inside of Chrome. That's something we can grab using a tool called osascript. I have the code here, which I'm going to copy and paste into a script action.
1:19 I'll create that here, action being a Run Script. If I paste that here, this will grab the current URL inside of Chrome. This essentially invokes osascript and tells it to grab Google Chrome and the current URL of the active tab.
1:37 If I hit Save here and connect these together like this, I'll delete this one to select it and hit Delete, and then connect these. You'll see Command M will trigger grabbing the current URL, which will trigger copying that to the clipboard three times.
1:53 Now, if I delete all this, I'll type something, I'll select it, hit Command M, and you'll see the URL will come out three separate times. To bring the current selection and the URL together, we'll do that inside of our script by opening this. Instead of echoing out the result, we'll set this to a variable called URL with no whitespace.
2:16 Now, we'll echo-out the markdown syntax for a link. Two square brackets will be the text and two parens will make up the link. Inside of the square brackets, we'll put $1 which represents the first argument or the argument coming in as the selected text.
2:32 For the link, we'll put $url, which is this URL right here. I'll hit Save here, now when I go into here and type out something. I'll select it, I'll hit Command M, and you'll see it did something inside of a link and it pasted all of that three times.
2:50 Let's remove those three. It's just a single one. Now, we'll hit Save. Now the workflow will be something like, "I enjoy creating node.js CLI tools." I would select this text, hit Command M and it would generate the markdown link for me with the current Chrome URL.