Monday, March 16, 2009

Opening Header Files via LaunchBar

I’ve long used LaunchBar to quickly open Mac OS X header files. The built-in “Development Resources” indexing rule can be configured to scan headers. However, this has two problems:

  1. The headers are commingled with the HTML reference files. I do want access to the reference files, but sometimes I know I want to open the header.
  2. It opens headers from the 10.4u SDK even though I’m running Leopard.

Here’s a LaunchBar AppleScript that will only open headers, and it will open all the matching headers:

on handle_string(_string)
    do shell script "echo '1' | open -h " & _string's quoted form
end handle_string

The “1” is because if there are multiple matches, open will ask you what it should do:

open -h NSAttr
[0] cancel
[1] all
[2] /System/Library/Frameworks/AppKit.framework/Headers/NSAttributedString.h
[3] /System/Library/Frameworks/CoreData.framework/Headers/NSAttributeDescription.h
[4] /System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h

And I want to pick “all.”

Comments RSS · Twitter

Leave a Comment