Latest in Commandline

Image credit:

Five Dropbox tips for Mac Unix nerds

TJ Luoma, @tjluoma

Dropbox is already a very powerful utility for Mac OS X, but if you're knowledgable in Unix, you can make it even better. Here are five ways that you can use Unix to get more out of Dropbox.

1. I wanted to update my copy of the HTML processing tool Tidy today. I was happy to find instructions for building Tidy under Snow Leopard, but it also reminded me of another way that I've been using Dropbox for some time now.

If you compile and install Unix utilities on your own instead of using MacPorts, Fink or Rudix, you will most often be asked where you want to install these utilities to. Normally the answer is /usr/local/, and you would use ./configure –prefix=/usr/local. I became frustrated with installing programs to /usr/local/ because I use two or three different Macs, and I would inevitably find that I was trying to use a program on a computer where it wasn't installed. I'd have to find it, download it, configure it, compile it and install it before I could actually do whatever it was that I wanted to do.

That's when it occurred to me that instead of installing to /usr/local/, I could install to my $HOME/Dropbox/ and have the program "instantly" available on all of my computers. This has been as simple as using ./configure –prefix="$HOME/Dropbox/" and then doing make and make install as usual.

Now it's important to note that all of my Macs are running the same version of OS X (10.6). It is theoretically possible that you could compile software on Mac #1 that would then fail on Mac #2 because Mac #2 doesn't have the necessary library, etc. To me, this is actually an argument in favor of using Dropbox, so all those library files are available anywhere Dropbox is linked. In practice, I have been doing this for two years and have not had any problems with it. (Older versions of Dropbox would not sync the "execute" bit, but that hasn't been true for quite some time now.)

This is especially handy if you have one computer that has a faster processor, more RAM or a better internet connection than the others, because you can use that machine to actually build the program, then simply sync it to the others. For example, my iMac is on a "fastest possible" DSL connection, and it has a faster CPU and more RAM than my MacBook Pro (which is on a slower internet connection here at home). When I need to compile a program, I pause Dropbox on my MacBook Pro, ssh to the iMac, download the source (I download the source to /tmp/ unless there's a really good reason to keep it. Generally, by the time I want to build it again, there will be a new version of the source anyway), and then I compile it using:./configure –prefix="$HOME/Dropbox/" && make && make install.

After testing that everything works fine on the iMac, I resume Dropbox on the MacBook Pro, and all the files I need (and onlythe files I need) are downloaded.

This has required a few minor configuration changes. You either need to point a few environmental variables to $HOME/Dropbox/lib instead of $HOME/lib or just make soft links (ln -s), which is what I did.

2. Speaking of soft links, I also linked my .zshrc to Dropbox too, so all of my customizations, aliases, functions, etc. are available everywhere. (See also my article on mstmp, which mentions putting its configuration file in Dropbox.)

3. I put my iMac's crontab file on Dropbox and wrote a launchd agent that reloads it any time the file has changed (Download the plist here). Some people think crontab is the devil, but I still find it useful. If you're not a fan of crontab, though, you can use launchd instead.

4. I have a launchd agent that runs a script that saves my IP address to a file in my Dropbox (which, in turn, gets uploaded to Simplenote via Notational Velocity ALT, which lets me know where to ssh into if DynDNS and/or "Back to My Mac" fails to connect me). The script checks to see if the information has changed, so it's only uploaded when necessary.

5. Want to be able to use "vi" on your Simplenote files? Move your Notational Velocity folder to Dropbox. Note that if you use Notational Velocity on more than one computer, you need to be sure that only one of them points to Dropbox, or else you'll get a lot of file duplication. If you sync preferences via MobileMe, Notational Velocity's directory will be synced, so be careful. You could probably find some sort of cron script to sync Simplenote, but to me, there's no real reason not to use Notational Velocity for flawless Simplenote syncing.

Surely there are some command-line geeks out there who can come up with some more Dropbox tips. Leave us a note in the comments.

From around the web

ear iconeye icontext file