Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to update VS Code on Linux
#!/usr/bin/env bash
set -euo pipefail
url="https://update.code.visualstudio.com/latest/linux-x64/insider"
target="$HOME/.local/share/vscode"
xattr="user.vscode.updatename"
mkdir -p "$target"
cd "$target"
# fetch 'version'
echo -n "Fetching version: "
name=$(curl -sI "$url" | rg '^Location:' | rg -o 'code.+[.]tar[.]gz')
echo "$name"
# check 'version'
if [[ $(getfattr --only-values -n "$xattr" "$(find . -type f -print -quit)") == "$name" ]]; then
echo "Already at latest version"
exit
fi
# remove anything that isn't marked
for topfile in $(ls -A); do
if ! getfattr --only-values -n "$xattr" "$topfile"; then
rm -rf "$topfile"
fi
done
# fetch and extract
echo "Fetching update"
curl -L "$url" \
| tar xz --strip-components=1 --recursive-unlink --unlink-first
# mark all with 'version'
find . -exec setfattr -n "$xattr" -v "$name" '{}' \;
echo "You'll want to restart vscode"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment