Skip to content

Instantly share code, notes, and snippets.

@jeremija
Last active August 29, 2015 14:17
Show Gist options
  • Save jeremija/2d32c5ad747cffd312a9 to your computer and use it in GitHub Desktop.
Save jeremija/2d32c5ad747cffd312a9 to your computer and use it in GitHub Desktop.
Sublime Text automatic update script
#!/bin/bash
# Checks for a new version of Sublime Text and automatically downloads and
# extracts it.
#
# author: https://github.com/jeremija
SUBLIME_INSTALL_DIR="$HOME/opt/"
DOWNLOAD_LOC="/tmp/sublime.tar.bz2"
CURRENT_VERSION=$(sublime --version | grep -o '[0-9]*')
URL=$(wget -O - -q https://www.sublimetext.com/3dev | grep -o 'http://[^"]*x64.tar.bz2')
LATEST_VERSION=$(echo $URL | grep 'build_[0-9]*' -o | grep -o '[0-9]*')
echo "Current version: $CURRENT_VERSION, latest version: $LATEST_VERSION"
if [ $LATEST_VERSION -le $CURRENT_VERSION ]; then
echo "No new version found"
exit 0
fi
echo "Downloading..."
wget $URL -q -O "$DOWNLOAD_LOC"
echo "Extracting..."
tar xjvf $DOWNLOAD_LOC -C $SUBLIME_INSTALL_DIR
echo "Removing temp files..."
rm "$DOWNLOAD_LOC"
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment