osx - Open php file in browser using http://localhost with applescript -


i'm trying write applescript textwrangler open active document in chrome. script looks @ moment:

tell application "textwrangler" set thefile file of document 1 tell application "finder" open thefile using (path application "google chrome") 

let's working on file absolute path 'applications/mamp/www/index.php'. script open file in browser 'file:// localhost/applications/mamp/www/index.php', showing php code.

instead of need script replace 'file:// localhost/applications/mamp/' 'http:// localhost/' showing actual site.

i have tried bunch of stuff found online, have little experience applescript achieve this.

how this, following chase's lead , using javascript string replacing.

property delim : "mamp" -- break path , prepend localhost  tell application "textwrangler" set thefile file of document 1  tell application "finder" set p posix path of thefile -- convert unix path first  tell application "google chrome" execute front window's active tab javascript ("pth='" & p & "';window.open('http://localhost'+ pth.split('" & delim & "').pop());") 

makes hard read code multi language concatenation , string delimiting, should work.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -