From 7fee3b3cb68bec537841ef84e057a52e77492e46 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Fri, 9 May 2025 12:10:49 +0300 Subject: [PATCH 01/15] fix: typo in --remove flag --- cvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvm.sh b/cvm.sh index bef8609..d128b89 100755 --- a/cvm.sh +++ b/cvm.sh @@ -443,7 +443,7 @@ case "$1" in selectVersion "$version" ;; --remove) - version=$2c + version=$2 if [ -z "$version" ]; then echo "Usage: $0 --remove " exit 1 From 43b49bc6dc02040b6f7080d5d56d1cc4e090c9b2 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Fri, 9 May 2025 12:11:38 +0300 Subject: [PATCH 02/15] feat: enhance --update functionality for version management - Added checks to determine if the latest version is already downloaded and active. - Improved user feedback for version switching and downloading processes. --- cvm.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cvm.sh b/cvm.sh index d128b89..cae679d 100755 --- a/cvm.sh +++ b/cvm.sh @@ -393,9 +393,25 @@ case "$1" in fi ;; --update) - latestVersion=$(getLatestRemoteVersion) - downloadVersion "$latestVersion" - selectVersion "$version" + latestRemoteVersion=$(getLatestRemoteVersion) + activeVersion=$(getActiveVersion 2>/dev/null || echo "None") + + if [ "$latestRemoteVersion" = "$activeVersion" ]; then + print_color "$GREEN" "You are already running the latest version: $activeVersion" + exit 0 + fi + + localFileForLatest="$DOWNLOADS_DIR/cursor-$latestRemoteVersion.AppImage" + if [ -f "$localFileForLatest" ]; then + echo "Latest version $latestRemoteVersion is already downloaded." + selectVersion "$latestRemoteVersion" + print_color "$GREEN" "Switched to version $latestRemoteVersion." + else + echo "Downloading latest version $latestRemoteVersion..." + downloadVersion "$latestRemoteVersion" + selectVersion "$latestRemoteVersion" + print_color "$GREEN" "Downloaded and switched to version $latestRemoteVersion." + fi ;; --list-local) echo "Locally available versions:" From 1c05dc83a1413a2787f5a509d40ab4fc7d4ccd72 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 22:57:25 +0300 Subject: [PATCH 03/15] refactor: changed the shebang from sh to bash for better compatibility. - Added error handling with 'set -euo pipefail' and a user-friendly interrupt message. --- cvm.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cvm.sh b/cvm.sh index cae679d..f6fc295 100755 --- a/cvm.sh +++ b/cvm.sh @@ -1,4 +1,7 @@ -#!/bin/sh +#!/bin/bash + +set -euo pipefail +trap 'printf "\nScript interrupted by user.\n"; exit 130' INT TERM #H# #H# cvm.sh — Cursor version manager From 51d453d0f025e3edb293ba500e2bb8e0dfb799b5 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 22:58:42 +0300 Subject: [PATCH 04/15] fix: improve local version listing and error handling --- cvm.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cvm.sh b/cvm.sh index f6fc295..181c386 100755 --- a/cvm.sh +++ b/cvm.sh @@ -122,10 +122,11 @@ getLatestRemoteVersion() { getLatestLocalVersion() { # shellcheck disable=SC2010 - ls -1 "$DOWNLOADS_DIR" \ + ls -1 "$DOWNLOADS_DIR" 2>/dev/null \ | grep -oP 'cursor-\K[0-9.]+(?=\.)' \ - | sort -r \ - | head -n 1 + | sort -V -r \ + | head -n 1 \ + || true } downloadVersion() { From e7e38dd794986ca585477d80ac696eec60661679 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:07:18 +0300 Subject: [PATCH 05/15] refactor: improved consistency in argument handling across commands. --- cvm.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cvm.sh b/cvm.sh index 181c386..dea4109 100755 --- a/cvm.sh +++ b/cvm.sh @@ -429,12 +429,12 @@ case "$1" in getRemoteVersions | sed 's/^/ - /' ;; --download) - version=$2 - if [ -z "$version" ]; then + if [ -z "${2:-}" ]; then echo "Usage: $0 --download " exit 1 fi + version=$2 # check if version is available for download if ! getRemoteVersions | grep -q "^$version\$"; then echo "Version $version not found for download." @@ -453,22 +453,22 @@ case "$1" in getActiveVersion ;; --use) - version=$2 - if [ -z "$version" ]; then + if [ -z "${2:-}" ]; then echo "Usage: $0 --use " exit 1 fi + version=$2 exitIfVersionNotInstalled "$version" selectVersion "$version" ;; --remove) - version=$2 - if [ -z "$version" ]; then + if [ -z "${2:-}" ]; then echo "Usage: $0 --remove " exit 1 fi + version=$2 exitIfVersionNotInstalled "$version" activeVersion=$(getActiveVersion) From f0772078aeb14722c286c48bb1721455d6c57e16 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:08:30 +0300 Subject: [PATCH 06/15] refactor: enhanced local version listing with improved error handling and user feedback for no installed versions. --- cvm.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cvm.sh b/cvm.sh index dea4109..c01a0bb 100755 --- a/cvm.sh +++ b/cvm.sh @@ -420,13 +420,20 @@ case "$1" in --list-local) echo "Locally available versions:" # shellcheck disable=SC2010 - ls -1 "$DOWNLOADS_DIR" \ - | grep -oP 'cursor-\K[0-9.]+(?=\.)' \ - | sed 's/^/ - /' + local_versions_list=$(ls -1 "$DOWNLOADS_DIR" 2>/dev/null | grep -oP 'cursor-\K[0-9.]+(?=\.)' || true) + if [ -n "$local_versions_list" ]; then + while IFS= read -r version; do + echo " - $version" + done <<< "$local_versions_list" + else + echo " No versions installed." + fi ;; --list-remote) echo "Remote versions:" - getRemoteVersions | sed 's/^/ - /' + while IFS= read -r version; do + echo " - $version" + done < <(getRemoteVersions) ;; --download) if [ -z "${2:-}" ]; then From e074ca61e0e9e5a1508bd3acf7c431594f869214 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:09:07 +0300 Subject: [PATCH 07/15] refactor: simpler version extraction logic in getActiveVersion function --- cvm.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cvm.sh b/cvm.sh index c01a0bb..143bc51 100755 --- a/cvm.sh +++ b/cvm.sh @@ -158,7 +158,9 @@ selectVersion() { getActiveVersion() { if [ -L "$CURSOR_DIR/active" ]; then appimage_path=$(readlink -f "$CURSOR_DIR/active") - version=$(basename "$appimage_path" | sed -E 's/cursor-([0-9.]+)\.AppImage/\1/') + filename=$(basename "$appimage_path") + version=${filename#cursor-} + version=${version%.AppImage} echo "$version" else echo "No active version. Use \`cvm --use \` to select one." From ca286a23602a9137c277c05d187045df12acc833 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:13:24 +0300 Subject: [PATCH 08/15] fix: add disown command to fish cursor function for better process management this lets you use the terminal you used to open cursor for other commands --- cvm.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cvm.sh b/cvm.sh index 143bc51..3c5768c 100755 --- a/cvm.sh +++ b/cvm.sh @@ -206,9 +206,12 @@ installCVM() { fish) if [ ! -f "$HOME/.config/fish/functions/cursor.fish" ] || ! grep -q "function cursor" "$HOME/.config/fish/functions/cursor.fish"; then mkdir -p "$HOME/.config/fish/functions" - echo "function cursor" > "$HOME/.config/fish/functions/cursor.fish" - echo " $CURSOR_DIR/active \$argv" >> "$HOME/.config/fish/functions/cursor.fish" - echo "end" >> "$HOME/.config/fish/functions/cursor.fish" + { + echo "function cursor" + echo " $CURSOR_DIR/active \$argv" + echo " disown" + echo "end" + } > "$HOME/.config/fish/functions/cursor.fish" fi ;; esac From 093b435d233ecad27ad0dbfab10a734716efadb8 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:21:42 +0300 Subject: [PATCH 09/15] refactor: improve version removal process with enhanced checks and user feedback --- cvm.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cvm.sh b/cvm.sh index 3c5768c..c4c3213 100755 --- a/cvm.sh +++ b/cvm.sh @@ -423,10 +423,10 @@ case "$1" in fi ;; --list-local) - echo "Locally available versions:" # shellcheck disable=SC2010 local_versions_list=$(ls -1 "$DOWNLOADS_DIR" 2>/dev/null | grep -oP 'cursor-\K[0-9.]+(?=\.)' || true) if [ -n "$local_versions_list" ]; then + echo "Locally available versions:" while IFS= read -r version; do echo " - $version" done <<< "$local_versions_list" @@ -482,12 +482,25 @@ case "$1" in version=$2 exitIfVersionNotInstalled "$version" - activeVersion=$(getActiveVersion) + + # Check if this version is currently active + if [ -L "$CURSOR_DIR/active" ]; then + activeVersion=$(getActiveVersion) + if [ "$activeVersion" = "$version" ]; then + echo "Removing active version $version..." + rm "$CURSOR_DIR/active" + print_color "$GREEN" "✓ Removed active symlink" + fi + fi - if [ "$activeVersion" = "$version" ]; then - rm "$CURSOR_DIR/active" + # Remove the AppImage file + echo "Removing AppImage for version $version..." + if rm "$DOWNLOADS_DIR/cursor-$version.AppImage"; then + print_color "$GREEN" "✓ Successfully removed version $version" + else + print_color "$ORANGE" "! Failed to remove version $version" + exit 1 fi - rm "$DOWNLOADS_DIR/cursor-$version.AppImage" ;; --install) installCVM From ee3cf670c5db119a3a5196d0a35060dea275112d Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:29:38 +0300 Subject: [PATCH 10/15] refactor: enhance version information display and user feedback for local installations --- cvm.sh | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/cvm.sh b/cvm.sh index c4c3213..19d7448 100755 --- a/cvm.sh +++ b/cvm.sh @@ -385,20 +385,26 @@ case "$1" in echo "" echo "Cursor App Information:" latestRemoteVersion=$(getLatestRemoteVersion) - latestLocalVersion=$(getLatestLocalVersion) - activeVersion=$(getActiveVersion 2>/dev/null || echo "None") - echo " - Latest remote version: $latestRemoteVersion" - echo " - Latest locally available: $latestLocalVersion" - echo " - Currently active: $activeVersion" - - if [ "$latestRemoteVersion" != "$latestLocalVersion" ]; then - print_color "$ORANGE" "There is a newer Cursor version available for download!" - print_color "$ORANGE" "You can download and activate it with \`cvm --update\`" - elif [ "$latestRemoteVersion" != "$activeVersion" ]; then - print_color "$ORANGE" "There is a newer Cursor version already installed!" - print_color "$ORANGE" "You can activate it with \`cvm --use $latestRemoteVersion\`" + if [ -d "$DOWNLOADS_DIR" ] && [ -n "$(ls -A "$DOWNLOADS_DIR" 2>/dev/null)" ]; then + latestLocalVersion=$(getLatestLocalVersion) + activeVersion=$(getActiveVersion 2>/dev/null || echo "None") + echo " - Latest remote version: $latestRemoteVersion" + echo " - Latest locally available: $latestLocalVersion" + echo " - Currently active: $activeVersion" + + if [ "$latestRemoteVersion" != "$latestLocalVersion" ]; then + print_color "$ORANGE" "There is a newer Cursor version available for download!" + print_color "$ORANGE" "You can download and activate it with \`cvm --update\`" + elif [ "$latestRemoteVersion" != "$activeVersion" ]; then + print_color "$ORANGE" "There is a newer Cursor version already installed!" + print_color "$ORANGE" "You can activate it with \`cvm --use $latestRemoteVersion\`" + else + print_color "$GREEN" "You are running the latest Cursor version!" + fi else - print_color "$GREEN" "You are running the latest Cursor version!" + echo " - Latest remote version: $latestRemoteVersion" + echo " - No local Cursor installation found" + print_color "$ORANGE" "To install Cursor, run: $0 --install" fi ;; --update) From c46195fd90e42775890f46b34f6781a8ab81d523 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:33:23 +0300 Subject: [PATCH 11/15] refactor: improve user feedback for script interruption --- cvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvm.sh b/cvm.sh index 19d7448..8a18b77 100755 --- a/cvm.sh +++ b/cvm.sh @@ -1,7 +1,7 @@ #!/bin/bash set -euo pipefail -trap 'printf "\nScript interrupted by user.\n"; exit 130' INT TERM +trap 'printf "\nScript interrupted by user. Please remove any unfinished downloads (if any) using --remove option.\n"; exit 130' INT TERM #H# #H# cvm.sh — Cursor version manager From dcb32e835d2f89c2e80be20dacd1f6d5e293bee0 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sat, 10 May 2025 23:43:16 +0300 Subject: [PATCH 12/15] feat: enhance --update command to download latest version if none exists locally. --- cvm.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cvm.sh b/cvm.sh index 8a18b77..c2f3547 100755 --- a/cvm.sh +++ b/cvm.sh @@ -409,6 +409,16 @@ case "$1" in ;; --update) latestRemoteVersion=$(getLatestRemoteVersion) + + if [ ! -d "$DOWNLOADS_DIR" ] || [ -z "$(ls -A "$DOWNLOADS_DIR" 2>/dev/null)" ]; then + echo "No Cursor versions found locally." + echo "Downloading latest version $latestRemoteVersion..." + downloadVersion "$latestRemoteVersion" + selectVersion "$latestRemoteVersion" + print_color "$GREEN" "Downloaded and switched to version $latestRemoteVersion." + exit 0 + fi + activeVersion=$(getActiveVersion 2>/dev/null || echo "None") if [ "$latestRemoteVersion" = "$activeVersion" ]; then From 7e363f08b87b05ae1940c7a2889466d04f3faf67 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sun, 11 May 2025 11:07:29 +0300 Subject: [PATCH 13/15] fix: update fish cursor function to run in the background with nohup for improved process management --- cvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cvm.sh b/cvm.sh index c2f3547..e132001 100755 --- a/cvm.sh +++ b/cvm.sh @@ -208,7 +208,7 @@ installCVM() { mkdir -p "$HOME/.config/fish/functions" { echo "function cursor" - echo " $CURSOR_DIR/active \$argv" + echo " nohup $CURSOR_DIR/active \$argv --no-sandbox /dev/null 2>&1 &" echo " disown" echo "end" } > "$HOME/.config/fish/functions/cursor.fish" From e7ebad4be13e64548660c8350500b98f83a76196 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sun, 11 May 2025 11:33:15 +0300 Subject: [PATCH 14/15] docs: add user instruction to close and reopen Cursor after version update or after --use option for better clarity --- cvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cvm.sh b/cvm.sh index e132001..2b884d6 100755 --- a/cvm.sh +++ b/cvm.sh @@ -153,6 +153,7 @@ selectVersion() { appimage_path="$DOWNLOADS_DIR/$filename" ln -sf "$appimage_path" "$CURSOR_DIR/active" echo "Symlink created: $CURSOR_DIR/active -> $appimage_path" + echo "Close all instances of Cursor and reopen it to use the new version." } getActiveVersion() { From e23feed400dc53a41cb30856acf70928a62035a3 Mon Sep 17 00:00:00 2001 From: "Dagim G. Astatkie" Date: Sun, 11 May 2025 11:57:50 +0300 Subject: [PATCH 15/15] fix: add usage instruction for missing arguments in cvm.sh --- cvm.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cvm.sh b/cvm.sh index 2b884d6..0347469 100755 --- a/cvm.sh +++ b/cvm.sh @@ -364,6 +364,12 @@ checkDependencies mkdir -p "$DOWNLOADS_DIR" cleanupAppImages +if [ -z "${1:-}" ]; then + echo "Usage: $0 " + help + exit 1 +fi + case "$1" in --help|-h) help