Skip to content

Instantly share code, notes, and snippets.

@skgsergio
Last active May 22, 2025 07:59
Show Gist options
  • Save skgsergio/f8d688f1bed076f0e0a2d38a1a334bbe to your computer and use it in GitHub Desktop.
Save skgsergio/f8d688f1bed076f0e0a2d38a1a334bbe to your computer and use it in GitHub Desktop.
I fucking hate software distribution using AppImage
#!/bin/bash
set -euo 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"
echo "Getting download information..."
API_RESPONSE=$(curl -s "https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=latest")
DOWNLOAD_URL=$(echo "$API_RESPONSE" | jq -r '.downloadUrl')
if [ -z "$DOWNLOAD_URL" ] || [ "$DOWNLOAD_URL" = "null" ]; then
echo "Error: Could not get download URL"
exit 1
fi
VERSION=$(echo "$API_RESPONSE" | jq -r '.version')
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
echo "Error: Could not get version"
exit 1
fi
APPIMAGE_FILE=$(basename "$DOWNLOAD_URL")
APPIMAGE_PATH="$BASE_PATH/$APPIMAGE_FILE"
if [ -f "$APPIMAGE_PATH" ]; then
echo "Latest Cursor version $VERSION is already installed!"
exit 0
fi
echo "Downloading Cursor version $VERSION..."
sudo curl -L "$DOWNLOAD_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"
ICON_PATH="$BASE_PATH/icon.png"
if [ ! -f "$ICON_PATH" ]; then
echo "Downloading icon..."
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"
else
echo "Error: Could not get icon URL"
exit 1
fi
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 $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