Skip to content

Instantly share code, notes, and snippets.

@passcod
Created June 30, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passcod/b0e56711839f5583dc82864ebfbdce79 to your computer and use it in GitHub Desktop.
Save passcod/b0e56711839f5583dc82864ebfbdce79 to your computer and use it in GitHub Desktop.
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