-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall-cursor.sh
More file actions
executable file
·104 lines (82 loc) · 4.02 KB
/
install-cursor.sh
File metadata and controls
executable file
·104 lines (82 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# --- System-Wide Configuration ---
# We use standard FHS locations for system-wide installations.
INSTALL_DIR="/opt"
APP_DIR_NAME="Cursor-patched"
FINAL_APP_PATH="$INSTALL_DIR/$APP_DIR_NAME"
EXECUTABLE_SYMLINK="/usr/local/bin/cursor"
ICON_NAME="cursor-ai.png"
# Standard location for system-wide icons that are not part of a specific theme.
ICON_PATH="/usr/share/icons/hicolor/512x512/apps/$ICON_NAME"
ICON_URL="https://img.icons8.com/nolan/512/cursor-ai.png"
DESKTOP_ENTRY_NAME="cursor-patched.desktop"
DESKTOP_ENTRY_PATH="/usr/share/applications/$DESKTOP_ENTRY_NAME"
TEMP_DOWNLOAD_DIR=$(mktemp -d) # Create a temporary directory for downloads
# --- Permission Check ---
# This script must be run as root to write to system directories.
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root or with sudo."
exit 1
fi
# --- Dependencies ---
echo "--> Checking for dependencies (curl, wget, grep)..."
apt-get update > /dev/null
apt-get install -y curl wget libfuse2 > /dev/null
echo "--> Dependencies are satisfied."
# --- Installation ---
echo "--> Fetching the latest Cursor AppImage download link..."
# The API now returns HTML instead of JSON, so we need to extract the AppImage URL from the HTML response
LATEST_URL=$(curl -s 'https://cursor.com/api/download?platform=linux-x64&releaseTrack=latest' | grep -o 'https://downloads\.cursor\.com/[^"]*linux/x64/[^"]*\.AppImage' | head -1)
if [ -z "$LATEST_URL" ]; then
echo "Error: Failed to retrieve the AppImage download URL from the response. Aborting."
exit 1
fi
echo "--> Found AppImage URL: $LATEST_URL"
echo "--> Downloading the latest Cursor AppImage to a temporary directory..."
wget --show-progress -O "$TEMP_DOWNLOAD_DIR/Cursor.AppImage" "$LATEST_URL"
echo "--> Making the AppImage executable..."
chmod +x "$TEMP_DOWNLOAD_DIR/Cursor.AppImage"
# Clean up any previous installation
if [ -d "$FINAL_APP_PATH" ]; then
echo "--> Removing existing installation at $FINAL_APP_PATH..."
rm -rf "$FINAL_APP_PATH"
fi
echo "--> Extracting the AppImage to $FINAL_APP_PATH..."
(cd "$TEMP_DOWNLOAD_DIR" && ./Cursor.AppImage --appimage-extract)
mv "$TEMP_DOWNLOAD_DIR/squashfs-root" "$FINAL_APP_PATH"
echo "--> Patching product.json for MS Marketplace and Copilot..."
# ** CORRECTED PATH based on your feedback **
PRODUCT_JSON_PATH="$FINAL_APP_PATH/usr/share/cursor/resources/app/product.json"
if [ ! -f "$PRODUCT_JSON_PATH" ]; then
echo "Error: product.json not found at the expected path: $PRODUCT_JSON_PATH"
echo "The AppImage internal structure may have changed. Aborting."
exit 1
fi
# Patch 1: Replace Anysphere's marketplace with the official VSCode Marketplace
sed -i 's|"serviceUrl": "https://marketplace.cursorapi.com/_apis/public/gallery"|"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery"|g' "$PRODUCT_JSON_PATH"
sed -i 's|"itemUrl": "https://marketplace.cursorapi.com/items"|"itemUrl": "https://marketplace.visualstudio.com/items"|g' "$PRODUCT_JSON_PATH"
sed -i 's|"resourceUrlTemplate": "https://marketplace.cursorapi.com/{publisher}/{name}/{version}/{path}"|"resourceUrlTemplate": "https://{publisher}.vscode-unpkg.net/{publisher}/{name}/{version}/{path}"|g' "$PRODUCT_JSON_PATH"
echo "--> Installing system-wide icon to $ICON_PATH..."
mkdir -p "$(dirname "$ICON_PATH")"
wget -q -O "$ICON_PATH" "$ICON_URL"
gtk-update-icon-cache /usr/share/icons/hicolor || true
echo "--> Creating system-wide symlink for terminal access at $EXECUTABLE_SYMLINK..."
ln -sf "$FINAL_APP_PATH/AppRun" "$EXECUTABLE_SYMLINK"
echo "--> Creating system-wide desktop entry at $DESKTOP_ENTRY_PATH..."
cat > "$DESKTOP_ENTRY_PATH" <<EOL
[Desktop Entry]
Name=Cursor (Patched)
Comment=The AI-first Code Editor
Icon=$ICON_NAME
StartupWMClass=Cursor
Exec=$EXECUTABLE_SYMLINK
Type=Application
Categories=Development;IDE;
Terminal=false
EOL
chmod 644 "$DESKTOP_ENTRY_PATH"
rm -rf "$TEMP_DOWNLOAD_DIR"
echo ""
echo "✅ Installation complete."
echo "✅ Cursor is now installed system-wide."
echo "You can now run 'cursor' from any terminal or find 'Cursor (Patched)' in your applications menu."