-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·71 lines (62 loc) · 1.33 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
#!/bin/bash
OS=$(uname)
ARCH=$(uname -m)
LOOKS_PATH=~/.looks
handleOS() {
if [[ "$OS" != "Darwin" && "$OS" != "Linux" ]] ; then
echo "unsupported operating system"
else
handleArch
fi
}
getLooks() {
mkdir ~/.looks
lowerCase "looks-$OS-$ARCH"
curl -L https://github.com/clickpop/looks/releases/latest/download/$FILENAME >> "$LOOKS_PATH/looks"
chmod 777 "$LOOKS_PATH/looks"
}
handlePath() {
IN_PATH=false
IFS=':' read -ra ADDR <<< "$PATH"
for i in "${ADDR[@]}"; do
if [[ "$i" == "$LOOKS_PATH" ]] ; then
IN_PATH=true
fi
done
if [[ ! $IN_PATH ]] ; then
if [[ -f ~/.bashrc ]] ; then
echo "profile"
handlePathPersist $HOME/.bashrc
fi
if [[ -f ~/.zshrc ]] ; then
handlePathPersist $HOME/.zshrc
fi
fi
}
handlePathPersist() {
IN_FILE=false
NEW_PATH="export PATH=\"\$PATH:$LOOKS_PATH\""
if grep -q "$NEW_PATH" $1 ; then
echo "In file"
IN_FILE=true
fi
if [[ ! $IN_FILE ]] ; then
echo $NEW_PATH >> $1
fi
}
handleArch() {
if [[ "$ARCH" != "arm64" && "$ARCH" != "x84_64" ]] ; then
echo "unsupported cpu architecture"
else
if [[ "$ARCH" == "x84_64" ]] ; then
ARCH="amd64"
fi
getLooks
handlePath
fi
}
lowerCase() {
FILENAME=$(echo "$1" | awk '{print tolower($0)}')
}
handleOS
echo -e "\nplease restart your terminal to use looks"