How to change part of file Quick Look previews?
For specific files I would like Quick Look to preview the end of the document, rather than its front. In this case I am working with CSVs and want the preview to show the most recent additions. (I’m aware the previews are cached and maybe not fully up to date.)
1. Is there a way to change what Quick Look displays, especially which parts of a file?
2. Can this be done for specific files, rather than globally?
My research so far leads me to think qlmanage
in Terminal is how I’d change this, but I’m not sure how. (Also not on Mac right now and qlmanage’s man page is ... sparse.)
I could also imagine an approach that changes where a file opens to – opening to the end of the document instead of its start – and that the preview would then do similar
You're on the right path with qlmanage
. Unfortunately, using qlmanage
is the last step in assigning a Quick Look generator to your file type. You first have to obtain the generator, or write it from scratch.
So, to quickly answer both of your questions... yes, you can change what QL displays and yes, you can do it for a single file type.
To see what generators are associated with what file types, use the -m
flag. Here's a sample of the output
% qlmanage -m
com.apple.iwork.pages.pages-tef -> /System/Library/QuickLook/iWork.qlgenerator (209)
com.microsoft.powerpoint.ppt -> /System/Library/QuickLook/Office.qlgenerator (40)
public.comma-separated-values-text -> /System/Library/QuickLook/Office.qlgenerator (40)
com.apple.ical.ics.todo -> /System/Library/QuickLook/iCal.qlgenerator (906.3)
com.adobe.encapsulated-postscript -> /System/Library/QuickLook/EPS.qlgenerator (906.3)
Within each of those directories is code, very similar to a macOS Application, that generates a QL preview; so you can, in fact, create a preview to your specifications.
As for how to create that code, see the Introduction to Quick Look Programming Guide to get started. The code is written in ANSI-C or Objective-C.