Skip to content

Commit

Permalink
install_sublime_text: Update
Browse files Browse the repository at this point in the history
- 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 "<p class="latest"><i>Version:</i> Build 4169</p>" which appears at the very top of the page as “Version: Build 4169”
  • Loading branch information
0xmachos committed Apr 23, 2024
1 parent c34030b commit cf38da7
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions bittersweet
Original file line number Diff line number Diff line change
Expand Up @@ -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:" \ : <p class="latest"><i>Version:</i> Build 3143</p>
# awk '{print $4}' : 3143</p>
# 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("</p>", "", $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"
Expand Down

0 comments on commit cf38da7

Please sign in to comment.