diff --git a/install b/install new file mode 100755 index 0000000..e3ac77e --- /dev/null +++ b/install @@ -0,0 +1,64 @@ +#!/bin/sh + +_have() { type "$1" >/dev/null 2>&1; } + +help() { + cat <.*: "\(.*\)".*>\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