forked from moretension/duti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duti.1
325 lines (323 loc) · 6.2 KB
/
duti.1
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
.TH duti "1" "_DUTI_BUILD_DATE" "Andrew Mortensen" "User Commands"
.SH NAME
.B duti
\- set default document and URL handlers
.SH SYNOPSIS
.B duti
[
.BI \-hVv
] [
.BI \-d\ uti
] [
.BI \-l\ uti
] [
.I settings_path
]
.sp
.B duti
.BI \-s
.I bundle_id
{
.I uti
|
.I url_scheme
|
.I extension
|
.I MIME_type
}
[
.I role
]
.sp
.B duti
.BI \-x\ extension
.sp
.SH DESCRIPTION
.B duti
sets applications as default handlers for Apple's Uniform Type Identifiers,
for URL schemes, filename extensions, and MIME types.
If
.I settings_path
is not given on the command line,
.B duti
reads settings lines from stdin. If
.I settings_path
is a directory,
.B duti
applies settings from the files in
.IR settings_path .
.sp
The
.BI \-s
flag tells
.B duti
to set a handler based on arguments from the command line. Two arguments
following
.BI \-s
means that
.B duti
will set the handler for a URL scheme. Three arguments means
.B duti
will set the handler for a UTI, an extension or a MIME type, depending on
the formatting of the second argument.
.B duti
treats an argument beginning with a dot as an extension. If the argument
contains no dots,
.B duti
also considers the argument a filename extension, unless it contains a slash,
in which case
.B duti
treats the argument as a MIME type. In all other cases,
.B duti
treats the second argument as a UTI.
.sp
.B duti
.BI \-x
retrieves and prints out information describing the default application
for files with the extension
.IR extension .
.sp
See
.B EXAMPLES
below for usage cases.
.sp
.SH SETTINGS FILE
A settings file is made up of lines with the following format:
.sp
.br
app_id UTI role
.br
.sp
The
.I app_id
is a bundle ID representing the application that will act as the
handler for documents associated with
.IR UTI .
For example:
.sp
.br
com.apple.Safari public.html all
.br
.sp
would cause
.B duti
to set Safari as the default handler in all situations for HTML documents.
A settings file can also contain lines with this format:
.sp
.br
app_id url_scheme
.br
.sp
In this case,
.I app_id
is again a bundle ID, this time for the application that will act as the
default handler for
.IR url_scheme .
For example:
.sp
.br
org.mozilla.Firefox ftp
.br
.sp
would cause
.B duti
to set Firefox as the handler for "ftp://" URLs.
.SH SETTINGS PLIST
If the extension of the file given to
.B duti
is
.IR \.plist ,
.B 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:
.sp
.br
<?xml version="1.0" encoding="UTF-8"?>
.br
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
.br
<plist version="1.0">
.br
<dict>
.br
<key>DUTISettings</key>
.br
<array>
.br
<dict>
.br
<key>DUTIBundleIdentifier</key>
.br
<string>com.apple.Safari</string>
.br
<key>DUTIUniformTypeIdentifier</key>
.br
<string>public.html</string>
.br
<key>DUTIRole</key>
.br
<string>all</string>
.br
</dict>
.br
<dict>
.br
<key>DUTIBundleIdentifier</key>
.br
<string>org.mozilla.Firefox</string>
.br
<key>DUTIURLScheme</key>
.br
<string>ftp</string>
.br
</dict>
.br
</array>
.br
</dict>
.br
</plist>
.br
.sp
.SH ROLES
Valid roles are defined as follows:
.sp
.TP 19
.B all
application handles all roles for the given UTI.
.TP 19
.B viewer
application handles reading and displaying documents with the given UTI.
.TP 19
.B editor
application can manipulate and save the item. Implies viewer.
.TP 19
.B shell
application can execute the item.
.TP 19
.B none
application cannot open the item, but provides an icon for the given UTI.
.SH EXAMPLES
Running
.B duti
with
.BI \-s
:
.sp
.br
# Set Safari as the default handler for HTML documents
.br
duti -s com.apple.Safari public.html all
.br
.sp
# Set Finder as the default handler for the ftp:// URL scheme
.br
duti -s com.apple.Finder ftp
.sp
Retrieving default application information for an extension:
.sp
.br
# default application information for .html files
.br
% duti -x html
.br
Safari
.br
/Applications/Safari.app
.br
com.apple.Safari
.br
.sp
The following examples can be used by passing them to
.B duti
on stdin or as lines in a .duti file.
.sp
Set TextEdit as the default viewer for Microsoft Word documents:
.sp
.br
com.apple.TextEdit com.microsoft.word.doc viewer
.br
.sp
Set VLC as the default viewer for files with .m4v extensions:
.sp
.br
org.videolan.vlc m4v viewer
.br
.sp
Set iHook as the default executor of shell scripts:
.sp
.br
edu.umich.iHook public.shell-script shell
.br
.sp
Set Xcode as the default editor for C source files:
.sp
.br
com.apple.Xcode public.c-source editor
.br
.sp
.SH OPTIONS
.TP 19
.BI \-d\ uti
display the default handler for
.I uti
and exit.
.TP 19
.B \-h
print usage and exit.
.TP 19
.BI \-l\ uti
display all handlers for
.I uti
and exit.
.TP 19
.BI \-s
set the handler from data provided on the command line.
.TP 19
.B \-V
print version number and exit.
.TP 19
.B \-v
verbose output.
.TP 19
.BI \-x\ ext
print information describing the default application for extension
.IR ext .
.sp
.SH EXIT STATUS
.TP 5
0
All settings applied or displayed successfully.
.TP 5
1
Settings could not be applied, or the UTI has no handler.
.TP 5
>1
Error.
.sp
.SH 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:
.sp
.br
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html
.br
.sp
To get a list of UTIs on your system, you can use the following command line:
.sp
.br
$(mdfind -name lsregister) -dump | grep -E '^uti:' \\
.br
| awk '{ print $2 }' | sort | uniq
.sp
.SH SEE ALSO
plutil(1), plist(5)