#!/bin/sh # Downloads the latest ThruLine release for this machine from GitHub. # Checks SHA-256 against SHA256SUMS, then installs to ~/.local/bin. # Same script as the README's install block -- read it first: # https://github.com/thrulinehq/thruline#install set -e install_thruline() ( set -eu case "$(uname -s)-$(uname -m)" in Darwin-arm64) target=aarch64-apple-darwin ;; Darwin-x86_64) target=x86_64-apple-darwin ;; Linux-aarch64|Linux-arm64) target=aarch64-unknown-linux-musl ;; Linux-x86_64) target=x86_64-unknown-linux-musl ;; *) printf 'No ThruLine archive for this platform.\n' >&2; exit 1 ;; esac archive="thruline-cli-$target.tar.gz" base="https://github.com/thrulinehq/thruline/releases/latest/download" work=$(mktemp -d) trap 'rm -rf "$work"' 0 cd "$work" curl -fsSLO "$base/$archive" curl -fsSLO "$base/SHA256SUMS" expected=$(awk -v name="$archive" '$2 == name { print $1 }' SHA256SUMS) [ -n "$expected" ] || { printf 'Missing checksum entry.\n' >&2; exit 1; } if command -v shasum >/dev/null 2>&1; then actual=$(shasum -a 256 "$archive" | awk '{ print $1 }') elif command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$archive" | awk '{ print $1 }') else printf 'Install shasum or sha256sum to verify the download.\n' >&2 exit 1 fi [ "$expected" = "$actual" ] || { printf 'Checksum mismatch.\n' >&2; exit 1; } tar -xzf "$archive" mkdir -p "$HOME/.local/bin" install -m 0755 "thruline-cli-$target/thruline" "$HOME/.local/bin/thruline" ) install_thruline printf '\nThruLine is installed at %s/.local/bin/thruline\n' "$HOME" # Put ~/.local/bin on PATH for new shells, once: macOS does not have it there by default. # Set THRULINE_NO_MODIFY_PATH=1 to leave every startup file alone. mark='# added by the ThruLine installer' case ":$PATH:" in *":$HOME/.local/bin:"*) ;; *) if [ "${THRULINE_NO_MODIFY_PATH:-}" = 1 ]; then printf 'Left your PATH alone (THRULINE_NO_MODIFY_PATH=1).\n' else line='export PATH="$HOME/.local/bin:$PATH"' case "${SHELL:-}" in */zsh) rc="$HOME/.zshrc"; shown='~/.zshrc' ;; */bash) if [ "$(uname -s)" = Darwin ]; then rc="$HOME/.bash_profile"; shown='~/.bash_profile' else rc="$HOME/.bashrc"; shown='~/.bashrc'; fi ;; */fish) rc="$HOME/.config/fish/conf.d/thruline.fish"; shown='~/.config/fish/conf.d/thruline.fish' line='fish_add_path "$HOME/.local/bin"' ;; *) rc='' ;; esac if [ -z "$rc" ]; then printf 'To type just `thruline`, add ~/.local/bin to your PATH.\n' elif [ -f "$rc" ] && grep -qF "$mark" "$rc"; then printf '%s already puts ~/.local/bin on your PATH.\n' "$shown" else mkdir -p "$(dirname "$rc")" printf '\n%s %s\n' "$line" "$mark" >> "$rc" printf 'Added ~/.local/bin to your PATH in %s, for new Terminal windows.\n' "$shown" printf 'To undo it, delete the line ending "%s" from %s.\n' "$mark" "$shown" fi fi ;; esac # This window cannot see the new PATH yet; the full path works right away. printf 'Open HQ now: ~/.local/bin/thruline ui\n'