#!/bin/sh set -e # Truto CLI installer # Usage: curl -fsSL https://cli.truto.one/install.sh | bash TRUTO_BASE_URL="https://cli.truto.one" INSTALL_DIR="${TRUTO_INSTALL_DIR:-$HOME/.truto/bin}" main() { os=$(detect_os) arch=$(detect_arch) binary="truto-${os}-${arch}" if [ -n "$TRUTO_VERSION" ]; then url="${TRUTO_BASE_URL}/releases/${TRUTO_VERSION}/${binary}" else url="${TRUTO_BASE_URL}/latest/${binary}" fi printf "\033[1m> Downloading Truto CLI (%s/%s)\033[0m\n" "$os" "$arch" mkdir -p "$INSTALL_DIR" target="${INSTALL_DIR}/truto" download "$url" "$target" chmod +x "$target" if [ "$(uname -s)" = "Darwin" ]; then xattr -d com.apple.quarantine "$target" 2>/dev/null || true codesign --sign - --force "$target" 2>/dev/null || true fi add_to_path printf "\n\033[32m✓ Truto CLI installed to %s\033[0m\n" "$target" printf " Run '\033[1mtruto --help\033[0m' to get started\n" printf " Run '\033[1mtruto login\033[0m' to authenticate\n" printf " Optional (for AI-powered \033[1mtruto integrations build\033[0m): set \033[1mANTHROPIC_API_KEY\033[0m or run \033[1mtruto profiles set-key anthropic\033[0m\n" printf " Embedding model (~35 MB) auto-downloads on first \033[1mtruto integrations build\033[0m\n" if ! command -v truto >/dev/null 2>&1; then printf "\n \033[33mRestart your shell or run:\033[0m\n" printf " export PATH=\"%s:\$PATH\"\n" "$INSTALL_DIR" fi } detect_os() { case "$(uname -s)" in Linux*) echo "linux" ;; Darwin*) echo "darwin" ;; MINGW*|MSYS*|CYGWIN*) printf "\033[31mError: This is the POSIX installer.\033[0m\n" >&2 printf "On native Windows, run this in PowerShell instead:\n" >&2 printf " irm %s/install.ps1 | iex\n" "$TRUTO_BASE_URL" >&2 printf "(WSL users: run inside your Linux distro — bash, not Git Bash.)\n" >&2 exit 1 ;; *) printf "\033[31mError: Unsupported OS: %s\033[0m\n" "$(uname -s)" >&2 printf "Truto CLI supports Linux, macOS, and Windows (via install.ps1).\n" >&2 exit 1 ;; esac } detect_arch() { case "$(uname -m)" in x86_64|amd64) echo "x64" ;; aarch64|arm64) echo "arm64" ;; *) printf "\033[31mError: Unsupported architecture: %s\033[0m\n" "$(uname -m)" >&2 printf "Truto CLI supports x64 and arm64.\n" >&2 exit 1 ;; esac } download() { url="$1" dest="$2" if command -v curl >/dev/null 2>&1; then curl -fsSL --progress-bar -o "$dest" "$url" elif command -v wget >/dev/null 2>&1; then wget -qO "$dest" "$url" else printf "\033[31mError: curl or wget is required to download Truto CLI.\033[0m\n" >&2 exit 1 fi } add_to_path() { case ":$PATH:" in *":${INSTALL_DIR}:"*) return ;; esac export_line="export PATH=\"${INSTALL_DIR}:\$PATH\"" for rc in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do if [ -f "$rc" ]; then if ! grep -qF "$INSTALL_DIR" "$rc" 2>/dev/null; then printf "\n# Truto CLI\n%s\n" "$export_line" >> "$rc" fi fi done # Create .zshrc if on macOS and it doesn't exist (zsh is the default shell) if [ "$(uname -s)" = "Darwin" ] && [ ! -f "$HOME/.zshrc" ]; then printf "# Truto CLI\n%s\n" "$export_line" > "$HOME/.zshrc" fi } main