
Written by Mathias Michel who lives and works in Munich building useful things. Follow me on Twitter
Recently I’ve been copying links from interesting pages and then adding them to a Markdown document in my knowledge repo. My workflow is that I always have to format the link accordingly. Here is an example how a link looks like in Markdown:
Link: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
Output: [github.com](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
I found this workflow annoying after some time, so I started looking for a solution and found Automator from Apple. This tool is built into macOS and allows you to run automation workflow. You can then a automation by a keyboard shortcut. In this blog post, I’ll show you how you can also do that.
CMD + Space
and search for Automator
)
Quick Action
.text
Any application
Run Javascript
action and drag it into the right cornerCopy to clipboard
action and drag after the javascript actionfunction run(input, parameters) {
var url = `${input}`;
var domain = url.match(/^(?:https?:)?(?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/)
return `[${domain[1]}](${input})`;
}
The final step is to configure a shortcut which executes the workflow.
Settings
-> Keyboard
-> Shortcuts
^
+ ALt
+ CMD
+ C
Written by Mathias Michel who lives and works in Munich building useful things. Follow me on Twitter