Skip to content

Instantly share code, notes, and snippets.

@githubdebugger
Created August 25, 2024 18:58
Show Gist options
  • Save githubdebugger/67ce7cfbfe786c53fb637f636fe0c4f1 to your computer and use it in GitHub Desktop.
Save githubdebugger/67ce7cfbfe786c53fb637f636fe0c4f1 to your computer and use it in GitHub Desktop.
cursor.sh
#!/usr/bin/bash
# Check if the "--clean" or "--install" argument is provided
if [ "$1" == "--clean" ]; then
# Clean installation
echo "Deleting Cursor files..."
if [ -d ~/.cursor ] || [ -d ~/.config/Cursor ] || [ -d ~/.cache/cursor-updater ]; then
rm -rf ~/.cursor
rm -rf ~/.config/Cursor
rm -rf ~/.cache/cursor-updater
echo "User-specific Cursor files deleted."
else
echo "No user-specific Cursor files found."
fi
if [ -d /opt/cursor ]; then
sudo rm -rf /opt/cursor
echo "System-wide Cursor files deleted."
else
echo "No system-wide Cursor files found."
fi
exit 0
elif [ "$1" == "--install" ]; then
# Clean installation and proceed with fresh install
echo "Deleting user-specific Cursor files..."
rm -rf ~/.cursor ~/.config/Cursor ~/.cache/cursor-updater
echo "Deleting system-wide Cursor files..."
sudo rm -rf /opt/cursor
shift
else
# No cleaning, proceed with normal installation
shift
fi
# Check if the URL is provided as an argument
if [ $# -eq 0 ]; then
URL="https://downloader.cursor.sh/linux/appImage/x64"
elif [ $# -eq 1 ]; then
URL=$1
else
echo "Invalid arguments"
exit 1
fi
# Create the cursor directory under /opt if it does not exist
sudo mkdir -p /opt/cursor
# Download the Cursor AppImage
if ! sudo curl -o /opt/cursor/cursor.AppImage $URL; then
sudo curl -o /opt/cursor/cursor.AppImage https://downloader.cursor.sh/linux/appImage/x64
fi
# Download the Cursor icon
sudo curl -o /opt/cursor/cursor.svg https://sourcegraph.com/assets/compare/cursor.svg || sudo curl -o /opt/cursor/cursor.svg https://blog.mlq.ai/content/images/2024/01/icon-1.svg
# Make the file executable
sudo chmod +x /opt/cursor/cursor.AppImage
# Check if FUSE is installed and install if not
if ! dpkg -s fuse &> /dev/null; then
sudo apt-get update
sudo apt-get install -y fuse
fi
# Run the AppImage - have commented this out
# /opt/cursor/cursor.AppImage
# Create a desktop entry for Cursor
echo "[Desktop Entry]
Name=Cursor
GenericName=Cursor
Exec=/opt/cursor/cursor.AppImage
Icon=/opt/cursor/cursor.svg
Type=Application
Categories=Programming;Development;
StartupNotify=true
Terminal=false
MimeType=application/x-executable
X-AppImage-Version=1.0.0
X-AppImage-BuildId=abcdefghijklmnopqrstuvwxyz" | sudo tee /usr/share/applications/cursor.desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment