Sync Mac Desktops

Sync Mac Desktops

Modern web worker’s workflow needs to be as efficient as possible. Part of that workflow demands that we work on multiple computers. I, for one, love to work on my iMac. I have space, both at my desk and at on my computer’s Desktop screen. When I have to leave to speak with someone or to go to a class I take my MacBook Pro. It is a very capable machine but that is all I take with me. I don’t have any peripherals like mice, keyboard, or external drives or monitors. Basically, I need an Internet connection to take notes and look up references. If I could sync my Mac Desktops I could save a lot of time. 

What’s the problem

Dropbox and Google Drive are my favorite syncing methods. These services let me share work with others. Google Drive, in particular, lets me collaborate with other people at the same time! When I’m on a team that is great.

I use my desktop as a temporary holding space for the work I’m currently involved in. It could be images that I want to upload to a website or research for a presentation. It doesn’t really matter.

Since I go back and forth between machines I needed to come up with a solution. Since the Desktop on our computers are just directories anyway why couldn’t I just link them together somehow?

Symlink all the stuff

I already use Dropbox and in that service I hold all my other syncs settings. Settings for text editors, email clients, and productivity tools are kept there. So that is what I did with my Desktops; I symlinked them to the same directory.

What is a symlink?

Basically it is a reference to another location in your operating system. When your operating goes looking for the Desktop it’ll be immediately directed to the location that resides in your Dropbox.

What happens if I can’t connect to my Dropbox account?

It won’t matter. Dropbox has placed a folder in your user directory to hold information. Your data actually lives in that location and then is synchronized up to the cloud, wherever that is.

How to do it

I’m assuming that you have a Dropbox account and that it is installed on your computer. I’m also assuming that you’re on a Mac. You also obviously have more than one machine. This process will involve some intermediary synchronizing so purge your Desktop of unnecessary items; i.e. clean it down to the metal. Move all your Desktop items to a temporary location for now.

Let’s get started.

On your first machine, open Terminal. If you don’t know it’s in Applications>Utilities.

From there you’ll need to move into your Dropbox folder. Use this command from Terminal

mv ~/Dropbox

You can identify what directory you’re in if you type: pwd

Now create the link:

ln -s ~/Desktop

Pro tip: For the really deep file paths, save yourself some headache and drag and drop from Finder onto Terminal.

Next, let any file syncing happen. It shouldn’t be much. Mounted volumes won’t sync so don’t worry about that. Ideally, your desktop is clean, anyway.

Next turn off Dropbox on your first machine. Your local symlink will exist and your Dropbox version will also exist. Remember the Dropbox version will exist in the cloud and on your local machine. Now got to your other machine. You’ll have a Dropbox folder in there that you can check to see if there is directory named Desktop. I put all my symlinked directories at the root of my Dropbox folder. From your other computer you’ll see that new Desktop directory.

Now, quit Dropbox on your second machine. Next, move into your second machine’s Dropbox folder and delete the Desktop directory. Don’t worry. If you delete a symlink it does nothing to the original files. Now go into the second machine’s Terminal and repeat the steps from above. You’re going to symlink your Desktop to that machine’s Dropbox. As in:

cd ~/Dropbox


ln -s ~/Desktop

On your second machine turn Dropbox back on. Turn your Dropbox back on on your first machine. You can’t symlink to a file that already exists. It wouldn’t be symbolic, it’d be actual. You destroyed the first symlink and replaced it with an identical one. The first machine is none the wiser. It thinks it is and always has been pointing to the exact location since spelling and locations are exactly the same. Pretty sweet.  


Automate Local Development with BASH

I can’t afford to be inefficient at Efficiency of Movement. I am a one-man show and any wasted movement is wasted money. I started to notice that I was repeating myself more than I should have been. It was high time to automate my process even more.

Developing Locally

When I start a new project, like many other developers, I’m sure, I go out to download a fresh copy of WordPress and set it up manually. It is a fairly straight forward process and the development team at WordPress has done an excellent job at making it easy. They even coined the process the famous 5-Minute Installation. They’ve done their part to make it easy, the rest is up to the professional developer. This is especially true if the developer is making multiple websites a week or month. The amount of time spent on opening up applications, alone, is cringe-worthy. Much less the inconsistencies of file names, user names and profiles, installing plugins, activating, blah, blah, blah. Hours later…

BASH to the Rescue

imgresBASH scripts are not complex. At their foundation, they are a series of steps performed by the machine set in particular order. You write the script and tell the machine what to do and the machine does it. It is automation at it’s purest. I had used BASH before and knew that was powerful but combined with tools that others have created specifically for WordPress this script is now a powerhouse. I estimate that it saves 1.5 hours of development time. I wish I can only image the amount of frustration that it saves by creating with consistent naming convents and consistent file locations.

Save Time

My estimation comes from the fact that the fastest that WordPress can be installed is 5 minutes. I don’t install WordPress, I make WordPress websites and that takes considerably more time to set up. I have to create a database locally, that if done right can be used on a live server. I have to remove cruft that I don’t need like plugins and themes that come preinstalled. I have to add users and their roles to to the site. I have to add pages to the site. This script now takes care of all of that. Basically, those items are nothing more than a series of commands performed in a specific order.

I also have to add things to each site I start. I have to add my starter theme and my plugins. I have to activate some and deactivate others. Again, a script is the perfect tool to make this an automatic process.

Automate my Local Development

mamp-pro-logo-bigI don’t want to place the code in this post because it will likely change as time goes on. But, here is a link to my script, but I’ll walk you through it here, too. First I want consistency in names and locations. I prompt for the web site’s name. The user can use regular English words and spaces. The name of the web site is then used to create the rest of the variables inside of the script, such as database name, user names, and file locations. See, consistant.

I install WordPress and delete all the themes I don’t want. Then I clone into my own fork of Ole Frederick‘s fantastic starter theme, FoundationPress. I have made my own customizations that I want but that the community may not. My BASH brings down the files, runs the grunt tasks, and then opens up a browser window that is ready for my login information.


Fork my script and add your own customizations. Think about what keystrokes you are performing repeatedly. Can those keystrokes be performed by a machine? If so, then you should really get a script to do it for you. That way you can get back to solving the more interesting problems of web development.