-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·49 lines (43 loc) · 1.33 KB
/
install
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
#!/bin/bash
replace=""
# git
[ -e 'files/gitconfig' ] && rm files/gitconfig
if [ -e 'files/gitconfig.user' ]; then
cat files/gitconfig.user >> files/gitconfig
echo "" >> files/gitconfig # add newline
else
echo "Create a gitconfig.user with just your own user details."
fi
cat files/gitconfig.withoutuser >> files/gitconfig
# dotfiles
for f in files/*
do
# skip
test "$f" = "install" && continue
test "$f" = "README.md" && continue
test "$f" = "files/gitconfig.withoutuser" && continue
test "$f" = "files/gitconfig.user" && continue
test "$f" = "files/Brewfile" && continue
test "$f" = "files/Brewfile.lock.json" && continue
dest="$HOME/.${f##*/}"
file="$PWD/$f"
if [ -e "$dest" ] || [ -h "$dest" ]; then
if [ "$replace" != "a" ]; then
echo "$dest already exists, replace? [y/n/a] "
read -r replace
fi
if [ "$replace" = "a" ] || [ "$replace" = "y" ]; then
echo "linking $file to $dest..."
rm -f "$dest"
ln -s "$file" "$dest"
test "$replace" != "a" && replace=""
else
echo "skipping $file as it already exists..."
fi
elif [ "$f" == "README" ]; then
echo "skipping README: $f."
else
echo "linking $file to $dest..."
ln -s "$file" "$dest"
fi
done