-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·96 lines (75 loc) · 2.05 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
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
#!/usr/bin/env zsh
0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
builtin emulate -L zsh -o extendedglob -o noshortloops \
-o warncreateglobal -o typesetsilent \
-o nopromptsubst
typeset -g DOTFILEDIR=$(cd $(dirname $0);pwd)
function link_conf() {
local source="$1"
local target="$2"
if [ -e "$target" ]; then
echo -e "\t\e[3mSkipping ${target}\e[0m"
return
fi
[ -d $(dirname "$target") ] || mkdir -p $(dirname "$target")
echo -e "\tLinking ${target}"
ln -s $source "$target"
}
function copy_conf() {
local source="$1"
local target="$2"
if [ -e "$target" ]; then
echo -e "\t\e[3mSkipping ${target}\e[0m"
return
fi
[ -d $(dirname "$target") ] || mkdir -p $(dirname "$target")
echo -e "\tCopying ${target}"
cp "$source" "$target"
}
function git_clone() {
local source="$1"
local target="$2"
if [ -e "$target" ]; then
echo -e "\t\e[3mSkipping ${target}\e[0m"
return
fi
[ -d $(dirname "$target") ] || mkdir -p $(dirname "$target")
echo -e "\tCloning ${target}"
git clone --quiet --depth 1 "$source" "$target"
}
function http_get() {
local source="$1"
local target="$2"
if [ -e "$target" ]; then
echo -e "\t\e[3mSkipping ${target}\e[0m"
return
fi
[ -d $(dirname "$target") ] || mkdir -p $(dirname "$target")
echo -e "\tDownloading ${target}"
curl -fqsSL -o "${target}" "${source}"
}
function install_module() {
readonly module="${1}"
readonly install_script="${DOTFILEDIR}/${module}/install.zsh"
echo "Installing ${module} module"
if [ ! -e "${install_script}" ]; then
echo "No such module: ${module}"
exit 1
fi
source "${install_script}" $(dirname "${install_script}")
}
install() {
local -a modules_to_install
local dir module
if (($# == 0)); then
for dir in ${DOTFILEDIR}/*/install.zsh; do
modules_to_install+=($(basename $(dirname "$dir")))
done
else
modules_to_install+=($@)
fi
for module in ${modules_to_install}; do
install_module "${module}"
done
}
install