[TxMt] TM autostart trigger - Example for Rdaemon

Hans-Joerg Bibiko bibiko at eva.mpg.de
Wed Mar 19 13:59:55 UTC 2008


Hi,

I do not know whether this is interesting for other users as well,  
but I find it's worth to have a small note on it.

Up to now TM doesn't have the chance to do something when it starts.  
But there is an easy way to trigger a tmCommand or whatever.

A concrete example:
I want to open TM and it should start Rdaemon automatically.

Solution:
I wrote a tiny AppleScript with Script Editor:

tell application "TextMate"
	activate
	tell application "System Events" to keystroke "r" using {control  
down,command down,option down}
end tell

and I save it as an application with the name "TM_Rdaemon" (if you  
want, customize the icon ;). Now you put this app to any location or  
drag'n'drop it to the Finder's toolbar.

If you invoke TM_Rdaemon.app it starts TM and it executes the key  
combo CTRL+OPTION+APPLE+R which is a shortcut to open Rsession.proj  
and to start Rdaemon.


To generalize it a bit one can also use this simple approach to  
trigger a auto-start-up script. The only thing to do is to create a  
tmCommand, let's say AUTOSTART, with the desired commands you want to  
call after TM started and bind it to a UNIQUE key combo without  
setting a scope.
After doing it, change the above mentioned AppleScript and  
change ...to keystroke ... to your UNIQUE key combo.
Then you can change the AUTOSTART tmCommand easily to trigger some  
stuff, e.g. open the Bundle Editor and open a specific project or  
whatever; or open a file and set it to specific grammar language.  
Everthing is done by using AppleScript's '"System Events" to keystroke'.

At least for me, it saves sometimes a bit time.

[BTW Is this worth to mention it in TM's wiki "How to > AppleScript" ?]

Cheers,

--Hans




More information about the textmate mailing list