When searching the internet, I couldn't find a script to install and update Cursor, this editor that uses Artificial Intelligence with AI agents to assist and speed up development.
Script to install
#!/bin/bash
# Script: cursor-install.sh# Description: This script automates the installation of the Cursor editor on Linux.# It downloads the latest version of Cursor, installs it as an AppImage in /opt,# and creates a shortcut in the system's application menu.## Features:# - Checks for and requests sudo privileges# - Downloads the latest version of Cursor# - Installs the AppImage to /opt# - Creates a shortcut in the application menu# - Handles download and installation errors
if [ "$EUID" -ne 0 ]; then echo "Requesting sudo access to install Cursor..." exec sudo "$0" "$@" exit $?fi
if [ -f "/opt/cursor.appimage" ]; then echo "Cursor is already installed at /opt/cursor.appimage" echo "To update, use the cursor-update.sh script" exit 1fi
TEMP_DIR=$(mktemp -d)cd "$TEMP_DIR"
echo "Checking for the latest version of Cursor..."if ! DOWNLOAD_INFO=$(curl -s -H "sec-ch-ua: \"Google Chrome\";v=\"135\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"135\"" \ -H "sec-ch-ua-mobile: ?0" \ -H "sec-ch-ua-platform: \"Linux\"" \ "https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=stable"); then echo "Error: Failed to fetch download information" exit 1
Script to update Cursor:
#!/bin/bash
# Script: cursor-update.sh# Description: This script updates an existing installation of the Cursor editor on Linux.# It downloads the latest version of Cursor, backs up the previous version,# and updates the installation in /opt.## Features:# - Checks for and requests sudo privileges# - Checks if Cursor is already installed# - Downloads the latest version of Cursor# - Backs up the previous version# - Updates the installation in the same location
if [ "$EUID" -ne 0 ]; then echo "Requesting sudo access to update Cursor..." exec sudo "$0" "$@" exit $?fi
if [ ! -f "/opt/cursor.appimage" ]; then echo "Error: Cursor is not installed at /opt/cursor.appimage" echo "Please run the installation script first" exit 1fi
TEMP_DIR=$(mktemp -d)cd "$TEMP_DIR"
echo "Checking for the latest version of Cursor..."if ! DOWNLOAD_INFO=$(curl -s -H "sec-ch-ua: \"Google Chrome\";v=\"135\", \"Not-A.Brand\";v=\"8\", \"Chromium\";v=\"135\"" \ -H "sec-ch-ua-mobile: ?0" \ -H "sec-ch-ua-platform: \"Linux\"" \ "https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=stable"); then echo "Error: Failed to fetch download information" exit 1fi
DOWNLOAD_URL=$(echo "$DOWNLOAD_INFO" | grep -o '"downloadUrl":"[^"]*"' | cut -d'"' -f4)VERSION=$(echo "$DOWNLOAD_INFO" | grep -o '"version":"[^"]*"' | cut -d'"' -f4)
if [ -z "$DOWNLOAD_URL" ] || [ -z "$VERSION" ]; then echo "Error: Failed to parse download information" exit 1fi
echo "Downloading Cursor version ${VERSION}..."if ! curl -L -o cursor.AppImage "$DOWNLOAD_URL"; then echo "Error: Failed to download the Cursor AppImage" exit 1fi
chmod +x cursor.AppImage
echo "Updating Cursor..."mv /opt/cursor.appimage /opt/cursor.appimage.bakmv cursor.AppImage /opt/cursor.appimage
echo "Update complete! The previous version was backed up to /opt/cursor.appimage.bak"echo "You can now run the updated version of Cursor (version ${VERSION})"
# Cleanupcd /rm -rf "$TEMP_DIR"
I use Linux, so I developed these scripts for this Operating System (OS), but if you need them for a different OS, just let me know.
Check out more useful everyday scripts on my GitHub (albertosouza): 🔗 https://github.com/albertosouza/scripts