#!/usr/bin/env bash # This script gets the latest release from GitHub and installs it to ~/.local/bin timetreat_ascii_logo=" _ _ _ _ | | (_) | | | | | |_ _ _ __ ___ ___| |_ _ __ ___ __ _| |_ | __| | '_ ' _ \ / _ \ __| '__/ _ \/ _' | __| | |_| | | | | | | __/ |_| | | __/ (_| | |_ \__|_|_| |_| |_|\___|\__|_| \___|\__,_|\__|" set -e latest_release_version="$(curl -s --show-headers https://github.com/Criomby/timetreat/releases/latest | grep "location:" | sed "s/.*\///" | sed "s/\r//")" latest_semver="${latest_release_version#*v}" download_url="https://github.com/Criomby/timetreat/releases/download/${latest_release_version}" detect_platform() { platform="$(uname -s | tr '[:upper:]' '[:lower:]')" case "${platform}" in msys_nt*) platform="pc-windows-msvc" ;; cygwin_nt*) platform="pc-windows-msvc";; mingw*) platform="pc-windows-msvc" ;; esac # no installer support on Windows if [ "{$platform}" = "pc-windows-msvc" ]; then echo "Error: Please download & install the exe manually on Windows." exit 1 fi printf '%s' "${platform}" } detect_arch() { arch="$(uname -m | tr '[:upper:]' '[:lower:]')" case "${arch}" in x86_64) arch="amd64" ;; armv*) arch="arm" ;; esac # `uname -m` in some cases mis-reports 32-bit OS as 64-bit, so double check # 32-bit targets will have to be built from source if [ "${arch}" = "amd64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then arch=i686 elif [ "${arch}" = "arm64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then arch=arm fi # adjust for armv* 64 bit targets if [ "${arch}" = "arm" ] && [ "$(getconf LONG_BIT)" -eq 64 ]; then arch=arm64 fi printf '%s' "${arch}" } confirm() { if [ -z "${FORCE-}" ]; then printf "%s " "$* [y/N]" set +e read -r yn