Skip to content

Instantly share code, notes, and snippets.

@Kinyugo
Last active April 26, 2025 13:14
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
@el22or
Copy link

el22or commented Apr 26, 2025

Some fixes — see my fork.

If nececessary, please run the command below.

curl https://gist.githubusercontent.com/markruler/2820bd05d613c61dac906814a4e282b7/raw/install_cursor.sh | sh
# source ~/.bashrc
# cursor

I only changed two lines in the script.

+ local response=$(curl -s "https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=stable")
+ local CURSOR_URL=$(echo "$response" | jq -r '.downloadUrl')
- local CURSOR_URL="https://downloader.cursor.sh/linux/appImage/x64"

Hi @markruler,

The help and effort is very much appreciated, thank you so much!

I must also say that linking or making a commands that would run a code from your repo and putting it in this repo (which is not mine and I do not know a person who owns it) is not nice in one perspective, and not secure for the end user from other perspective. Many people will not check for the code they would run by using the command you have posted.

The correct way would be to fork a repo, make a change, create pull request to the original repo, and make a post once the code is merged.

I have nothing against you, I just want to point out the concern about security and author's feelings.

Hope you understand.

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