-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·64 lines (52 loc) · 2.07 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·64 lines (52 loc) · 2.07 KB
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
#!/bin/sh
_have() { type "$1" >/dev/null 2>&1; }
help() {
cat <<EOF
Usage: ${0##*/} [options] [version]
Options:
-h, --help Show this help message and exit.
Arguments:
version Specify the version of gitmux to install. If not provided, the latest version will be installed.
Environment Variables:
INSTALL_PATH Specify the directory where gitmux should be installed. Required
Description:
This script installs the gitmux tool, which provides Git status information in the tmux status line.
It automatically detects the system architecture and downloads the appropriate version of gitmux.
Examples:
INSTALL_PATH=/usr/local/bin ${0##*/} Install the latest version of gitmux to /usr/local/bin.
INSTALL_PATH=/usr/local/bin ${0##*/} v0.7.0 Install version 0.7.0 of gitmux to /usr/local/bin.
EOF
}
gh_install() {
ver="$1"
repo='arl/gitmux'
[ -z "$ver" ] && {
latest="https://api.github.com/repos/$repo/releases/latest"
ver=$(curl -sS "$latest" | grep tarball_url | sed 's>.*: "\(.*\)".*>\1>') && test -n "$ver"
ver=${ver##*/}
}
tarname=''
archi=$(uname -sm)
case "$archi" in
Darwin\ arm64) tarname="gitmux_${ver}_macOS_arm64.tar.gz" ;;
Darwin\ x86_64) tarname="gitmux_${ver}_macOS_amd64.tar.gz" ;;
Linux\ aarch64*) tarname="gitmux_${ver}_linux_arm64.tar.gz" ;;
Linux\ *64) tarname="gitmux_${ver}_linux_amd64.tar.gz" ;;
*) echo "Unsupported architecture" && return 1 ;;
esac
tmpdir="$(mktemp -d)"
cd "$tmpdir" || :
curl -sSLO "https://github.com/$repo/releases/download/$ver/$tarname"
tar -xf gitmux*.tar.gz &&
mv gitmux "${INSTALL_PATH}"
[ -d "$tmpdir" ] && rm -rf "$tmpdir"
}
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then help && exit 0; fi
! _have curl && echo "This script depends on curl" && exit 1
[ -z "$INSTALL_PATH" ] && echo "Please set the INSTALL_PATH envvar to specify installation directory" && exit 1
echo "Installing gitmux..."
if gh_install "$@"; then
echo "Successfully installed gitmux"
else
echo "Could not install gitmux" && exit 1
fi