manicwave Surf the wave

git clone from Safari

It is often the late night exploration of code in the wild that gives rise to these cute little hacks.

With my wrist tiring of flipping between safari and terminal, the following was born.


git clone the repository ref found in the system pasteboard


When perusing gitHub, I'll find something I want to check out. I click on the "clone" button which copies the git reference to the clipboard. I typically flip over to a terminal session, change directory to my favorite dumping grounds, and do a git clone Cmd-V enter.

Here's a script that will do all of that. The secret sauce is teaming this up with something like FastScripts (an excellent status bar accessory).


cd $DUMPDIR && /usr/local/git/bin/git clone $REPO
if [ "$EXITCODE" -ne "0" ]; then
echo "Download of $REPO failed: $EXITCODE" | /usr/local/bin/growlnotify -p 1 "Clone Failed"
echo "Download of $REPO successful" | /usr/local/bin/growlnotify "Clone Succeeded"

What's happening here?

First we grab the repo reference from the pasteboard using pbpaste. Then we cd to our dumping grounds, execute the git clone. If it fails (because it's already there, no access, etc) we use growlnotify to throw up the appropriate message.

I bind this script in ~/Library/Scripts/Applications/Safari and then use Cmd- Shift-C - so click to copy, Cmd-Shift-C to clone.

Filed under