-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_sublime.sh
executable file
·66 lines (56 loc) · 1.86 KB
/
setup_sublime.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
#!/usr/bin/env bash
shopt -s expand_aliases
source $(dirname $0)/functions.sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if ls -d "${HOME}/Library/Application Support/Sublime Text"* >/dev/null 2>&1
then
SUBLIME_SUPPORT=$(ls -d "${HOME}/Library/Application Support/Sublime Text"* | head -1)
msg "Using SUBLIME_SUPPORT dir: ${SUBLIME_SUPPORT}"
else
error "No Sublime Text directory found ${HOME}/Library/Application Support"
fi
packages="${SUBLIME_SUPPORT}/packages"
user_packages="${packages}/User"
user_packages_backup=${user_packages}.$(tstamp)
source_packages="${SUBLIME_SUPPORT}/packages/User"
# quit if sublime isn't installed
if is_installed "Sublime Text"
then
msg "Sublime Text is installed; proceeding"
else
error "Please install Sublime Text before running setup"
fi
# quit if sublime is running
if is_running "Sublime Text"
then
error "Refusing to run setup while Sublime Text is running"
fi
# quit if there's no Packages directory
if [[ -e "${packages}" ]]
then
msg "Package directory found: ${packages}"
else
error "Package directory not found: ${packages}"
fi
# quit if current sublime user package dir is a symlink
[[ -L "${user_packages}" ]] && error "Already symlinked: ${user_packages}"
# mv current sublime user package dir to User.old
if [[ -e "${user_packages}" ]]
then
msg "Backing up User packages: ${user_packages}"
mv "${user_packages}" "${user_packages_backup}" || error "Unable to to back up User packages"
msg "User packages backed up to ${user_packages_backup}"
fi
# link local sublime user packages dir to User
msg "Create symlink: ${user_packages} ->"
msg " ${source_packages}"
(
cd "${packages}"
ln -s "${source_packages}"
)
if ls -l "${user_packages}" >/dev/null
then
msg "Sublime Text settings are now available"
else
error "Something went wrong; Sublime Text settings not installed"
fi