57 lines · 1.3 KB · executable
#!/usr/bin/env bash
set -euo pipefail

# Install the latest Zellij binary on Linux.
# https://zellij.dev/

# Only support Linux.
if [[ "$OSTYPE" != linux* ]]; then
    echo "This script only supports Linux."
    exit 1
fi

# Detect architecture.
arch="$(uname -m)"
case "$arch" in
x86_64)
    target="x86_64-unknown-linux-musl"
    ;;
aarch64)
    target="aarch64-unknown-linux-musl"
    ;;
*)
    echo "Unsupported architecture: $arch"
    exit 1
    ;;
esac

# Get the latest release URL.
echo "Fetching latest Zellij release..."
release_url="https://api.github.com/repos/zellij-org/zellij/releases/latest"
download_url=$(curl -s "$release_url" | grep -o "https://github.com/zellij-org/zellij/releases/download/[^\"]*/zellij-$target.tar.gz" | head -1)

if [[ -z "$download_url" ]]; then
    echo "Failed to find download URL for $target"
    exit 1
fi

# Create temp directory and download.
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT