-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·67 lines (47 loc) · 1.35 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
#!/usr/bin/env bash
# enable strict error handling
set -euo pipefail
PLATFORM=$(uname -ms)
# determine the target platform
case $PLATFORM in
'Darwin x86_64')
TARGET=darwin-x64
;;
'Darwin arm64')
TARGET=darwin-arm64
;;
'Linux aarch64' | 'Linux arm64')
TARGET=linux-arm64
;;
'Linux x86_64' | *)
TARGET=linux-x64
;;
esac
# create installation directory if it doesn't exist
INSTALL_DIR="$HOME/.how/bin"
mkdir -p "$INSTALL_DIR"
# download binary from GitHub
BINARY_URL="https://github.com/kynnyhsap/how/releases/latest/download/how-$TARGET"
EXECUTABLE_NAME="how"
curl -L "$BINARY_URL" -o "$INSTALL_DIR/$EXECUTABLE_NAME"
# make the binary executable
chmod +x "$INSTALL_DIR/$EXECUTABLE_NAME"
# update PATH in shell profile
if [[ "$SHELL" == */zsh ]]; then
PROFILE="$HOME/.zshrc"
elif [[ "$SHELL" == */bash ]]; then
PROFILE="$HOME/.bashrc"
else
echo "Unsupported shell. Please add $INSTALL_DIR to your PATH manually."
exit 1
fi
if ! grep -q "$INSTALL_DIR" "$PROFILE"; then
echo -e "\n\n# how cli" >> "$PROFILE"
echo "export PATH=\$PATH:$INSTALL_DIR" >> "$PROFILE"
echo "Added $INSTALL_DIR to PATH in $PROFILE"
else
echo "PATH already includes $INSTALL_DIR"
fi
echo "Installation complete."
echo "Please restart your terminal or run 'source $PROFILE' to use the command."
echo "Run 'how --help' to get started."