|
8 | 8 | #H# ./cvm.sh --check |
9 | 9 | #H# bash cvm.sh --use 0.40.4 |
10 | 10 | #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# |
11 | 17 | #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 |
22 | 30 |
|
23 | 31 |
|
24 | 32 |
|
|
27 | 35 | # |
28 | 36 | CURSOR_DIR="$HOME/.local/share/cvm" |
29 | 37 | DOWNLOADS_DIR="$CURSOR_DIR/app-images" |
30 | | -CVM_VERSION="1.0.0" |
| 38 | +CVM_VERSION="1.1.0" |
31 | 39 |
|
32 | 40 |
|
33 | 41 |
|
@@ -63,6 +71,17 @@ downloadLatest() { |
63 | 71 | echo "Cursor $version downloaded to $DOWNLOADS_DIR/$filename" |
64 | 72 | } |
65 | 73 |
|
| 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 | + |
66 | 85 | selectVersion() { |
67 | 86 | version=$1 # e.g. 2.1.0 |
68 | 87 | filename="cursor-$version.AppImage" |
@@ -91,6 +110,13 @@ exitIfVersionNotInstalled() { |
91 | 110 | fi |
92 | 111 | } |
93 | 112 |
|
| 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 | + |
94 | 120 | installCVM() { |
95 | 121 | latestRemoteVersion=$(getLatestRemoteVersion) |
96 | 122 | latestLocalVersion=$(getLatestLocalVersion) |
@@ -216,6 +242,31 @@ case "$1" in |
216 | 242 | | grep -oP 'cursor-\K[0-9.]+(?=\.)' \ |
217 | 243 | | sed 's/^/ - /' |
218 | 244 | ;; |
| 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 | + ;; |
219 | 270 | --check) |
220 | 271 | latestRemoteVersion=$(getLatestRemoteVersion) |
221 | 272 | latestLocalVersion=$(getLatestLocalVersion) |
@@ -245,7 +296,7 @@ case "$1" in |
245 | 296 | selectVersion "$version" |
246 | 297 | ;; |
247 | 298 | --remove) |
248 | | - version=$2 |
| 299 | + version=$2c |
249 | 300 | if [ -z "$version" ]; then |
250 | 301 | echo "Usage: $0 --remove <version>" |
251 | 302 | exit 1 |
|
0 commit comments