Skip to content

Instantly share code, notes, and snippets.

@macournoyer
Created January 14, 2011 15:31
Show Gist options
  • Save macournoyer/779735 to your computer and use it in GitHub Desktop.
Save macournoyer/779735 to your computer and use it in GitHub Desktop.
Reveal in GitHub TextMate command
#!/usr/bin/env ruby
# Reveal in GitHub TextMate command
require 'pathname'
path = Pathname.new(ENV["TM_FILEPATH"]).relative_path_from(Pathname.new(ENV["TM_PROJECT_DIRECTORY"]))
repo_path = `/usr/local/bin/git remote show origin`[/Fetch URL: git@(.*)\.git$/, 1].tr(":", "/")
branch = `/usr/local/bin/git symbolic-ref HEAD`[/refs\/heads\/(.*)$/, 1]
exec "open 'http://#{repo_path}/blob/#{branch}/#{path}'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment