Skip to content

Instantly share code, notes, and snippets.

@tsibley
Created September 23, 2011 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsibley/1237317 to your computer and use it in GitHub Desktop.
Save tsibley/1237317 to your computer and use it in GitHub Desktop.
git-on-github
#!/usr/bin/env perl
use strict;
use warnings;
use Config::GitLike::Git;
my $c = Config::GitLike::Git->new;
$c->load;
my $remote = $c->get( key => 'remote.origin.url' );
if ($remote =~ m{github\.com[:/](\w+)/([^/]+?)(?:\.git)?$}) {
my $sha = shift @ARGV;
my ($user, $repo) = ($1, $2);
my $url = "https://github.com/$user/$repo";
$url .= "/commit/$sha" if defined $sha and length $sha;
exec('xdg-open', $url) or die "Couldn't exec xdg-open: $!\n";
} else {
die "Remote origin doesn't point to github ($remote)\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment