Skip to content

Faster project search for Textmate

Sometimes, searching in Projects for stuff using Textmate is a real drag. If the project is big, TM will freeze and will put you in that situation where you’re not sure whether an app will crash or not, which for me is reason enough not to use the feature. Nevertheless, it is very handy to be able to search for strings or patterns within a project tree – especially when we are talking about 10K + lines of code.

SO, quite late at the party on this one I guess, but I just discovered Ack, which is -apparently- better than grep. We all know grep is the man of course, what with being responsive for all the Quicksilver and Spotlight goodness Macs come with, so no disrespect here, but the ack tmbundle is indeed faster than the native grep based one.

Ack is friendlier that the mightly grep, featuring results highlighting, and easier command argument structure

Here is how to install it, assuming you use MacPorts:

  1. install ack
    sudo port install p5-app-ack

    If you don’t use MacPorts, you can always go for:

    sudo curl http://betterthangrep.com/ack-standalone > ~/bin/ack && sudo chmod 0755 !#:3

    I’m not sure the second one will work, but can’t see why not, as this version professed to work with default perl libs.

  2. Install AckMate by following the instruction on the GitHub page (Download latest, unzip and double click)
  3. AckMate’s menu item is installed under Edit->Find->Search Project With AckMate... and its default keyboard shortcut is ctrl-option-command-f. If you want to change AckMate’s keyboard shortcut to something else, you can easily do so in System Preferences under Keyboard->Keyboard Shortcuts. View the usage page for details.

Here is an example highlighting the difference in execution speed:

$> wc -l `find . -iname "*.php"`
$> 448549 total
$> irb
now = Time.now.to_i
system(%[grep -R "ArticlePeer" .])
puts "grep finished in #{Time.now.to_i - now} seconds"
now = Time.now.to_i
system(%[ack ArticlePeer])
puts "ack finished in #{Time.now.to_i - now} seconds"

Output:

> grep finished in 39 seconds
> ack finished in 11 seconds

Of course, the real big deal is that with AckMate you start getting results back as ack identifies them, so your Textmate doesn’t get locked.

Categories: Tricks.

Tags: , , , ,

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.