1@c This is part of the GNU Mailutils manual.
2@c Copyright (C) 1999--2021 Free Software Foundation, Inc.
3@c See file mailutils.texi for copying conditions.
4@comment *******************************************************************
5@pindex mimeview
6
7  For each file given in its command line, @command{mimeview} attempts
8to autodetect its type and invoke an appropriate file viewer.
9
10  To detect the file type, @command{mimeview} uses @file{mime.types}
11file.  This file is a part of Common UNIX Printing System,
12@ref{mime.types,,,mime.types(5), mime.types man page}.  By default
13@command{mimeview} searches for @file{mime.types} in
14@file{$prefix/etc/cups/}@footnote{The exact location is determined at
15configuration time by setting environment variable
16@env{DEFAULT_CUPS_CONFDIR}.  On most sites running
17
18@example
19./configure DEFAULT_CUPS_CONFDIR=/etc/cups
20@end example
21
22@noindent
23should be recommended.}, however its exact location can be specified
24at runtime as well (see @option{--mimetypes} below).
25
26  Once file MIME type is successfully determined, @command{mimeview}
27consults @file{mailcap} files in order to determine how to display
28the file.  It does so essentially in the same manner as
29@command{metamail} utility, i.e., it scans all files specified
30in @code{METAMAIL} environment variable until it finds an entry
31describing the desired file format or until the list of files is
32exhausted.  If @code{METAMAIL} variable is not set, @command{mimeview}
33uses the following default path instead:
34
35@example
36$HOME/.mailcap:/usr/local/etc/mailcap:\
37 /usr/etc/mailcap:/etc/mailcap:\
38 /etc/mail/mailcap:/usr/public/lib/mailcap
39@end example
40
41@menu
42* Mimeview Invocation::
43* Mimeview Config::
44@end menu
45
46@node Mimeview Invocation
47@subsection Mimeview Invocation
48
49  The following table summarizes options specific for @command{mimeview}:
50
51@table @option
52@item -a[@var{type-list}]
53@itemx --no-ask[=@var{type-list}]
54By default @command{mimeview} asks for confirmation before running
55interpreter to view a message.  If this option is used without
56argument, it disables the default behavior for all message
57types.  Otherwise, if argument @var{type-list} is given, it specifies
58a comma-separated list of MIME types for which no questions should be
59asked.  Elements of this list may include shell-style globbing
60patterns, e.g. setting
61
62@example
63--no-ask='text/*,image/jpeg'
64@end example
65
66@noindent
67will disable prompting before displaying any textual files, no
68matter what their subtype is, and before displaying files with
69type @samp{image/jpeg}.
70
71  Notice, that when the long form is used, its argument
72must be separated from the option by a single equal sign, as shown
73in the example above.  When the short form (@option{-a}) is used, its argument
74must follow the option immediately, without any intervening whitespace,
75e.g.  @option{-a'text/*'}).
76
77@item -d[@var{flags}]
78@itemx --debug[=@var{flags}]
79Enables debugging output.  @var{Flags} is a sequence of characters
80specifying the desired debugging level.  Following characters are
81meaningful in @var{flags}:
82
83@table @asis
84@item g
85Enables debugging of @file{mime.types} parser
86
87@item l
88Enables debugging of @file{mime.types} lexical analyzer (warning:
89produces @emph{very} copious output)
90
91@item 0
92Prints basic information about actions to be executed and reports
93about exit status of executed commands.
94
95@item 1
96Additionally displays each file name along with its MIME type
97
98@item 2
99Additionally traces the process of looking up the matching entry
100in @code{mailcap} files.
101
102@item 3
103Additionally, enables debugging of @file{mime.types} parser (@samp{g}).
104
105@item 4
106Additionally, enables debugging of @file{mime.types} lexer (@samp{l}).
107
108@item digits from 5 to 9
109The same as 4, currently.
110@end table
111
112If @var{flags} are not given, the default @samp{2} is assumed.
113
114@item --metamail[=@var{file}]
115Run @command{metamail} to display files, instead of using the internal
116mechanisms.  If @var{file} is specified, it is taken as
117@command{metamail} command line.
118
119@item -h
120@itemx --no-interactive
121@itemx --print
122This options tells @command{mimeview} that it should run in
123non-interactive mode.  In this mode prompting is disabled, and
124the normal mailcap @code{command} field is not executed.  Instead
125@command{mimeview} will execute the command specified in
126the @code{print} field.  If there is nothing in the print field,
127the mailcap entry is ignored and the search continues for a matching
128mailcap entry that does have a @code{print} field.
129
130Notice, that unlike in @command{metamail -h}, this option does
131not force @command{mimeview} to send the output to the printer
132daemon.
133
134When used with @option{--metamail} option, this option passes
135@option{-h} flag to the invocation of @command{metamail}.
136
137By default @command{mimeview} behaves as if given
138@option{--no-interactive} option whenever its standard input is not
139a @asis{tty} device.
140
141@item -i
142@itemx --identify
143Identifies and prints the MIME type for each input file.
144
145@item -n
146@itemx --dry-run
147Do not do anything, just print what would be done.  Implies
148@option{--debug=1}, unless the debugging level is set up explicitly.
149
150@item -f @var{file}
151@itemx --mimetypes @var{file}
152Use @var{file} as @file{mime.types} file.  If @var{file} is a
153directory, use @file{@var{file}/mime.types}
154
155@item -t
156@itemx --lint
157Check syntax of the @file{mime.types} file and exit.  Command line
158arguments are ignored.
159@end table
160
161@node Mimeview Config
162@subsection Mimeview Config
163
164The following configuration statements affect the behavior of
165@command{mimeview}:
166
167@multitable @columnfractions 0.3 0.6
168@headitem Statement @tab Reference
169@item debug @tab @xref{Debug Statement}.
170@end multitable
171
172@deffn {Mimeview Config} mimetypes @var{file}
173Read @var{file} instead of the default @file{mime.types}.
174@end deffn
175
176@deffn {Mimeview Config} metamail @var{program}
177Use @var{program} to display files.
178@end deffn
179