Created
June 30, 2020 09:54
-
-
Save passcod/b0e56711839f5583dc82864ebfbdce79 to your computer and use it in GitHub Desktop.
Script to update VS Code on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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