RUN-MAILCAP(1)
๐ RUN-MAILCAP โ ok bestie, let's open some files
Soooo the vibe here is: run-mailcap, plus its lil alias squad โ view, see, edit, compose, and print โ all exist to run programs for you based on what's written in the mailcap file. It's giving "the middleman you didn't know you needed." ๐
โจ SYNOPSIS โจ
run-mailcap --action=ACTION [--option[=value]] [MIME-TYPE:[ENCODING:]]FILE [...]
Okay so real talk: see, edit, compose and print? They're literally just aliases that default to the view, edit, compose and print actions respectively. Same program, different lewk. ๐
๐ธ DESCRIPTION ๐ธ
run-mailcap (or literally any of its aliases, they all work) takes the action you give it and uses it to process each mime-type/file, one at a time, in turn. No skipping. We do them all.
Every file gets described as its mime-type, its encoding (think compression, bestie), and its filename โ all glued together with colons. That's the format, periodt.
- If you leave out the mime-type, it tries to figure it out by matching the file's extension against the ones sitting in the
mime.typesfiles. ๐ - If that comes up empty, it makes one last attempt by running the
filecommand โ if it's available, no promises. - If you leave out the encoding, it gets determined from the file's extensions too. Easy.
The encodings it supports right now are:
gzipโ.gzbzip2โ.bz2xzโ.xzzstdโ.zst[d]compressโ.Z
And here's a cute one: a filename of - means "standard input" ๐ โ but if you do that, you must specify a mime-type. Non-negotiable, bestie.
Both the user's files (~/.mailcap; ~/.mime.types) and the system files (/etc/mailcap; /etc/mime.types) get searched in turn for the info. User stuff, then system stuff. Both get a moment. ๐ซถ
๐ EXAMPLES ๐
see picture.jpg
print output.ps.gz
compose text/html:index.htm
extract-mail-attachment msg.txt | see image/tiff:gzip:-
Look at that last one โ piping straight into see with a fully spelled out mime-type, encoding AND - for stdin. She understood the assignment. ๐ญ
๐ OPTIONS ๐
Heads up: every single option is in the form --<opt>=<value>. That's just how we do it here.
--action=<action>โ does the specified action on the files. The valid actions areview,cat(this one only uses"copiousoutput"rules and sends output to STDOUT),compose,composetyped,edit, andprint. And if you don't specify an action at all? Then the action gets decided by how the program was called. Mystery! ๐--debugโ turns on extra information so you can actually see what's going on. It's giving detective mode. ๐--nopagerโ ignores any"copiousoutput"directive and just sends the output to STDOUT. No pager, no drama.--norunโ shows you the found command without actually running it. A little preview, a little teaser. โจ
๐ฅ SECURITY ๐ฅ
Okay bestie, listen up, this part is important.
A temporary symbolic link to the file gets opened if the file name matches this Perl regular expression:
"[^[:alnum:],.:/@%^+=_-]"
Why? To protect against the injection of shell commands ๐ and to make sure the name can always be displayed in the current locale. Two birds.
On top of that, the file is opened using its absolute path, which prevents the injection of command-line arguments โ for instance, using file names that start with dashes. Yes, that's a real thing people try. We see you. ๐
๐ SEE ALSO ๐
file(1) mailcap(5) mailcap.order(5) update-mime(8)
๐ฆ AUTHOR ๐ฆ
run-mailcap (and all its aliases, the whole crew) was written by Brian White <bcwhite@pobox.com>. Shoutout. ๐ซถ
๐ COPYRIGHT ๐
run-mailcap (and its aliases) is in the public domain โ which the page describes as the only true "free". Iconic. Ate. No notes.
And that's the whole thing, bestie ๐ This page comes to you from the Debian Project, dated 1st Jan 2008. Go forth and let the mailcap file decide your destiny. Mwah. ๐ ๐ธ
๐ฆ where this page comes from
- debian trixie: mailcap 3.74 ยท ad-hoc
- ubuntu questing: mailcap 3.74ubuntu1
- ubuntu questing: mailcap 3.74ubuntu1.1
- ubuntu resolute: mailcap 3.75ubuntu1 ยท ad-hoc
- ubuntu resolute: mailcap 3.75ubuntu1.1 ยท ad-hoc
- ubuntu stonking: mailcap 3.77ubuntu1 ยท ad-hoc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms