duti(1)

πŸ“¦ version 1.5.5pre, in nixpkgs unstable

πŸ’… duti(1) β€” the manual, but make it make sense

okay so first things first: this is the duti(1) page, and it lives in the User Commands section of your manual. she's a macOS girlie and she's here to make your default apps behave. let's get into it πŸŽ€


✨ NAME ✨

duti β€” set default document and URL handlers. that's it, that's the whole vibe. she picks which app opens what, and she does not miss. πŸ‘‘


🌸 SYNOPSIS 🌸

duti [ -hVv ] [ -d uti ] [ -l uti ] [ settings_path ]

duti -s bundle_id { uti | url_scheme | extension | MIME_type } [ role ]

duti -x extension

πŸ¦‹ DESCRIPTION πŸ¦‹

so duti sets applications as default handlers for Apple's Uniform Type Identifiers (UTIs), for URL schemes, filename extensions, and MIME types. literally the whole roster. πŸ’–

if settings_path is not given on the command line, duti reads settings lines from stdin. if settings_path is a directory, duti applies settings from the files in settings_path. flexible queen.

the -s flag tells duti to set a handler based on arguments from the command line. here's the read:

  • two arguments following -s β†’ duti sets the handler for a URL scheme.
  • three arguments following -s β†’ duti sets the handler for a UTI, an extension or a MIME type, depending on the formatting of the second argument.

and how does she decide which is which? bestie, she's reading the formatting:

  • an argument beginning with a dot β†’ treated as an extension.
  • an argument containing no dots β†’ also considered a filename extension, unless it contains a slash, in which case duti treats the argument as a MIME type.
  • all other cases β†’ the second argument is treated as a UTI.

duti -x retrieves and prints out information describing the default application for files with the extension extension. cute little peek behind the curtain. πŸ™ˆ

see EXAMPLES below for usage cases. πŸ‘‡


πŸ“ SETTINGS FILE πŸ“

a settings file is made up of lines with the following format:

app_id    UTI    role

the app_id is a bundle ID representing the application that will act as the handler for documents associated with UTI. for example:

com.apple.Safari    public.html    all

would cause duti to set Safari as the default handler in all situations for HTML documents. slay. πŸ¦‹

a settings file can also contain lines with this format:

app_id    url_scheme

in this case, app_id is again a bundle ID, this time for the application that will act as the default handler for url_scheme. for example:

org.mozilla.Firefox     ftp

would cause duti to set Firefox as the handler for "ftp://" URLs. no cap. πŸ”₯


🧚 SETTINGS PLIST 🧚

if the extension of the file given to duti is .plist, duti treats the file as an XML property list (plist). the plist must contain a key-value pair in which the key is "DUTISettings" and the value is an array of dictionaries.

each dictionary in the array contains three key-value pairs representing the application's bundle ID, the UTI and the role, respectively. alternatively, a dictionary in the array may contain two key-value pairs representing the application's bundle ID, and the URL scheme.

a simple plist designed to set Safari as the default handler of HTML files, and Firefox as the default handler for "ftp://" URLs, would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>DUTISettings</key>
     <array>
          <dict>
               <key>DUTIBundleIdentifier</key>
               <string>com.apple.Safari</string>
               <key>DUTIUniformTypeIdentifier</key>
               <string>public.html</string>
               <key>DUTIRole</key>
               <string>all</string>
          </dict>
          <dict>
               <key>DUTIBundleIdentifier</key>
               <string>org.mozilla.Firefox</string>
               <key>DUTIURLScheme</key>
               <string>ftp</string>
          </dict>
     </array>
</dict>
</plist>

πŸ’œ ROLES πŸ’œ

valid roles are defined as follows β€” think of it as the job description for each app:

  • all β€” application handles all roles for the given UTI. she does it all, main character energy. πŸ‘‘
  • viewer β€” application handles reading and displaying documents with the given UTI.
  • editor β€” application can manipulate and save the item. implies viewer.
  • shell β€” application can execute the item. 🐚
  • none β€” application cannot open the item, but provides an icon for the given UTI. icon-only era, we respect it. πŸ’…

🌈 EXAMPLES 🌈

running duti with -s :

# Set Safari as the default handler for HTML documents
duti -s com.apple.Safari public.html all

# Set Finder as the default handler for the ftp:// URL scheme
duti -s com.apple.Finder ftp

retrieving default application information for an extension:

# default application information for .html files
% duti -x html
Safari
/Applications/Safari.app
com.apple.Safari

the following examples can be used by passing them to duti on stdin or as lines in a .duti file. 🫢

set TextEdit as the default viewer for Microsoft Word documents:

com.apple.TextEdit    com.microsoft.word.doc    viewer

set VLC as the default viewer for files with .m4v extensions:

org.videolan.vlc   m4v   viewer

set iHook as the default executor of shell scripts:

edu.umich.iHook    public.shell-script    shell

set Xcode as the default editor for C source files:

com.apple.Xcode    public.c-source    editor

⭐ OPTIONS ⭐

  • -d uti β€” display the default handler for uti and exit.
  • -h β€” print usage and exit.
  • -l uti β€” display all handlers for uti and exit.
  • -s β€” set the handler from data provided on the command line.
  • -V β€” print version number and exit.
  • -v β€” verbose output.
  • -x ext β€” print information describing the default application for extension ext.

πŸ’€ EXIT STATUS πŸ’€

  • 0 β€” all settings applied or displayed successfully. we ate. πŸ“
  • 1 β€” settings could not be applied, or the UTI has no handler. rough. 😭
  • >1 β€” error.

πŸ” MORE INFO πŸ”

macOS ships with a number of UTIs already defined. most third-party software is responsible for defining its own UTIs. Apple documents UTIs in the Apple Developer Documentation Archive at:

https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html

to get a list of UTIs on your system, you can use the following command line:

$(mdfind -name lsregister) -dump | grep '[[:space:]]uti:' \
     | awk '{ print $2 }' | sort | uniq

πŸŽ€ SEE ALSO πŸŽ€

plutil(1), plist(5) β€” go read those next, bestie, they're lowkey essential.


ngl, that's the whole page. every flag, every role, every plist key β€” nothing skipped, nothing invented. iykyk. πŸ’–

okay and like a proper sign-off: this page was written by Andrew Mortensen, it's the _DUTI_BUILD_DATE build, and the manual page is duti(1). periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from