73

How can I add an application to the Open With menu (shown after right-clicking) for a given file type, without making that file always open with that application?

In this specific instance, I'd like to the option to open an Web site location (.URL) file with TextEdit, while still defaulting to Safari.

I'm running OS 10.7.4.

2
  • 3
    If the program can open it, then it will add itself to that menu. Otherwise, it means it can't open it. Commented May 31, 2011 at 7:56
  • 25
    This seems to not always be true. TextEdit can open URLs, but it is not in the "Open With" submenu.
    – KatieK
    Commented Jun 1, 2011 at 22:07

7 Answers 7

36
+200
  1. Add this to the CFBundleDocumentTypes array in /Applications/TextEdit.app/Contents/Info.plist:

    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>url</string>
        </array>
    </dict>
    
  2. /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f /Applications/TextEdit.app/

  3. killall Finder
  4. Change the default application back to Safari in Finder

If the application is signed, modifying an Info.plist invalidates the code signature. It also makes a few applications like TextEdit and WriteRoom crash on launch on 10.8.

5
  • 1
    Perhaps it's just my computer, but this does not work for me. After following this procedure (to step 3), TextEdit is not available under "Open With" for .URL files. Also, modifying Info.plist seems to cause TextEdit to crash in 10.7, too.
    – KatieK
    Commented Oct 16, 2012 at 20:50
  • 16
    Is there a way to make this more general? E.g. I want my hex editor (currently HexFiend) as an option to open every goddamn file type including those not having a file extension...
    – Steven Lu
    Commented May 20, 2016 at 4:05
  • @StevenLu: I made a Finder shortcut in BetterTouchTool to open the currently selected file in HexFiend. Commented Dec 27, 2018 at 10:52
  • 1
    Been struggling with this for a very long time. @StevenLu's question is still valid, especially for editors, but being able to do it for the most common files is useful. Repeating this exercise for Visual Studio Code I wasn't sure which CFBundleTypeExtensions group it belonged in. I added the new extension just under <string>txt</string> but I'm not entirely sure if that's correct. Regardless, it worked. So far, no issues with breaking signatures either.
    – tresf
    Commented Oct 16, 2020 at 15:16
  • 1
    @Lri or to anyone who can answer: I have questions about this part of Lri's answer: "If the application is signed, modifying ... crash on launch on 10.8." What are the consequences of having TextEdit (or another app) having an invalidated sig.? Does it cause problems when attempting to update the app to a newer release? Or? Does step 2 (lsregister) resolve the problem of invalidating the code sig.? What exactly does the lsregister command do? Does the problem with TextEdit/WriteRoom crashing still exist in more current releases such as macOS 12? Commented Apr 16, 2023 at 20:41
16

Try selecting the file in the Finder and doing File > Get Info. From there you should be able to choose any application to open it with. Once you've opened that type of file in that application once, it should start appearing in the Open With menu.

EDIT: The answer above does not work. Alternate suggestion:

I felt bad that my prev answer was incorrect, so I googled around. I found this tip from Mac OS X Hints:

  • Control-click (or right-click) the app in question and select "Show Package Contents"
  • Open the Contents folder in the app bundle. There you'll find a file called Info.plist. This is an XML property list that stores all sorts of information about the app.
  • Open the file with your favourite text editor. I recommend Hydra, but TextEdit will do just fine.
  • Search for something that looks like the following:

    <key>CFBundleTypeExtensions</key>
    <array>
        <string>txt</string>
        <string>srt</string>
        <string>suffix1</string>
        <string>suffix2</string>
        …
    

    and so forth, with the suffices the app is able to open contained within the tags. Then you simply delete [or add --newtron] the suffix for items you don't want [or want] the app to open.

  • Save the file, and close it (or quit the editor).

5
  • This does not seem to work. In "Get Info", I can "Open With" the same applications as normal, or choose "Other". If I choose "Other", I can choose from all applications, and either check or uncheck "Always Open With". Even after opening the file once with TextEditor, it does not appear as an additional option in the "Open With" submenu.
    – KatieK
    Commented Jun 1, 2011 at 22:12
  • Shoot, you're right. I will edit the answer to reflect this and update it with an alternate suggestion.
    – newtron
    Commented Jun 2, 2011 at 0:37
  • 1
    This updated answer doesn't work all by itself, even after a reboot.
    – KatieK
    Commented Jun 8, 2011 at 3:37
  • Think this method worked in snow leopard..superuser.com/questions/222065/… Commented Oct 10, 2012 at 12:37
  • 2
    The amended instructions are the same as Lri's answer, but theirs is better because it has the lsregister and killall Finder forcing refresh immediately.
    – tresf
    Commented Oct 16, 2020 at 15:18
9

newtron's second solution worked for me but only after I opened Terminal and executed the following command:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

After restarting the system the desired app was in my "open with" context menu.

Thanks

2
  • This is also useful if you want to clear the list and start again. e.g. VMWare Fusion had placed entries somehow that where orphaned when the corresponding VM was deleted. Using this cleared the incorrect entries
    – ferdil
    Commented Nov 23, 2016 at 12:25
  • 1
    Lri's steps in another answer (accepted solution) worked just fine for me. Posting this in 2020 using MacOS Big Sur 11.0.
    – tresf
    Commented Oct 16, 2020 at 15:19
8

Instead of opening the file with the context menu, you can also drag any file to any desired application while pressing + keys. This will force any app to try even if it thinks it can't do so. I use this all the time.

2
  • 1
    I just dragged an unknown document type to a text editor's app shortcut on the Dock without holding these key combinations and it worked. These additional shortcut keys may no longer be needed.
    – tresf
    Commented Oct 16, 2020 at 15:21
  • This is the easiest answer. What an obscure keyboard shortcut though!
    – wisbucky
    Commented Jul 28, 2021 at 4:08
8

You can add the option as a Service with Automator and then trigger it with a Hotkey from Keyboard Maestro.

  1. Open Automator and select Quick Action document type (formerly Service)
  2. Select Files and Folders in the top Workflow receives selected menu
  3. Search for and select the Open Finder Items action.
  4. Now select TextEdit in Open with:
  5. Save the service with a name you want to see in the menus

You can now find this by:

  • Right-clicking the file and searching near the bottom or in Quick Actions

enter image description here

OR

  • Finder Menu > Services (with a file selected)

enter image description here

But you don't have to stop there!

I then made a Keyboard Maestro macro so I can just use a Hotkey to do it: enter image description here

I got this idea from this site: http://www.mactricksandtips.com/2013/05/add-open-with-textedit-or-any-other-app-to-right-click-menu-item.html

5
  • 1
    This is a great way of doing this, thank you very much!!
    – Lucas P.
    Commented Nov 7, 2018 at 13:07
  • I use the service all the time but I forgot I made a macro to do this. Nothing like rediscovering a macro! Commented Nov 7, 2018 at 13:13
  • 1
    I've never used Automator before (or knew what it does), you've just opened a whole new world in OSX for me :)
    – Lucas P.
    Commented Nov 7, 2018 at 14:04
  • 1
    This is the best answer. This applies to all file extensions, even when there is none. And it doesn't require maintenance and doesn't require messing with the terminal. Not that I'm against messing with the terminal, but for the common user it is best to avoid it ofcourse. Commented Feb 10, 2021 at 16:45
  • 1
    This is a very nice alternative. I did the Info.plist approach, but on MacOS 13 (at least), system integrity then prevents you from running the application (in my case, XnViewMP) at all. This approach is much more flexible, and doesn't make the system paranoid that someone has hacked an executable. Commented Dec 31, 2023 at 23:13
0

This worked for me : Right click your app and goto contents and open /Applications/*****.app/Contents/Info.plist

Open Plist in Xcode as SourceCode and then place this :

        <dict>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>jpeg</string>
                <string>jpg</string>
                <string>png</string>
                <string>gif</string>
            </array>
            <key>CFBundleTypeIconFile</key>
            <string>AutomatorApplet.icns</string>
            <key>CFBundleTypeName</key>
            <string>AutomatorApplet.icns</string>
            <key>CFBundleTypeOSTypes</key>
            <array>
                <string>GIFf</string>
                <string>JPEG</string>
                <string>PNGf</string>
            </array>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
        </dict>

I had 'AutomatorApplet.icns' in Resources Folder.

1
  • Please add what you tried to achieve by adding the dict entry. As your answer stands now, it doesn't use the example (.url) given in the question.
    – klanomath
    Commented Nov 16, 2015 at 11:09
-4

Check out the tech-recipes.com for detailed instructions. As @Anriëtte pointed out the app should appear on the Open with menu if it can open the specific file.

1
  • This doesn't work for me because I don't want to change the default application which opens the file. I just want an additional choice.
    – KatieK
    Commented May 31, 2011 at 15:12

You must log in to answer this question.

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