-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·74 lines (59 loc) · 1.42 KB
/
setup
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
#!/bin/sh
CONFIG_DIR=$(pwd)/config
GIT_CONFIG_FILE=".gitconfig"
filelist=()
for file in $(ls -a $CONFIG_DIR)
do
if [ -f "$CONFIG_DIR/$file" ] && [ "$file" != "$GIT_CONFIG_FILE" ]; then
filelist[${#filelist[@]}]=$file
fi
done
show_help() {
echo "Commands:"
echo "\t install - Installs symlinks to config"
echo "\t clean - Removes symlinks to config"
}
install() {
for file in ${filelist[@]}
do
echo "[INSTALL]: Adding $file to $HOME"
ln -s $CONFIG_DIR/$file $HOME 2> /dev/null
done
git config --global include.path "$CONFIG_DIR/$GIT_CONFIG_FILE"
echo "[INSTALL]: Adding Sublime Text 3 user settings"
mkdir -p $HOME/Library/Application\ Support/Sublime\ Text\ 3/Packages
cd $HOME/Library/Application\ Support/Sublime\ Text\ 3/Packages
if [ -d "User" ]; then
mv User User.backup
fi
ln -s $CONFIG_DIR/sublime User
cd -
}
clean() {
for file in ${filelist[@]}
do
echo "[CLEAN]: Removing config $file from $HOME"
rm $HOME/$file 2> /dev/null
done
cd $HOME/Library/Application\ Support/Sublime\ Text\ 3/Packages
if [ -L "User" ]; then
echo "[CLEAN]: Restoring Sublime Text 3 user settings"
rm User
if [ -d "User.backup" ]; then
mv User.backup User
fi
fi
cd -
}
update() {
echo "[UPDATE]: Upgrading to latest settings"
clean &> /dev/null && \
git fetch &> /dev/null && \
git reset origin/master &> /dev/null && \
install &> /dev/null
}
if [ `type -t $1`"" = "function" ]; then
$1
else
show_help
fi