QuickLook

MacOS (upto Ventura checked) QuickLook preview for .srt .vtt and other subtitle files.

QuickLook is great – when it works… photos, some audio, some video, some documents…. what about the rest?

There are many plugins available, but since MacOS 12 (Monterey) – they have been breaking.  Much of worked last year, is near impossible for non developers to get working.  I did a deeper look into exploiting QuickLook tools for my own use back in 2019 – here.  But the two tools I use most now are described below:

SyntaxHighlight
For code, with an excellent and functioning tool is SyntaxHighlight, which allows you to setup preferences for different languages… be it C, python, pearl or plain old bash scripts.

 

Many document files are, in their bare essence, plain text files, but without support for a specific file extension we are left high and dry – being forced to open them in their respective application just to take a look.

qlstephenThe solution I found best for me is the QuickLookStephen plugin – which allows you to view any type of text file with any extension without their own dedicated QuickLook plugin. For example files like README, INSTALL, CHANGELOG, etc..

And with a little tweaking, you can add any other extensions you need… which is exactly what I did for text subtitle files — formats such as .srt and .vtt.

Here’s how to get it setup:

  1. Download & Install QuickLookStephen – I prefer to do this via homebrew

    $ brew install qlstephen

  2. force QuickLook to reset and rescan:

    $ qlmanage -r
    $ qlmanage -r cache
    Restart Finder

  3. Get the string ID UTi for the file type you want by running the following on a text file with the extension you are interested in… e.g. .srt file MyMovie.srt residing on my Desktop:
    $

    mdls -name kMDItemContentType ~/Desktop/MyMove.srt

    Which will result in something like: kMDItemContentType = “dyn.a…
    ->

  4. Edit the Info.plist of QLstephen.qlgenerator, adding the result of the previous command into a <string></string> block:
    $

    nano ~/Library/QuickLook/QLStephen.qlgenerator/Contents/Info.plist

    Find the block with the following:

    <key>LSItemContentTypes</key>
    <array>
    <string>public.data</string>
    </array>
    </key>

    and add the result of #3 above as <string>dyn.a…</string> BEFORE the closing </array> tag. Save -> qlmanage -r -> restart Finder
    ->

  5. ALTERNATIVE TO MANUAL INSERTION – the following is ONE line – make sure to replace the “PLACE-ID-TO-ADD-HERE” with the ID retrieved as instructed abouve in #3.

    $
    plutil -insert CFBundleDocumentTypes.0.LSItemContentTypes.0 -string PLACE-ID-TO-ADD-HERE ~/Library/QuickLook/QLStephen.qlgenerator/Contents/Info.plist

  6. refresh everything:

    $ qlmanage -r
    $ qlmanage -r cache
    Restart Finder

  7. 7. if you get the “damage / can’t be opened / etc..” message

    $ sudo xattr -cr ~/Library/QuickLook/QLStephen.qlgenerator

and refresh everything (see #6 above)

You should be all good to go!

You can add as many text file format extensions into qlstephen as needed.

**NOTE: when you update QLStephen – you will need to re-register all the extensions you’ve previously added – as the Info.plist will be replaced!

Previous Notes/Posts regarding QuickLook:
OSX QuickLook – fix all those broken things…

Reference links:
Homebrew / brew – https://brew.sh/
QLStephen @ GitHub – https://github.com/NSGod/qlstephen/tree/qlstephen.app
Add support for dynamic and unknown UTI types (issue #87) – https://github.com/whomwah/qlstephen/issues/87