From 8fd96ca4646a00716e1be6729c32b0a0e3f2c311 Mon Sep 17 00:00:00 2001 From: Ted Chambers Date: Sun, 20 Sep 2026 13:54:51 -0400 Subject: [PATCH] Install the Pinpoint VS Code extension on new machines Adds vscode/install.sh, which installs extensions that are not on the Marketplace from the .vsix attached to their latest GitHub release, and hooks it into install.sh. It is skipped when VS Code is not installed. Co-Authored-By: Claude Fable 5.1 --- install.sh | 3 +++ vscode/install.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 vscode/install.sh diff --git a/install.sh b/install.sh index 1075f30..b5e080b 100755 --- a/install.sh +++ b/install.sh @@ -41,3 +41,6 @@ source "$DOTFILESPATH/pwsh/install.sh" # shellcheck source=./logfmtpp/install.sh "$DOTFILESPATH/logfmtpp/install.sh" + +# shellcheck source=./vscode/install.sh +"$DOTFILESPATH/vscode/install.sh" diff --git a/vscode/install.sh b/vscode/install.sh new file mode 100755 index 0000000..a4c1836 --- /dev/null +++ b/vscode/install.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Installs my VS Code extensions that are not on the Marketplace, from the +# .vsix attached to their latest GitHub release. Skips when VS Code is absent. + +set -e + +codeCli=$(command -v code || true) +if [[ -z "$codeCli" && -x "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" ]]; then + # VS Code is installed but its shell command has not been added to PATH yet. + codeCli="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" +fi + +if [[ -z "$codeCli" ]]; then + echo "VS Code not found; skipping VS Code extensions" + exit 0 +fi + +# installExtensionFromGitHubRelease +installExtensionFromGitHubRelease() { + local repo=$1 + local extensionId=$2 + local assetName=$3 + + # The latest-release page redirects to /releases/tag/; the tag is the version with a "v" prefix. + local latestTag + latestTag=$(curl -fsSI --retry 5 -o /dev/null -w '%{redirect_url}' "https://github.com/$repo/releases/latest" | sed 's#.*/tag/##') + if [[ -z "$latestTag" ]]; then + echo "Could not find the latest release of $repo" + return 1 + fi + local latestVersion=${latestTag#v} + + local installedVersion + installedVersion=$("$codeCli" --list-extensions --show-versions 2>/dev/null | awk -F@ -v id="$extensionId" '$1 == id { print $2 }') + if [[ "$installedVersion" == "$latestVersion" ]]; then + echo "$extensionId $installedVersion is already installed" + return 0 + fi + + echo "Installing $extensionId $latestVersion from https://github.com/$repo/releases/tag/$latestTag" + local tempDir + tempDir=$(mktemp -d) + curl -fsSL --retry 5 -o "$tempDir/$assetName" "https://github.com/$repo/releases/download/$latestTag/$assetName" + "$codeCli" --install-extension "$tempDir/$assetName" --force + rm -rf "$tempDir" +} + +installExtensionFromGitHubRelease tedchamb/vscode-pinpoint tedchamb.pinpoint pinpoint.vsix