Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix Quick Look for TypeScript files

My Mac recognises the .ts extension as MPEG-2 Transport Stream, while I use it more often as TypeScript files. Because of that Quick Look does not show the contents of .ts files.

I found on Stackoverflow that I should be able to assign custom extensions to the text editor, but I'm not sure how.

like image 253
tomitrescak Avatar asked Jun 20 '15 05:06

tomitrescak


2 Answers

QLColorCode is a very nice Quick Look plugin which allows you to set syntax highlighting for ANY extension file you want.

1. Install QLColorCode Quick Look plugin

If you have Homebrew, you can install it with:

brew cask install qlcolorcode

Otherwise, you can just copy / paste the QLColorCode.qlgenerator to your ~/Library/QuickLook/ folder from a release.

2. Add .ts and .tsx syntax highlighting support

  • First get the kMDItemContentType of the extension you want to quick look at with the plugin:
mdls -name kMDItemContentType /path/to/any/file.ts
  • Add an entry with the string returned by the previous command to the plugin settings list — for a .ts file, this should be public.mpeg-2-transport-stream. To do so, just open the file ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Info.plist with any text editor (it's not a compiled file) and in the section CFBundleDocumentTypes > Item 0 > LSItemContentTypes (~ 15th line), add a line like this:
<string>public.mpeg-2-transport-stream</string>

You can find more information on how to add language type support to the plugin in the project README.md.


Here is the original post where I found all this useful information.

like image 100
MarsLevin Avatar answered Oct 17 '22 03:10

MarsLevin


According this article, there is another solution:

1) Remove filetype definition from: /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist
You need to do that in recovery mode.

215 => {
      "UTTypeConformsTo" => "public.movie"
      "UTTypeDescription" => "MPEG-2 Transport Stream"
      "UTTypeIdentifier" => "public.mpeg-2-transport-stream"
      "UTTypeTagSpecification" => {
        "public.filename-extension" => [
          0 => "ts"
        ]
      }
    }

2) Then run /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill

like image 27
pravdomil Avatar answered Oct 17 '22 02:10

pravdomil