6 .Nd view, edit, compose or print a file, directory or URL
14 utility views, edits, composes or prints a local file, directory or URL.
15 In this manual page simply
17 to denote either of the three, while specifically
19 means a file actually present in the local file hierarchy.
20 Commands to execute are chosen from the first matching entry in the
22 .Sx the mailcap file ) ,
23 based on the local file/directory's MIME type or the URL's scheme.
24 The view-command of a matching mailcap entry is executed by default.
25 File extensions and URI schemes can be mapped via the mime.types file
27 .Sx the mime.types file ) .
28 If no such mapping is found, directories are automatically recognised to
29 have the pseudo-MIME type
31 and normal files are recognised using the
35 The options are as follows:
38 Use the compose-command istead of the view-command.
40 Use the edit-command istead of the view-command.
42 Use the print-command istead of the view-command.
44 Don't spawn a new terminal even if needsterminal is set, and either stdin,
45 stdout, or both are not associated to a terminal.
47 Always spawn a new terminal when needsterminal is set, even if both stdin and
48 stdout are associated with a terminal.
51 The mailcap file describes commands to execute depending on the file's
53 Empty lines and lines, whose first non-whitespace character is a number
55 Other lines consist of fields, separated by semicolons (;), optionally
56 continued on the next line if the last character is a backslash (\\).
57 Backslashes may also be used for quoting characters: if a character
58 (including another backslash) is preceeded by a backslash, it is
59 stripped of its special meaning, and is used literally.
60 Semicolon following the last field is optional.
62 There are two types of variables: single-letter variables, and named
64 Named variables begin with
70 simply ignores such strings.
72 recognises two single-letter variables:
75 Is replaced with the file's MIME type.
77 Is replaced with the file's name.
80 The first field always contains the MIME type to match against.
81 Subtype may be ommited by either only specifying the type, or writing an
82 asterisk (*) in subtype's place, in which case the subtype is
83 disregarded when matching.
84 For example, consider these fields:
85 .Bd -literal -offset indent
91 The first two fields will match all files with type
93 regardless of the subtype, while the last one will only match files,
97 The second field is always the view-command.
98 The others are either flags or named fields.
100 Flag fields are as follows:
101 .Bl -tag -width needsterminalx
103 If both the standard input and standard output are associated with a
104 terminal, the command is unchanged.
107 is running under X11, the command is executed in a new terminal.
108 Finally, if neither is true, the match fails.
109 Not used when executing the print-command.
111 If the view-command is being executed, the output is piped into a
113 Only used when needsterminal is specified as well.
116 Named fields contain the name of the field, followed by the equality
117 sign (=), followed by the field's value, e.g.:
121 Following named fields are recognised:
122 .Bl -tag -width composex
124 If nametemplate is set, before executing the command,
126 will create a symlink to file, named as the value of nametemplate.
127 It can be useful with programs that expect files to be named in a
129 Only used with local files.
131 The value of test is a command to be executed before the main command.
132 If this commands returns >0, the entry doesn't match.
141 If there is no named field for the requested command, the mailcap entry
143 Unrecognised fields are ignored.
144 .Ss The mime.types file
145 The mime.types file contains mappings of file extensions and URL schemes
147 Empty lines, and lines whose first non-whitespace character is the
148 number sign (#) are ignored.
149 Other lines are divided into a number of whitespace separated fields.
150 The first field always denotes a MIME type.
153 the other fields correspond URL schemes; otherwise they denote
156 For example, given the entries
157 .Bd -literal -offset indent
158 scheme/http http https
162 strings starting with
166 will be recognised as scheme/http; otherwise, strings ending with
170 will be recognised as text/html.
172 .Bl -tag -width TERMINALX
174 Terminal command to use.
178 Pager command to use.
183 .Bl -tag -width /etc/mime.typesx
186 .It Pa /etc/mime.types
187 System-wide MIME type mappings.
192 User-specific MIME types mappings.
199 .Bd -literal -offset indent
206 .Bd -literal -offset indent
207 scheme/mailto; guimail %s
208 text/org; less %s; needsterminal
209 text; cat %s; edit=vi %s; needsterminal
214 .Dl $ rmc mailto:user@site.org
216 will execute the GUI program guimail with the argument
217 .Dq mailto:user@site.org ,
220 .Dl $ rmc ./mailto:user@site.org
227 .Dq ./mailto:user@site.org ,
230 .Dl $ rmc -e ./mailto:user@site.org
235 .Dq ./mailto:user@site.org .
243 .%T A User Agent Configuration Mechanism For Multimedia Mail Format Information
246 .An Alexander Arkhipov Aq Mt aa@manpager.net .
248 According to RFC 1524 all files in the
251 .Pa ~/.mailcap : Ns Pa /etc/mailcap : Ns Pa /usr/etc/mailcap : Ns Pa /usr/local/etc/mailcap
252 path should be searched until a match is found.
253 This behaviour is not considered to be useful, intuitive, or secure, so