On 15. Oct 2004, at 20:53, Mats Persson wrote:
I have a project in the following location: [ /Users/mats/Sites/projectName/ ]
In my template I use Custom Shell variables to auto-enter the relevant info.
Template, as in file template?
The "TM_FILEPATH" returns: [ /Volumes/WorkDisk/Users/mats/Sites/projectName/index.php ]
So TM_PROJECT_DIRECTORY/FILEPATH would probably also have the /Volumes/WorkDisk-prefix?
*but* I would prefer to have: [ /projectName/index.php ]
I.e. _including_ the last path of the project location?
in other words remove [ /Volumes/WorkDisk/Users/mats/Sites ] from the TM_FILEPATH or alternatively create a new shell variable with this info only.
You probably want to use 'sed' which can do single-line regex-substitutions, e.g. if I enter and select these three lines in TextMate:
echo $TM_FILEPATH echo $TM_PROJECT_DIRECTORY echo $TM_FILEPATH | sed "s|^$TM_PROJECT_DIRECTORY/(.*)$|\1|"
And press control-r, they return:
/tmp/myProject/untitled.txt /tmp/myProject untitled.txt
So the first two are just the variables, the third is the TM_FILEPATH but w/o the TM_PROJECT_DIRECTORY-prefix [1]
But in your case, you'd preferred it to be 'myProject/untitled.txt' ?
I guess that I would use some form of 'grep' and remove the bits that I don't want, but I can't work out how.
sed is probably what you want, but feel free to ask any followup questions (but provide as much context as possible).
Kind regards Allan
[1] before beta 5 I didn't run the project file/directory through stringByStandardizingPath, so e.g. /tmp would be /private/tmp etc.