Skip to content

Instantly share code, notes, and snippets.

@joaomoreno
Last active February 1, 2024 22:19
Show Gist options
  • Save joaomoreno/7d3926e67e91317cd9d053c2c3956ddc to your computer and use it in GitHub Desktop.
Save joaomoreno/7d3926e67e91317cd9d053c2c3956ddc to your computer and use it in GitHub Desktop.
VS Code Insiders Updater for Linux

VS Code Insiders Updater for Linux

This script will download and replace ~/Applications/VSCode-linux-x64 with the latest VS Code Insiders.

gif

Install

  1. Install jq: https://stedolan.github.io/jq/download/
  2. Place update-code somewhere in your PATH
#!/usr/bin/env bash
APPLICATIONS_PATH="$HOME/Applications"
CODE_PATH="$APPLICATIONS_PATH/VSCode-linux-x64"
PRODUCT_JSON="$CODE_PATH/resources/app/product.json"
[ -f $PRODUCT_JSON ] && VERSION=$(cat $PRODUCT_JSON | jq -r '.commit') || VERSION="latest"
UPDATE_URL="https://update.code.visualstudio.com/api/update/linux-x64/insider/$VERSION"
echo "Fetching $UPDATE_URL..."
UPDATE_RESPONSE_FILE=$(mktemp)
UPDATE_RESPONSE_CODE=$(curl --silent --output $UPDATE_RESPONSE_FILE --write-out "%{http_code}" $UPDATE_URL)
if [ $UPDATE_RESPONSE_CODE -ne 200 ]; then
echo "Got $UPDATE_RESPONSE_CODE from server, update not available"
exit 0
fi
UPDATE_RESPONSE=$(cat $UPDATE_RESPONSE_FILE)
rm $UPDATE_RESPONSE_FILE
AVAILABLE_PRODUCT_VERSION=$(echo $UPDATE_RESPONSE | jq -r '.productVersion')
HASH=$(echo $UPDATE_RESPONSE | jq -r '.sha256hash')
DOWNLOAD_URL=$(echo $UPDATE_RESPONSE | jq -r '.url')
echo "Found update: $AVAILABLE_PRODUCT_VERSION"
echo "Downloading $DOWNLOAD_URL..."
DOWNLOAD_PATH=$(mktemp)
curl $DOWNLOAD_URL --output $DOWNLOAD_PATH
echo "Downloaded to $DOWNLOAD_PATH"
echo -n "Hash check: "
echo "$HASH $DOWNLOAD_PATH" | sha256sum -c
echo "Removing old version..."
rm -rf $CODE_PATH
echo "Extracting to $CODE_PATH..."
mkdir -p $CODE_PATH
tar xzf $DOWNLOAD_PATH -C $APPLICATIONS_PATH
rm $DOWNLOAD_PATH
@elsandosgrande
Copy link

Any time!

@Jayprecode
Copy link

How do i install it and apply this to code-insiders ..... i use garuda linux ...kinda new to linux actually......i'm trying to install code-insiders on linux with its tar.gz file....kinda stuck , please help

@henry701
Copy link

henry701 commented Oct 2, 2021

Forked and working for portable VSCode Insiders on Windows (update with zip): https://gist.github.com/henry701/79a872003e3a399c230f4001518d49f0#file-readme-md

@Ali-Flt
Copy link

Ali-Flt commented Feb 1, 2024

This does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment