Last active
March 30, 2023 03:34
-
-
Save tos-kamiya/f426671c2ad991e1568263c3155c069b to your computer and use it in GitHub Desktop.
cli tool to update vscode extensions
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 | |
# Temporary files for storing the list of extensions | |
tempfile1=$(mktemp) | |
tempfile2=$(mktemp) | |
# Save versions of extensions before the extension update process | |
code --list-extensions --show-versions > "$tempfile1" | |
# Print a message to indicate that the extension update process starts | |
printf "[INFO] start: vscode extension updating." | |
sleep 0.5 | |
# Define a spinner animation | |
spiner_figs='-\\|/' | |
spiner_i=0 | |
# Loop over the list of extensions and update each one | |
for ext in $(code --list-extensions) | |
do | |
# Print a message to show an extension being updated | |
spiner_i=$(( (spiner_i+1)%4 )) | |
printf "\33[2K\r" | |
printf "[INFO] (${spiner_figs:$spiner_i:1}) try updating: $ext" | |
# Try to update the extension | |
code --force --install-extension "$ext" > /dev/null | |
done | |
# Print a message to indicate that the extension update process has completed | |
printf "\33[2K\r" | |
echo "[INFO] done: vscode extension updating." | |
# Identify and show which extensions have been updated | |
code --list-extensions --show-versions > "$tempfile2" | |
git diff --no-index -U0 "$tempfile1" "$tempfile2" | tail -n +5 | grep -v '@@' | |
# Clean up the temprary files | |
rm -rf "$tempfile1" | |
rm -rf "$tempfile2" | |
# ref: https://github.com/microsoft/vscode/issues/56578#issuecomment-554025719 |
(Some people have said the same thing to the VSCode developers, but for whatever reason they don't seem to be in the mood to be proactive about it.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have a lot of VSCode extensions installed (like me), do you get a "reload required" every time you open VSCode?
This could be a particular annoyance if you are using an integrated package management tool.
I have solved such frustrations by running this script immediately after an integrated package management tool (namely, topgrade).