summary refs log tree commit diff stats
path: root/README
blob: 7d042929317fcb82906c0ef79d2c5b66b90d3b94 (plain) (blame)
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
generated by cgit-pink 1.4.1-2-gfad0 (git 2.36.2.497.gbbea4dcf42) at 2025-01-02 16:10:53 +0000
 


\-ansi\[rq] content type handler.
This means that you get colors, formatting, etc.
displayed with ANSI escape sequences.
.IP \[bu] 2
\f[CR]needsterminal\f[R] hands over control of the terminal to the
command while it is running.
Note: as of now, \f[CR]needsterminal\f[R] does nothing if either
\f[CR]copiousoutput\f[R] or \f[CR]x\-htmloutput\f[R] is specified.
.IP \[bu] 2
For a description of \f[CR]nametemplate\f[R], see the RFC.
Note however, that it does not work with test (since %s is not supported
there).
.SS Environment variables
As noted above, the \f[CR]$MAILCAP_URL\f[R] variable is set to the URL
of the target resource before the execution of the mailcap command.
Backwards compatibility with mailcap agents that do not support this
variable can be achieved through shell substitution,
e.g.\ \f[CR]${MAILCAP_URL:\-string for when it is unsupported}\f[R].
.PP
Note that it is not recommended to set \f[CR]%s\f[R] as the fallback,
because it will force Chawan to download the entire file before
displaying it even if it could have been piped into the command.
.SS Note
Entries with a content type of text/html or text/plain are ignored.
.PP
Content types that do not appear in mailcap files are handled as text
files in case they start with \f[CR]text/\f[R].
Otherwise, they prompt the user to save the file to the disk.
.SS Examples
.IP
.EX
# Note: these examples require an entry in mime.types that sets e.g. md as
# the markdown content type.

# Handle markdown files using pandoc.
text/markdown; pandoc \- \-f markdown \-t html \-o \-; x\-htmloutput

# Show syntax highlighting for JavaScript source files using bat.
text/javascript; bat \-f \-l es6 \-\-file\-name ${MAILCAP_URL:\-STDIN} \-; x\-ansioutput

# Play music using mpv, and hand over control of the terminal until mpv exits.
audio/*; mpv \-; needsterminal

# Play videos using mpv in the background, redirecting its standard output
# and standard error to /dev/null.
video/*; mpv \-

# Open docx files using LibreOffice Writer.
application/vnd.openxmlformats\-officedocument.wordprocessingml.document;lowriter %s
# (Wow that was ugly.)

# Display manpages using pandoc. (Make sure the mime type matches the one
# set in your mime.types file for extensions .1, .2, .3, ...)
application/x\-troff\-man;pandoc \- \-f man \-t html \-o \-; x\-htmloutput

# Following entry will be ignored, as text/html is supported natively by Chawan.
text/html; cha \-dT text/html \-I %{charset}; copiousoutput
.EE
.SS See also
\f[B]cha\f[R](1)