Skip to content

Instantly share code, notes, and snippets.

@abdelouahabb
Created August 22, 2026 12:33
Show Gist options
  • Select an option

  • Save abdelouahabb/e27b44c1690adbe71820fe999dfc648a to your computer and use it in GitHub Desktop.

Select an option

Save abdelouahabb/e27b44c1690adbe71820fe999dfc648a to your computer and use it in GitHub Desktop.
Script that grabs VSCode extensions to install them offline, converted the original powershell script using Gemini, nothing new, source : https://github.com/KevinKvissberg/Get-vsix/blob/main/get-vsix.ps1
#!/usr/bin/env bash
# Exit immediately if a command exits with a non-zero status
set -euo pipefail
# Check mandatory url argument
if [ -z "${1:-}" ]; then
echo "Usage: $0 <url> [version]"
exit 1
fi
url="$1"
version="${2:-}"
# Extract publisher and extension name from URL query parameter 'itemName=Publisher.ExtensionName'
# 1. Isolate the itemName query parameter value
item_name=$(echo "$url" | sed -n 's/.*itemName=\([^&#]*\).*/\1/p')
# 2. Extract Publisher (everything before the last dot) and ExtensionName (everything after the last dot)
publisher="${item_name%.*}"
extensionName="${item_name##*.}"
if [ -z "$publisher" ] || [ -z "$extensionName" ]; then
echo "Error: Could not parse publisher and extension name from URL."
exit 1
fi
# If version is not provided, fetch the marketplace page and scrape the version
if [ -z "$version" ]; then
html_content=$(curl -sL "$url")
version=$(echo "$html_content" | grep -o '"version":"[^"]*"' | head -n 1 | sed -E 's/"version":"([^"]*)"/\1/')
if [ -z "$version" ]; then
echo "Error: Could not retrieve version automatically."
exit 1
fi
fi
vsixUrl="https://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${extensionName}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage"
output_file="./${publisher}.${extensionName}.${version}.vsix"
echo "Downloading $extensionName ($version) by $publisher..."
curl -fL -o "$output_file" "$vsixUrl"
echo "Saved to $output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment