VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app

A Couple of Usefule Snippets When Working with Textmate

       

Here is the snippet

f path/to/directory 'search string' | open_in_mate

This snippet (technically 2 snippets) will recursively scan the contents of files in a directory and then open all the files it finds in Textmate.

It's useful on large projects where you would otherwise use a "find in project" feature.

However, what's useful about the snippet is that it let's me narrow my search very quickly.

Typically, I'll start w/ a broad search term...

f path/to/dir "something"

And I'll then narrow it down...

f path/to/dir "something more specific"

From the command line I can just hit the up arrow or "ctl+p" so I can very quickly refine what I'm looking for very doing.

The "f" command is just an alias around ACK. I inverted the argument order so that I can hit "ctl+w" to erase the search term without having to retype the path.

# in ~/.bash_profile
function f { ack -i "$2" "$1"; }

Then when I feel like I have found what I'm looking for, I'll pipe it to a little script I wrote

open_in_mate

The open_in_mate script will extract file paths from a blob of text and then runs the mate command, which opens up the file in Textmate if it exists.

data = ''
while $stdin.gets
    data << $_
end

data.scan(/^(app.*.(erb|rb|coffee|js|css|scss))/i).each do |f|
    f = f[0]
    if File.exists?(f)
        `mate #{f}`
    end
end

Note that I'm only looking for certain file type in a Rails app. You could make it more generic if needed.

Tagged w/ #command line #snippets #textmate #ack #ruby #rails