Sublime Settings + Packages Sync with Dropbox


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/bin/sh
  2. #
  3. # Set-up Sublime settings + packages sync over Dropbox
  4. #
  5. # Will sync settings + Installed plug-ins
  6. #
  7. # Tested on OSX - should support Linux too as long as
  8. # you set-up correct SOURCE folder
  9. #
  10. # Copyright 2012 Mikko Ohtamaa http://opensourcehacker.com
  11. # Licensed under WTFPL
  12. #
  13.  
  14. # Note: If there is an existing installation in Dropbox,
  15. # it will replace settings on a local computer
  16.  
  17. # No Warranty! Use on your own risk. Take backup of Library/Application Support/Sublime Text 2 folder first.
  18.  
  19. DROPBOX="$HOME/Dropbox"
  20.  
  21. # Where do we put Sublime settings in our Dropbox
  22. SYNC_FOLDER="$DROPBOX/Sublime"
  23.  
  24. # Where Sublime settings have been installed
  25. if [ `uname` = "Darwin" ];then
  26. SOURCE="$HOME/Library/Application Support/Sublime Text 2"
  27. elif [ `uname` = "Linux" ];then
  28. SOURCE="$HOME/.config/sublime-text-2"
  29. else
  30. echo "Unknown operating system"
  31. exit 1
  32. fi
  33.  
  34. # Check that settings really exist on this computer
  35. if [ ! -e "$SOURCE/Packages/" ]; then
  36. echo "Could not find $SOURCE/Settings/"
  37. exit 1
  38. fi
  39.  
  40. # Detect that we don't try to install twice and screw up
  41. if [ -L "$SOURCE/Packages" ] ; then
  42. echo "Dropbox settings already symlinked"
  43. exit 1
  44. fi
  45.  
  46. # XXX: Disabled Settings/ folder syncing as looks like
  47. # Sublime keeps only license and .sublime_session files -
  48. # the latter
  49. # which are autosaved and would cause unnecessary conflicts
  50. # and traffic
  51.  
  52. # Dropbox has not been set-up on any computer before?
  53. if [ ! -e "$SYNC_FOLDER" ] ; then
  54. echo "Setting up Dropbox sync folder"
  55. mkdir "$SYNC_FOLDER"
  56. cp -r "$SOURCE/Installed Packages/" "$SYNC_FOLDER"
  57. cp -r "$SOURCE/Packages/" "$SYNC_FOLDER"
  58. # cp -r "$SOURCE/Settings/" "$SYNC_FOLDER"
  59. fi
  60.  
  61. # Now when settings are in Dropbox delete existing files
  62. rm -rf "$SOURCE/Installed Packages"
  63. rm -rf "$SOURCE/Packages"
  64. #rm -rf "$SOURCE/Settings"
  65.  
  66. # Symlink settings folders from Drobox
  67. ln -s "$SYNC_FOLDER/Installed Packages" "$SOURCE"
  68. ln -s "$SYNC_FOLDER/Packages" "$SOURCE"
  69. #ln -s "$SYNC_FOLDER/Settings" "$SOURCE"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.