Sync and back-up Sublime Text settings and plug-ins using Dropbox on Linux and OSX

Dropbox is a wonderful service to sync and back-up files across multiple computers. Sublime Text 2 is what developer’s text editor should look like circa 2012.

Power users often use many computers (work, home, university, etc.). They have very optimized workflow to their specific needs. The thing with Sublime Text is that you can customize to be more than just a text editor: the editor becomes natural extensions of your fingers.

Since the customization work (settings, installing plug-ins) takes some effort you don’t want to

  • Redo customizations on every computer
  • Lose your customizations

Below is a shell script which will make Sublime Text to sync its configuration files and installed plug-ins across different computer.

  • Back-up your Sublime settings first – just in case
  • Run the script on the first computer to copy Sublime stuff to Dropbox
  • Run the script on other computers and it will pull in the settings from Dropbox and set-up the automatic sync

Tested on OSX and Ubuntu Linux. Please note that Sublime Text settings folder locations on Linux may depend on the Linux distribution and the installation method. For Windows users see this manual method.

The code lives in Github if you wish to contribute patches.

# Set-up Sublime settings + packages sync over Dropbox
# Will sync settings + Installed plug-ins
# Tested on OSX - should support Linux too as long as
# you set-up correct SOURCE folder
# Copyright 2012 Mikko Ohtamaa
# Licensed under WTFPL

# Note: If there is an existing installation in Dropbox,
# it will replace settings on a local computer

# No Warranty! Use on your own risk. Take backup of Library/Application Support/Sublime Text 2 folder first.


# Where do we put Sublime settings in our Dropbox

# Where Sublime settings have been installed
if [ `uname` = "Darwin" ];then
        SOURCE="$HOME/Library/Application Support/Sublime Text 2"
elif [ `uname` = "Linux" ];then
        echo "Unknown operating system"
        exit 1

# Check that settings really exist on this computer
if [ ! -e "$SOURCE/Packages/" ]; then
        echo "Could not find $SOURCE/Settings/"
        exit 1

# Detect that we don't try to install twice and screw up
if [ -L "$SOURCE/Packages" ] ; then
        echo "Dropbox settings already symlinked"
        exit 1

# XXX: Disabled Settings/ folder syncing as looks like
# Sublime keeps only license and .sublime_session files -
# the latter
# which are autosaved and would cause unnecessary conflicts
# and traffic

# Dropbox has not been set-up on any computer before?
if [ ! -e "$SYNC_FOLDER" ] ; then
        echo "Setting up Dropbox sync folder"
        mkdir "$SYNC_FOLDER"
        cp -r "$SOURCE/Installed Packages/" "$SYNC_FOLDER"
        cp -r "$SOURCE/Packages/" "$SYNC_FOLDER"
#        cp -r "$SOURCE/Settings/" "$SYNC_FOLDER"

# Now when settings are in Dropbox delete existing files
rm -rf "$SOURCE/Installed Packages"
rm -rf "$SOURCE/Packages"
#rm -rf "$SOURCE/Settings"

# Symlink settings folders from Drobox
ln -s "$SYNC_FOLDER/Installed Packages" "$SOURCE"
ln -s "$SYNC_FOLDER/Packages" "$SOURCE"
#ln -s "$SYNC_FOLDER/Settings" "$SOURCE"



\"\" Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+

14 thoughts on “Sync and back-up Sublime Text settings and plug-ins using Dropbox on Linux and OSX

  1. When I run this, I get a bunch of error dialogs like this:

    Error loading syntax file “Packages/JavaScript/JSON.tmLanguage”: Error parsing plist xml: Failed to open file In file “Packages/JavaScript/JSON.tmLanguage”

    And the window shows up with a hideous gradient and no syntax highlighting.

  2. Update: I got this working. The symlinks were showing up as files, not folders, and there was some weird nesting of the folders in Dropbox. I redid the symlinks by hand, and I had to run `ln -s …` as root to get the folders to link up properly.

  3. I had the same problem as Zev! The issue is caused by a bug in the script…

    Where it says:

    cp -r “$SOURCE/Installed Packages/” “$SYNC_FOLDER”
    cp -r “$SOURCE/Packages/” “$SYNC_FOLDER”

    It should actually NOT have the TRAILING SLASH after the source directories. The trailing slash causes it to copy the directory CONTENTS, not the directories themselves (apologies for the emphasis).

    This is the correct 2 lines 56-57:

    cp -r “$SOURCE/Installed Packages” “$SYNC_FOLDER”
    cp -r “$SOURCE/Packages” “$SYNC_FOLDER”

    With that change everything works seamlessly. Extremely nice script, thanks for doing this!

  4. Yep, you’re completely right, the solution in github works just as well. If the directories are there already then the trailing slash doesn’t matter.

    Maybe the author would be so kind as to update the code on this page one way or the other?

  5. Pingback: Sublime Text 2 tips for Python and web developers

  6. Pingback: Exporting and sharing Sublime Text configuration

Leave a Reply

Your email address will not be published. Required fields are marked *