TextMate’s bundle system is pretty cool. If you make modifications to bundles, the difference is written as deltas to
~/Library/Application Support/. The original bundle is kept in its unchanged, pristine state – inside the TextMate application, in
~/Library/Application Support/ if downloaded and installed, or in
/Library/Application Support/ if you did a SVN checkout. (See this post for a fuller explanation of where bundles go and why.)
Since your local changes are kept apart from the distributed bundle, updates by the bundle author do not overwrite your own changes, and all is well.
But what if you are the bundle author?
If you distribute the bundle as a web download, you can just drag-and-drop it from the Bundle Editor to the desktop, zip it up and share. The bundle you share will include any local changes.
If you version control a bundle you’re developing, though, you probably don’t want deltas, but to have any changes made in the Bundle Editor written directly to the bundle itself. This is achieved by keeping the bundle in
~/Library/Application Support/ (which is, incidentally, where bundles go when you do “New Bundle” in the Bundle Editor). No deltas are created; all changes are written directly to the bundle.
But sometimes you do want deltas. For my Greasemonkey bundle, I want TextMate-global keyboard shortcuts for some stuff (creating a new userscript from template, opening an installed userscript), but bundles should not be distributed with TextMate-global keyboard shortcuts unless it’s necessary (e.g. the Subversion bundle).
To be able to easily switch between writing changes as deltas and writing changes to the bundle proper would be quite useful. So I wrote a TextMate command for this.
Download: MyBundle Toggle Deltas.tmCommand.
The command assumes you keep the bundle in
~/Library/Application Support/. When run, the command switches the deltas and the complete bundle between that directory and
Pristine Copy/Bundles. When the deltas are in the non-pristine directory, any changes you make become deltas, and local changes (e.g. my global keyboard shortcuts) are available to use and modify. When the deltas are in the pristine directory, they are ignored. Changes are written directly to the bundle, and your personal, local changes are not available.
The command requires you have Growl installed, with growlnotify – it informs you of the current editing mode with a Growl notification. The notification is sticky, meaning it doesn’t go away until you click it. The idea is to keep you aware of the current mode.
You need to edit the command to specify the name of the bundle in question. I only maintain one bundle, so the command only handles one. You can simply create several copies of the command, one for each bundle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Bug reports and suggestions are very welcome.