puts Blog.new(”nonsense”)

history meme

Posted by Jason Rudolph on 16th April 2008

Rob dared me to fire up my favorite shell and jump into the game. Imagine my disappointment when I was greeted with this bummer of an error message.

20080416 History Meme Commodore 64

Hmm. No dice. OK, on to my second choice.

  1. jason@jmac:~> history | awk ‘{a[$2]++}END{for(i in a){print a[i] " " i}}’ | sort -rn | head
  2. 48 cd
  3. 30 exit
  4. 29 m
  5. 20 ls
  6. 18 git
  7. 13 mman
  8. 12 **
  9. 10 cap1
  10. 9 ssh
  11. 9 rake


The result? A few well-known friends and some that likely deserve a bit of elaboration.

Tags: , , , , , | No Comments »

Manning up: TextMate Meets Man Pages

Posted by Jason Rudolph on 14th March 2008

Navigating through man pages in a terminal window doesn’t exactly rank as a highlight of this developer’s day. The experience feels like 1971 for a reason, and that means of interaction just leaves something to be desired. Perhaps you could make the argument that A) people that read man pages don’t rank humane interfaces as a top priority, or that B) I could spend more time mastering the ways to navigate via less (the default man page browser in OS X). But, believe it or not, apparently I’m not alone in my crazy desire to consult man pages outside of the terminal. So with web-based solutions, PDF generators, and full-blown apps dedicated solely to “manning up,” where should we turn? Queue The Pragmatic Programmer for some welcome words of wisdom:

Use a Single Editor Well

The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable.

For me, that editor is undoubtedly TextMate. I already spend most of my day in TextMate, be it for coding, blogging, editing wiki pages (and other Safari-based content), or sometimes even writing e-mail. So, if I can use TextMate to find my way around a man page, that’s an all-around win.

Goal

While working in the terminal, be able to quickly open a man page in TextMate.

Making it happen

First, install the mate shell command. (Even if you have no interest in viewing man pages in TextMate, this command is simply indispensable for anyone that even occasionally ventures into the land of the terminal.)

Now that we have access to TextMate from the command line, we can assemble a quick script to get us the rest of the way toward achieving our goal. I keep all of my custom scripts in a .scripts directory that I include in my path, so I’ll define this handy scriptbaby in a file named mman (for “mate man”) in that directory.

  1. > ls -l /Users/jason/.scripts/mman
  2. -rwxr-xr-x@ 1 jason  jason  43 Mar 14 15:52 /Users/jason/.scripts/mman


And once we drop a bit of Unix-fu into that file, we’ll be good to go.

  1. #!/usr/bin/env bash
  2.  
  3. man $1 | col -b | mate


To see it in action, just use mman anywhere you would have previously used the vanilla man command.

Running mman in Terminal to open man page in TextMate

Kicking it up a notch?

That approach has served me well for several months now, but in the course of writing this post, I came across an associated TextMate bundle that some folks may find helpful as well. The TextMate Man Pages bundle offers some (minor) syntax highlighting, the ability to open a man page from within TextMate, and the ability to use Command + Shift + T (i.e., “Go To Symbol”) to quickly find and access key sections of the man page by name.

Showing off the TextMate man page bundle

Now go forth and devour some man pages already.

Tags: , | No Comments »

Getting Groovy with TextMate

Posted by Jason Rudolph on 2nd November 2006

Graeme Rocher has assembled Groovy and Grails bundles for the splendid (and increasingly popular) TextMate editor for Mac OS X. These bundles offer a whole host of code snippets for common Groovy and Grails tasks, and as you might expect, the bundles provide some handy syntax highlighting as well. While these bundles are certainly useful for anyone working with Groovy and Grails in TextMate, they should be especially helpful for Groovy and Grails newbies.

"Hmmm. I need to iterate over each line in a file. How exactly do I do that in Groovy?"

Goes to TextMate menu…

Bundles –> Groovy –> Iteration –> Files & Streams –> eachLine

TextMate Groovy Bundle Menu Screen Shot

The developer finds the answer he needs without ever leaving the editor. (Less context switching equals greater productivity, so it's an all-around win.) In fact, it's really a great way to discover various Groovy and Grails features. Just by looking through the available code snippets, a developer can quickly check out all sorts of APIs and idioms he might not have otherwise known about. Of course, you're not required to use the menu to benefit from the code snippets; you can also tab through various code completion options. Sticking with the example above, you can type File, hit tab, and TextMate inserts the same code snippet we'd get from the menu.

TextMate Groovy Bundle Code Snippet Screen Shot

If you're ready to give it a shot, just follow the pleasantly-simple installation process, and you'll be good to go.

  1. Download and untar the tarball.

  2. Copy the bundle files (Groovy.tmbundle and Grails.tmbundle) to ~/Library/Application Support/TextMate/Bundles
  3. jason> ls -l ~/Library/Application\ Support/TextMate/Bundles/
    total 0
    drwxr-xr-x 5 jason jason 170 Nov 1 17:33 Grails.tmbundle
    drwxr-xr-x 6 jason jason 204 Nov 1 17:33 Groovy.tmbundle
    jason>
  4. Fire up TextMate and start groovin'!

For more examples of what you'll get from these bundles, be sure to check out the initial release notes.

And, there's still more to come. Graeme points out that these bundles are a work in progress. In addition to more code snippets, future releases will likely provide the ability to execute a Groovy unit test directly from within TextMate, execute a Groovy script inside TextMate, etc.

If you have a chance to try it out, shoot a quick note to the Groovy mailing list with your thoughts (or post a comment here, and I'll be happy to pass it along).

– 

Update (2006-11-03)

Work in progress, indeed! Graeme has just added the ability to run Groovy scripts and Groovy classes from within TextMate.

To take advantage of these new features, first make sure you have Groovy installed and that your GROOVY_HOME variable is set. Then, just grab the current version of the bundle, install it, and you're ready to rock.

Once you've installed the latest bundle, open any Groovy file in TextMate, and hit Command + R to run the file in your editor.

Presenting…the gratuitous Hello World example…

TextMate Screen Shot - Groovy Output w/ Command + R

Or, if you just want to execute the currently selected text, hit Command + Option + R to run just the selection.

TextMate Screen Shot - Groovy Output w/ Command + Option + R

Stay tuned for more updates as they come in. 

– 

Update (2007-01-13)

I modified the bundle links above to point to the locally hosted copy of the bundles, until such time that these bundles make their way to the official TextMate repository.  Thanks, Martin, for this suggestion

– 

Update (2007-01-28)

The bundles still have yet to make their way to the official TextMate repository, but the Groovy site is now hosting a page on TextMate integration.

– 

Update (2007-02-19)

At long last, the bundles have found a new home at the official TextMate repository.  Not only have they found a new home, but you'll also find some nice new features in the latest revision of the bundles.  So, if you previously fetched the bundles from anywhere other than the official TextMate repository, you'll likely want to upgrade to the latest version. 

Tags: , , | 4 Comments »