On 18 Nov 2014, at 15:41, Baldwin, Dave wrote:
Here’s a simpler solution:
[ Build/** ] windowTitle = "$windowTitle **** BUILD **** "
Can you explain what is going on here?
The first line (`[ Build/** ]`) means that settings below that line are only applied to file paths that match the pattern `Build/**`, i.e. files under the `Build` directory.
The next line simply appends a `**** BUILD ****` to the `windowTitle` variable (which has a default value from the default properties file included with TextMate).
Also what is the magic to get the git branch name?
If you use ⌃⌘T (Bundles → Select Bundle Item…) and switch to settings, then enter `windowtitle` and you’ll see that it gets assigned to from `Defaults.tmProperties`. You can select to “edit” it to see the full properties file, which reveal how the default title is constructed.
This is also shown as the syntax:
(?«var»:«if»:«else»)
which is what I have (as far as I can see).
Sorry, I didn’t read your code carefully.
Your issue is that you try to match `Build` and if it matches, replace it with `**** BUILD ****`.
Now, incase you do not match `Build` then no replacement is done, which means the value of TM_DIRECTORY is inserted as-is.
So what you should have used was something like this:
${TM_DIRECTORY/(.*Build.*)|.*/(?1:**** BUILD ****:)/}
Here we always match the entire value of TM_DIRECTORY, and only if capture register 1 is set, do we replace it with `**** BUILD ****`. If nothing is captured, we replace the entire string with nothing.
The manual has the full syntax here: http://manual.textmate.org/references.html#format-string
I was aware of this but without some explanation it is too cryptic and I am sure the majority of TM users are in the same boat.
Right, the manual is still work-in-progress (and very incomplete), but it has the full/exact format string syntax.
The blog post from James has a lot of examples about how to use format strings in practice.