#!/bin/bash clear mkdir -p /tmp/vsc-updates rm -f /tmp/vsc-updates/*.deb local IFS=$'\n' local CURRENT_VERSION=($(code -v)) echo "Updating Visual Studio Code" echo "Current: $CURRENT_VERSION" echo "Downloading latest..." wget -q --user-agent Mozilla --content-disposition -E -c https://update.code.visualstudio.com/latest/linux-deb-x64/stable && mv *.deb /tmp/vsc-updates/ local DEB=$(find /tmp/vsc-updates -maxdepth 1 -type f) local REGEX="code_([0-9.]+)" if [[ $DEB =~ $REGEX ]] then local NEW_VERSION=${BASH_REMATCH[1]} else local NEW_VERSION=$CURRENT_VERSION fi echo "Latest: $NEW_VERSION" if test "$CURRENT_VERSION" == "$NEW_VERSION"; then echo "You're running the latest ($NEW_VERSION), no need to upgrade" && \ rm -f /tmp/vsc-updates/*.deb else # install update and restart the app sudo apt install /tmp/vsc-updates/*.deb && \ killall -9 code && \ code && \ echo "Update complete" fi