Blob


1 .Dd May 30, 2023
2 .Dt RMC 1
3 .Os
4 .Sh NAME
5 .Nm rmc
6 .Nd view, edit, compose or print a file, directory or URL
7 .Sh SYNOPSIS
8 .Nm
9 .Op Fl ceptT
10 .Ar file
11 .Sh DESCRIPTION
12 The
13 .Nm
14 utility views, edits, composes or prints a local file, directory or URL.
15 In this manual page simply
16 .Dq file
17 to denote either of the three, while specifically
18 .Dq local file
19 means a file actually present in the local file hierarchy.
20 Commands to execute are chosen from the first matching entry in the
21 mailcap file (see
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
26 (see
27 .Sx the mime.types file ) .
28 If no such mapping is found, directories are automatically recognised to
29 have the pseudo-MIME type
30 .Dq directory ,
31 and normal files are recognised using the
32 .Xr file 1
33 command.
34 .Pp
35 The options are as follows:
36 .Bl -tag -width Ds
37 .It Fl c
38 Use the compose-command istead of the view-command.
39 .It Fl e
40 Use the edit-command istead of the view-command.
41 .It Fl p
42 Use the print-command istead of the view-command.
43 .It Fl t
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.
46 .It Fl T
47 Always spawn a new terminal when needsterminal is set, even if both stdin and
48 stdout are associated with a terminal.
49 .El
50 .Ss The mailcap file
51 The mailcap file describes commands to execute depending on the file's
52 MIME type.
53 Empty lines and lines, whose first non-whitespace character is a number
54 sign (#) are ignored.
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.
61 .Pp
62 There are two types of variables: single-letter variables, and named
63 variables.
64 Named variables begin with
65 .Dq %{
66 and end with
67 .Dq } .
68 Currently
69 .Nm
70 simply ignores such strings.
71 .Nm
72 recognises two single-letter variables:
73 .Bl -tag -width Ds
74 .It %t
75 Is replaced with the file's MIME type.
76 .It %s
77 Is replaced with the file's name.
78 .El
79 .Pp
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
86 text/*
87 text
88 text/plain
89 .Ed
90 .Pp
91 The first two fields will match all files with type
92 .Dq text
93 regardless of the subtype, while the last one will only match files,
94 whose MIME type is
95 .Dq text/plain .
96 .Pp
97 The second field is always the view-command.
98 The others are either flags or named fields.
99 .Pp
100 Flag fields are as follows:
101 .Bl -tag -width needsterminalx
102 .It needsterminal
103 If both the standard input and standard output are associated with a
104 terminal, the command is unchanged.
105 Otherwise if
106 .Nm
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.
110 .It copiousoutput
111 If the view-command is being executed, the output is piped into a
112 pager.
113 Only used when needsterminal is specified as well.
114 .El
115 .Pp
116 Named fields contain the name of the field, followed by the equality
117 sign (=), followed by the field's value, e.g.:
118 .Pp
119 .Dl edit=$VISUAL %s
120 .Pp
121 Following named fields are recognised:
122 .Bl -tag -width composex
123 .It nametemplate
124 If nametemplate is set, before executing the command,
125 .Nm
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
128 certain way.
129 Only used with local files.
130 .It test
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.
133 .It compose
134 The compose-command.
135 .It edit
136 The edit-command.
137 .It print
138 The print-command.
139 .El
140 .Pp
141 If there is no named field for the requested command, the mailcap entry
142 doesn't match.
143 Unrecognised fields are ignored.
144 .Ss The mime.types file
145 The mime.types file contains mappings of file extensions and URL schemes
146 to MIME types.
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.
151 If the type is
152 .Dq scheme ,
153 the other fields correspond URL schemes; otherwise they denote
154 filename extensions.
155 .Pp
156 For example, given the entries
157 .Bd -literal -offset indent
158 scheme/http http https
159 text/html html htm
160 .Ed
161 .Pp
162 strings starting with
163 .Dq http:
164 or
165 .Dq https:
166 will be recognised as scheme/http; otherwise, strings ending with
167 .Dq .html
168 or
169 .Dq .htm
170 will be recognised as text/html.
171 .Sh ENVIRONMENT
172 .Bl -tag -width TERMINALX
173 .It Ev TERMINAL
174 Terminal command to use.
175 Default is
176 .Dq xterm .
177 .It Ev PAGER
178 Pager command to use.
179 Default is
180 .Dq less .
181 .El
182 .Sh FILES
183 .Bl -tag -width /etc/mime.typesx
184 .It Pa ~/.mailcap
185 The mailcap file.
186 .It Pa /etc/mime.types
187 System-wide MIME type mappings.
188 Unused if
189 .Pa ~/.mime.types
190 is present.
191 .It Pa ~/.mime.types
192 User-specific MIME types mappings.
193 .El
194 .Sh EXIT STATUS
195 .Ex -std
196 .Sh EXAMPLES
197 With the following
198 .Pa ~/.mime.types :
199 .Bd -literal -offset indent
200 scheme/mailto mailto
201 text/org org
202 .Ed
203 .Pp
204 and the following
205 .Pa ~/.mailcap :
206 .Bd -literal -offset indent
207 scheme/mailto; guimail %s
208 text/org; less %s; needsterminal
209 text; cat %s; edit=vi %s; needsterminal
210 .Ed
211 .Pp
212 typing
213 .Pp
214 .Dl $ rmc mailto:user@site.org
215 .Pp
216 will execute the GUI program guimail with the argument
217 .Dq mailto:user@site.org ,
218 while typing
219 .Pp
220 .Dl $ rmc ./mailto:user@site.org
221 .Pp
222 will execute
223 .Xr less 1
224 with the arguments
225 .Dq -X
226 and
227 .Dq ./mailto:user@site.org ,
228 and finally, typing
229 .Pp
230 .Dl $ rmc -e ./mailto:user@site.org
231 .Pp
232 will execute
233 .Xr vi 1
234 with the argument
235 .Dq ./mailto:user@site.org .
236 .Sh SEE ALSO
237 .Xr file 1
238 .Sh STANDARDS
239 .Rs
240 .%A N. Borenstein
241 .%D September 1993
242 .%R RFC 1524
243 .%T A User Agent Configuration Mechanism For Multimedia Mail Format Information
244 .Re
245 .Sh AUTHORS
246 .An Alexander Arkhipov Aq Mt aa@manpager.net .
247 .Sh CAVEATS
248 According to RFC 1524 all files in the
249 .Ev MAILCAPS
250 or
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
254 only the
255 .Pa ~/.mailcap
256 file is searched.