On 06/10/2005, at 11.24, salvo wrote:
sometimes I test anything (like html page and perl scripts) writing directly on Desktop, first to pass them in the correct localhost web site folders, so I've set Apache to handle also $USER/desktop as localhost directory. I try to put in bundle editor, html this line:
open `echo $TM_FILEPATH | sed "s|.*/$USER/Sites/(.*)|http:// localhost/~$USER/desktop/\1|"`
You probably want:
open "`echo $TM_FILEPATH | sed "s|.*/$USER/Desktop/(.*)|http:// localhost/~$USER/desktop/\1|"`"
Which makes a file path of e.g. /Users/duff/Desktop/test.html into http://localhost/~duff/desktop/test.html
You can also use the shells ability to chop off a prefix ($HOME points to your home folder), e.g.: open "http://localhost/~%24USER%24%7BTM_FILEPATH#%24HOME%7D"
If you do spell Desktop in different case (lowercase for the URL): open "http://localhost/~%24USER/desktop%24%7BTM_FILEPATH#%24HOME/Desktop%7D"
Btw: instead of opening the URL, you can also set the commands output to HTML and then let it redirect to the URL, so you'll view the page inside TextMate: echo "<meta http-equiv='Refresh' content='0;URL=http://localhost/~ $USER${TM_FILEPATH#$HOME}'>"
I recently blogged about both shell variable substitutions and HTML output capabilities: http://macromates.com/blog/archives/2005/09/28/html-output-for- commands/ http://macromates.com/blog/archives/2005/09/26/shell-variables/