Summary: I geek out by putting all my shell scripts in ~/Dropbox/bin/ and a few other tweaks and tricks.
Like most computer-savvy folks I know, I ♥ .
If you don’t know what Dropbox is, here’s a simple summary:
- It’s a folder on your local computer which is also sync’d with Amazon.com’s super cool S3 service
- You can sync that folder with all your computers, so all your files are on all your computers
- It’s free (up to 2GB, which is plenty for documents)
- It works for Mac, Windows, and Linux
- You can access your files via a web browser (ever been away from home without your computer and wished you could get a file off your computer? Now you can, if the file is on your Dropbox.
The same files, everywhere.
If you have more than one computer, you realize how this can be valuable.
Also, it works in the background, flawlessly (for me, thus far) and you never know that anything is happening.
“Ok, I knew all that, what’s new?”
Like most geeks I know, I’ve got a small collection of shell scripts that I’ve written over the years.
I would like those scripts to be accessible on all my computers as well.
I also have a bunch of shell customizations in my .zshenv file which I would also like sync’d on all my computers.
As I was getting ready to write some complicated syncing script to do that, it occurred to me: “Why don’t I just use Dropbox?”
Scripts are small and self-contained, and I can put them in any folder as long as I add that folder to my $PATH.
So I changed this:
PATH=$HOME/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:
to this
PATH=$HOME/Dropbox/bin:/usr/local/bin:/usr/local/sbin:/opt/loc
then I simply moved my ~/bin/ folder to ~/Dropbox/
Then I renamed ~/.zshenv to ~/Dropbox/zshenv.txt (so it would be visible and have a known file extension to open in a text editor) and finally I did this
cd ~ && ln -s Dropbox/zshenv.txt .zshenv
so now I have the same setup everywhere.
Wow! That was easy.
Not So Fast
I should have known this because about 4 months ago.
I am developing a shell script. Since I want to use the same version on all my Macs, I have saved it in ~/Dropbox/ and issued chmod 755. However, the ‘execute’ bit keeps getting dropped off when it syncs.
to which I was told:
Dropbox doesn’t actually track most extended attributes for any operating system, the file comes down as a standard read/writeable file. The problem here is that the “file system” on the cloud isn’t ntfs, or ext3, or zfs, or hfs +, so there is no analogous part to the execute bit. or file permissions or any of that extra stuff, but all your bits are there. But OS X supports ACLs that you can set on a directory so that all files created there inherit the same permissions, so drop your script into a folder, and set an ACL for it.
Now I’ve heard of , but since I’m the only user on my computer, I’ve never actually used them before.
Like most geeks I know, I only really learn about something when I have some practical reason to know it. When people ask me how I know so much about computers, I always tell them “practice” and it’s true.
I don’t sit around reading about something, and if there’s something I just have a casual interest in learning (*cough*perl, emacs, vi*cough*) I probably won’t learn about it even if I do read about it.
Now I had a reason, so I set off to learn something about ACLs.
And here is what I learned about ACLs: they’re fairly complicated for what I’m trying to do.
Here’s another thing about me and (I believe) most geeks: we’re lazy. By which I mean, we’ll accept any acceptable solution, and tend to prefer the first one that “just works”.
(Look at the GUI for most large free software packages, and you’ll understand what I mean. Most geeks don’t care so much about making things pretty as making things work. When things work, they go on to making something else work.)
So, since I didn’t wake up today and say “Hey, I want to learn about ACLs today!” and I don’t know that I’ll have much use to know about them in the future, I went for the easiest solution I could think of, which is this:
chmod -R 755 ~/Dropbox/bin/
which says “Make everything inside the ~/Dropbox/bin/ folder executable.”
And I put that line in my ~/.zshenv, so that whenever I open a new shell, the command gets run. Sure if I had thousands and thousands of files in there, it might be slow, but there 205, and it takes almost no ‘time’ at all:
$ time chmod -R 755 ~/Dropbox/bin
chmod -R 755 ~/Dropbox/bin 0.00s user 0.00s system 16% cpu 0.019 total
Or, to put it another way:
$ date;chmod -R 755 ~/Dropbox/bin;date
Wed Dec 3 23:20:24 EST 2008
Wed Dec 3 23:20:25 EST 2008
It takes less than a second.
Note: because I am a hardcore, comment-happy geek, this is actually what I put in my .zshenv:
# if the folder is found
# make everything inside it executable
# since Dropbox doesn't save execute bit
if [[ -d $HOME/Dropbox/bin ]]
then
chmod -R 755 $HOME/Dropbox/bin
fi
which means that the command only gets run if the folder is located.
All in all, a pretty dang slick.
Just One More Thing
Did I mention that Dropbox saves revisions?
Yeah, so now if I make a change to a script and decide I want to undo that, I can go back and get a previous version.
Oh, and about those ACLs
15 Geek Cred points to anyone who can tell me the proper ‘chmod’ command to set ~/Dropbox/bin/ so that all the files inside of it are automatically set to be executable.
25 Geek Cred points to anyone who can point me to an online “ACLs in Plain English” explanation (and no, ‘man acl’ doesn’t count :-)
If you want to deal with ACLs in Mac OS X and would like a GUI tool, checkout (not to be confused with by the same company) which . It sells for € 7.00 (as of 2008-12-03).
If you take nothing else away from this, remember one thing:
(No, no, I don’t mean it’s like a box of rocks, I mean it rocks. Nevermind.)