Created
February 4, 2012 03:01
-
-
Save Suor/1734753 to your computer and use it in GitHub Desktop.
Sublime Text 2 updater for Linux
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/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"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put it next to your "Sublime Text 2" dir and run. You'll need perl 5.10+ with Mojolicious package installed.