-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.zsh
executable file
·80 lines (69 loc) · 1.34 KB
/
install.zsh
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
#!/bin/zsh
COMPUTER_NAME="Vladimir’s MacBook Pro"
HOST_NAME=$(echo $COMPUTER_NAME | sed "s, ,-,g;s,[^-a-zA-Z],,g")
# https://github.com/myfreeweb/dotfiles
clear
autoload colors && colors
MSG="${fg_bold[blue]}====>${reset_color}"
INFO="${fg[green]}==>${reset_color}"
WARN="${fg[yellow]}==>${reset_color}"
ERROR="${fg[red]}==>${reset_color}"
is-macos(){
if [[ "$OSTYPE" =~ ^darwin ]]; then
return 0
fi
return 1
}
is-executable(){
if [ $commands[$*] ]; then
return 0
fi
return 1
}
require() {
if [ ! $commands[$*] ]; then
echo "$ERROR '$*' is not installed or not a command')"
exit 1
fi
}
# load modules
MODULES=(
homebrew
git
nvim
zsh
bash
apps
dev
#jetbrains
osx
fonts
tools
mc
sublime
)
if [[ -n "$@" ]]; then
MODULES="$@"
fi
for m in $MODULES; do
module=$(echo $m | sed -E "s,(.*)(/.*),\1,g")
module_params=$(echo $m | cut -d'/' -s -f2)
if [[ -d "$module" ]]; then
if [[ -f "$module/apply.zsh" ]]; then
echo "$MSG Installing module '${fg_bold[white]}$module${reset_color}'"
(
cd "$module"
PWD=$(pwd)
if source apply.zsh "${module_params}" ; then
echo "$INFO Module '$module' has been installed"
else
echo "$ERROR Module '$module' failed"
fi
)
else
echo "$ERROR '$module' is not a module (missing apply.zsh)"
fi
else
echo "$ERROR '$module' is not a module directory"
fi
done