Title: How to Set Default Apps for File Extensions Using duti on macOS

Below is a combined step-by-step instruction set for changing default apps for file extensions using the duti command: macOS: 

Purpose:

This guide explains how to change the default applications for specific file extensions on macOS using the terminal and the duti command-line tool.

Step-by-Step Instructions:

1. Install duti using Homebrew

If you don’t already have duti installed, you can install it using Homebrew:

brew install duti

2. Find the Bundle ID for the Application

To associate a file extension with a specific application, you’ll need the Bundle ID (App ID) of the app. Here’s how to find it:

Run the following command in the terminal, replacing App Name with the name of the app (e.g., Obsidian):

osascript -e 'id of app "App Name"'

Example for Obsidian:

osascript -e 'id of app "Obsidian"'

This will return the Bundle ID (e.g., md.obsidian).

3. Set the Default App for a File Extension

Now that you have the Bundle ID, you can set the app as the default for a specific file extension using the duti command.

The general syntax is:

duti -s <bundle-id> <extension> <role>

  • : The Bundle ID of the app.
  • : The file extension (without a period).
  • : The role, which can be all, viewer, editor, or shell.

Example to set Obsidian as the default for .md files:

duti -s md.obsidian md all

4. Role Options in duti

  • all: The application will be set for all roles (viewing, editing, and launching).
  • viewer: The application will be the default for viewing files of that type.
  • editor: The application will be the default for editing files of that type.
  • shell: The application will handle files of that type when executed from the terminal.

5. Verify the Change

You can check if the change was successful by using the following command to see the current default app for a specific file extension:

duti -x <extension>

Example for .md files:

duti -x md

This will display the app currently associated with .md files.

Additional Notes:

  • You do not need to include the period (.) before the file extension (e.g., use md instead of .md).
  • If you’d like to manually change the default app without using the terminal, you can:
    1. Right-click a file.
    2. Select Get Info.
    3. In the Open With section, choose the desired application.
    4. Click Change All to apply the change to all files of that type.

This combined guide should cover everything you need to change file extension associations on macOS.
Please let us know if you need more info! 😊

Sub-Domain
Confidentiality
No