-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·54 lines (46 loc) · 1.39 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
#!/bin/sh
set -e
if ! command -v tar >/dev/null; then
echo "Error: tar is required to install clibgen" 1>&2
exit 1
fi
if [ "$OS" = "Windows_NT" ]; then
target="windows-amd64"
else
case $(uname -sm) in
"Darwin x86_64") target="darwin-amd64" ;;
"Darwin arm64") target="darwin-arm64" ;;
*) target="linux-amd64" ;;
esac
fi
if [ $# -eq 0 ]; then
clibgen_uri="https://github.com/laureanray/clibgen/releases/latest/download/clibgen_${target}.tar.gz"
else
clibgen_uri="https://github.com/laureanray/clibgen/releases/download/${1}/clibgen_${target}.tar.gz"
fi
clibgen_install="${CLIBGEN_INSTALL:-$HOME/.clibgen}"
bin_dir="$clibgen_install/bin"
exe="$bin_dir/clibgen"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
echo "$clibgen_uri"
curl --fail --location --progress-bar --output "$exe.tar.gz" "$clibgen_uri"
tar -xf "$exe.tar.gz" -C "$bin_dir"
chmod +x "$exe"
# Clean up
rm "$exe.tar.gz"
echo "Clibgen was installed successfully to $exe"
if command -v clibgen >/dev/null; then
echo "Run 'clibgen --help' to get started. Happy reading!"
else
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
/usr/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export CLIBGEN_INSTALL=\"$clibgen_install\""
echo " export PATH=\"\$CLIBGEN_INSTALL/bin:\$PATH\""
echo "Run '$exe --help' to get started"
fi