Last active
August 18, 2025 18:27
-
-
Save gitmpr/4a3cf9e9732c76fb7bd4e9631a59ac85 to your computer and use it in GitHub Desktop.
Install Cursor AppImage on Ubuntu 24.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e # Exit on error | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| NC='\033[0m' # No Color | |
| # Print colored output | |
| print_status() { | |
| echo -e "${GREEN}✓${NC} $1" | |
| } | |
| print_warning() { | |
| echo -e "${YELLOW}⚠${NC} $1" | |
| } | |
| print_error() { | |
| echo -e "${RED}✗${NC} $1" | |
| } | |
| # Get current user info | |
| USERNAME="${USER}" | |
| HOME_DIR="${HOME}" | |
| echo "Installing Cursor IDE for user: ${USERNAME}" | |
| # Setup directories | |
| APPS_DIR="${HOME_DIR}/Applications" | |
| ICON_DIR="${HOME_DIR}/.local/share/icons" | |
| DESKTOP_DIR="${HOME_DIR}/.local/share/applications" | |
| # Create Applications directory | |
| mkdir -p "${APPS_DIR}" | |
| print_status "Created Applications directory: ${APPS_DIR}" | |
| # Get latest download URL from Cursor API | |
| API_URL="https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=stable" | |
| APPIMAGE_PATH="${APPS_DIR}/cursor.appimage" | |
| echo "Getting latest download URL from Cursor API..." | |
| # Get JSON response and parse downloadUrl (follow redirects) | |
| API_RESPONSE=$(curl -sL "${API_URL}") | |
| if [[ -z "${API_RESPONSE}" ]]; then | |
| print_error "Failed to get response from API" | |
| exit 1 | |
| fi | |
| # Extract downloadUrl from JSON (simple grep/sed approach) | |
| DOWNLOAD_URL=$(echo "${API_RESPONSE}" | grep -o '"downloadUrl":"[^"]*"' | sed 's/"downloadUrl":"//; s/"//') | |
| if [[ -z "${DOWNLOAD_URL}" ]]; then | |
| print_error "Failed to parse download URL from API response" | |
| echo "API Response: ${API_RESPONSE}" | |
| exit 1 | |
| fi | |
| echo "Latest download URL: ${DOWNLOAD_URL}" | |
| echo "Downloading Cursor IDE..." | |
| if wget --user-agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36" -O "${APPIMAGE_PATH}" "${DOWNLOAD_URL}"; then | |
| # Check if download was successful and file is not empty | |
| if [[ -s "${APPIMAGE_PATH}" ]] && file "${APPIMAGE_PATH}" | grep -q "executable"; then | |
| chmod +x "${APPIMAGE_PATH}" | |
| print_status "Downloaded and saved to ${APPIMAGE_PATH}" | |
| else | |
| print_error "Downloaded file is not a valid AppImage" | |
| rm -f "${APPIMAGE_PATH}" | |
| exit 1 | |
| fi | |
| else | |
| print_error "Failed to download Cursor AppImage" | |
| exit 1 | |
| fi | |
| # Extract and install icon | |
| echo "Extracting icon from AppImage..." | |
| TEMP_DIR=$(mktemp -d) | |
| cd "${TEMP_DIR}" | |
| if "${APPIMAGE_PATH}" --appimage-extract >/dev/null 2>&1; then | |
| # Find icon in extracted files | |
| ICON_SOURCE=$(find squashfs-root -name "*.png" -path "*/pixmaps/*" | head -1) | |
| if [[ -n "${ICON_SOURCE}" ]]; then | |
| mkdir -p "${ICON_DIR}" | |
| ICON_PATH="${ICON_DIR}/cursor.png" | |
| cp "${ICON_SOURCE}" "${ICON_PATH}" | |
| print_status "Icon installed to ${ICON_PATH}" | |
| else | |
| print_warning "No icon found in AppImage, using generic icon" | |
| ICON_PATH="cursor" | |
| fi | |
| else | |
| print_warning "Failed to extract AppImage, using generic icon" | |
| ICON_PATH="cursor" | |
| fi | |
| # Cleanup temp directory | |
| rm -rf "${TEMP_DIR}" | |
| # Create desktop file | |
| echo "Creating desktop file..." | |
| mkdir -p "${DESKTOP_DIR}" | |
| DESKTOP_FILE="${DESKTOP_DIR}/cursor.desktop" | |
| cat > "${DESKTOP_FILE}" << EOF | |
| [Desktop Entry] | |
| Name=Cursor | |
| Comment=AI-powered code editor | |
| Exec=${APPIMAGE_PATH} --no-sandbox | |
| Icon=${ICON_PATH} | |
| Terminal=false | |
| Type=Application | |
| Categories=Development;TextEditor;IDE; | |
| MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/javascript;application/json;text/css;text/html;text/xml;text/markdown; | |
| StartupWMClass=cursor | |
| EOF | |
| print_status "Desktop file created at ${DESKTOP_FILE}" | |
| # Update desktop database | |
| echo "Updating desktop database..." | |
| if command -v update-desktop-database >/dev/null 2>&1; then | |
| update-desktop-database "${DESKTOP_DIR}" | |
| print_status "Desktop database updated" | |
| else | |
| print_warning "update-desktop-database not found, desktop file may not appear immediately" | |
| fi | |
| # Final summary | |
| echo | |
| print_status "Cursor IDE installation completed!" | |
| print_status "AppImage: ${APPIMAGE_PATH}" | |
| print_status "Icon: ${ICON_PATH}" | |
| print_status "Desktop file: ${DESKTOP_FILE}" | |
| echo | |
| echo "Cursor IDE should now appear in your application menu." | |
| echo "You can also run it directly: ${APPIMAGE_PATH}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment