Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preview files with extention #23

Closed
clankill3r opened this issue May 11, 2013 · 13 comments
Closed

preview files with extention #23

clankill3r opened this issue May 11, 2013 · 13 comments

Comments

@clankill3r
Copy link

hi,

is it possible to preview pde files for example? It's just a text file with a pde extention.
It would be nice if people can set which extentions should be previewed as text.

@mklement0
Copy link

qlstephen's logic is to preview everything as text (by virtue of being associated with the UTI (Uniform Type Identifier) public.data) , except for the blacklisted items.

Thus, if extension *.pde is not blacklisted and a given file does not reside in a blacklisted directory, qlstephen should preview that file as text, UNLESS a different, more type-specific Quick Look plugin is registered for the type at hand.

To examine the situation:

  • Run mdls -name kMDItemContentType <someFile>.pde on a given *.pde file.
  • (a) If the result looks something like kMDItemContentType = "dyn.ah62d4rv4ge8047k": No specific UTI is defined for *.pde.
  • (b) Otherwise: The reported UTI is the one associated with *.pde files.

If (a), qlstephen should handle the preview, unless blacklisted.

if (b), another Quick Look plugin may be preempting qlstephen. To remedy that, you could edit the .../QLStephen.qlgenerator/Contents/Info.plist file and add the specific UTI to the LSItemContentTypes key.
To make the change take effect, run qlmanage -r. To verify that it is effective, run qlmanage -m, search for the UTI in the output.

Needless to say, you'll have to reapply this change whenever you update qlstephen itself.

@whomwah whomwah closed this as completed Oct 30, 2013
@flemingm
Copy link
Contributor

flemingm commented Apr 6, 2019

Testing and debug QuickLook plugins:

In terminal, use qlmanage with -d4 to see debug information such as:

  • mime types of given document and
  • quicklook installed and what mime types they support.

example:

qlmanage -p -d4 /Users/markf/Downloads/quicklook\ plugins/qlstephen-1.4.4/LICENSE

...
[DEBUG] Registering <QLGenerator /Library/QuickLook/iWork.qlgenerator> for com.apple.iwork.keynote.kth
[DEBUG] Registering <QLGenerator /Library/QuickLook/QLStephen.qlgenerator> for public.unix-executable
[DEBUG] Registering <QLGenerator /Library/QuickLook/QLStephen.qlgenerator> for com.apple.xcode.strings-text
[DEBUG] Registering <QLGenerator /Library/QuickLook/QLStephen.qlgenerator> for public.unix-executable
[DEBUG] Registering <QLGenerator /Library/QuickLook/iBooksAuthor.qlgenerator> for com.apple.ibooksauthor.book
[DEBUG] Registering <QLGenerator /Library/QuickLook/QuickLookCSV.qlgenerator> for public.tab-separated-values-text
[DEBUG] Registering <QLGenerator /Library/QuickLook/QuickLookCSV.qlgenerator> for public.comma-separated-values-text
...
[DEBUG] Preview test for file:///Users/markf/Downloads/quicklook%20plugins/qlstephen-1.4.4/LICENSE. Content type UTI: public.unix-executable

@xiao-zang
Copy link

xiao-zang commented Mar 12, 2020

qlstephen's logic is to preview everything as text (by virtue of being associated with the UTI (Uniform Type Identifier) public.data) , except for the blacklisted items.

Thus, if extension *.pde is not blacklisted and a given file does not reside in a blacklisted directory, qlstephen should preview that file as text, UNLESS a different, more type-specific Quick Look plugin is registered for the type at hand.

To examine the situation:

  • Run mdls -name kMDItemContentType <someFile>.pde on a given *.pde file.
  • (a) If the result looks something like kMDItemContentType = "dyn.ah62d4rv4ge8047k": No specific UTI is defined for *.pde.
  • (b) Otherwise: The reported UTI is the one associated with *.pde files.

If (a), qlstephen should handle the preview, unless blacklisted.

if (b), another Quick Look plugin may be preempting qlstephen. To remedy that, you could edit the .../QLStephen.qlgenerator/Contents/Info.plist file and add the specific UTI to the LSItemContentTypes key.
To make the change take effect, run qlmanage -r. To verify that it is effective, run qlmanage -m, search for the UTI in the output.

Needless to say, you'll have to reapply this change whenever you update qlstephen itself.

You said that if no specific UTI is defined for a text file, QLStephen should handle it. However, I have some text files that have no specific UTI, but QLStephen still cannot preview the content. For example, if I create a test.pbs (a qsub script), the kMDItemContentType is "dyn.ah62d4rv4ge81a2xx", but QuickLook does not show the content. Actually, it seems that I am not getting previews into any text file that has no specific UTI. Do you have any suggestions about what could be the problem?

Update: I found people are actively discussing this issue in #87

Thanks!

@ruslaniv
Copy link

ruslaniv commented Jul 5, 2020

Same here:

mdls -name kMDItemContentType database.env
kMDItemContentType = "dyn.ah62d4rv4ge80n5x0"

<key>LSItemContentTypes</key>
			<array>
				<string>public.data</string>
				<string>public.content</string>
				<string>public.yaml</string>
				<string>public.env</string>
			</array>
qlmanage -m | grep env
public.env -> /Users/ruslan/Library/QuickLook/QLStephen.qlgenerator (1.5.1)

And it still would not preview the "database.env" file

@saileshkotha
Copy link

@ruslaniv basically you have to add the content type to LSItemContentTypes array.

mdls -name kMDItemContentType database.env
kMDItemContentType = "dyn.ah62d4rv4ge80n5x0"

Then add the content type "dyn.ah62d4rv4ge80n5x0" to the list not public.env, like below

<key>LSItemContentTypes</key>
<array>
	<string>public.data</string>
	<string>public.content</string>
	<string>dyn.ah62d4rv4ge80n5x0</string>
</array>

Then

  1. run qlmanage -r
  2. run qlmanage -r cache
  3. Restart finder by holding down the option key and right click on Finder’s dock icon, then select “Relaunch” from the menu

@fcherman
Copy link

Testing and debug QuickLook plugins:

In terminal, use qlmanage with -d4 to see debug information such as:

  • mime types of given document and
  • quicklook installed and what mime types they support.

@flemingm THANK YOU! I haven't been able to preview .txt files forEVER. Using -d4, I discovered that QLColorCode.qlgenerator was being invoked … and failing. Removing QLColorCode (which I didn't need anyway) solved this years-old problem.

@eddideku
Copy link

eddideku commented Aug 6, 2021

LSItemContentTypes

Doesn't seem to be working for me. Anyone else on Big Sur?

			<key>LSItemContentTypes</key>
			<array>
				<string>public.data</string>
				<string>public.content</string>
				<string>dyn.ah62d4rv4ge80u25q</string>
			</array>

Edit, I am getting this prompt after I added that string

“QLStephen.qlgenerator” is damaged and can’t be opened.

@CyberWake
Copy link

getting the same prompt. For me, the QuickLook qlstephen doesn't seem to work on any file extension.

@grigorye
Copy link

grigorye commented Feb 15, 2022

Just in case, LSItemContentTypes manipulation works perfectly for me on Monterey 12.2.1. I'm really happy now, thanks for the hints!

To be safe in terms of accidental damaging the Info.plist, you can probably try something like below, after installing the stock extension (replace public.unix-executable with whatever you get from mdls -name kMDItemContentType <your-file>):

/usr/libexec/PlistBuddy -c 'Add :CFBundleDocumentTypes:0:LSItemContentTypes: string public.unix-executable' ~/Library/Quicklook/QLStephen.qlgenerator/Contents/Info.plist

@frankrolf
Copy link

I’ve reinstalled QLStephen on macOS Ventura (13.0.1), unfortunately I cannot edit the Info.plist without the Finder suggesting the “application is damaged and should be moved to the Trash”. 🤦‍♂️

I understand this happens because the code signature is now outdated. Does anyone have a suggestion for me?

It’s disappointing that such a seemingly-simple QuickLook generator like QLStephen has to overcome such annoying obstacles with every major OS release (does nobody within Apple use this extension??)

@frankrolf
Copy link

Update – after a little thinking, I realized that I couldn’t go the Homebrew route – instead, I downloaded the repo, edited the Info.plist file within, and built the Extension via make / make install

Everything works now! 🎉

@HofiOne
Copy link

HofiOne commented Nov 28, 2022

FYI
if you have no rosetta installed and you are on a silicon apple machine, you HAVE TO rebuild it from source, the homebrew version is X86_64 only currently (and will fail silently)
just clone the git dir, make, make install, just like it is shown in the readme.md of the project
it will build and install a compatible arm64 version

@rhcproc
Copy link

rhcproc commented Dec 2, 2022

Update – after a little thinking, I realized that I couldn’t go the Homebrew route – instead, I downloaded the repo, edited the Info.plist file within, and built the Extension via make / make install

Everything works now! 🎉

Great!, It is working. Now I can open .sol (solidity) file on my mac. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests