Friday, March 6, 2009

OS X: Quick Look for Groovy

Update: The info in this post is deprecated, check out my post Quick Look for Groovy with Syntax Highlighting.


Quick Look is one of the coolest features of OS X Leopard.

Unfortunately it only supports a limited range of file types.
I blogged before how I got Quick Look to display .properties files.

Lately I am playing a lot with Groovy... and .groovy files are also not supported by Quick Look out of the box.

Finally I got Quick Look working to show .groovy files. But it has been quite a hassle.

In the following I am using TextMate, but this should also work with another text-editor like Smultron or TextEdit.

This is what I did:
  • I navigated into the TextMate package (right-click->Show Package Contents).
  • I edited Contents/Info.plist with a text-editor.
  • I added the follwing snippet at the end of Info.plist (just before the ending </dict> </plist>)
  • 	
    	UTExportedTypeDeclarations
      
        
          UTTypeConformsTo
          
            public.text
    			public.plain-text
          
          UTTypeDescription
          Code
          UTTypeIdentifier
          com.macromates.textmate
          UTTypeTagSpecification
          
            com.apple.ostype
            TEXT
            public.filename-extension
            
              properties
              groovy
            
          
        
      
    

  • Then I set TextMate as the default editor for .groovy files.

  • Then I did the following steps on the command-line, without really knowing what they do. Probably not all of them are necessary:
  • touch /Applications/TextMate.app
  • qlmanage -r
  • touch ~/Library/QuickLook/QLColorCode.qlmanager
  • /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f -v ~/Library/QuickLook/QLColorCode.qlmanager

  • The result is that QuickLook at least displays .groovy files as plain text:
    Picture 1.png
    Next on the wishlist would be syntax-highlighting. Unfortunately this does not work with the qlcolorcode-plugin since Highlight does not support Groovy.

    Last tip: To find out which Quick Look generator is configured for a file type you can use the following command: qlmanage -p Greet.groovy 2>&1 | grep 'Generator used'

    I collected these infos mainly from here and here.

    3 comments:

    1. I definitely love Quick Look, and having it for groovy files is awesome! Thanks for the writeup. Let me know if you figure out how to get it working with a highlighter, added bonus!

      ReplyDelete
    2. This is an awesome tip, thanks a lot!

      ReplyDelete
    3. I found out how to enable Quick Look with syntax highlighting for Groovy.

      Check out Quick Look for Groovy with Syntax Highlighting.

      ReplyDelete

    Related Posts Plugin for WordPress, Blogger...