summaryrefslogtreecommitdiff
path: root/share/mailcap
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-30 23:17:15 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-30 23:17:15 +0900
commite05b1e51921016a8a83afa4bff06f97ab830033d (patch)
tree70c0be7909023c703b9dc0d932c8e0d96d58d08d /share/mailcap
parent696ce7215119801a3420f01b99e1db41984741c5 (diff)
updates
Diffstat (limited to 'share/mailcap')
-rw-r--r--share/mailcap253
1 files changed, 243 insertions, 10 deletions
diff --git a/share/mailcap b/share/mailcap
index 601419c..cf6e3b3 100644
--- a/share/mailcap
+++ b/share/mailcap
@@ -1,10 +1,243 @@
-text/plain; $EDITOR %s ;
-text/html; /usr/local/lib/mutt-wizard/openfile %s ; nametemplate=%s.html
-text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump -width=1024 %s; nametemplate=%s.html; copiousoutput;
-image/*; /usr/local/lib/mutt-wizard/openfile %s ;
-video/*; setsid mpv --quiet %s &; copiousoutput
-audio/*; mpv %s ;
-application/pdf; /usr/local/lib/mutt-wizard/openfile %s ;
-application/pgp-encrypted; gpg -d '%s'; copiousoutput;
-application/pgp-keys; gpg --import '%s'; copiousoutput;
-application/x-subrip; $EDITOR %s ;
+# Save as ~/.mailcap. Then use run-mailcap to:
+#
+# - open files by `run-mailcap --action=view <file>`, or
+# - view them in the terminal by `run-mailcap --action=cat <file>`.
+#
+# Useful
+#
+# - in mutt by `set mailcap_file $HOME/.mailcap`
+# - in Vim by adding to your vimrc
+#
+# autocmd BufReadPost * if empty(&l:buftype) && !did_filetype() && !&l:binary &&
+# \ system('file --mime --brief ' . fnamemodify(resolve(expand('%')), ':p:S')) !~# '^text/' |
+# \ silent exe '%!run-mailcap --action=cat %:S' |
+# \ setlocal filetype=text readonly buftype=nowrite | endif
+#
+# - in less by LESSOPEN="|run-mailcap --action=cat %s", or
+# - in ranger or lf by making scope.sh run
+#
+# `run-mailcap --action=cat "$1" | head -n 200`
+#
+# - Since ~/.mailcap is read by firefox (and xdg-open!) when opening a
+# (downloaded) file, add for each file type foo/bar a sensible line like
+# `foo/bar; xdg-open %s; test=test -n "$DISPLAY"` for run-mail --action=view
+#
+# Uses lesspipe.sh, bat (or highlight), pandoc, w3m, xdg-open, feh, mpv, ...
+# Since bat is batcat, you can either use `batcat` instead of `bat` in the file,
+# or add `alias bat=batcat` to your shell configuration (~/.profile or ~/.zshenv).
+#
+# From https://github.com/cglindkamp/run-mailcap-rs/blob/master/README.md :
+#
+# Run-mailcap has multiple advantages over Xdg-open: While xdg-open is easier
+# to extend for the application writers and distributions itself (just add an
+# application desktop file with each application), this is not so easy done by
+# the user. A mailcap file on the other hand is simple text file. Just add a
+# new line for the mime type, you want to customize, and your done.
+#
+# In addition, you can have different actions with run-mailcap, e.g. open for
+# viewing or editing or just print the file without looking at it. In
+# principle, you can have the same with desktop files in a desktop environment,
+# but there is just one default, that xdg-open uses. You can add even more
+# flexibility with mailcap files by making entries context dependend ("test"
+# command value in the entry).
+#
+# Last but not least, Mutt already use mailcap files, so if you use one of them
+# and xdg-open, you had to maintain configuration for both programs.
+
+# LibreOffice, Word, Excel et PowerPoint
+# From http://wiki.free-unices.org/doku.php/config/mutt/new_mailcap
+application/vnd.oasis.opendocument.text; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+# application/vnd.oasis.opendocument.text; /usr/local/lib/mutt-wizard/openfile okular %s; test=test -n "$DISPLAY"
+application/vnd.oasis.opendocument.text; odt2txt %s | cat --squeeze-blank; copiousoutput
+# application/vnd.oasis.opendocument.text; pandoc --from=odt --to=plain %s | cat --squeeze-blank ; copiousoutput
+# application/vnd.oasis.opendocument.text; soffice --cat %s | cat --squeeze-blank ; copiousoutput
+
+application/vnd.oasis.opendocument.spreadsheet; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.oasis.opendocument.spreadsheet; odt2txt %s | cat --squeeze-blank; copiousoutput
+# application/vnd.oasis.opendocument.spreadsheet; soffice --cat %s | cat --squeeze-blank ; copiousoutput
+
+application/vnd.oasis.opendocument.presentation; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.oasis.opendocument.presentation; odt2txt %s | cat --squeeze-blank; copiousoutput
+# application/vnd.oasis.opendocument.presentation; soffice --cat %s | cat --squeeze-blank ; copiousoutput
+
+application/vnd.openxmlformats-officedocument.wordprocessingml.document; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; nametemplate=%s.docx; test=test -n "$DISPLAY"
+# application/vnd.openxmlformats-officedocument.wordprocessingml.document; docx2txt.pl %s - | cat --squeeze-blank; nametemplate=%s.docx; copiousoutput
+application/vnd.openxmlformats-officedocument.wordprocessingml.document; pandoc --from=docx --to=plain %s | cat --squeeze-blank; nametemplate=%s.docx; copiousoutput
+application/vnd.openxmlformats-officedocument.wordprocessingml.template; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; nametemplate=%s.docm; test=test -n "$DISPLAY"
+application/vnd.openxmlformats-officedocument.wordprocessingml.template; docx2txt.pl %s - | cat --squeeze-blank; nametemplate=%s.docm; copiousoutput
+
+application/msword; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/msword; wvHtml %s - | w3m -dump -T text/html; copiousoutput
+# application/msword; antiword -- %s | cat --squeeze-blank; copiousoutput
+# application/msword; catdoc -- %s | cat --squeeze-blank; copiousoutput
+# application/msword; soffice --cat %s | cat --squeeze-blank ; copiousoutput
+
+application/vnd.msword; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.msword; wvHtml %s - | w3m -dump -T text/html; copiousoutput
+
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; xlsx2csv --all --ignoreempty --delimiter x09 --outputencoding utf-8 %s | cat --squeeze-blank; nametemplate=%s.xlsx; copiousoutput
+# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; xlsx2csv xlscat --trim -S all %s | cat --squeeze-blank; nametemplate=%s.xlsx; copiousoutput
+# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; excel2csv --file %s; nametemplate=%s.xlsx; copiousoutput
+application/vnd.openxmlformats-officedocument.spreadsheetml.template; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+
+application/vnd.ms-excel; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.ms-excel; xlscat -a utf-8 -b WINDOWS-1252 %s; copiousoutput
+# application/vnd.ms-excel; xlscat -a %{charset} -b WINDOWS-1252 %s; copiousoutput
+# application/vnd.ms-excel; excel2csv %s --trim; copiousoutput
+
+application/csv; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/csv; trim < %s | column -t -s,; copiousoutput
+
+application/vnd.openxmlformats-officedocument.presentationml.presentation; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.openxmlformats-officedocument.presentationml.presentation; pptx2md --disable-image --disable-wmf --disable-color --disable-escaping %s --output $HOME/.cache/mutt/presentation.md 2>/dev/null && cat --squeeze-blank $HOME/.cache/mutt/presentation.md; nametemplate=%s.pptx; copiousoutput
+application/vnd.openxmlformats-officedocument.presentationml.template; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.openxmlformats-officedocument.presentationml.slideshow; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+
+application/vnd.ms-powerpoint; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/vnd.ms-powerpoint; ppthtml %s | w3m -dump -T text/html; copiousoutput
+
+
+# RTF, EPUB
+application/rtf; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/rtf; unrtf --html %s | w3m -dump -T text/html; copiousoutput
+application/richtext; /usr/local/lib/mutt-wizard/openfile soffice --nologo %s; test=test -n "$DISPLAY"
+application/richtext; unrtf --html %s | w3m -dump -T text/html; copiousoutput
+
+application/epub+zip; /usr/local/lib/mutt-wizard/openfile kchmviewer %s; test=test -n "$DISPLAY"
+application/epub+zip; pandoc --from epub --to plain %s | cat --squeeze-blank; copiousoutput
+
+# PDF, DJVU
+application/pdf; /usr/local/lib/mutt-wizard/openfile "${PDFVIEWER:-zathura}" %s; test=test -n "$DISPLAY"; nametemplate=%s.pdf; description="PDF Document"
+application/pdf; pdftotext -l 20 -nopgbrk -q -htmlmeta -- %s - | w3m -dump -T text/html; nametemplate=%s.pdf; copiousoutput
+
+application/x-pdf; /usr/local/lib/mutt-wizard/openfile "${PDFVIEWER:-zathura}" %s; test=test -n "$DISPLAY"; nametemplate=%s.pdf; description="PDF Document"
+application/x-pdf; pdftotext -l 20 -nopgbrk -q -htmlmeta -- %s - | w3m -dump -T text/html; nametemplate=%s.pdf; copiousoutput
+
+application/x-bzpdf; /usr/local/lib/mutt-wizard/openfile "${PDFVIEWER:-zathura}" %s; test=test -n "$DISPLAY"; nametemplate=%s.pdf.bz2; description="PDF Document"
+application/x-gzpdf; /usr/local/lib/mutt-wizard/openfile "${PDFVIEWER:-zathura}" %s; test=test -n "$DISPLAY"; nametemplate=%s.pdf.gz; description="PDF Document"
+application/x-xzpdf; /usr/local/lib/mutt-wizard/openfile "${PDFVIEWER:-zathura}" %s; test=test -n "$DISPLAY"; nametemplate=%s.pdf.xz; description="PDF Document"
+
+image/vnd.djvu; /usr/local/lib/mutt-wizard/openfile "${PDFVIEWER:-qpdfview --unique --instance mutt}" %s; test=test -n "$DISPLAY"; nametemplate=%s.pdf.gz; description="DJVU Document"
+image/vnd.djvu; djvutxt --page=1-20 %s | cat --squeeze-blank; copiousoutput
+
+# Archives
+application/x-executable; readelf -WCa %s; copiousoutput
+application/x-pie-executable; readelf -WCa %s; copiousoutput
+application/x-sharedlib; readelf -WCa %s; copiousoutput
+
+application/vnd.debian.binary-package; dpkg-deb --contents %s; copiousoutput
+application/x-rpm; rpm -qlp %s; copiousoutput
+application/x-xpinstall; unzip -l %s; copiousoutput
+
+application/x-tar; tar tvvf %s; copiousoutput
+application/x-bzip-compressed-tar; tar jtvvf %s; copiousoutput
+application/x-bzip; tar jtvvf %s; copiousoutput
+application/x-bzip2; tar jtvvf %s; copiousoutput
+application/x-gtar; tar tvfz %s; copiousoutput
+application/x-tar-gz; tar tvfz %s; copiousoutput
+application/x-lzip; tar --lzip -tvf %s; copiousoutput
+application/x-xz; tar tvfJ %s; copiousoutput
+application/x-compress; tar Ztvf %s; copiousoutput
+application/x-rar-compressed; unrar v %s; copiousoutput
+
+application/java-archive; jar tf %s; copiousoutput
+application/zip; jar tf %s; nametemplate=%s.jar; copiousoutput
+application/zip; unzip -l %s; copiousoutput
+application/x-zip-compressed; unzip -l %s; copiousoutput
+
+application/x-zstd; zstd -lv %s; copiousoutput
+
+application/x-7z-compressed; 7z l %s; copiousoutput
+
+# Multimedia
+image/*; /usr/local/lib/mutt-wizard/openfile feh -Tview -- %s; description="Image"; test=test -n "$DISPLAY"
+# image/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+image/*; identify -ping %s; copiousoutput
+
+audio/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; description="Audio"; test=test -n "$DISPLAY"
+# audio/*; /usr/local/lib/mutt-wizard/openfile smplayer 2>/dev/null %s; description="Audio"; test=test -n "$DISPLAY"
+audio/*; mpv --aid=no --vid=no --sid=no '%s' || : ; copiousoutput
+# audio/*; mediainfo %s; copiousoutput
+
+video/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; description="Video"; test=test -n "$DISPLAY"
+# video/*; /usr/local/lib/mutt-wizard/openfile smplayer 2>/dev/null %s; description="Audio"; test=test -n "$DISPLAY"
+video/*; mpv --aid=no --vid=no --sid=no '%s' || : ; copiousoutput
+# video/*; mediainfo %s; copiousoutput
+
+# Text
+text/markdown; gvim %s; test=test -n "$DISPLAY"
+text/markdown; mdcat %s; copiousoutput
+
+text/html; /usr/local/lib/mutt-wizard/openfile "${BROWSER:-firefox}" %s; test=test -n "$DISPLAY"; description="HTML Document"
+# text/html; pandoc --from=html --to=markdown %s | mdcat; copiousoutput
+# text/html; pandoc --from=html --to=man %s | groff -Tutf8 -man; copiousoutput
+# text/html; w3m -I %{charset} -T text/html; charset=%{charset:-UTF-8}; copiousoutput; description="HTML Document"
+text/html; w3m -T text/html; copiousoutput; description="HTML Document"
+
+application/json; gvim %s; test=test -n "$DISPLAY"
+application/json; jq --color-output . %s; copiousoutput
+
+text/x-vcard; gvim %s; test=test -n "$DISPLAY"
+text/x-vcard; /usr/local/bin/mutt.vcard.filter; copiousoutput
+
+text/calendar; gvim %s; test=test -n "$DISPLAY"
+text/x-vcalendar; gvim %s; test=test -n "$DISPLAY"
+application/ics; gvim %s; test=test -n "$DISPLAY"
+# # Alternatively, you can use `mutt-ics` instead of `vcalendar-filter`:
+# text/calendar; mutt-ics; nametemplate=%s.ics; copiousoutput
+text/calendar; /usr/local/bin/vcalendar-filter; nametemplate=%s.ics; copiousoutput
+text/x-vcalendar; /usr/local/bin/vcalendar-filter; nametemplate=%s.ics; copiousoutput
+application/ics; /usr/local/bin/vcalendar-filter; nametemplate=%s.ics; copiousoutput
+
+# # Alternatively, use `highlight --out-format=ansi --force -- %s; copiousoutput`
+# # instead of `bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput`
+
+# PGP
+application/pgp-encrypted; gpg -d '%s'; copiousoutput;
+application/pgp-keys; gpg --import '%s'; copiousoutput;
+application/pgp-signature; gvim %s; test=test -n "$DISPLAY"
+application/pgp-signature; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+
+application/x-subrip; $EDITOR %s;
+application/x-tex; gvim %s; test=test -n "$DISPLAY"
+application/x-latex; gvim %s; test=test -n "$DISPLAY"
+application/x-perl; gvim %s; test=test -n "$DISPLAY"
+application/x-script; gvim %s; test=test -n "$DISPLAY"
+application/x-shellscript; gvim %s; test=test -n "$DISPLAY"
+application/x-sh; gvim %s; test=test -n "$DISPLAY"
+application/x-diff; gvim %s; test=test -n "$DISPLAY"
+application/x-patch; gvim %s; test=test -n "$DISPLAY"
+application/x-tex; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-latex; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-perl; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-script; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-shellscript; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-sh; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-diff; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+application/x-patch; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+
+text/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+# text/*; highlight --out-format=ansi --force -- %s; copiousoutput
+text/*; bat --paging=never --style=plain --color=always --theme=ansi %s; copiousoutput
+
+# Kitchen-sink
+message/rfc822; mu view -- %s | cat --squeeze-blank; copiousoutput
+message/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+message/*; LESSQUIET=1 lesspipe.sh %s | cat --squeeze-blank; copiousoutput
+
+multipart/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+multipart/*; LESSQUIET=1 lesspipe.sh %s | cat --squeeze-blank; copiousoutput
+
+x-content/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+x-content/*; LESSQUIET=1 lesspipe.sh %s | cat --squeeze-blank; copiousoutput
+
+x-epoc/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+x-epoc/*; LESSQUIET=1 lesspipe.sh %s | cat --squeeze-blank; copiousoutput
+
+application/octet-stream; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+application/octet-stream; ccze -AC < %s; nametemplate=%s.log; copiousoutput
+application/octet-stream; LESSQUIET=1 lesspipe.sh %s | cat --squeeze-blank; copiousoutput
+
+application/*; /usr/local/lib/mutt-wizard/openfile xdg-open 2>/dev/null %s; test=test -n "$DISPLAY"
+application/*; LESSQUIET=1 lesspipe.sh %s | cat --squeeze-blank; copiousoutput