From cae2e36b6fbe2c8da6eebdffaed8b091f006a782 Mon Sep 17 00:00:00 2001 From: Umar Ijaz <60422606+umarijaz04@users.noreply.github.com> Date: Wed, 21 May 2025 15:37:43 +0500 Subject: [PATCH 1/2] Update cursor_setup.sh Updated the download URL with the current cursor AppImage and changed the flow to retrieve the version, among other enhancements. --- cursor_setup.sh | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/cursor_setup.sh b/cursor_setup.sh index 8a2bc8f..c54d86a 100755 --- a/cursor_setup.sh +++ b/cursor_setup.sh @@ -7,9 +7,9 @@ readonly SCRIPT_ALIAS_NAME="cursor-setup" readonly DOWNLOAD_DIR="$HOME/.AppImage" readonly ICON_DIR="$HOME/.local/share/icons" readonly USER_DESKTOP_FILE="$HOME/Desktop/cursor.desktop" -readonly DOWNLOAD_URL="https://downloader.cursor.sh/linux/appImage/x64" +readonly DOWNLOAD_URL="https://downloads.cursor.com/production/0781e811de386a0c5bcb07ceb259df8ff8246a52/linux/x64/Cursor-0.49.6-x86_64.AppImage" readonly ICON_URL="https://mintlify.s3-us-west-1.amazonaws.com/cursor/images/logo/app-logo.svg" -readonly VERSION_CHECK_TIMEOUT=5 # in seconds | if you have a slow connection, increase this value to 10, 15, or more +readonly VERSION_CHECK_TIMEOUT=360 # in seconds | if you have a slow connection, increase this value to 10, 15, or more readonly SPINNERS=("meter" "line" "dot" "minidot" "jump" "pulse" "points" "globe" "moon" "monkey" "hamburger") readonly SPINNER="${SPINNERS[0]}" readonly DEPENDENCIES=("gum" "curl" "wget" "pv" "bc" "find:findutils" "chmod:coreutils" "timeout:coreutils" "mkdir:coreutils" "apparmor_parser:apparmor-utils") @@ -126,8 +126,18 @@ edit_this_script() { } extract_version() { - [[ "$1" =~ ([0-9]+\.[0-9]+\.[0-9]+) ]] && { echo "${BASH_REMATCH[1]}"; return 0; } - echo "Error: No version found in filename" >&2; return 1 + # Make this function more robust + if [[ "$1" =~ [Cc]ursor[-_]([0-9]+\.[0-9]+\.[0-9]+) ]]; then + echo "${BASH_REMATCH[1]}" + return 0 + elif [[ "$1" =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then + echo "${BASH_REMATCH[1]}" + return 0 + else + # Default version from DOWNLOAD_URL if no version found + echo "0.49.6" + return 0 + fi } convert_to_mb() { printf "%.2f MB" "$(bc <<< "scale=2; $1 / 1048576")"; } @@ -176,14 +186,24 @@ fetch_remote_version() { return 1 fi logg success "Latest version details retrieved successfully." - remote_name=$(echo "$headers" | grep -oE 'filename="[^"]+"' | sed 's/filename=//g; s/\"//g') || remote_name="" + + # Extract the filename from the download URL if headers don't have it + if [[ "$DOWNLOAD_URL" =~ /([^/]+)$ ]]; then + remote_name="${BASH_REMATCH[1]}" + else + remote_name=$(echo "$headers" | grep -oE 'filename="[^"]+"' | sed 's/filename=//g; s/\"//g') || remote_name="" + fi + remote_size=$(echo "$headers" | grep -oE 'Content-Length: [0-9]+' | sed 's/Content-Length: //') || remote_size="0" remote_version=$(extract_version "$remote_name") remote_md5=$(echo "$headers" | grep -oE 'ETag: "[^"]+"' | sed 's/ETag: //; s/"//g' || echo "unknown") + if [[ -z "$remote_name" ]]; then - logg error "Could not fetch the filename info. Please check that the 'DOWNLOAD_URL' variable is correct and try again." - return 1 + logg error "Could not fetch the filename info. Using default from DOWNLOAD_URL." + remote_name=$(basename "$DOWNLOAD_URL") + remote_version=$(extract_version "$remote_name") fi + logg info "$(echo -e "Latest version online:\n - name: $remote_name\n - version: $remote_version\n - size: $(convert_to_mb "$remote_size")\n - MD5 Hash: $remote_md5\n")" } @@ -191,7 +211,7 @@ find_local_version() { show_log=${1:-false} [[ $show_log == true ]] && spinner "Searching for a local version..." "sleep 2;" mkdir -p "$DOWNLOAD_DIR" - local_path=$(find "$DOWNLOAD_DIR" -maxdepth 1 -type f -name 'cursor-*.AppImage' -printf '%T@ %p\n' 2>/dev/null | sort -nr | head -n 1 | cut -d' ' -f2-) + local_path=$(find "$DOWNLOAD_DIR" -maxdepth 1 -type f -name 'Cursor-*.AppImage' -printf '%T@ %p\n' 2>/dev/null | sort -nr | head -n 1 | cut -d' ' -f2-) if [[ -n "$local_path" ]]; then local_name=$(basename "$local_path") local_size=$(stat -c %s "$local_path" 2>/dev/null || echo "0") From 161ae95cefb8b6c0c4ff8a11a1aa02c63af138f9 Mon Sep 17 00:00:00 2001 From: Umar Ijaz <60422606+umarijaz04@users.noreply.github.com> Date: Thu, 22 May 2025 18:52:17 +0500 Subject: [PATCH 2/2] Modified cursor latest version URL --- cursor_setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cursor_setup.sh b/cursor_setup.sh index c54d86a..0af5e98 100755 --- a/cursor_setup.sh +++ b/cursor_setup.sh @@ -7,7 +7,7 @@ readonly SCRIPT_ALIAS_NAME="cursor-setup" readonly DOWNLOAD_DIR="$HOME/.AppImage" readonly ICON_DIR="$HOME/.local/share/icons" readonly USER_DESKTOP_FILE="$HOME/Desktop/cursor.desktop" -readonly DOWNLOAD_URL="https://downloads.cursor.com/production/0781e811de386a0c5bcb07ceb259df8ff8246a52/linux/x64/Cursor-0.49.6-x86_64.AppImage" +readonly DOWNLOAD_URL="https://downloads.cursor.com/production/96e5b01ca25f8fbd4c4c10bc69b15f6228c80771/linux/x64/Cursor-0.50.5-x86_64.AppImage" readonly ICON_URL="https://mintlify.s3-us-west-1.amazonaws.com/cursor/images/logo/app-logo.svg" readonly VERSION_CHECK_TIMEOUT=360 # in seconds | if you have a slow connection, increase this value to 10, 15, or more readonly SPINNERS=("meter" "line" "dot" "minidot" "jump" "pulse" "points" "globe" "moon" "monkey" "hamburger") @@ -135,7 +135,7 @@ extract_version() { return 0 else # Default version from DOWNLOAD_URL if no version found - echo "0.49.6" + echo "0.50.5" return 0 fi }