From cf38da7baeaea5295969e1c36eea20ae2d71d404 Mon Sep 17 00:00:00 2001 From: 0xmachos <0xmachos@gmail.com> Date: Wed, 24 Apr 2024 00:41:46 +0100 Subject: [PATCH] install_sublime_text: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The old curl command was pulling down an old version of Sublime Text because it curling https://www.sublimetext.com/3 however the latest major version is Sublime Text 4 - Sublime Text 4 is shipped as a zip instead of a DMG - Awk extracts the latest build number from the Download page which lists all releases of Sublime Text 4 - It extracts the build number from the string "

Version: Build 4169

" which appears at the very top of the page as “Version: Build 4169” --- bittersweet | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/bittersweet b/bittersweet index ee598ab..b6eb067 100755 --- a/bittersweet +++ b/bittersweet @@ -694,21 +694,17 @@ function install_sublime_text { echo "[🍺] Installing Sublime Text" local latest_build - latest_build="$(curl -s https://www.sublimetext.com/3 \ - | grep "Version:" \ - | awk '{print ($4+0)}')" - # Get the latest build string - # grep "Version:" \ :

Version: Build 3143

- # awk '{print $4}' : 3143

- # awk '{print ($4+0)}' : 3143 - # ($4+0) converts captured string to numeric - local dmg_name="Sublime Text Build ${latest_build}.dmg" - local dmg_download_path="${HOME}/Downloads/${dmg_name}" - local dmg_mount_point="/Volumes/Sublime Text" - - download_application "${dmg_download_path}" "https://download.sublimetext.com/Sublime%20Text%20Build%20${latest_build}.dmg" + latest_build="$(curl -s https://www.sublimetext.com/download \ + | awk -F 'Build ' 'BEGIN {found=0} /Build/ && !found {sub("

", "", $2); print $2; found=1}')" + # Get the latest build number + # TIL https://stackoverflow.com/a/28879552 + + local zip_name="sublime_text_build_${latest_build}_mac.zip" + local zip_download_path="${HOME}/Downloads/${zip_name}" + + download_application "${zip_download_path}" "https://download.sublimetext.com/sublime_text_build_${latest_build}_mac.zip" - install_application "Sublime Text" "${dmg_download_path}" + install_application "Sublime Text" "${zip_download_path}" ## Install config files echo "[🍺] Installing Sublime Text config files"