Insta cloning

Nikita
3 min readJul 29, 2017

--

This is old article, check my wiki to get latest info on KM macros I use, including this one.

There is a really cool thing you can do that I started to use and abuse lately.

I use Keyboard Maestro and Alfred to make it happen.

The idea is simple. I found a cool GitHub repo and I want to check out the code of it in the comfort of my own text editor. I can make that happen in just two clicks.

I have a folder named ~/src/clones in my home directory where I clone different repos I like to hack on. I created a macro in Keyboard Maestro that looks like this:

You can find this macro here or quickly make it yourself.

It is very simple. This line:

tell application "Safari" to return URL of front document

takes the current URL of my browser (Safari) and puts the URL into my system clipboard. If you use chrome or some other browser, you can check this to change the line to suit your browser.

Then it simply cd’s into my ~/src/clones folder and git clones the URL into that folder.

Awesome. Now what can make it even more amazing is if I could instantly open that newly cloned repo in my favorite editor.

I made another macro to do just that. Here is how it looks:

I also have a similar macro that opens the cloned repo in Sublime Text instead of VS Code as I find Sublime to be much faster to use for many cases.

Aside from these few KM macros, I also use this awesome workflow by Vítor Galvão that lets you watch a folder and present the files of the folder in Alfred. Here is the original workflow that watches over /Downloads . I modified it to watch other folders too like the folder where I clone things to inside ~/src/clones. Here is my modified workflow.

And here is in action. It scans my ~/src/clones dir and if I press return on any of the folders it will open it in VS Code. If I press ⌘+↩ it will open it in Sublime and if I press ⌥+↩ it will open it in iTerm.

So all together, I find a cool repo, press a button to run my KM macro, it clones the repo to my preferred folder and I can start hacking away on it immediately.

--

--