Synchronize Bash Alias's Across Multiple Macs

I admit I’m kind of a nerdy designer. I’m picky about text editors and love the command line. I like tools that save me time, and so at some point I started collecting and writing bash alias’s to help me do things like use compass, start a local server, and interact with Drupal via drush. I recently started using different macs at home and work, and so I needed a nice way to keep these little tools aligned between both places.

Bash Background

Your Mac uses a little file called .bashrc in your home directory in order to load up your preferences when you use the terminal.* It’s invisible in the Finder because the filename begins with a period, but you can find it if you open a terminal and type the following:

$ ls -la

If you don’t have one already you can just create it and start adding your own alias’s to it. This tutorial from Lifehacker is a pretty good place to start.

Syncing it up

I rely on Dropbox for all sorts of other syncing, and so it struck me that I should try to keep my .bashrc file there. It turns out to be really simple.

Mac 1

  1. $ cp .bashrc .bashrc-bak
  2. $ mv .bashrc Dropbox/sync/.bashrc
  3. $ ln -s Dropbox/sync/.bashrc .bashrc
  4. $ source .bashrc

Mac 2

  1. $ mv .bashrc .bashrc-bak
  2. $ ln -s Dropbox/sync/.bashrc .bashrc
  3. $ source .bashrc

This will create a safety copy of your existing .bashrc file on both machines. Then copy the first one to Dropbox. (I already have a folder called “sync” set up in mine.) Then create a symbolic link to the new location. And then reload terminal using the new file.

* Actually this is a much deeper topic, but this is a simple way to use it, and the way that I do.

Add your comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.