1

I want to customize which app is used to open all unknown plain text files from Quick Look. For example, for extension-less VERSION file, Quick Look shows Open with TextEdit:

I'd like to make VSCode the default editor for unknown file types.

BTW, to even achieve a textual preview of the VERSION file, I had to install https://github.com/whomwah/qlstephen.


UPDATE & solution: This question is indeed closely related to Replace Text Edit as the default text editor, the problem was that neither of the answers mentioned public.data which was necessary for the VERSION file in this example. (Without 'public.data', VSCode was offered for .txt files but not for extension-less files.)

I've updated this answer to that question to include info about 'public.data', in which case this question is really a duplicate of Replace Text Edit as the default text editor.

6
  • 2
    The image you are showing is not of Preview, it's: Quick Look Commented Mar 31, 2020 at 16:23
  • Can you open terminal app and type mdls and drag the file you have for quicklook from finder into the terminal window? Editing this to post your file type might help people understand what you need to change.
    – bmike
    Commented Mar 31, 2020 at 17:01
  • @user3439894 That's a great point, I didn't realize that, thank you. Commented Apr 1, 2020 at 7:44
  • This qn is closed but is actually asking a different thing to the linked qn. This qn is about changing the app for QuickLook (hitting spacebar in Finder), the linked qn is about changing the default opening app (double clicking in Finder). Please re-open.
    – Robino
    Commented Nov 16, 2020 at 21:04
  • @Robino Please see the "UPDATE & solution" section above. Commented Nov 19, 2020 at 8:31

2 Answers 2

1

Extension-less files are tricky ones for OS to figure out if it is an executable or a text file. I have two README files, one of which is unix executable for some reason and I get a warning if I open it. Another is text file but still recognised as public.data as opposed to public.plain-text.

mdls path/to/file

gives you its kMDItemContentType. public.data files' QuickLook are generated by

/Users/me/Library/QuickLook/QLStephen.qlgenerator

Run qlmanage -m to get a list.

Unless you can find a QuickLook generator by VSCode, which can preview public.data files, you don't have much to do.

I haven't used it, but this seems promising: https://github.com/whomwah/qlstephen

OP's response

This worked: duti -s com.microsoft.VSCode public.data all

3
  • Lots of great clues, thanks! I actually have QLStephen installed – otherwise, the OP screenshot would have just a binary icon, not a real text (default behavior of macOS). So if I understand correctly, it's QLStephen that has the power to change "Open with TextEdit" to something different? Could I possibly open a feature request there? Commented Apr 1, 2020 at 8:57
  • This is one of the lines in qlmanage -m output: public.data -> /Users/borekb/Library/QuickLook/QLStephen.qlgenerator (1.5.1) Commented Apr 1, 2020 at 8:59
  • 1
    This worked 🎉 duti -s com.microsoft.VSCode public.data all Commented Apr 1, 2020 at 9:04
0
  • Right click on any .txt file on your system.
  • Click on 'Get Info'
  • Find the Open With: section and choose the app you want. (VSCode for this case)
  • Finally, click on Change All button and you are good to go!
2

Not the answer you're looking for? Browse other questions tagged .