-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·72 lines (60 loc) · 1.46 KB
/
install.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
#!/usr/bin/env bash
# setup from sontek's great dotfiles
function backup_rename {
if [ -e "$HOME/${1}" ];
then
backup_rename "$1.bak";
else
echo "Backing up ${target##*/} to ${1}"
cp -P $target "$HOME/${1}"
rm $target
fi
}
echo "Installing symlinks"
function link_file {
source="${PWD}/$1"
base="${1##*/}"
target="${HOME}/.${base/\.symlink/}"
if [ -e "${target}" ]; then
current_pointer="$(readlink -f ${target})"
if [ ${current_pointer} = ${source} ]; then
echo "Already symlinked: ${target}"
return 0
else
backup_rename "${target##*/}.bak"
fi
fi
ln -sf ${source} ${target}
}
function setup_vim_swaps {
mkdir -p $HOME/.vim-cache/backups
mkdir -p $HOME/.vim-cache/swaps
mkdir -p $HOME/.vim-cache/undo
}
# find symlinks in subdirectories
for i in *
do
if [ -d "${PWD}/${i}" ]; then
for j in $i/*.symlink
do
if [ -e "${PWD}/${j}" ]; then
link_file $j
fi
done
fi
done
# find symlinks in current directory
for i in *.symlink
do
if [ -e "${PWD}/${i}" ]; then
link_file $i
fi
done
setup_vim_swaps
echo "Updating submodules"
git submodule sync
git submodule init
git submodule update
git submodule foreach git pull origin master
git submodule foreach git submodule init
git submodule foreach git submodule update