Skip to content

Instantly share code, notes, and snippets.

@david-roark
Last active May 13, 2025 14:21
Show Gist options
  • Save david-roark/20eda287d926424f6f1805996c104f4c to your computer and use it in GitHub Desktop.
Save david-roark/20eda287d926424f6f1805996c104f4c to your computer and use it in GitHub Desktop.
#!/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 <<EOL
[Desktop Entry]
Name=Cursor AI IDE
Exec=/opt/cursor/AppRun --no-sandbox
Icon=/opt/cursor/code.png
Type=Application
Categories=Development;
EOL
# Set permissions for .desktop file and move it to the correct directory
sudo chown root: cursor.desktop
sudo chmod 644 cursor.desktop
sudo mv cursor.desktop /usr/share/applications
echo "Cursor IDE version $VERSION installed successfully."
echo "Hint: To use Cursor IDE from the command line, add the following to your shell configuration file (~/.bashrc, ~/.zshrc, etc.):"
echo "alias cursor='sudo /opt/cursor/AppRun --no-sandbox'"
echo "Then restart your terminal or run: source ~/.zshrc (or your shell's config file)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment