This repository was archived by the owner on Feb 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·175 lines (148 loc) · 5.55 KB
/
install.sh
File metadata and controls
executable file
·175 lines (148 loc) · 5.55 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print status messages
print_status() {
echo -e "${BLUE}==>${NC} $1"
}
# Function to print success messages
print_success() {
echo -e "${GREEN}==>${NC} $1"
}
# Function to print error messages
print_error() {
echo -e "${RED}==>${NC} $1"
}
# Function to print warning messages
print_warning() {
echo -e "${YELLOW}==>${NC} $1"
}
# Function to get latest download URL
get_latest_url() {
# Define the API endpoint
local api_endpoint="https://www.cursor.com/api/download?platform=linux-x64&releaseTrack=stable"
# Fetch the JSON response and extract the downloadUrl
local download_url=$(curl -s "$api_endpoint" | grep -o '"downloadUrl":"[^"]*' | cut -d'"' -f4)
# Return the download URL
echo "$download_url"
}
# Function to handle script cleanup
cleanup() {
local exit_code=$?
if [ $exit_code -ne 0 ]; then
print_error "Installation failed with exit code $exit_code"
fi
# Remove temporary directory if it exists
if [ -n "$TEMP_DIR" ] && [ -d "$TEMP_DIR" ]; then
rm -rf "$TEMP_DIR"
fi
exit $exit_code
}
# Set up trap for cleanup
trap cleanup EXIT
# Main installation function
main() {
# Print welcome message
echo -e "\n${BLUE}╔══════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║${NC} ${GREEN}Cursor Installation Script${NC} ${BLUE}║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════════════════════╝${NC}\n"
# Check if running as root
if [ "$EUID" -ne 0 ]; then
print_error "Please run as root (use sudo)"
exit 1
fi
# Check if cursor is installed in /opt/cursor
if [ -d "/opt/cursor" ]; then
print_warning "Cursor is already installed"
read -p "Do you want to overwrite it? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_status "Installation cancelled"
exit 0
fi
fi
# Create temporary directory
print_status "Creating temporary directory..."
TEMP_DIR=$(mktemp -d)
# Get download URL
print_status "Getting download URL..."
DOWNLOAD_URL=$(get_latest_url)
if [ $? -ne 0 ]; then
print_error "Failed to get download URL"
exit 1
fi
# Download the AppImage
print_status "Downloading Cursor..."
curl -L --progress-bar "$DOWNLOAD_URL" -o "$TEMP_DIR/cursor.AppImage"
if [ $? -ne 0 ]; then
print_error "Failed to download Cursor"
exit 1
fi
# Download the icon
print_status "Downloading Cursor icon..."
curl -L --progress-bar "https://www.cursor.com/apple-touch-icon.png" -o "$TEMP_DIR/cursor.png"
if [ $? -ne 0 ]; then
print_error "Failed to download icon"
exit 1
fi
# Create /opt/cursor directory
print_status "Creating installation directory..."
mkdir -p /opt/cursor
# Move the AppImage and icon to /opt/cursor
print_status "Installing files..."
mv "$TEMP_DIR/cursor.AppImage" /opt/cursor/
mv "$TEMP_DIR/cursor.png" /opt/cursor/
# Make the AppImage executable
print_status "Setting up permissions..."
chmod +x /opt/cursor/cursor.AppImage
# Create symlink in /usr/local/bin
print_status "Creating command-line symlink..."
ln -sf /opt/cursor/cursor.AppImage /usr/local/bin/cursor
# Create desktop entry
print_status "Creating desktop entry..."
cat > /usr/share/applications/cursor.desktop << EOL
[Desktop Entry]
Name=Cursor
Comment=AI-first code editor
Exec=/opt/cursor/cursor.AppImage --ozone-platform-hint=auto
Icon=/opt/cursor/cursor.png
Terminal=false
Type=Application
Categories=Development;TextEditor;IDE;
StartupWMClass=Cursor
[Desktop Action new-empty-window]
Name=New Empty Window
Name[cs]=Nové prázdné okno
Name[de]=Neues leeres Fenster
Name[es]=Nueva ventana vacía
Name[fr]=Nouvelle fenêtre vide
Name[it]=Nuova finestra vuota
Name[ja]=新しい空のウィンドウ
Name[ko]=새 빈 창
Name[ru]=Новое пустое окно
Name[zh_CN]=新建空窗口
Name[zh_TW]=開新空視窗
Exec=/opt/cursor/cursor.AppImage --ozone-platform-hint=auto --new-window %F
Icon=/opt/cursor/cursor.png
Terminal=false
Type=Application
Categories=Development;TextEditor;IDE;
StartupWMClass=Cursor
EOL
# Extract version from download URL and create version.txt
VERSION=$(echo "$DOWNLOAD_URL" | grep -o 'Cursor-[0-9.]*-x86_64' | cut -d'-' -f2)
echo "$VERSION" > /opt/cursor/version.txt
# Print success message
echo -e "\n${GREEN}╔══════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║${NC} ${GREEN}Installation Complete!${NC} ${GREEN}║${NC}"
echo -e "${GREEN}╚══════════════════════════════════════════════════════════╝${NC}\n"
print_success "Cursor has been successfully installed!"
print_status "Version: $VERSION"
print_status "You can now launch Cursor from your applications menu or by typing 'cursor' in your terminal"
}
# Execute main function
main "$@"