I have been wanting to get specific terminal applications to be targets of Launchbar, or to be clickable in the dock. Basically, I want to treat terminal applications like GUI applications, and switch to them rather than switching to the termial.app and then trying to get to the window I want. With this tip, I can activate Lauchbar, type "pine" and have my pine window come to the foreground, even if it had not been the frontmost terminal window before, and then switch to "top" without touching the mouse.
With the new terminal application in 10.2, this is now possible, thanks to the addition of an addition to the scripting dictionary called "frontmost" under "Window".
To make a command line application "targetable" as a unique application, you need to make a *.term file to launch the application, and a short AppleScript to launch the term file or activate the window if it is already running. The applescript relies on the name of the terminal window, rather than the process running in that window. This lets you have some general "command" sorts of windows that you can run different programs in, but still target them by name.
Read the rest of the article for the how-to...
The first step is to create the *.term file that you will use to launch each application that you want to target. You do this by opening terminal and getting it to look just like you want it to. Set the placement on the screen just where you want it, get the colors, fonts and transparencies set just they way you like. I like to color code my windows, so that I know that "pine is always green text, Top is always black text on yellow background, etc. Then set the terminal window's title to something unique. To do this, select "Set Title" from the File menu, and then type the name you wish to give the window in the "title" box, and be sure to deselect all of the options below the name. This terminal window MUST be called something simple that never changes. Then go to File and select "Save As" and give the file a nice short name, and save it to a place that you can call with an AppleScript. You will have one such file for each application you want to target. I put all of mine into their own folder under a folder called Toys that I put in my Applications directory. For this example, I set the title of my terminal window to "pine" and saved it to: /Applications -> Toys -> PineActivator -> pine.term.
Next you have to edit the *.term file that you just created so that it automatically launches whatever terminal application you are interested in targeting. You can do this by editing the term file in any text editor. You can use pico from the terminal , or TextEdit from the Applications folder, or whatever. What you do is find the section that looks like:
ExecutionStringAdd in the command you wish to launch (along with a return), so that it looks like this (with pine as an example) between the "string" tags. this (for our example will look like:
ExecutionStringThen save the document.
pine
on runSave the script as an application, and select the "Stay open" option when you save it. By having it stay open, you have an icon in the dock that you can click when you want to activate the application you created this for, and you don't have to wait for it to relaunch to use it. You will have to relaunch "LaunchBar" if you want it to find your new "activation" application. You can give the script a nice little icon if you want so it looks good in you dock as well.
if the window "Pine" of the application "Terminal" exists then
tell application "Terminal"
activate
set frontmost of window "Pine" to true
end tell
else
tell application "Finder"
open "40Gigger:Applications:Toys:PineActivator:Pine.term"
end tell
end if
end run
on reopen
run
end reopen
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020828082820976