Simple textmate applescripting question ([TxMt] TermMate bug)

William Scott wgscott at chemistry.ucsc.edu
Wed Nov 1 00:14:01 UTC 2006


OK, I think this should work for iTerm.  It opens a new tab and goes  
to the directory corresponding to the file displayed in the frontmost  
TextMate window:


tell application "TextMate"
	set ThePath to path of the first document
end tell


set ArgString to "cd $( dirname " & ThePath & ")"

tell application "iTerm"
	make new terminal
	tell the first terminal
		activate current session
		launch session "Default Session"
		tell the last session
			write text ArgString
		end tell
	end tell
	
end tell




On Oct 31, 2006, at 10:45 AM, William Scott wrote:

> Hi Bill:
>
> I was hoping for something similar when I wrote to the mailing list  
> a couple of months ago.  If $TM_DIRECTORY could be made available  
> to the outside world via applescript, morons like me could make use  
> of this.
>
> If he does let you hack on it, I'd be grateful for this  
> functionality too.
>
> Thanks.
>
> Bill
>
> PS:  What I have in mind is something similar to Gary Kerbaugh's  
> Terimal/iTerm -- Finder interaction osa/shell scripts:  http:// 
> xanana.ucsc.edu/xtal/terminal_finder_interactions.html
>
>
> William G. Scott
>
> contact info:  http://chemistry.ucsc.edu/~wgscott
>
>
>
>
> Begin forwarded message:
>
>> From: William Scott <wgscott at chemistry.ucsc.edu>
>> Date: August 12, 2006 8:02:30 PM PDT
>> To: textmate at lists.macromates.com
>> Subject: Simple textmate applescripting question
>> Reply-To: wgscott at chemistry.ucsc.edu
>>
>> Hi:
>>
>> I am trying to write a simple osascript command-line utility that  
>> acquires the directory of the file displayed in the frontmost  
>> TextMate editor window, and am having trouble.
>>
>> I've been trying to use applescript syntax such as this:
>>
>> osascript<< END
>> tell application "TextMate"
>> 	activate
>> 	do shell script "echo $TM_DIRECTORY"
>> end tell
>> END
>>
>> but the variable $TM_DIRECTORY is apparently empty.
>>
>> Is there another way to accomplish this, with or without  
>> applescripting? (I'd prefer a less pathological scripting language.)
>>
>> Thanks.
>>
>> Bill
>>
>>
>>
>>
>>
>




More information about the textmate mailing list