1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
| duti(1) User Commands duti(1)
NAME duti - set default document and URL handlers
SYNOPSIS duti [ -hVv ] [ -d uti ] [ -l uti ] [ settings_path ]
duti -s bundle_id { uti | url_scheme | extension | MIME_type } [ role ]
duti -x extension
DESCRIPTION duti sets applications as default handlers for Apple's Uniform Type Identifiers, for URL schemes, filename extensions, and MIME types. 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.
The -s flag tells duti to set a handler based on arguments from the command line. Two arguments following -s means that duti will set the handler for a URL scheme. Three arguments means duti will set the handler for a UTI, an extension or a MIME type, depending on the formatting of the second argument. duti treats an argument beginning with a dot as an extension. If the argument contains no dots, duti also considers the argument a filename extension, unless it contains a slash, in which case duti treats the argument as a MIME type. In all other cases, duti treats the second argument as a UTI.
duti -x retrieves and prints out information describing the default application for files with the extension extension.
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. 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.
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:
all application handles all roles for the given UTI.
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.
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.
1 Settings could not be applied, or the UTI has no handler.
>1 Error.
MORE INFO Mac OS X 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 Connection Library at:
http://developer.apple.com/referencelibrary/
More technical information, including APIs, can be found at:
http://developer.apple.com/macosx/uniformtypeidentifiers.html
To get a list of UTIs on your system, you can use the following command line:
`locate lsregister` -dump | grep '[[:space:]]uti:' \ | awk '{ print $2 }' | sort | uniq
SEE ALSO plutil(1), plist(5)
Andrew Mortensen _DUTI_BUILD_DATE duti(1)
|