Update: The Git script described below has been updated, improved, and folded into the BBRails Toolkit.

In the two short years since its 1.0 release, the open-source version control system Git has grown to become the SCM of choice for open source and web development projects worldwide. Last year we took the plunge and moved all of our projects to Git from SVN. I won't say that it hasn't been a rocky transition, but I'm hopeful that in the long run it will prove to have been the right decision.

One of the niceties of SVN was the fact that BBEdit supported it out of the box. No such support exists for Git, unfortunately, so I found myself having to make frequent trips to the command line (or the only decent Git client I can find, GitX) for anything Git-related.

One could argue that due to its complexity— think branching, one of the strong points of Git— full-fledged Git integration would be beyond the scope of an IDE. But there are definitely basic things that would be nice to do without command-tabbing out of BBEdit.

To that end, I've created a basic AppleScript that lets you perform the two most common (for me, anyway) Git operations from within BBEdit: git status and git pull.

bbedit_git.png
bbedit_git_pull.png

If there are no conflicts with your pull operation, the script lets you know with a dialog box.
Otherwise, the results are opened in a new BBEdit window.

bbedit_git_status.png

Similarly, 'status' will give you a quickly dismissable dialog box if you're up to date,
or full list of changes in a new window.

To install:

  1. Download git_for_bbedit.zip (5k)
  2. Uncompress the archive and copy the entire folder to the BBEdit script folder in ~/Library/Application Support/BBEdit/Scripts/
  3. Make sure that the accompanying shell script has execute privileges:

    • Open Terminal
    • Type this: chmod +x ~/Library/Application Support/BBEdit/Scripts/Git/find_enclosing_project.sh
  4. In BBEdit, assign a keyboard shortcut to the script:

    • Click on Window > Palettes > Scripts
    • Highlight Git, and click Set Key....

Now, with any file open in your Project window, you can activate the Git script using the keyboard shortcut you assigned. The script determines the location of your local Git repository and performs the command you select (status or pull).

Robert Hanviriyapunt's UNIX wizardry was critical for creating the shell script to determine the current Git repository for the selected file— many thanks, Robert!

If you have any suggestions on how to improve the script, please let me know by leaving a comment below. Happy hacking...

Related Articles


Comments

Brad Gessler
February 1, 2009 at 8:04 AM

I've got to share gitx in any git post: http://gitx.frim.nl/ Its a a gitk that doesn't suck!

Peter Murphy
February 24, 2009 at 4:17 PM

Bugger off you git.

Corey Ehmke
February 24, 2009 at 4:35 PM

Peter-- er, Jon-- you've got a memory like an elephant! Thanks for the chuckle.
Leave a Comment


IdolHands.com Spam-o-MeterTM
Bot
Spammer
Moron
Human






* Required fields.