Following my last post, a few people asked me to create a Pygments TextMate bundle. Ask and ye shall receive (on GitHub).

The Pygments menu

Prerequisites


Install Pygments following these instructions.


Installation


First method:

sudo mkdir -p /Library/Application\ Support/TextMate/Bundles
cd /Library/Application\ Support/TextMate/Bundles
git clone git://github.com/acangiano/pygments-textmate-bundle.git "Pygments.tmbundle"

If TextMate is running while you perform the update, execute the following:

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

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

Second method: Download this file, unzip it, and double click on Pygments.tmbundle.

By the way, add the following to your stylesheet if you’d like to see a scrollbar when displaying very long lines of code. This adds a nice border as well:

.highlight { border: 1px solid silver; padding-left: 5px; margin-bottom: 0.5em; overflow-x:auto; }

Related Articles:


If you enjoyed this post, then make sure you subscribe to our RSS Feed.

Comments

5 Responses to “Pygments TextMate Bundle”

  1. Integrating TextMate and Pygments | Zen and the Art of Programming on October 28th, 2008 12:50 pm

    [...] I made a Pygments TextMate Bundle out of [...]

  2. Kit Plummer on October 28th, 2008 1:19 pm

    Thanks man. Haven’t looked deeply – just noticed this when I tried to use the bundle for the first time:

    Traceback (most recent call last):
    File “/tmp/temp_textmate.Rff5iz”, line 6, in
    from pygments import highlight
    ImportError: No module named pygments

    I did install through port. It isn’t your problem…just figured I share something I saw. But, if you do happen to know a quick fix, it’d be appreciated. ;)

  3. Antonio Cangiano on October 28th, 2008 1:42 pm

    My apologies, Kit, it looks like Mac Ports is not going to work. I’ve changed my instructions.

  4. Daniel Luz on October 28th, 2008 2:45 pm

    Wouldn’t it be better to name that repository pygments.tmbundle? Maybe that’s a bit late… just a minor convenience, anyway.

  5. Antonio Cangiano on October 28th, 2008 2:57 pm

    Hi Daniel, the repository name is already in lowercase form. In the instructions, I ‘git clone’ in the folder “Pygments.tmbundle” because TextMate bundles conventionally start with a capital letter.

Leave a Reply