-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·154 lines (136 loc) · 2.13 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/sh
umask 022
dry_run=
if [ "$1" = "--dry-run" ]
then
dry_run=echo
shift
fi
if [ -n "$1" ]
then
echo "$0: No args" 1>&2
exit 1
fi
if [ -z "$HOME" ]
then
if [ -z "$USERPROFILE" ]
then
echo "$0: Can't find HOME" 1>&2
exit 1
fi
HOME="$USERPROFILE"
fi
case "$0" in
./install.sh)
;;
*)
cd `dirname $0` 2> /dev/null
;;
esac
uname=`uname 2> /dev/null`
installFile() {
src="$1"
dest="$2"
if [ -f "$dest" ]
then
if diff -q "$dest" "$src" > /dev/null
then
return
fi
if [ -f "$dest.orig" ]
then
echo "Overwrite $dest? (y/N)"
read response
case "$response" in
y|Y)
;;
*)
echo "Skipping $dest..."
continue
;;
esac
else
$dry_run mv "$dest" "$dest.orig"
fi
fi
$dry_run cp "$src" "$dest"
unset src dest
}
installDir() {
if [ ! -d "$2" ]
then
$dry_run mkdir -p "$2"
$dry_run chmod $1 "$2"
fi
}
for i in .[a-z]*
do
if [ -d "$i" -o "$i" = ".gitattributes" ]
then
continue
fi
installFile "$i" "$HOME/$i"
done
for i in .ssh mail
do
installDir 700 "$HOME/$i"
done
for i in bin git src tmp
do
installDir 755 "$HOME/$i"
done
if [ "$uname" = "Darwin" -a -z "$APPDATA" ]
then
APPDATA="$HOME/Library/Application Support"
fi
if [ -d "$APPDATA" ]
then
cd appdata
for i in Code/User
do
installDir 755 "$APPDATA/$i"
for j in $i/*
do
installFile "$j" "$APPDATA/$j"
done
done
cd ..
fi
if [ -d "$LOCALAPPDATA" ]
then
cd localappdata
for i in Packages/Microsoft.*/LocalState
do
installDir 755 "$LOCALAPPDATA/$i"
for j in $i/*
do
installFile "$j" "$LOCALAPPDATA/$j"
done
done
cd ..
fi
case "$uname" in
MINGW*)
installFile apps/bc/dc.exe "$HOME/bin/dc.exe"
psprofile=`powershell -command 'echo $profile.CurrentUserAllHosts' 2> /dev/null | cygpath -f - 2> /dev/null`
if [ -n "$psprofile" ]
then
installDir 755 "`dirname $psprofile`"
installFile profile.ps1 "$psprofile"
fi
;;
*)
;;
esac
cd scripts
for i in *
do
installFile "$i" "$HOME/bin/$i"
done
cd ..
if [ -x "`command -v git`" ]
then
$dry_run git config --global push.default simple
$dry_run git config --global pull.rebase true
$dry_run git config --global diff.algorithm histogram
fi