Skip to content

[macOS] Dump/restore custom file type associations (eg. duti, SwiftDefaultApps, swda, etc) #5

Open

Description

@0xdevalias

Use https://github.com/moretension/duti to dump/restore custom file type applications, though it seems as though it may not be maintained anymore:

brew install duti

# Read
⇒  duti -x md
# Xcode.app
# /Applications/Xcode.app
# com.apple.dt.Xcode

duti -x html

⇒  duti -x mp4
# VLC.app
# /Applications/VLC.app
# org.videolan.vlc

# Write

# Find the application bundle identifier
⇒  mdls -name kMDItemCFBundleIdentifier /Applications/Sublime\ Text.app
# kMDItemCFBundleIdentifier = "com.sublimetext.4"

# Extract the bundle identifier in a crude automation friendly way to make it scriptable
⇒  mdls -name kMDItemCFBundleIdentifier /Applications/Sublime\ Text.app | awk '{ gsub(/"/, "", $3); print $3}'
# com.sublimetext.4

# Extract the bundle identifier in a much better/simpler automation friendly way to make it scriptable
⇒  mdls -name kMDItemCFBundleIdentifier -raw /Applications/Sublime\ Text.app
# com.sublimetext.4%

duti -s com.sublimetext.4 .txt all
duti -s com.sublimetext.4 .md all

# Confirming that it was set correctly
⇒  duti -x md
# Sublime Text.app
# /Applications/Sublime Text.app
# com.sublimetext.4

See also:


Could also use something like https://github.com/Lord-Kamina/SwiftDefaultApps to make it easier to configure in general, though it seems to have it's own issues too:

brew install --cask swiftdefaultappsprefpane

  • This will seemingly install both the prefpane and the CLI binary.

Seemingly it also includes a CLI tool swda.

swda -h

swda getUTIs | grep public.

Or we could just take a more manual/lower level approach:

See Also

Activity

  1. changed the title [-]Dump/restore custom file type associations[/-] [+]Dump/restore custom file type associations (eg. duti)[/+] on Jun 2, 2020
  2. changed the title [-]Dump/restore custom file type associations (eg. duti)[/-] [+]Dump/restore custom file type associations (eg. duti, SwiftDefaultApps, swda, etc)[/+] on Mar 12, 2022
  3. 0xdevalias commented on Mar 21, 2025

    @0xdevalias
    OwnerAuthor

    Edit:

    My version is now live :) https://github.com/philocalyst/infat/tree/v0.1.0-alpha

    Originally posted by @philocalyst in moretension/duti#46 (comment)

  4. 0xdevalias commented on Sep 16, 2025

    @0xdevalias
    OwnerAuthor

    See also:

  5. changed the title [-]Dump/restore custom file type associations (eg. duti, SwiftDefaultApps, swda, etc)[/-] [+][macOS] Dump/restore custom file type associations (eg. duti, SwiftDefaultApps, swda, etc)[/+] on Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions