diff options
| author | Igor Soarez <igor@soarez.org> | 2026-09-17 19:45:23 +0100 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-09-17 19:45:23 +0100 |
| commit | 13cc065ec014b86369dfe4ad60d1a43fa06fd251 (patch) | |
| tree | 684690c61b7b59758c2aac132c65b81c86de0608 /extra/install-cursor.sh | |
dotfiles
Shell, editor and terminal configuration, the tools that go with them, and
szecret, an age-based secret manager whose store lives elsewhere.
History restarts here. What came before was not written to be read by
anyone else, and carried machine names, addresses and an encrypted secret
store; it is kept privately instead. What is left is meant to be safe on
any machine, including one whose owner is not me: see CLAUDE.md for the
rule it is written to.
Diffstat (limited to 'extra/install-cursor.sh')
| -rw-r--r-- | extra/install-cursor.sh | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/extra/install-cursor.sh b/extra/install-cursor.sh new file mode 100644 index 0000000..fb9ca2c --- /dev/null +++ b/extra/install-cursor.sh @@ -0,0 +1,151 @@ +#!/usr/bin/env bash + +# Color support: check NO_COLOR or non-TTY (stdout) +if [ -n "${NO_COLOR+x}" ] || [ ! -t 1 ]; then + CYAN='' + GREEN='' + YELLOW='' + BLUE='' + PURPLE='' + RED='' + BOLD='' + DIM='' + NC='' +else + CYAN='\033[0;36m' + GREEN='\033[0;32m' + YELLOW='\033[0;33m' + BLUE='\033[0;34m' + PURPLE='\033[0;35m' + RED='\033[0;31m' + BOLD='\033[1m' + DIM='\033[2m' + NC='\033[0m' +fi + +# Fancy header +echo "" +echo -e "${BOLD}Cursor Agent Installer${NC}" +echo "" + +# Function to print steps with style +print_step() { + echo -e "${BLUE}▸${NC} ${1}" +} + +# Function to print success +print_success() { + # Move cursor up one line and clear it + echo -ne "\033[1A\033[2K" + echo -e "${GREEN}✓${NC} ${1}" +} + +# Function to print error +print_error() { + echo -e "${RED}✗${NC} ${1}" +} + +# Detect OS and Architecture +print_step "Detecting system architecture..." + +# Detect OS +OS="$(uname -s)" +case "${OS}" in + Linux*) OS="linux";; + Darwin*) OS="darwin";; + *) + print_error "Unsupported operating system: ${OS}" + exit 1 + ;; +esac + +# Detect Architecture +ARCH="$(uname -m)" +case "${ARCH}" in + x86_64|amd64) ARCH="x64";; + arm64|aarch64) ARCH="arm64";; + *) + print_error "Unsupported architecture: ${ARCH}" + exit 1 + ;; +esac + +print_success "Detected ${OS}/${ARCH}" + +# Installation steps +print_step "Creating installation directory..." +# Create temporary directory for atomic download inside versions folder +TEMP_EXTRACT_DIR="$HOME/.local/share/cursor-agent/versions/.tmp-2026.05.27-fe9a6e2-$(date +%s)" +mkdir -p "${TEMP_EXTRACT_DIR}" + +print_success "Directory created" + + +print_step "Downloading Cursor Agent package..." +DOWNLOAD_URL="https://downloads.cursor.com/lab/2026.05.27-fe9a6e2/${OS}/${ARCH}/agent-cli-package.tar.gz" +echo -e "${DIM} Download URL: ${DOWNLOAD_URL}${NC}" + +# Cleanup function +cleanup() { + command rm -rf "${TEMP_EXTRACT_DIR}" +} +trap cleanup EXIT + +# Download with progress bar and better error handling +if curl -fSL --progress-bar "${DOWNLOAD_URL}" \ + | tar --strip-components=1 -xzf - -C "${TEMP_EXTRACT_DIR}"; then + echo -ne "\033[1A\033[2K" + echo -ne "\033[1A\033[2K" + echo -ne "\033[1A\033[2K" + print_success "Package downloaded and extracted" +else + print_error "Download failed. Please check your internet connection and try again." + print_error "If the problem persists, the package might not be available for ${OS}/${ARCH}." + cleanup + exit 1 +fi + +print_step "Finalizing installation..." +# Atomically move from temp to final destination +FINAL_DIR="$HOME/.local/share/cursor-agent/versions/2026.05.27-fe9a6e2" +command rm -rf "${FINAL_DIR}" +if mv "${TEMP_EXTRACT_DIR}" "${FINAL_DIR}"; then + print_success "Package installed successfully" +else + print_error "Failed to install package. Please check permissions." + cleanup + exit 1 +fi + + +print_step "Creating bin directory..." +mkdir -p ~/.local/bin +print_success "Bin directory ready" + + +print_step "Creating symlinks to agent executable..." +# Remove any existing symlink or file +command rm -f ~/.local/bin/cursor-agent +# Create symlinks to the Cursor Agent executable +ln -s ~/.local/share/cursor-agent/versions/2026.05.27-fe9a6e2/cursor-agent ~/.local/bin/cursor-agent +print_success "Symlink created" + +# Success message +echo "" +echo -e "${BOLD}${GREEN}✨ Installation Complete! ${NC}" +echo "" +echo "" + +# Check if ~/.local/bin is already in PATH +if [[ ":${PATH}:" == *":${HOME}/.local/bin:"* ]]; then + # PATH already configured, just show usage + echo -e "${BOLD}Start using Cursor Agent:${NC}" + echo -e " ${BOLD}cursor-agent${NC}" +else + echo -e "${BOLD}Add ~/.local/bin to PATH:${NC}" +fi + +echo "" +echo "" +echo -e "${BOLD}${CYAN}Happy coding! 🚀${NC}" +echo "" |
