Last active
November 12, 2025 08:32
-
-
Save skgsergio/f8d688f1bed076f0e0a2d38a1a334bbe to your computer and use it in GitHub Desktop.
I fucking hate software distribution using AppImage
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 -uo pipefail | |
| echo -e "⚠️ This script needs root permissions, it will request privileges for sudo.\n" | |
| BASE_PATH="/opt/cursor" | |
| APPLICATIONS_PATH="/usr/share/applications" | |
| sudo mkdir -p "$BASE_PATH" | |
| CURRENT_VERSION=$(ls "$BASE_PATH" | { grep -E '^Cursor-[^-]+-' || true; } | sort -V | tail -n 1 | sed 's/.*Cursor-\([^-]*\)-.*/\1/') | |
| if [ -n "$CURRENT_VERSION" ]; then | |
| echo "ℹ️ Current Cursor version: $CURRENT_VERSION" | |
| else | |
| echo "ℹ️ No previous Cursor version found." | |
| fi | |
| echo "🔍 Getting latest version information..." | |
| LATEST_VERSION_INFO=$(curl -s 'https://api2.cursor.sh/updates/api/update/linux-x64/cursor/0.0.0/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855/prerelease') | |
| LATEST_VERSION_URL=$(echo "$LATEST_VERSION_INFO" | jq -r '.url' | grep -o 'https://[^"]*\.AppImage') | |
| if [ -z "$LATEST_VERSION_URL" ] || [ "$LATEST_VERSION_URL" == "null" ]; then | |
| echo "❌ Error: Could not get download URL" | |
| exit 1 | |
| fi | |
| LATEST_VERSION=$(echo "$LATEST_VERSION_INFO" | jq -r '.version') | |
| if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" == "null" ]; then | |
| echo "❌ Error: Could not get latest version" | |
| exit 1 | |
| fi | |
| APPIMAGE_FILE=$(basename "$LATEST_VERSION_URL") | |
| APPIMAGE_PATH="$BASE_PATH/$APPIMAGE_FILE" | |
| if [ "$LATEST_VERSION" == "$CURRENT_VERSION" ]; then | |
| echo "ℹ️ Latest Cursor version $LATEST_VERSION is already installed!" | |
| exit 0 | |
| fi | |
| echo "💾 Downloading Cursor version $LATEST_VERSION..." | |
| sudo curl -L "$LATEST_VERSION_URL" -o "$APPIMAGE_PATH" | |
| sudo chmod +x "$APPIMAGE_PATH" | |
| cat << EOL | sudo tee "/usr/local/bin/cursor" > /dev/null | |
| #!/bin/sh | |
| nohup $APPIMAGE_PATH --no-sandbox "\$@" > /dev/null 2>&1 & | |
| EOL | |
| sudo chmod +x "/usr/local/bin/cursor" | |
| echo "💾 Downloading icon..." | |
| ICON_PATH="$BASE_PATH/icon.png" | |
| ICON_URL=$(curl -s "https://forum.cursor.com" | grep -o '<meta property="og:image" content="[^"]*' | cut -d'"' -f4) | |
| if [ -n "$ICON_URL" ]; then | |
| sudo curl -L "$ICON_URL" -o "$ICON_PATH" | |
| fi | |
| cat << EOL | sudo tee "$APPLICATIONS_PATH/cursor.desktop" > /dev/null | |
| [Desktop Entry] | |
| Version=1.0 | |
| Type=Application | |
| Name=Cursor | |
| Comment=AI-first code editor | |
| Exec=$APPIMAGE_PATH --no-sandbox %F | |
| Icon=$ICON_PATH | |
| Terminal=false | |
| Categories=Development;TextEditor;IDE; | |
| MimeType=application/x-code-workspace; | |
| StartupWMClass=Cursor | |
| Keywords=code;editor;IDE; | |
| EOL | |
| sudo chmod +x "$APPLICATIONS_PATH/cursor.desktop" | |
| sudo update-desktop-database "$APPLICATIONS_PATH" | |
| echo "🧹 Removing older versions..." | |
| sudo find "$BASE_PATH" -name "*.AppImage" -not -name "$APPIMAGE_FILE" -delete | |
| echo "✅ Cursor version $LATEST_VERSION has been installed successfully!" | |
| echo "ℹ️ You can now find Cursor in your applications menu." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment