[ANN] Rushmate

On and off over the last few months I have been using rush. Basically, rush is a replacement for the unix shell (bash, zsh, etc) which uses pure Ruby syntax. It adds a lot of convenience to the commandline for people familiar with ruby.

It brings pure ruby syntax to searching (grep), copying files, killing processes, changing permissions and globbing. You can even do all this remotely and it still feels like you are working locally. Here is a quick example.

rush> myproject
=> localhost:/Users/schlueter/myproject
rush> myproject["**/*.rb"].search(/class Bill/).mate

This will open up all the files that contain the string “class Bill” in TextMate. You could just do a find in project in this instance but, with this you can target certain files quicker.

I recently started writing a Textmate command and really wanted to use a few things in rush.

That us why I am announcing Rushmate, the first gem I have written individually. Rushmate provides a Command object that allows you to seamlessly go back and forth between Textmate and rush. It adds a few accessors for TextMate Environment variables so you can access the project dir, current word, etc.

Here is a quick example:

#!/usr/bin/env ruby
require 'rubygems'
require 'rushmate'
Rushmate::Command.new {
  # find ruby files with the current word in textmate
  found_files = project_directory[
    "**/#{current_word.downcase}.rb"]
  if found_files.empty?
    # if you can't find any files show a tool tip
    exit.show_tool_tip(
      "can't find #{current_word.downcase}.rb in project")
  else
    if found_files.size == 1
      # if there is only 1 file go ahead and switch to that file
      found_files.mate
    else
      # if there are multiple files prompt the user for
      # which file they want to switch to
      # then switch to their selection
      menu_files = found_files.collect {
        |f| f.full_path.gsub(project_directory.full_path, "")
      }
      project_directory[
        user_input.quick_menu_from_array(menu_files)
      ].mate
    end
  end
}

It is pretty well commented, but basically it looks at the current word in TextMate then tries to find a ruby file with that name and switch to it. If it finds multiple files with that name, it puts a little menu up and waits for the user to select.

For more information on Rushmate you can view the rdoc online.

ruby-debug meet TextMate

I love [Ruby](http://www.ruby-lang.org/ “Ruby Programming Language”) and [TextMate](http://macromates.com/ “TextMate — The Missing Editor for Mac OS X”). So when my coworker said, “come on, ruby-debug opens in TextMate, it’s a conspiracy”, I nearly jumped for joy.

As of rails 2+, you can interactively debug **”script/server -u”**. One of the commands is **tmate**:

ruby-debug

After you type that, it will open up TextMate with the cursor on the correct line:

ruby-debug-textmate

Once inside TextMate, you can’t really do anything interactively. But, it does become kinda handy when stepping into rails code, you can take a look at the whole method to get a little context.

Pretty Cool!

Skitch Test

I do find these [stats](http://blogs.computerworld.com/canalys_figures_in_iphone_clear_winner_in_north_america “Canalys figures in, iPhone clear winner in North America | Computerworld Blogs”) interesting, maybe a little unbelievable.

Canalys figures in, iPhone clear winner in North America | Computerworld Blogs

But mostly I am just testing skitch + TextMate blogging.

TextMate — Power Editing for the Mac

A couple of days ago a little surprise came in the mail. It was the [TextMate](http://macromates.com/) book written by [James Edward Gray II](http://blog.grayproductions.net/) titled [TextMate -- Power Editing for the Mac](http://www.pragmaticprogrammer.com/titles/textmate/). As a web developer I believe all information can be found on the internet, cheaper and more up to date. This sentiment explains why I haven’t purchased a programming book for several years. This is probably true of the information in this book also. TextMate is a tool that has saved me hours upon hours of my life. So it is only natural that I would buy a book about TextMate saving me hours upon hours of time learning about TextMate. Ok, I admit it is a stretch, but I like the book so much that I feel I have to justify its purchase. This book is obviously the most comprehensive resource for any TextMate user, I only hope it gets quickly updated when TextMate 2 comes out later this year.

The shining star of the book is James’s ability to make difficult concepts reasonable. He is also very active in the Ruby community, he gives you some good Ruby related examples in this book. If you don’t use Ruby this book is language agnostic.

I particularly like the way he explains defining your own languages. It is an important feature for super advanced automation, however it is kind of complicated. There are also great references that are invaluable for day to day text editing automation.

This book will serve as a great reference for anyone trying to become a TextMate super star. But, more importantly this book will show basic TextMate users what they have been missing. If you are a TextMate user pick this book up it will save you seconds each day. The seconds you will save are typically the most tedious part of your day. As a TextMate user obsessed with automating his life, let me tell you it is ok spending 2 hours trying to automate a task that only takes 15 seconds. And if you are not a TextMate user WTF? And don’t give me that I use Windows crap either, buck up and [switch](http://www.apple.com/getamac/).

As proof of the greatness of TextMate, I write all my blog entries in TextMate. Unfortunately, TextMate won’t make good your writing quality :). You need to proof read without automation.

TextMate Javascript Tools Bundle

[Thomas Aylott](http://subtlegradient.com/) committed a bundle that he adopted from [Andrew Dupont](http://andrewdupont.net/) to [BundleForge](http://bundleforge.com/) called Javascript Tools. I can’t tell you how much I am looking forward to using this bundle. It has a bunch of stuff in it, but the thing I am most excited about is [TextMate](http://macromates.com/) integration with [JS Lint](http://www.jslint.com/lint.html). I have only used it for about two minutes, and I can tell that it works exactly like a syntax checker should work.

When you save a file it gives you a little tool tip telling you how many errors and warnings you have.

![Javascript Tools Tooltip](http://www.simpltry.com/wp-content/uploads/2007/02/javascript_tools_tooltip.png)

At this point you can see I have warnings. This is my hint to push \[control]\[shift]\[v]. This shows me my warnings, it is important to get rid of all the warnings so that it works cross browser.

![Javascript Tools Validate js Output](http://www.simpltry.com/wp-content/uploads/2007/02/javascript_tools_validate_js_output.png)

Hers is the code with the warnings:

var MyObject = {
myMethod: function(){
return
},
}

And here is the code after I removed all the validation warnings:

var MyObject = {
myMethod: function(){
return;
}
};

It works great, just don’t run it on [Prototype](http://www.prototypejs.org/) ;)

Here is how I got it installed (you need subversion for this to work).

* Open a terminal
* cd ~/Library/Application Support/TextMate/Bundles
* svn co http://bundles.bundleforge.com/trunk/bundles/JavaScript%20Tools.tmbundle/
* Then go to TextMate and run Bundles > Bundle Editor > Reload Bundles

I have high hopes for the BundleForge project, if it works anything like [Allan Odgaard](http://macromates.com/blog/archives/2007/02/16/javascript-tools/) vision, TextMate will just get better and better. Like all great products, the user community is *almost* better than the product itself.

Feeds/Syndication