Skip to content

Instantly share code, notes, and snippets.

@Suor
Created February 4, 2012 03:01
Show Gist options
  • Save Suor/1734753 to your computer and use it in GitHub Desktop.
Save Suor/1734753 to your computer and use it in GitHub Desktop.
Sublime Text 2 updater for Linux
#!/usr/bin/perl
use v5.10;
use strict;
use warnings FATAL => 'all';
use Mojo::UserAgent;
my $latest_url = Mojo::UserAgent->new->get('http://www.sublimetext.com/2')
->res->dom->at('a[href$=x64.tar.bz2]')->{href};
my ($filename) = $latest_url =~ m~/([^/]+)$~;
my $current_version = `./Sublime\\ Text\\ 2/sublime_text -v`;
chomp $current_version;
say("You already have latest Sublime Text 2"), exit
if $current_version and $filename =~ /^$current_version/;
unless (-f $filename) {
say ">>> Downloading $filename";
system "wget '$latest_url'";
}
say ">>> Installing $filename";
system <<CODE;
rm -rf 'Sublime Text 2.prev'
mv 'Sublime Text 2' 'Sublime Text 2.prev'
tar xjvf '$filename'
CODE
say ">>> Done";
@Suor
Copy link
Author

Suor commented Feb 4, 2012

Put it next to your "Sublime Text 2" dir and run. You'll need perl 5.10+ with Mojolicious package installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment