forked from twam/.dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·55 lines (44 loc) · 1.75 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
#!/bin/sh
#
# Modeled after https://github.com/holman/dotfiles/blob/master/Rakefile
GIT_VERSION_A=`git --version | sed -e 's/git version \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\1/'`
GIT_VERSION_B=`git --version | sed -e 's/git version \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\2/'`
GIT_VERSION_C=`git --version | sed -e 's/git version \([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\).*/\3/'`
if [ "$GIT_VERSION_A" -le "1" -a $GIT_VERSION_B -le "7" -a "$GIT_VERSION_C" -lt "10" ]; then
echo "Warning: You need at least git version 1.7.10 to support include.path!"
fi
symlinks=$(find . -name "*.symlink")
overwrite_all=false
backup_all=false
for file in $symlinks; do
overwrite=false
backup=false
basename=$(basename $file .symlink)
target="$HOME/$basename"
if [ -e "$target" ] || [ -h "$target" ]; then
if ! $overwrite_all && ! $backup_all; then
while true; do
echo "$target already exists"
echo "[s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all "
read answer
case $answer in
"s" ) continue 2;; # continue the outer for loop
"S" ) break 2;; # break out of the outer for loop
"o" ) overwrite=true; break;;
"O" ) overwrite_all=true; break;;
"b" ) backup=true; break;;
"B" ) backup_all=true; break;;
* ) continue ;;
esac
done
fi
if $overwrite || $overwrite_all; then
rm $target
fi
if $backup || $backup_all; then
mv $target "$HOME/$basename.backup"
fi
fi
echo "Installing $target"
ln -s "$PWD/$file" "$target"
done