[TxMt] TM autostart trigger - Example for Rdaemon

Hans-Joerg Bibiko bibiko at eva.mpg.de
Wed Mar 19 17:12:22 UTC 2008


Hi,

of course, my tiny approach only works if TM opens at least one  
document window at startup.
Thus I changed the code a bit for the general solution:

[assuming that the AUTOSTART tmCommand has the unique key combo ctrl 
+shift+opt+apple+a]

try
   tell application "TextMate"
     activate
     set n to count of (every window where visible is true)
     set flag to 0
     repeat with x from 1 to n
       set winName to the name of window x
       if length of winName < 8 then set winName to "dummmmmy"
       if length of ((path of (document x)) as text) > 0 or text 1  
thru 8 of winName = "untitled" then
         set flag to 1
         exit repeat
       end if
     end repeat
     if flag = 0 then
       tell application "System Events" to keystroke "n" using  
{command down}
     end if
     tell application "System Events" to keystroke "a" using {control  
down, command down, option down, shift down}
   end tell
end try

##########

To start Rdaemon even there is no window open, I replaced the  
tmCommand "Open Rsession" by a tmTemplate "Open Rsession", because a  
template key combo can be pressed even if there's no window open ;)  
[is already in the svn repository]


--Hans



More information about the textmate mailing list