99# H# bash cvm.sh --use 0.40.4
1010# H#
1111# H# Notice*:
12- # H# The --download command uses an unofficial source for the AppImage.
13- # H# It is voluntarily made available by ivstiv at cursor-archive.ivstiv.dev
14- # H# If you want to use the official Cursor AppImage, you can use the
15- # H# --update or--install command to automatically download and install the latest version.
12+ # H# The AppImage files are downloaded from the official Cursor releases.
13+ # H# The list of download sources can be found at https://github.com/oslook/cursor-ai-downloads
1614# H#
1715# H# Options:
1816# H# --list-local Lists locally available versions
3533#
3634CURSOR_DIR=" $HOME /.local/share/cvm"
3735DOWNLOADS_DIR=" $CURSOR_DIR /app-images"
38- CVM_VERSION=" 1.1.2"
39-
36+ CVM_VERSION=" 1.2.0"
37+ _CACHE_FILE=" /tmp/cursor_versions.json"
38+ VERSION_HISTORY_URL=" https://raw.githubusercontent.com/oslook/cursor-ai-downloads/refs/heads/main/version-history.json"
4039
4140
4241#
@@ -46,11 +45,37 @@ help() {
4645 sed -rn ' s/^#H# ?//;T;p' " $0 "
4746}
4847
48+ getVersionHistory () {
49+ # Check if cache file exists and is less than 15 min old
50+ if [ -f " $_CACHE_FILE " ] && [ -n " $( find " $_CACHE_FILE " -mmin -15 2> /dev/null) " ]; then
51+ cat " $_CACHE_FILE "
52+ return 0
53+ fi
54+
55+ # Fetch JSON directly from remote and cache it
56+ # echo "Fetching version history..." >&2
57+ if wget -qO " $_CACHE_FILE .tmp" " $VERSION_HISTORY_URL " ; then
58+ mv " $_CACHE_FILE .tmp" " $_CACHE_FILE "
59+ cat " $_CACHE_FILE "
60+ return 0
61+ else
62+ rm -f " $_CACHE_FILE .tmp"
63+ echo " Error: Failed to fetch version history" >&2
64+ return 1
65+ fi
66+ }
67+
68+ getRemoteVersions () {
69+ getVersionHistory | \
70+ jq -r ' .versions[] | select(.platforms["linux-x64"] != null) | .version' \
71+ | sort -V
72+ }
73+
4974getLatestRemoteVersion () {
50- curl -s -r 0-0 \
51- https://downloader.cursor.sh/ linux/appImage/ x64 \
52- -o /dev/null -D - \
53- | grep -oP ' filename="cursor-\K[0-9.]+ '
75+ getVersionHistory | \
76+ jq -r ' .versions[] | select(.platforms[" linux- x64"] != null) | .version ' \
77+ | sort -V \
78+ | tail -n1
5479}
5580
5681getLatestLocalVersion () {
@@ -61,23 +86,20 @@ getLatestLocalVersion() {
6186 | head -n 1
6287}
6388
64- downloadLatest () {
65- version=$1 # e.g. 2.1.0
66- filename=" cursor-$version .AppImage"
67- url=" https://downloader.cursor.sh/linux/appImage/x64"
68- echo " Downloading Cursor $version ..."
69- curl -L " $url " -o " $DOWNLOADS_DIR /$filename "
70- chmod +x " $DOWNLOADS_DIR /$filename "
71- echo " Cursor $version downloaded to $DOWNLOADS_DIR /$filename "
72- }
73-
7489downloadVersion () {
7590 version=$1 # e.g. 2.1.0
76- remoteFilename=" cursor-$version " x86_64.AppImage
91+ if [ -z " $version " ]; then
92+ echo " Error: Version number is required, use \` cvm --list-remote\` to see available versions" >&2
93+ return 1
94+ fi
95+
7796 localFilename=" cursor-$version .AppImage"
78- url=" https://cursor-archive.ivstiv.dev/archive/linux-x64/$remoteFilename "
97+ url=$(
98+ getVersionHistory | \
99+ jq -r --arg v " $version " ' .versions[] | select(.version == $v and .platforms["linux-x64"] != null) | .platforms["linux-x64"]'
100+ )
79101 echo " Downloading Cursor $version ..."
80- curl -L " $url " -o " $ DOWNLOADS_DIR /$localFilename "
102+ wget -O " $DOWNLOADS_DIR /$localFilename " " $url "
81103 chmod +x " $DOWNLOADS_DIR /$localFilename "
82104 echo " Cursor $version downloaded to $DOWNLOADS_DIR /$localFilename "
83105}
@@ -110,18 +132,11 @@ exitIfVersionNotInstalled() {
110132 fi
111133}
112134
113- getRemoteVersions () {
114- curl -s https://cursor-archive.ivstiv.dev/archive/linux-x64/ |
115- grep -oP ' cursor-\K[0-9.]+(?=x86_64\.AppImage)' |
116- sort -V |
117- uniq
118- }
119-
120135installCVM () {
121136 latestRemoteVersion=$( getLatestRemoteVersion)
122137 latestLocalVersion=$( getLatestLocalVersion)
123138 if [ " $latestRemoteVersion " != " $latestLocalVersion " ]; then
124- downloadLatest " $latestRemoteVersion "
139+ downloadVersion " $latestRemoteVersion "
125140 fi
126141 selectVersion " $latestRemoteVersion "
127142
@@ -188,7 +203,7 @@ uninstallCVM() {
188203
189204checkDependencies () {
190205 mainShellPID=" $$ "
191- printf " sed\ncurl\ ngrep\n" | while IFS= read -r program; do
206+ printf " sed\ngrep\njq\nfind\nwget \n" | while IFS= read -r program; do
192207 if ! [ -x " $( command -v " $program " ) " ]; then
193208 echo " Error: $program is not installed." >&2
194209 kill -9 " $mainShellPID "
@@ -254,7 +269,7 @@ case "$1" in
254269 ;;
255270 --update)
256271 latestVersion=$( getLatestRemoteVersion)
257- downloadLatest " $latestVersion "
272+ downloadVersion " $latestVersion "
258273 selectVersion " $version "
259274 ;;
260275 --list-local)
@@ -300,6 +315,9 @@ case "$1" in
300315 if [ " $latestRemoteVersion " != " $latestLocalVersion " ]; then
301316 echo " There is a newer version available for download!"
302317 echo " You can activate the latest version with \` cvm --update\` "
318+ elif [ " $latestRemoteVersion " != " $activeVersion " ]; then
319+ echo " There is a newer version already installed!"
320+ echo " You can activate the latest version with \` cvm --use $latestRemoteVersion \` "
303321 else
304322 echo " Already up to date."
305323 fi
0 commit comments