Adding preview to (C#) source files in OS X
So I’ve been forced to use OS X a lot these days, what with an iOS project and teaching programming to kids (see Jono’s post). I’ve tried on a few occasions to get comfortable in OS X, and even own an old early G4-based macbook. Well, that is to say, I bought it from my sister for $50 and used it for a few months freshman year before lending it to a friend… long story short it was a nice little reliable laptop which I could carry around with me, check e-mail, browse the web, etc. Basically I used it as a netbook before netbooks were cool.
Obviously judging the OS X experience from my short time with a then-obsolete laptop is unfair, but I would say that that’s the type of use these computers are geared towards. I certainly consider myself a Windows power user–I’ve been using a Microsoft OS since DOS 5–but I’m still pretty clueless when it comes to OS X. I’m taking it slow, trying to learn about features as the need arises. I’m a fan of menu-bar activity monitors, though I haven’t settled on which is my favorite. One feature I’m very pleased with is the OS-wide quick-look preview, but I was disappointed to find that it didn’t know how to understand my .cs source files (or a few other types for that matter). Not only that, but when it comes across a type that it can’t understand, the “default” is very minimal. If the content is just text, why not show a text preview? A quick Google search came up with a solution, but configuring it was a little hairy. Here’s what I did:
- Google “OS X preview C#”
- Discover preview feature is called “Quick Look”
- Google “Quick Look Syntax Highlight”
- Try just installing qlcolorcode
// -*- mode: XML; -*- ... UTImportedTypeDeclarations ... UTTypeConformsTo public.source-code UTTypeDescription C# Source File UTTypeIdentifier com.microsoft.csharp-source UTTypeReferenceURL http://www.microsoft.com/ UTTypeTagSpecification public.filename-extension cs ...
If I’m following your solution here correctly, it didn’t work for me — I think you:
-Installed qlcolorcode to ~/Library/QuickLook/
-Modified the MD Info.plist as posted
That said, my Info.plist already was as you posted. Did I miss something?
BolnerTJ said this on September 3, 2011 at 5:41 am |
Damn. I was afraid of that. Like I think I mentioned, I did this a little while ago and I don’t fully remember what it was that I did to finally get it working, but I know the .plist file was the key. You may have to add this
public.source-code
to the .cs listing, but I can’t fully remember. Let me try this on another machine, and come back with an edit.
Now that I look more clearly, I’m pretty sure I just added the lines above (post-edit) to the info.plist of qlcolorcode itself.
Sorry for the confusion!
Schoen said this on September 4, 2011 at 1:10 am |
In my qlcolorcode info.plist (this post first referred to MD’s info.plist, no?), again I find that your posted xml is already there (a public.source-code entry for C# Source Files), so no edits necessary.
Update on my situation: I am now indeed getting a preview for my C# files (I think that was just from rebooting since installing qlcolorcode), but alas, not color coded!
BolnerTJ said this on September 5, 2011 at 7:43 pm |
thanks for this.
you CAN select text in quick look!
http://www.techrepublic.com/blog/mac/how-to-enable-copying-text-from-within-quick-look-previews-via-the-terminal/1850
now everything is perfect. great!
mike said this on July 26, 2012 at 2:52 am |