#!/bin/bash set -e # Fetch latest version information from API API_RESPONSE=$(curl -s "https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=stable") DOWNLOAD_URL=$(echo "$API_RESPONSE" | grep -oP '(?<="downloadUrl":")[^"]*') VERSION=$(echo "$API_RESPONSE" | grep -oP '(?<="version":")[^"]*') if [ -z "$DOWNLOAD_URL" ] || [ -z "$VERSION" ]; then echo "Failed to retrieve download URL or version. Exiting." exit 1 fi echo "Downloading Cursor IDE version $VERSION..." sudo rm -f /tmp/cursor.AppImage || true sudo rm -rf ./squashfs-root || true # Download the latest version with lowercase filename FILENAME="/tmp/cursor.AppImage" curl -JLo "$FILENAME" "$DOWNLOAD_URL" # Extract AppImage and fix permissions echo "Extracting AppImage..." chmod +x "$FILENAME" # Make executable "$FILENAME" --appimage-extract # Extract appimage rm "$FILENAME" # Remove any previously installed versions if they exist sudo rm -rf /opt/cursor || true sudo rm -f /usr/share/applications/cursor.desktop || true sudo mv ./squashfs-root /opt/cursor # Move extracted image to program directory sudo chown -R root: /opt/cursor # Change owner to root sudo find /opt/cursor -type d -exec chmod 755 {} \; # Fix directory permissions sudo chmod 644 /opt/cursor/code.png # Ensure the app icon has correct permissions # Create Desktop entry cat >cursor.desktop <