Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
0xdevalias opened this issue May 14, 2020 · 0 comments

Comments

@0xdevalias
Copy link
Owner

0xdevalias commented May 14, 2020

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:

@0xdevalias 0xdevalias changed the title Dump/restore custom file type associations Dump/restore custom file type associations (eg. duti) Jun 2, 2020
@0xdevalias 0xdevalias changed the title Dump/restore custom file type associations (eg. duti) Dump/restore custom file type associations (eg. duti, SwiftDefaultApps, swda, etc) Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant