Skip to content

Instantly share code, notes, and snippets.

@Kinyugo
Last active April 18, 2025 06:20
Show Gist options
  • Save Kinyugo/9845e18998744ff54b8f0cde3bb37182 to your computer and use it in GitHub Desktop.
Save Kinyugo/9845e18998744ff54b8f0cde3bb37182 to your computer and use it in GitHub Desktop.
Cursor AI IDE Installer and Updater Script
#!/bin/bash
installCursor() {
local CURSOR_URL="https://downloader.cursor.sh/linux/appImage/x64"
local ICON_URL="https://miro.medium.com/v2/resize:fit:700/1*YLg8VpqXaTyRHJoStnMuog.png"
local APPIMAGE_PATH="/opt/cursor.appimage"
local ICON_PATH="/opt/cursor.png"
local DESKTOP_ENTRY_PATH="/usr/share/applications/cursor.desktop"
echo "Checking for existing Cursor installation..."
# Detect the user's shell
local SHELL_NAME=$(basename "$SHELL")
local RC_FILE=""
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"
echo "Please manually add the alias to your shell configuration file."
return 1
;;
esac
# 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
# Install curl if not installed
if ! command -v curl &> /dev/null; then
echo "curl is not installed. Installing..."
sudo apt-get update
sudo apt-get install -y curl || { echo "Failed to install curl."; exit 1; }
fi
# 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
# Cursor alias
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 to reload the shell
echo "To apply changes, please restart your terminal or run the following command:"
echo " source $RC_FILE"
echo "Cursor AI IDE installation or update complete. You can find it in your application menu."
}
installCursor

Cursor AI IDE Installer and Updater Script

Description:

This script installs or updates the Cursor AI IDE on Linux systems. It downloads the AppImage, sets up an application menu entry, and adds a shell alias (cursor) for easy usage. The script supports multiple shells (bash, zsh, fish) and gracefully handles updates.

Features:

  • Downloads and installs the Cursor AI IDE AppImage and icon.
  • Adds a .desktop entry for the system's application menu.
  • Configures an alias for quick access (cursor).
  • Automatically detects the user's shell and modifies the appropriate configuration file.
  • Allows overwriting the existing installation for updates.

Prerequisites:

  • Some users have reported crashes due to compatibility issues with other versions of libfuse. To prevent this, ensure you have libfuse2 installed by running:

    sudo apt install libfuse2

Instructions:

  1. Copy the script into a file, e.g., install_cursor.sh.

    curl https://gist.githubusercontent.com/Kinyugo/9845e18998744ff54b8f0cde3bb37182/raw/a9425582958c14f80acea08e51c49b1bf63840c7/install_cursor.sh

    or

    wget https://gist.githubusercontent.com/Kinyugo/9845e18998744ff54b8f0cde3bb37182/raw/a9425582958c14f80acea08e51c49b1bf63840c7/install_cursor.sh
  2. Make the script executable:

    chmod +x install_cursor.sh
  3. Run the script

    ./install_cursor.sh
  4. Restart your terminal or run the following command:

    source /path/to/terminal/config
@odilson-dev
Copy link

Thank you @Kinyugo but this script didn't help me much
After running the script, it has just installed the version 0.45 of cursor while the v.48 is already out. I don't know what went wrong, I need some help to upgrade my Cursor.

@gaswirth
Copy link

Hiya @odilson-dev -- it's not the script that's not working, it's something with the Cursor "latest" link (https://downloader.cursor.sh/linux/appImage/x64). For some reason, even though newer versions have been released, this link consistently pulls down 0.45.

This repo keeps an up-to-date list of the latest Cursor releases. If you replace the CURSOR_URL var in this script with the latest Linux link (or whatever version you'd like) in the script, you'll be in business.

In my fork of this script, I've added a prompt to replace the default URL with another for ease of use, with a fallback to the existing "latest" URL if none is provided.

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