Meditations on programming, startups, and technology
New Relic

TextMate bundle for DB2

Before leaving on a recent business trip to Italy I begun working on a TextMate bundle for DB2. Here I’ll introduce it in the hope that it will interest some TextMate and DB2 users.


There are two simple prerequisites for using this bundle: 1) Install DB2 as a regular user (not root); 2) Source the db2profile by, for example, adding . ~/sqllib/db2profile to your shell profile (e.g., in ~/.profile). Both of these will ensure that your user is able to issue DB2 commands.

To install the bundle, you can run the following (assuming you have git installed):

sudo mkdir -p /Library/Application\ Support/TextMate/Bundles
cd /Library/Application\ Support/TextMate/Bundles
git clone git:// "DB2.tmbundle"

Alternatively, you can download this file, unzip it and then double click on the DB2.tmbundle that was extracted. Of course, the previous method has the advantage of being able to easily update the bundle through git pull.

If TextMate is running while you executed the previous step, you may want to also execute the following line:

osascript -e 'tell app "TextMate" to reload bundles'

This is equivalent to selecting Bundles ? Bundle Editor ? Reload Bundles from within TextMate.

Using the bundle

If you followed the instructions above, at this point you should see a DB2 menu under Bundles:

DB2 Bundle for Textmate

TextMate is a text editor, and as such it expects you to have an open document, in order to execute commands from this bundle. The good news is that an empty, untitled, open by default window will suffice.

As you can see from the image above, you can start the DB2 server, stop it, run an arbitrary query or DB2 command and open up the Information Center for DB2 9.5 in your browser. Below the separating line there are also two submenus, Database and Tables.

Let’s consider Database first:

The Database submenu

Within the Database menu we can connect to a database (this step is required before being able to query a database), disconnect, create a database, drop it, and create the SAMPLE database that ships with DB2 so you can get some practice.

Likewise, while it’s at a very early stage of development, we have the Tables submenu:

The Tables submenu

So far we can list the tables within the database we are currently connected to, and drop an existing table.

You can use the Shift-Command-D combination to bring up a convenient contextual menu of the most common tasks, while you are within a document (unless you are editing an HTML file, in which case that combination brings up Safari):

DB2's menu

The result of each command executed is flashed to the user in the form of an informative tooltip:

The output of DB2START as a tooltip


The aim of this bundle is to provide a more convenient way to work with DB2 without having to switch between your coding editor and the command line. It’s admittedly just a “seed”, a very early effort, but I sincerely hope that even at this stage it can be useful to some people. Being an open source project that’s released under the MIT license, you are free to contribute to it and more than welcome to fork it on Github as well.

If you enjoyed this post, then make sure you subscribe to my Newsletter and/or Feed.

receive my posts by email

No Responses to “TextMate bundle for DB2”

  1. […] MySQL and DB2 Express-C on his Apple MacBook Pro.  He also posted an open source project for TextMate bundle for DB2. If use TextMate on your Apple Mac you will love what Antonio has done. And if you enjoy watching […]

Leave a Reply

I sincerely welcome and appreciate your comments, whether in agreement or dissenting with my article. However, trolling will not be tolerated. Comments are automatically closed 15 days after the publication of each article.

Copyright © 2005-2014 Antonio Cangiano. All rights reserved.