[TextMate] Custom Shell Variables question

Allan Odgaard allan at macromates.com
Tue Oct 19 00:47:07 UTC 2004


On 18. Oct 2004, at 15:35, Mats Persson wrote:

> So I am trying this inside a text doc in TM with no success. What's 
> wrong ??
>
> 	TM_PROJ_FILEPATH=`$TM_FILEPATH | sed 
> "s|^$TM_SITES_DIRECTORY\(.*\)\$|\1|"`
> 	echo $TM_PROJ_FILEPATH
> /bin/sh: line 1: 
> /Volumes/WorkDisk/Users/mats/Sites/projectName/index.php: Permission 
> denied

You need to put 'echo' before '$TM_FILEPATH'. So it should be:
    TM_PROJ_FILEPATH=`echo $TM_FILEPATH | sed 
"s|^$TM_SITES_DIRECTORY\(.*\)\$|\1|"`
    echo $TM_PROJ_FILEPATH

Stuff in `...` is executed as a command. $TM_FILEPATH expands to the 
file path, so doing `$TM_FILEPATH` alone would try to execute the file. 
Doing `echo $TM_FILEPATH` instead will echo (print) it. Of course we 
add `echo $TM_FILEPATH | sed ...` to run sed on the result, to replace 
the path prefix. The | char means take output from the command on the 
left side and use as input for the command on the right side.

Not sure how much shell stuff you know!?!

> Perhaps I could suggest that you guys who know and understand this 
> stuff could create a ShellScriptCorner on the wiki where you could 
> translate the incomprehensible stuff into examples and ENGLISH for us 
> non-geek's. Because the writers of man files and online UNIX guides 
> sure as hell hasn't.

It's a good idea, though personally I'm probably better at answering 
concrete questions than writing general tutorials/documentation.


Kind regards Allan




More information about the textmate mailing list