I mostly use IntelliJ for all my Grails dev work, but every now and then I end up doing some quick work with  the Groovy and Grails TextMate bundles on Windows. The e text editor for Windows can read Textmate bundles, so I can enjoy all the handle snippets and colouring that the bundles provide.

The recent copies of the bundles hit a snag on Windows, however, since they use Windows reserved filename characters like <g:>. You can’t git clone the bundles because of the filename, but you can download the zip from github and mangle the filenames later to make them windows-friendly. WinZip will tell you it’s a malformed zip, though 7zip does the right thing and will let you inspect and rename each dodgy filename. But there are dozens and dozens of them! There must be a better way!

In order to fix it up, I whipped up a little script that reads in the zip, fixes all the filesname, then writes out an win-friendly zip that you can use in for you e bundle. Here’s the magic for your groovyConsole-ing:

import java.util.zip.*

String infile = "/temp/textmate-groovy-grails.tmbundle.zip"
String outfile = "/temp/textmate-groovy-grails.tmbundle.win32.zip"

ZipInputStream inzip = new ZipInputStream(new FileInputStream(infile))
ZipOutputStream outzip = new ZipOutputStream(new FileOutputStream(outfile))

ZipEntry nextFile

while(nextFile = inzip.getNextEntry()) { 

    def winFriendlyName = nextFile.name.replaceAll(/[:<>"]/, "_")
    println "${nextFile.name} -> ${winFriendlyName}"
    outzip.putNextEntry(new ZipEntry(winFriendlyName))
    int nextByte
    while ((nextByte = inzip.read()) != -1) {
        outzip.write(nextByte);
    }
    outzip.flush()
    outzip.closeEntry()

}
outzip.flush()
outzip.close()

&nbsp;

I should be using Buffered versions of all those streams for performance, but the files are so tiny I couldn’t handle doing any more battle with the java.io.zip javadocs.

Once you have the new zip file, unzip it into %APPDATA%\e\Bundles and make sure the directory ends in .tmbundle (rather than the tmbundle.abdeadbeef git signature you’ll get) otherwise e will not load the bundle.

Happy Bundling!

&nbsp;

UPDATE: You don’t need all of the above pain! You can just download the latest Win-friendly-named version from this mirror on github.