git TextMate Bundle

January 24th, 2008 by vinbarnes

Prologue

I recently switched to git from svn. I was always more comfortable using the command-line to order the svn serfs around than TextMate’s built-in svn bundle. The same holds true for git. Although it would be nice if I could do a blame from inside the editor, rather than switch to the term and enter the path and filename. (Note: I favor the term blame over praise – I rarely give high fives when stumbling across a code snippet, rather I belch a guttural dismissal alongside a “WTF?!” for good measure.) Sadly, no git bundle is err… bundled with TextMate.

Luckily, this app is extremely customizable and many fine TextMate twiddlers have stepped up to the plate offering bundles serving the needs of everything from Ada to Quake to SecondLife and plenty in between.

Here are some resources to whet your whistle:

I’ll look the other way while you secretly download the Maven bundle. Don’t worry I won’t rat you out by telling the cool kids. What’s that? You want an Ant bundle? Yes, that’s there too.

Enough of the horseplay… Let’s get on with the dog and pony show already. You’ll find info on downloading the bundle and at the end there’s a git bundle command I wrote to do diff-ing in TextMate. Now if I can just figure out how to get this included in the experimental bundle repo…

One format to rule them all

If I didn’t do this,


export LC_CTYPE=en_US.UTF-8

svn would error out. After setting it the bundle pulled just fine.

svn export (or checkout) the bundle


cd ~/Library/Application\ Support/TextMate/Bundles
svn export http://macromates.com/svn/Bundles/trunk/Review/Bundles/Git.tmbundle

At this point, you will need to execute the Reload Bundles command from within the Bundles menu.

Add this to the git bundle

This is how I set up the command:

Save: Nothing

Command(s):


#!/usr/bin/env ruby -wKU

require ENV['TM_BUNDLE_SUPPORT'] + '/lib/git.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'

class SCM::Git
    def blame(file)
        base = File.expand_path("..", git_dir(file)) if base.nil?
        Dir.chdir(base)
        %x{#{e_sh @git} blame #{file}}
    end
end

git = SCM::Git.new

puts git.blame(ENV['TM_FILEPATH'])

Input: None

Output: Create New Document

Activation: Key Equivalent Control-Shift-G

Scope Selector:

Epilogue

I’m happy to report that due to git blaming, my obscenities are now correctly directed rather than being heaved willy-nilly upon an unsuspecting somebody.

1 Response to “git TextMate Bundle”

  1. Walther H Diechmann Says:

    Great post – just too bad the bundle is not there?

    Or, rather, I cannot seem to convince svn that the svn export …Bundles/Git.tmbundle really exist <:)

    Perhaps you’d try again, just to prove me wrong <:)

Sorry, comments are closed for this article.