Skip to content

Instantly share code, notes, and snippets.

@qasedak
Forked from Kinyugo/install_cursor.sh
Last active October 7, 2025 13:09
Show Gist options
  • Select an option

  • Save qasedak/fd073a20b617112bdb9d604fdd9aa5e4 to your computer and use it in GitHub Desktop.

Select an option

Save qasedak/fd073a20b617112bdb9d604fdd9aa5e4 to your computer and use it in GitHub Desktop.
Cursor AI IDE Installer/Updater and Uninstaller Script
#!/bin/bash
# Define variables
APPIMAGE_PATH="/opt/cursor.appimage"
ICON_PATH="/opt/cursor.png"
DESKTOP_ENTRY_PATH="/usr/share/applications/cursor.desktop"
# Determine the shell and RC file
SHELL_NAME=$(basename "$SHELL")
case "$SHELL_NAME" in
bash)
RC_FILE="$HOME/.bashrc"
;;
zsh)
RC_FILE="$HOME/.zshrc"
;;
fish)
RC_FILE="$HOME/.config/fish/config.fish"
;;
*)
echo "Unsupported shell: $SHELL_NAME"
exit 1
;;
esac
# Function to install or update Cursor AI IDE
installCursor() {
# Fetch the latest version from GitHub repository
echo "Fetching latest Cursor version information..."
local GITHUB_INFO=$(curl -s "https://raw.githubusercontent.com/oslook/cursor-ai-downloads/main/README.md")
# Get latest version by finding the first Linux AppImage file name
local CURSOR_VERSION=$(echo "$GITHUB_INFO" | grep -o 'Cursor-[0-9.]\+-x86_64.AppImage' | head -1 | cut -d'-' -f2)
# Extract clean URL by looking for the download link that ends with AppImage
local CURSOR_URL=$(echo "$GITHUB_INFO" | grep -o 'https://downloads.cursor.com/production/[^"]*\.AppImage' | head -1)
if [ -z "$CURSOR_URL" ]; then
echo "Error: Failed to fetch download URL. Please check your internet connection."
exit 1
fi
echo "Found latest Cursor version: $CURSOR_VERSION"
echo "Download URL: $CURSOR_URL"
local ICON_URL="https://registry.npmmirror.com/@lobehub/icons-static-png/1.13.0/files/light/cursor.png"
echo "Checking for existing Cursor installation..."
# Notify if updating an existing installation
if [ -f "$APPIMAGE_PATH" ]; then
echo "Cursor AI IDE is already installed. Updating existing installation..."
else
echo "Performing a fresh installation of Cursor AI IDE..."
fi
# Ensure required packages are installed
for package in curl libfuse2; do
if ! dpkg -s $package >/dev/null 2>&1; then
echo "$package is not installed. Installing..."
if ! sudo apt-get update; then
echo "Failed to update package list."
exit 1
fi
if ! sudo apt-get install -y $package; then
echo "Failed to install $package."
exit 1
fi
fi
done
# Download AppImage and Icon
echo "Downloading Cursor AppImage..."
curl -L "$CURSOR_URL" -o /tmp/cursor.appimage || { echo "Failed to download AppImage."; exit 1; }
echo "Downloading Cursor icon..."
curl -L "$ICON_URL" -o /tmp/cursor.png || { echo "Failed to download icon."; exit 1; }
# Move to final destination
echo "Installing Cursor files..."
sudo mv /tmp/cursor.appimage "$APPIMAGE_PATH"
sudo chmod +x "$APPIMAGE_PATH"
sudo mv /tmp/cursor.png "$ICON_PATH"
# Create a .desktop entry
echo "Creating .desktop entry..."
sudo bash -c "cat > $DESKTOP_ENTRY_PATH" <<EOL
[Desktop Entry]
Name=Cursor AI IDE
Exec=$APPIMAGE_PATH --no-sandbox
Icon=$ICON_PATH
Type=Application
Categories=Development;
EOL
# Add alias to the appropriate RC file
echo "Adding cursor alias to $RC_FILE..."
if [ "$SHELL_NAME" = "fish" ]; then
# Fish shell uses a different syntax for functions
if ! grep -q "function cursor" "$RC_FILE"; then
echo "function cursor" >> "$RC_FILE"
echo " /opt/cursor.appimage --no-sandbox \$argv > /dev/null 2>&1 & disown" >> "$RC_FILE"
echo "end" >> "$RC_FILE"
else
echo "Alias already exists in $RC_FILE."
fi
else
if ! grep -q "function cursor" "$RC_FILE"; then
cat >> "$RC_FILE" <<EOL
function cursor() {
/opt/cursor.appimage --no-sandbox "\$@" > /dev/null 2>&1 & disown
}
EOL
else
echo "Alias already exists in $RC_FILE."
fi
fi
# Inform the user about the installation completion
echo "Installation complete! You can now run Cursor by:"
echo "1. Using the application launcher"
echo "2. Running 'cursor' in terminal (after restarting your shell)"
# Inform the user to reload the shell
echo "To apply changes, please restart your terminal or run the following command:"
echo " source $RC_FILE"
# Clean up unused dependencies
sudo apt autoremove -y
echo "Cursor AI IDE installation or update complete. You can find it in your application menu."
}
# Function to uninstall Cursor AI IDE
uninstallCursor() {
echo "Uninstalling Cursor AI IDE..."
# Remove AppImage and icon
echo "Removing application files..."
sudo rm -f "$APPIMAGE_PATH"
sudo rm -f "$ICON_PATH"
# Remove .desktop entry
echo "Removing desktop entry..."
sudo rm -f "$DESKTOP_ENTRY_PATH"
# Remove configuration and cache
echo "Removing user configuration and cache..."
rm -rf ~/.config/Cursor
rm -rf ~/.cache/cursor-updater
# Remove alias from the appropriate RC file
echo "Removing shell integration..."
if [ "$SHELL_NAME" = "fish" ]; then
sed -i '/function cursor/,/end/d' "$RC_FILE"
else
sed -i '/function cursor {/,/}/d' "$RC_FILE"
fi
echo "Cursor AI IDE has been completely uninstalled."
}
# Dialog to choose between install/update or uninstall
echo "Choose an option:"
echo "1. Install/Update Cursor AI IDE"
echo "2. Uninstall Cursor AI IDE"
read -p "Enter your choice [1-2]: " choice
case $choice in
1)
installCursor
;;
2)
uninstallCursor
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac

Cursor AI IDE Installer and Uninstaller Script

Description

This script manages the installation, updating, and removal of Cursor AI IDE on Linux systems. It provides an interactive menu to either install/update or uninstall the application.

Features

  • Interactive menu for installation/update or uninstallation
  • Downloads and installs the Cursor AI IDE AppImage and icon
  • Creates application menu entry for system-wide access
  • Supports multiple shells (bash, zsh, fish)
  • Adds shell function for command-line access (cursor)
  • Handles dependencies (curl, libfuse2) automatically
  • Provides clean uninstallation option
  • Dynamic download URL for cursor

Prerequisites

  • Linux-based operating system
  • sudo privileges
  • Internet connection
  • One of the supported shells: bash, zsh, or fish

Installation Instructions

  1. Copy the script into a file named install_cursor.sh
  2. Make the script executable:
    chmod +x install_cursor.sh
  3. Run the script:
./install_cursor.sh
  1. Choose option 1 to install/update or 2 to uninstall
  2. After installation, either restart your terminal or source your shell config:
  • For bash: source ~/.bashrc
  • For zsh: source ~/.zshrc
  • For fish: source ~/.config/fish/config.fish

Usage

After installation, you can launch Cursor AI IDE in two ways:

  1. Through your system's application menu (search for "Cursor AI IDE")
  2. Using the terminal command: cursor

Uninstallation

  1. Run the script:
  2. Choose option 2 to uninstall
  3. The script will remove:
  • The AppImage file
  • The application icon
  • The desktop entry
  • The shell function
  • The configuration and cache
@qasedak
Copy link
Author

qasedak commented May 27, 2025

Cursor Image download Url is not works anymore: https://downloader.cursor.sh/linux/appImage/x64

the problem is fixed... two methods provided to be safe

@shahaj90
Copy link

shahaj90 commented Jun 2, 2025

Thanks. It's working fine. I used options 2

@qasedak
Copy link
Author

qasedak commented Jun 3, 2025

Thanks. It's working fine. I used options 2

so you didn't like cursor ai? :)

@shahaj90
Copy link

shahaj90 commented Jun 4, 2025

Thanks. It's working fine. I used options 2

so you didn't like cursor ai? :)

I don't use cursor ai. I installed for experiment. Normally I use vs code and void editor. But cursor is good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment