Files
rtk-ai__rtk/install.sh
T
Patrick szymkowiak daab79cca4 Initial commit: rtk (Rust Token Killer) v0.1.0
High-performance CLI proxy to minimize LLM token consumption:
- rtk ls: Token-optimized directory tree (filters .git, node_modules, etc.)
- rtk read: Intelligent code filtering (minimal/aggressive modes)
- rtk smart: Local LLM summaries via candle-core (Llama-3.2-1B)
Includes CI/CD (GitHub Actions), Homebrew formula, and install script.
2026-01-22 18:10:30 +01:00

126 lines
2.8 KiB
Bash

#!/bin/sh
# rtk installer - https://github.com/pszymkowiak/rtk
# Usage: curl -fsSL https://raw.githubusercontent.com/pszymkowiak/rtk/main/install.sh | sh
set -e
REPO="pszymkowiak/rtk"
BINARY_NAME="rtk"
INSTALL_DIR="/usr/local/bin"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
info() {
printf "${GREEN}[INFO]${NC} %s\n" "$1"
}
warn() {
printf "${YELLOW}[WARN]${NC} %s\n" "$1"
}
error() {
printf "${RED}[ERROR]${NC} %s\n" "$1"
exit 1
}
# Detect OS
detect_os() {
case "$(uname -s)" in
Linux*) OS="linux";;
Darwin*) OS="darwin";;
*) error "Unsupported operating system: $(uname -s)";;
esac
}
# Detect architecture
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) ARCH="x86_64";;
arm64|aarch64) ARCH="aarch64";;
*) error "Unsupported architecture: $(uname -m)";;
esac
}
# Get latest release version
get_latest_version() {
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
error "Failed to get latest version"
fi
}
# Build target triple
get_target() {
case "$OS" in
linux)
TARGET="${ARCH}-unknown-linux-gnu"
;;
darwin)
TARGET="${ARCH}-apple-darwin"
;;
esac
}
# Download and install
install() {
info "Detected: $OS $ARCH"
info "Target: $TARGET"
info "Version: $VERSION"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY_NAME}-${TARGET}.tar.gz"
TEMP_DIR=$(mktemp -d)
ARCHIVE="${TEMP_DIR}/${BINARY_NAME}.tar.gz"
info "Downloading from: $DOWNLOAD_URL"
if ! curl -fsSL "$DOWNLOAD_URL" -o "$ARCHIVE"; then
error "Failed to download binary"
fi
info "Extracting..."
tar -xzf "$ARCHIVE" -C "$TEMP_DIR"
# Check if we need sudo
if [ -w "$INSTALL_DIR" ]; then
mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"
else
info "Requesting sudo to install to $INSTALL_DIR"
sudo mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"
fi
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
# Cleanup
rm -rf "$TEMP_DIR"
info "Successfully installed ${BINARY_NAME} to ${INSTALL_DIR}/${BINARY_NAME}"
}
# Verify installation
verify() {
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
info "Verification: $($BINARY_NAME --version)"
else
warn "Binary installed but not in PATH. Add $INSTALL_DIR to your PATH."
fi
}
main() {
info "Installing $BINARY_NAME..."
detect_os
detect_arch
get_target
get_latest_version
install
verify
echo ""
info "Installation complete! Run '$BINARY_NAME --help' to get started."
}
main