-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·79 lines (68 loc) · 1.21 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
72
73
74
75
76
77
78
79
#!/bin/sh
YES=1
NO=2
yes_to_all=$NO
can_install () {
dest=$1
if [ $yes_to_all = $NO ] && [ -e "$dest" ]
then
echo -n "Dotfile $dest already exists. Overwrite it? [Y/n/a] "
read x
if [ "$x" = "a" ]
then
yes_to_all=$YES
fi
if [ "$x" = "y" ] || [ "$x" = "Y" ] || [ "$x" = "" ] || [ "$x" = "a" ]
then
return $YES
else
return $NO
fi
else
return $YES
fi
}
install () {
source=$1
dest=$2
echo "Install $source to $dest"
if [ "$MSYSTEM" = "MINGW32" ]
then
cp -a "$PWD/$source" "$dest"
else
rm "$dest"
ln -sf "$PWD/$source" "$dest"
fi
}
install_dotfiles_in () {
for file in $( find $1 -mindepth 1 -maxdepth 1 -name '*')
do
destination=$HOME/.${file#*/}
can_install $destination
if [ $? = $YES ]
then
install $file $destination
fi
done
}
fix_vimfiles () {
if [ "$MSYSTEM" = "MINGW32" ]
then
src="$HOME/.vim"
dest="$HOME/vimfiles"
if [ -e "$src" ]
then
can_install $dest
if [ $? = $YES ]
then
rm -rf "$dest"
mv "$src" "$dest"
else
rm -rf "$src"
fi
fi
fi
}
install_dotfiles_in "bash"
install_dotfiles_in "independent"
fix_vimfiles