Skip to content

Commit ceb59ee

Browse files
committed
Adding --download functionality of older versions
1 parent 8cdbf5a commit ceb59ee

File tree

2 files changed

+81
-22
lines changed

2 files changed

+81
-22
lines changed

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ Examples:
2929
./cvm.sh --check
3030
bash cvm.sh --use 0.40.4
3131
32+
Notice*:
33+
The --download command uses an unofficial source for the AppImage.
34+
It is voluntarily made available by ivstiv at cursor-archive.ivstiv.dev
35+
If you want to use the official Cursor AppImage, you can use the
36+
--update or--install command to automatically download and install the latest version.
37+
3238
Options:
33-
--list-local Lists locally available versions
34-
--check Check latest versions available for download
35-
--update Downloads and selects the latest version
36-
--use <version> Selects a locally available version
37-
--active Shows the currently selected version
38-
--remove <version> Removes a locally available version
39-
--install Adds an alias `cursor` and downloads the latest version
40-
--uninstall Removes the Cursor version manager directory and alias
41-
-v --version Shows the script version
42-
-h --help Shows this message
39+
--list-local Lists locally available versions
40+
--list-remote Lists versions available for download
41+
--download <version> Downloads a version
42+
--check Check latest versions available for download
43+
--update Downloads and selects the latest version
44+
--use <version> Selects a locally available version
45+
--active Shows the currently selected version
46+
--remove <version> Removes a locally available version
47+
--install Adds an alias `cursor` and downloads the latest version
48+
--uninstall Removes the Cursor version manager directory and alias
49+
-v --version Shows the script version
50+
-h --help Shows this message
4351
```

cvm.sh

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@
88
#H# ./cvm.sh --check
99
#H# bash cvm.sh --use 0.40.4
1010
#H#
11+
#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.
16+
#H#
1117
#H# Options:
12-
#H# --list-local Lists locally available versions
13-
#H# --check Check latest versions available for download
14-
#H# --update Downloads and selects the latest version
15-
#H# --use <version> Selects a locally available version
16-
#H# --active Shows the currently selected version
17-
#H# --remove <version> Removes a locally available version
18-
#H# --install Adds an alias `cursor` and downloads the latest version
19-
#H# --uninstall Removes the Cursor version manager directory and alias
20-
#H# -v --version Shows the script version
21-
#H# -h --help Shows this message
18+
#H# --list-local Lists locally available versions
19+
#H# --list-remote Lists versions available for download
20+
#H# --download <version> Downloads a version
21+
#H# --check Check latest versions available for download
22+
#H# --update Downloads and selects the latest version
23+
#H# --use <version> Selects a locally available version
24+
#H# --active Shows the currently selected version
25+
#H# --remove <version> Removes a locally available version
26+
#H# --install Adds an alias `cursor` and downloads the latest version
27+
#H# --uninstall Removes the Cursor version manager directory and alias
28+
#H# -v --version Shows the script version
29+
#H# -h --help Shows this message
2230

2331

2432

@@ -27,7 +35,7 @@
2735
#
2836
CURSOR_DIR="$HOME/.local/share/cvm"
2937
DOWNLOADS_DIR="$CURSOR_DIR/app-images"
30-
CVM_VERSION="1.0.0"
38+
CVM_VERSION="1.1.0"
3139

3240

3341

@@ -63,6 +71,17 @@ downloadLatest() {
6371
echo "Cursor $version downloaded to $DOWNLOADS_DIR/$filename"
6472
}
6573

74+
downloadVersion() {
75+
version=$1 # e.g. 2.1.0
76+
remoteFilename="cursor-$version"x86_64.AppImage
77+
localFilename="cursor-$version.AppImage2"
78+
url="https://cursor-archive.ivstiv.dev/archive/linux-x64/$remoteFilename"
79+
echo "Downloading Cursor $version..."
80+
curl -L "$url" -o "$DOWNLOADS_DIR/$localFilename"
81+
chmod +x "$DOWNLOADS_DIR/$localFilename"
82+
echo "Cursor $version downloaded to $DOWNLOADS_DIR/$localFilename"
83+
}
84+
6685
selectVersion() {
6786
version=$1 # e.g. 2.1.0
6887
filename="cursor-$version.AppImage"
@@ -91,6 +110,13 @@ exitIfVersionNotInstalled() {
91110
fi
92111
}
93112

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+
94120
installCVM() {
95121
latestRemoteVersion=$(getLatestRemoteVersion)
96122
latestLocalVersion=$(getLatestLocalVersion)
@@ -216,6 +242,31 @@ case "$1" in
216242
| grep -oP 'cursor-\K[0-9.]+(?=\.)' \
217243
| sed 's/^/ - /'
218244
;;
245+
--list-remote)
246+
echo "Remote versions:"
247+
getRemoteVersions | sed 's/^/ - /'
248+
;;
249+
--download)
250+
version=$2
251+
if [ -z "$version" ]; then
252+
echo "Usage: $0 --download <version>"
253+
exit 1
254+
fi
255+
256+
# check if version is available for download
257+
if ! getRemoteVersions | grep -q "^$version\$"; then
258+
echo "Version $version not found for download."
259+
exit 1
260+
fi
261+
262+
# check if version is already downloaded
263+
if [ -f "$DOWNLOADS_DIR/cursor-$version.AppImage" ]; then
264+
echo "Version $version already downloaded."
265+
else
266+
downloadVersion "$version"
267+
fi
268+
echo "To select the downloaded version, run \`cvm --use $version\`"
269+
;;
219270
--check)
220271
latestRemoteVersion=$(getLatestRemoteVersion)
221272
latestLocalVersion=$(getLatestLocalVersion)
@@ -245,7 +296,7 @@ case "$1" in
245296
selectVersion "$version"
246297
;;
247298
--remove)
248-
version=$2
299+
version=$2c
249300
if [ -z "$version" ]; then
250301
echo "Usage: $0 --remove <version>"
251302
exit 1

0 commit comments

Comments
 (0)