forked from thoughtbot/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·35 lines (33 loc) · 952 Bytes
/
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
#!/bin/sh
cutstring="DO NOT EDIT BELOW THIS LINE"
for name in *; do
target="$HOME/.$name"
if [ -e "$target" ]; then
if [ ! -L "$target" ]; then
cutline=`grep -n -m1 "$cutstring" "$target" | sed "s/:.*//"`
if [ -n "$cutline" ]; then
cutline=$((cutline-1))
echo "Updating $target"
head -n $cutline "$target" > update_tmp
startline=`sed '1!G;h;$!d' "$name" | grep -n -m1 "$cutstring" | sed "s/:.*//"`
if [ -n "$startline" ]; then
tail -n $startline "$name" >> update_tmp
else
cat "$name" >> update_tmp
fi
mv update_tmp "$target"
else
echo "WARNING: $target exists but is not a symlink."
fi
fi
else
if [ "$name" != 'install.sh' ]; then
echo "Creating $target"
if [ -n "$(grep "$cutstring" "$name")" ]; then
cp "$PWD/$name" "$target"
else
ln -s "$PWD/$name" "$target"
fi
fi
fi
done