Skip to content

Instantly share code, notes, and snippets.

@ahmedsomaa
Created March 15, 2025 12:32
Show Gist options
  • Select an option

  • Save ahmedsomaa/50722ddf1e81ec8f464371d8be8bfb8e to your computer and use it in GitHub Desktop.

Select an option

Save ahmedsomaa/50722ddf1e81ec8f464371d8be8bfb8e to your computer and use it in GitHub Desktop.
#!/bin/bash
installCursor() {
if ! [ -f /opt/cursor/cursor.appimage ]; then
echo "Installing Cursor AI IDE..."
# Check for sudo privileges
if [ "$(id -u)" -ne 0 ]; then
echo "This script needs sudo privileges to install Cursor AI."
echo "Please run with: sudo $0"
return 1
fi
# URLs for Cursor AppImage and Icon
CURSOR_URL="https://downloader.cursor.sh/linux/appImage/x64"
ICON_URL="https://paulstamatiou.com/gear/cursor-app-icon.png"
# Paths for installation
APP_DIR="/opt/cursor"
APPIMAGE_PATH="$APP_DIR/cursor.appimage"
ICON_PATH="$APP_DIR/cursor.png"
DESKTOP_ENTRY_PATH="/usr/share/applications/cursor.desktop"
# Create application directory if it doesn't exist
mkdir -p $APP_DIR
# Install curl if not installed
if ! command -v curl &> /dev/null; then
echo "curl is not installed. Installing..."
dnf install -y curl
fi
# Download Cursor AppImage
echo "Downloading Cursor AppImage..."
if ! curl -L $CURSOR_URL -o $APPIMAGE_PATH; then
echo "Failed to download Cursor AppImage. Please check your internet connection."
return 1
fi
chmod +x $APPIMAGE_PATH
# Download Cursor icon
echo "Downloading Cursor icon..."
if ! curl -L $ICON_URL -o $ICON_PATH; then
echo "Failed to download Cursor icon, but continuing installation."
fi
# Create a .desktop entry for Cursor
echo "Creating .desktop entry for Cursor..."
cat > $DESKTOP_ENTRY_PATH <<EOL
[Desktop Entry]
Name=Cursor
Exec=$APPIMAGE_PATH --no-sandbox
Icon=$ICON_PATH
Type=Application
Categories=Development;
EOL
echo "Adding cursor alias to .bashrc..."
if [ -f "$HOME/.bashrc" ]; then
cat >> $HOME/.bashrc <<EOL
# Cursor alias
function cursor() {
$APPIMAGE_PATH --no-sandbox "\${@}" > /dev/null 2>&1 & disown
}
EOL
echo "Alias added. To use it in this terminal session, run: source $HOME/.bashrc"
else
echo "Could not find .bashrc file. Cursor can still be launched from the application menu."
fi
echo "Cursor AI IDE installation complete. You can find it in your application menu."
else
echo "Cursor AI IDE is already installed."
fi
}
installCursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment