6

Files without extension always open in TextEdit ... I want them to open in SublimText 3

I tried to change my com.apple.launchservices.secure.plist, but simply adding public.text did not work ...

0

2 Answers 2

8

The solution was doing it with public.data

  1. Go to ~/Library/Preferences/com.apple.LaunchServices

  2. Open com.apple.launchservices.secure.plist with Xcode

  3. Add this :

screen

  1. Save & Reboot

Another way to do it

  • Without Xcode
  • Working on macOS Mojave
  • With Sublime Text 4
  1. Convert binary plist to xml plist (for easy editing)
plutil \
-convert xml1 \
~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist \
-o ~/Desktop/plist.xml
  1. Open plist.xml (on your Desktop) with Sublime Text

Add inside <array>

<dict>
    <key>LSHandlerContentType</key>
    <string>public.data</string>
    <key>LSHandlerPreferredVersions</key>
    <dict>
        <key>LSHandlerRoleAll</key>
        <string>-</string>
    </dict>
    <key>LSHandlerRoleAll</key>
    <string>com.sublimetext.4</string>
</dict>
  1. Convert back from XML to binary plist
plutil \
-convert binary1 \
~/Desktop/plist.xml \
-o ~/Desktop/com.apple.launchservices.secure.plist
  1. Move the new com.apple.launchservices.secure.plist, from your Desktop to ~/Library/Preferences/com.apple.LaunchServices/
mv ~/Desktop/com.apple.launchservices.secure.plist \
~/Library/Preferences/com.apple.LaunchServices/
  1. Reboot

You can also use Sublime package Plist Binary or BinaryPlist instead of manually converting from binary to XML

7
  • 1
    A .plist file can be edited with any text editor, such as SublimeText, for instance! ;)
    – Thecafremo
    Commented Oct 1, 2017 at 22:42
  • 1
    @Thecafremo, The com.apple.launchservices.secure.plist file is a binary plist file and while Sublime Text can open it, it does so in hex mode and as such cannot be edited in the manner proposed in this answer. If it was an XML plist file, then it could. Commented Oct 2, 2017 at 18:54
  • @user3439894 Weird. TextMate will open it, and make it readable, without a problem.
    – Thecafremo
    Commented Oct 3, 2017 at 16:26
  • 1
    @Thecafremo You can run plutil -convert xml1 ~/Library/Preferences/com.apple.LaunchServices.plist to edit it in Sublime or Vim. Source
    – Max Coplan
    Commented Oct 14, 2019 at 21:07
  • 2
    There's a Sublime package called BinaryPlist that does automatic conversion between binary and plain text. Commented Jan 9, 2020 at 23:38
3

Copy paste script (working with catalina):

defaults write ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}' '{LSHandlerContentType=public.unix-executable;LSHandlerRoleAll=com.sublimetext.3;}'

This sets the default to Sublime Text 3. If you want to have any other app you have to simply replace com.sublimetext.3 with the app id of your favorite app.

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