67

I find Finder's Quick Look feature (launched with Space) very useful, but it works only for a limited number of file extensions. In work I often get .properties, .conf, .ddl and other files which are essentially text, yet in Quick Look their content is never displayed:

alt text

Is there any way I can tell my Mac to treat those files as text?

Thanks!

Nikita Rybak
  • 785
  • 1
  • 6
  • 7

5 Answers5

48

QLStephen adds support for both files without a filename extension (like README) and files with arbitrary extensions (like file.xyz).


Quick Installation using Homebrew:

brew install qlstephen

Manual Installation:

  • Download plugin
  • Unzip
  • Move file to ~/Library/QuickLook

(Don't forget to star the repo if this plugin helps you.)

Chet
  • 103
  • 2
Lri
  • 40,894
  • 7
  • 119
  • 157
  • 3
    The way to do this is to add public.data to any quicklook generator's plist. The downside is that binary files also do not have an extension and so it will try to display them, albiet usually with no negative consequences – Brandon Nov 24 '11 at 10:06
  • @Brandon - it appears there is a directories blacklist in QLStephen which prevents files with no extensions from being shown if they are in the `bin` directory, also there is a whitelist which enables it for README and files of that sort which could work. I'm having trouble getting this to work on ML tho. – cwd Oct 18 '12 at 17:43
  • It's not the `bin` directory that blocks QLStephen; it's the executable file permissions. – Elliott B Sep 24 '14 at 07:58
  • What do I do once I install it? The README says `- Make sure you are editing (a) the correct plist of (b) the correct bundle. (For example, you might have two `QLStephen` plugins. It’s possible the plugin in another directory—perhaps `/Library/QuickLook/`—is what is being read.` but it doesn't say what plist I'm supposed to edit or what I'm supposed to add to that file. – incandescentman Jul 31 '15 at 23:18
  • 6
    Apparently QLStephen is now available on homebrew as `brew cask install qlstephen` – Pushpendre Feb 08 '16 at 02:42
  • 1
    For those looking for additional Quick Look plugins, check out https://github.com/sindresorhus/quick-look-plugins for a good list with examples and instructions. Or quick install: `brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlimagesize suspicious-package quicklookase qlvideo` – danVnest Aug 14 '20 at 04:22
  • I seem to recall having success with this in the past. However, I just tried it on Mojave 10.15.7 and it's not working for me. – Keyslinger Nov 05 '20 at 18:19
13

You might also want to have a look at the QLColorCode and QLMarkdown plugins, for syntax highlighting of many languages and markdown rendering respectively.

http://code.google.com/p/qlcolorcode/

http://github.com/toland/qlmarkdown/

_c

polypus74
  • 231
  • 2
  • 2
9

A search for quicklook on github reveals that there is a large variety of extensions available:

and some (incomplete) collections:

0 _
  • 309
  • 4
  • 10
  • related: http://superuser.com/questions/363915/how-can-i-view-indesign-incopy-quarkxpress-etc-documents-without-opening-them, http://superuser.com/questions/275839/how-do-i-make-powerpoint-files-open-with-quick-look-by-default-on-mac-os-x/275844#275844, http://superuser.com/questions/113410/use-text-quicklook-viewer-for-other-files, http://superuser.com/questions/472317/extend-capabilities-of-finders-quick-view/472325#472325, http://superuser.com/questions/248013/is-it-possible-to-set-a-custom-quick-look-preview-image-in-os-x/252503#252503 – 0 _ Aug 04 '13 at 05:25
  • and also: http://superuser.com/questions/171323/how-to-make-quick-look-preview-text-files-in-utf-8-by-default/171337#171337, http://superuser.com/questions/171323/how-to-make-quick-look-preview-text-files-in-utf-8-by-default/171415#171415 – 0 _ Aug 04 '13 at 05:26
  • 1
    None of those extensions or 'related' questions, as far as I can tell, answer the question I asked. – Nikita Rybak Aug 04 '13 at 22:30
5

It's possible, but not really easy.

If you look at /System/Library/QuickLook/Text.qlgenerator/Contents/Info.plist, you'll notice that the "text" preview is for the following UTIs:

public.plain-text
public.rtf
com.apple.rtfd
org.oasis-open.opendocument.text
com.apple.property-list
public.xml

This is how QuickLook knows which Plugin (qlgenerator) to use.


A (hackish) solution now would be to assign the extension properties the UTI public.plain-text. To do this, you could create a dummy application (e.g. created by Automator) that declares these file types like described here, only you'd use public.plain-text as UTI and properties as file extension.

Daniel Beck
  • 109,300
  • 14
  • 287
  • 334
2

A solution for 2021...

QLColorCode is an alternative to QLStephen. I have used them both over the years but have had more success with the former. My use case is being able to read my-example.Dockerfile but you should be able to adapt to what you need.

First, let's install QLColorCode:

>brew install qlcolorcode

Now get the metadata name that MacOS uses for your file. To do this we use the mdls command from the Terminal and call it on the path to an example of the filetype you want to configure quicklook for.

>mdls -name kMDItemContentType ~/Documents/my-example.Dockerfile

For me this outputs:

kMDItemContentType = "dyn.ah62d4rv4ge80k55drrw1e3xmrvwu"

Copy the part in quotes as you will need this in a moment. Open the Info.plist for QLColorCode in your favourite text editor. I like vim.

>vim ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Info.plist

Navigate down to the part that looks like this:

                    <array>
                            <string>public.source-code</string>
                            <string>public.yaml</string>
                            <string>com.apple.xcode.tcsh-script</string>
[...and so on...]
                    </array>

Insert a new element with your copied ContentType code. It should look something like this now:

                    <array>
                            <string>public.source-code</string>
                            <string>public.yaml</string>
                            <string>com.apple.xcode.tcsh-script</string>
[...and so on...]
                            <string>dyn.ah62d4rv4ge80k55drrw1e3xmrvwu</string>
                    </array>

Save your file and relaunch Finder. To restart Finder, click on the Apple icon (top left of screen), select "Force Quit..." and then select Finder. Hit "Relaunch".

Now, when you select a *.Dockerfile in Finder and hit spacebar, you should see the content

Robino
  • 818
  • 8
  • 15