-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
94 lines (76 loc) · 1.69 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
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/martinusso/zx/master/install.sh)"
# or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/martinusso/zx/master/install.sh)"
REPO=${REPO:-martinusso/zx}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
command_exists() {
command -v "$@" >/dev/null 2>&1
}
error() {
echo ${RED}"Error: $@"${RESET} >&2
}
setup_color() {
# Only use colors if connected to a terminal
if [ -t 1 ]; then
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
BOLD=$(printf '\033[1m')
RESET=$(printf '\033[m')
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
RESET=""
fi
}
setup_zx() {
umask g-w,o-w
echo "${BLUE}Cloning zx${RESET}"
command_exists git || {
error "git is not installed"
exit 1
}
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
error "Windows/MSYS Git is not supported on Cygwin"
error "Make sure the Cygwin git package is installed and is first on the \$PATH"
exit 1
fi
git clone -c core.eol=lf -c core.autocrlf=false \
--depth=1 --branch "$BRANCH" "$REMOTE" || {
error "git clone of zx repo failed"
exit 1
}
cd zx
make install
echo
}
main() {
setup_color
if command_exists zx; then
cat <<-EOF
${YELLOW}You already have zx installed.${RESET}
You'll need to remove zx if you want to reinstall.
EOF
exit 1
fi
setup_zx
printf "$GREEN"
cat <<-'EOF'
___________ ___
\___ /\ \/ /
/ / > <
/_____ \/__/\_ \
\/ \/ ... is now installed!
EOF
printf "$RESET"
exec zx info
}
main "$@"