SourceCodeSyntaxHighlight icon indicating copy to clipboard operation
SourceCodeSyntaxHighlight copied to clipboard

Disable UNIX Executable Support

Open alexclst opened this issue 1 year ago • 2 comments

I also have Apparency installed and would rather it take care of Quick Look for Unix executables. I see in this command line output that this app is handling these:

/usr/bin/pluginkit --match --protocol com.apple.quicklook.preview --platform native --platform maccatalyst --verbose QLSupportedContentTypes=public.unix-executable
+    com.mothersruin.Apparency.QLPreviewExtension(2.2)	83F0C042-B02C-4202-BC19-7782E99600FB	2024-11-18 03:19:06 +0000	/Applications/Apparency.app/Contents/PlugIns/ApparencyPreviewExtension.appex
+    org.sbarex.SourceCodeSyntaxHighlight.QuickLookExtension(2.1.24)	B23DE739-BEC8-41B8-B47F-1682AF311113	2024-10-28 17:01:36 +0000	/Applications/Syntax Highlight.app/Contents/PlugIns/Syntax Highlight Quick Look Extension.appex
 (2 plug-ins)

Yet the file inspector shows that it doesn't, which aligns with it not being in the Formats tab of settings:

Screenshot 2024-11-18 at 10 52 12

So how can I completely disable Syntax Highlight from handling this file format since I want a different extension to do so?

alexclst avatar Nov 18 '24 16:11 alexclst

Is not a simple operation, because every modification break the app signature.

You must edit the Syntax Highlight.app/Contents/PlugIns/Syntax Highlight Quick Look Extension.appex/Contents/Info.plist and remove the occurrence of<string>public.unix-executable</string>. This is used because some terminal scripts are written with bash scripting languages ​​but are recognized as Unix applications.

Alter the edit you must resign the app:

codesign --force --deep --sign - "Syntax Highlight.app"

I not tested if with this modification the app works correctly.

sbarex avatar Nov 19 '24 13:11 sbarex

For what it's worth, I've had luck removing the public.unix-executable UTI, such that Apparency gets a shot.

However, the simple re-signing command shown above will obliterate all of the entitlements. Among other things, that'll prevent macOS from even loading Syntax Highlight's Quick Look extension, because it won't be sandboxed as required.

Fortunately, that problem is easily solved by telling codesign to preserve entitlements, e.g.:

codesign -s - -f --preserve-metadata=entitlements,requirements,identifier,flags,runtime --deep "Syntax Highlight.app"

Here, I told it preserve everything for completeness (no idea if any of those other elements are strictly necessary, though).

I'd previously spent some time trying to figure out a better way to influence which Quick Look Preview extension macOS chooses for a specific UTI, without much success.

rsaldinger avatar Jan 13 '25 18:01 rsaldinger