-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
64 lines (47 loc) · 1.4 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
#!/bin/sh
: '###############################################
This is a script to install duzun/dotfiles
How to run:
curl -sLo- https://duzun.me/dotfiles.sh | sh
or
wget -qO- https://duzun.me/dotfiles.sh | sh
See an up to date version at:
https://raw.githubusercontent.com/duzun/dotfiles/master/install.sh
# ###############################################'
repoUrl=https://github.com/duzun/dotfiles
homeDir=$HOME
[ -z "$homeDir" ] && homeDir=~
no_tools() {
>&2 echo "Please, install git or unzip + curl"
exit 4
}
hasCmd() {
command -v "$1" > /dev/null
}
if [ -z "$homeDir" ]; then
>&2 echo "Can't find the \$HOME environment variable"
exit 1
fi
if [ ! -d "$homeDir" ]; then
>&2 echo "Folder \"$homeDir\" not found"
exit 2
fi
if hasCmd git; then
git clone --recurse-submodules "$repoUrl".git "$homeDir"/.dotfiles
else
hasCmd unzip || no_tools
if hasCmd curl; then
curl -sLo "$homeDir"/dotfiles.zip "$repoUrl/archive/master.zip"
else
wget -qO "$homeDir"/dotfiles.zip "$repoUrl/archive/master.zip"
fi && \
unzip "$homeDir"/dotfiles.zip -d "$homeDir" > /dev/null && \
mv -- "$homeDir"/dotfiles-master "$homeDir"/.dotfiles && \
rm -f -- "$homeDir"/dotfiles.zip
fi
if [ ! -s "$homeDir"/.dotfiles/~/source ]; then
exit 3
fi
chmod +x "$homeDir"/.dotfiles/~/source
"$homeDir"/.dotfiles/~/source init && \
echo "Now run: . ~/.source"