forked from mamartins/.dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-sync-sublime-over-dropbox.sh
executable file
·79 lines (65 loc) · 2.44 KB
/
setup-sync-sublime-over-dropbox.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
#
# 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 http://opensourcehacker.com
# 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.
DROPBOX="$HOME/Dropbox"
# Where do we put Sublime settings in our Dropbox
SYNC_FOLDER="$DROPBOX/Sublime"
# Where Sublime settings have been installed
if [ `uname` = "Darwin" ];then
SOURCE="$HOME/Library/Application Support/Sublime Text 2"
elif [ `uname` = "Linux" ];then
SOURCE="$HOME/.config/sublime-text-2"
else
echo "Unknown operating system"
exit 1
fi
# Check that settings really exist on this computer
if [ ! -e "$SOURCE/Packages/" ]; then
echo "Could not find $SOURCE/Settings/"
exit 1
fi
# Detect that we don't try to install twice and screw up
if [ -L "$SOURCE/Packages" ] ; then
echo "Dropbox settings already symlinked"
exit 1
fi
# 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"
# Creating the folders in separated categories
mkdir -p "$SYNC_FOLDER/Installed Packages"
mkdir -p "$SYNC_FOLDER/Packages"
# mkdir -p "$SYNC_FOLDER/Settings"
# Copy the files into their respective folder
cp -r "$SOURCE/Installed Packages/" "$SYNC_FOLDER/Installed Packages"
cp -r "$SOURCE/Packages/" "$SYNC_FOLDER/Packages"
# cp -r "$SOURCE/Settings/" "$SYNC_FOLDER/Settings"
fi
# 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
# The "Installed Packages" and "Packages" was never
# created inside of Dropbox folder. These lines are not working.
# Fixed to the correct folder.
ln -s "$SYNC_FOLDER/Installed Packages" "$SOURCE/Installed Packages"
ln -s "$SYNC_FOLDER/Packages" "$SOURCE/Packages"
#ln -s "$SYNC_FOLDER/Settings" "$SOURCE/Settings"