[TxMt] Open Document(s) in Running Browser - Does Nothing

Roger Roelofs roger.roelofs at gmail.com
Thu Feb 8 18:44:31 UTC 2007


Chip,

On Feb 5, 2007, at 2:02 AM, Chip Cullen wrote:

> well, i don't know what to do with getting textmate to work with
> safari. am i the only one who is running into this problem? i feel
> like it can't just be me.
>
> Roger, thanks for your insight. do you have any idea what safari's
> 'real name' would be?

Chip and list,

I played with the code for this command and have something that works  
on my machine.  Could some of yo q a it and make sure I haven't done  
something stupid :-)

----------------  Code for: Open Document(s) in Running Browser  
----------
### Preview in All Active Browsers
### v1.0. 2005-03-29
### v1.1. 2005-12-04
### v2.2. 2006-11-03
### v3.0. 2007-02-08
###
###	CONFIG OPTION:: Set TM_PROJECT_SITEURL in your TM Project Window  
Info Button in the following form: [ http://your.site.ext/ ]
###

# 1. Check if we have a SITE_URL
if [[ -n "$TM_PROJECT_SITEURL" ]]
     then activeURL="$TM_PROJECT_SITEURL${TM_FILEPATH## 
$TM_PROJECT_DIRECTORY}"
     else activeURL="file://$TM_FILEPATH"
fi

osascript <<"APPLESCRIPT" - "$activeURL"
on run(argv)
     set activeURL to item 1 of argv
	set startFrag to "on run(argv)" & return & "tell app "
	set makedoc to " to make new document with properties {URL: item 1  
of argv}" & return & "end run"
	set mbrowsers to {"Webkit", "Safari", "Shiira"}
	set gurl to " to Get URL (item 1 of argv)" & return & "end run"
	set gbrowsers to ["Camino", "Xyle scope", "firefox-bin"]
	set gurl2 to " to GetURL (item 1 of argv)" & return & "end run"
	set g2browsers to ["Omniweb", "Opera"]
	tell application "System Events" to set proclist to name of every  
application process
	
	repeat with browser in mbrowsers
		if proclist contains browser then
			set cmd to startFrag & "\"" & browser & "\"" & makedoc
			run script cmd with parameters {activeURL}
		end if
	end repeat
	
	repeat with browser in gbrowsers
		if proclist contains browser then
			set cmd to startFrag & "\"" & browser & "\"" & gurl
			run script cmd with parameters {activeURL}
		end if
	end repeat
	
	repeat with browser in g2browsers
		if proclist contains browser then
			set cmd to startFrag & "\"" & browser & "\"" & gurl2
			run script cmd with parameters {activeURL}
		end if
	end repeat

	-- I don't know what this does, so i left it in
	if proclist contains "$1" then
		run script "on run(argv)" & return & "tell app \"$1\" to `pbpaste`"  
& return & "end run" with parameters {activeURL}
	end if

	-- ie could also use GetuRL but then you can't tell it to ignore the  
cache
	if proclist contains "Internet Explorer" then
		run script "on run(argv)" & return & "tell app \"Internet Explorer 
\" to activate OpenURL (item 1 of argv) toWindow 0 Flags 1" & return  
& "end run" with parameters {activeURL}
	end if
end run
APPLESCRIPT
-------------------------  end code  -------------

Watch for line breaks when copying.

Thanks!

-- 
Roger Roelofs
"Remember, if you’re headed in the wrong direction,
	God allows U-turns!"
	  ~Allison Gappa Bottke




More information about the textmate mailing list