forked from tristanisham/zvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·104 lines (78 loc) · 3.72 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
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# ZVM install script - v0.1.5 - ZVM: https://github.com/tristanisham/zvm
ARCH=$(uname -m)
OS=$(uname -s)
if [ $ARCH = "x86_64" ]; then
ARCH="amd64"
fi
# echo "Installing zvm-$OS-$ARCH"
install_latest() {
echo -e "Installing $1 in $(pwd)/zvm"
if [ "$(uname)" = "Darwin" ]; then
# Do something under MacOS platform
if command -v wget >/dev/null 2>&1; then
echo "wget is installed. Using wget..."
wget -q --show-progress --max-redirect 5 -O zvm.tar "https://github.com/tristanisham/zvm/releases/latest/download/$1"
else
echo "wget is not installed. Using curl..."
curl -L --max-redirs 5 "https://github.com/tristanisham/zvm/releases/latest/download/$1" -o zvm.tar
fi
mkdir -p $HOME/.zvm/self
tar -xf zvm.tar -C $HOME/.zvm/self
rm "zvm.tar"
elif [ $OS = "Linux" ]; then
# Do something under GNU/Linux platform
if command -v wget >/dev/null 2>&1; then
echo "wget is installed. Using wget..."
wget -q --show-progress --max-redirect 5 -O zvm.tar "https://github.com/tristanisham/zvm/releases/latest/download/$1"
else
echo "wget is not installed. Using curl..."
curl -L --max-redirs 5 "https://github.com/tristanisham/zvm/releases/latest/download/$1" -o zvm.tar
fi
mkdir -p $HOME/.zvm/self
tar -xf zvm.tar -C $HOME/.zvm/self
rm "zvm.tar"
elif [ $OS = "MINGW32_NT" ]; then
# Do something under 32 bits Windows NT platform
curl -L --max-redirs 5 "https://github.com/tristanisham/zvm/releases/latest/download/$($1)" -o zvm.zip
elif [ $OS == "MINGW64_NT" ]; then
# Do something under 64 bits Windows NT platform
curl -L --max-redirs 5 "https://github.com/tristanisham/zvm/releases/latest/download/$($1)" -o zvm.zip
fi
}
if [ "$(uname)" = "Darwin" ]; then
# Do something under Mac OS X platform
install_latest "zvm-darwin-$ARCH.tar"
elif [ $OS = "Linux" ]; then
# Do something under GNU/Linux platform
install_latest "zvm-linux-$ARCH.tar"
elif [ $OS = "MINGW32_NT" ]; then
# Do something under 32 bits Windows NT platform
install_latest "zvm-windows-$ARCH.zip"
elif [ $OS == "MINGW64_NT" ]; then
# Do something under 64 bits Windows NT platform
install_latest "zvm-windows-$ARCH.zip"
fi
echo
echo "Run the following commands to put ZVM on your path via $HOME/.profile"
echo
# Check if TERM is set to a value that typically supports colors
if [[ "$TERM" == "xterm" || "$TERM" == "xterm-256color" || "$TERM" == "screen" || "$TERM" == "tmux" ]]; then
# Colors
RED='\033[0;31m' # For strings
GREEN='\033[0;32m' # For commands
BLUE='\033[0;34m' # For variables
NC='\033[0m' # No Color
echo -e "${GREEN}echo${NC} ${RED}\"# ZVM\"${NC} ${GREEN}>>${NC} ${BLUE}\$HOME/.profile${NC}"
echo -e "${GREEN}echo${NC} ${RED}'export ZVM_INSTALL=\"\$HOME/.zvm/self\"'${NC} ${GREEN}>>${NC} ${BLUE}\$HOME/.profile${NC}"
echo -e "${GREEN}echo${NC} ${RED}'export PATH=\"\$PATH:\$HOME/.zvm/bin\"'${NC} ${GREEN}>>${NC} ${BLUE}\$HOME/.profile${NC}"
echo -e "${GREEN}echo${NC} ${RED}'export PATH=\"\$PATH:\$ZVM_INSTALL/\"'${NC} ${GREEN}>>${NC} ${BLUE}\$HOME/.profile${NC}"
echo -e "Run '${GREEN}source ~/.profile${NC}' to start using ZVM in this shell!"
else
echo 'echo "# ZVM" >> $HOME/.profile'
echo 'echo '\''export ZVM_INSTALL="$HOME/.zvm/self"'\'' >> $HOME/.profile'
echo 'echo '\''export PATH="$PATH:$HOME/.zvm/bin"'\'' >> $HOME/.profile'
echo 'echo '\''export PATH="$PATH:$ZVM_INSTALL/"'\'' >> $HOME/.profile'
echo "Run 'source ~/.profile' to start using ZVM in this shell!"
fi
echo