diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-30 23:17:15 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-30 23:17:15 +0900 |
| commit | e05b1e51921016a8a83afa4bff06f97ab830033d (patch) | |
| tree | 70c0be7909023c703b9dc0d932c8e0d96d58d08d | |
| parent | 696ce7215119801a3420f01b99e1db41984741c5 (diff) | |
updates
| -rw-r--r-- | Makefile | 6 | ||||
| -rwxr-xr-x | bin/mutt.vcard.filter | 152 | ||||
| -rwxr-xr-x | bin/mw | 2 | ||||
| -rwxr-xr-x | bin/vcalendar-filter | 86 | ||||
| -rwxr-xr-x | lib/openfile | 87 | ||||
| -rw-r--r-- | share/mailcap | 253 | ||||
| -rw-r--r-- | share/mutt-wizard.muttrc | 10 |
7 files changed, 573 insertions, 23 deletions
@@ -8,6 +8,8 @@ install: mkdir -p $(DESTDIR)$(PREFIX)/lib/mutt-wizard mkdir -p $(DESTDIR)$(PREFIX)/share/mutt-wizard cp -f bin/mailsync $(DESTDIR)$(PREFIX)/bin/mailsync + cp -f bin/mutt.vcard.filter $(DESTDIR)$(PREFIX)/bin/mutt.vcard.filter + cp -f bin/vcalendar-filter $(DESTDIR)$(PREFIX)/bin/vcalendar-filter cp -f lib/openfile $(DESTDIR)$(PREFIX)/lib/mutt-wizard/openfile chmod 755 $(DESTDIR)$(PREFIX)/share/mutt-wizard for shared in share/*; do \ @@ -21,14 +23,14 @@ install: sed 's:/usr/local:$(PREFIX):' < bin/mw > $(DESTDIR)$(PREFIX)/bin/mw sed 's:/usr/local:$(PREFIX):' < mw.1 > $(DESTDIR)$(MANPREFIX)/man1/mw.1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/mw.1 $(DESTDIR)$(MANPREFIX)/man1/mailsync.1 - chmod 755 $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/lib/mutt-wizard/openfile + chmod 755 $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/bin/mutt.vcard.filter $(DESTDIR)$(PREFIX)/bin/vcalendar-filter $(DESTDIR)$(PREFIX)/lib/mutt-wizard/openfile mkdir -p $(DESTDIR)$(PREFIX)/share/zsh/site-functions/ chmod 755 $(DESTDIR)$(PREFIX)/share/zsh/site-functions/ cp -f completion/_mutt-wizard.zsh $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_mutt-wizard.zsh chmod 644 $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_mutt-wizard.zsh uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/lib/mutt-wizard/openfile + rm -f $(DESTDIR)$(PREFIX)/bin/mw $(DESTDIR)$(PREFIX)/bin/mailsync $(DESTDIR)$(PREFIX)/bin/mutt.vcard.filter $(DESTDIR)$(PREFIX)/bin/vcalendar-filter $(DESTDIR)$(PREFIX)/lib/mutt-wizard/openfile rm -rf $(DESTDIR)$(PREFIX)/share/mutt-wizard $(DESTDIR)$(PREFIX)/lib/mutt-wizard rm -f $(DESTDIR)$(MANPREFIX)/man1/mw.1 $(DESTDIR)$(MANPREFIX)/man1/mailsync.1 rm -f $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_mutt-wizard.zsh diff --git a/bin/mutt.vcard.filter b/bin/mutt.vcard.filter new file mode 100755 index 0000000..3a65a2d --- /dev/null +++ b/bin/mutt.vcard.filter @@ -0,0 +1,152 @@ +#!/usr/bin/perl -Tw + +# mutt.vcard.filter - vcard filter for use with the mutt autoview facility +# Copyright (C) 1997,1998,1999 David A Pearson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the license, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# This little perl script is a simple filter for text/x-vcard +# attachments. I'm pretty sure I've *not* included everything +# possible in here, but it "works for me". Feel free to improve +# in any way you see fit. +# +# Here is how I use it. In my ~/.mutt_mailcap (use your filename of +# choice) I have the following entry: +# +# text/x-vcard; mutt.vcard.filter; copiousoutput +# +# All you then need to do is add a line like: +# +# auto_view text/x-vcard +# +# to your ~/.muttrc (use your filename of choice). +# +# All comments/flames/feedback can be directed to: +# +# davep@hagbard.demon.co.uk +# + +use strict; + +my $in_card = 0; +my @address = (); +my @contacts = (); +my @additional = (); +my @notes = (); +my $name = ""; +my $title = ""; +my $org = ""; +my $found_note = 0; +my $len; +my $i; +my $addr_line; +my $contact_line; + +while ( <> ) +{ + if ( $in_card ) + { + if ( /^fn:\s*(.*)$/i ) + { + $name = $1; + } + elsif ( /^n:\s*(.*);\s*(.*)$/i ) + { + @additional = ( "", "Additional information:", "" ) if $#additional == -1; + + @additional = ( @additional, "Last Name:\t$1", "First Name:\t$2" ); + } + elsif ( /^title:\s*(.*)$/i ) + { + $title = $1; + } + elsif ( /^org:\s*(.*)$/i ) + { + $org = $1; + } + elsif ( /^adr:\s*(.*)$/i ) + { + my $addr = $1; + + $addr =~ s/;+/;/g; + + @address = split( /;/, $addr ); + } + elsif ( /^email;\s*(.*?):\s*(.*)$/i || /^tel;\s*(.*?):\s*(.*)$/i ) + { + my $type = $1; + my $value = $2; + + @contacts = ( @contacts, uc( substr( $type, 0, 1 ) ) . + substr( $type, 1 ) . ": $value" ); + } + elsif ( /^note:\s*(.*)$/i ) + { + @notes = ( "" ) if $#notes == -1; + @notes = ( @notes, $1 ); + + $found_note = 1; + } + elsif ( /^=.{2}=$/ && $found_note ) + { + my $line = <>; + + chomp( $line ); + + @notes = ( "" ) if $#notes == -1; + @notes = ( @notes, $line ); + } + elsif ( /^end:\s*vcard$/i ) + { + $in_card = 0; + } + } + else + { + $in_card = /^begin:\s*vcard\s*$/i; + } +} + +@address = ( $org, @address ) if $org; +@address = ( $title, @address ) if $title; +@address = ( $name, @address ) if $name; + +format STDOUT = +@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +$addr_line, $contact_line +. + +$len = $#address > $#contacts ? $#address : $#contacts; + +print "" . ( "=" x 76 ) . "\n"; + +for ( $i = 0; $i <= $len; $i++ ) +{ + $addr_line = $i <= $#address ? $address[ $i ] : ""; + $contact_line = $i <= $#contacts ? $contacts[ $i ] : ""; + write; +} + +for ( $i = 0; $i <= $#notes; $i++ ) +{ + print "$notes[ $i ]\n"; +} + +for ( $i = 0; $i <= $#additional; $i++ ) +{ + print "$additional[ $i ]\n"; +} + +print "" . ( "=" x 76 ) . "\n"; @@ -339,7 +339,7 @@ Options allowed with -a: -x Password for account (recommended to be in double quotes) Options allowed with -d/-D: - -X Delete an account's local email too when deleting + -X Delete an account's local email too when deleting NOTE: Once at least one account is added, you can run \`mbsync -a\` to begin downloading mail. diff --git a/bin/vcalendar-filter b/bin/vcalendar-filter new file mode 100755 index 0000000..ffdf27a --- /dev/null +++ b/bin/vcalendar-filter @@ -0,0 +1,86 @@ +#!/usr/bin/perl + +# vcalendar-filter is a simple filter to give plain text representations of vcards +# Copyright (C) 2008 Martyn Smith +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This script takes a simple VCALENDAR file as input on STDIN and produces a +# human readable text/plain representation of it on STDOUT +# +# It has been designed for use with mutt's auto_view config option, see the +# README file for more details + +use strict; +use warnings; + +use Data::ICal; +use Text::Autoformat; + +my $body = eval { local $/ = undef; <> }; +my $calendar = Data::ICal->new(data => $body); + +# If parsing failed, try parsing as version 1.0 +$calendar = Data::ICal->new(data => $body, vcal10 => 1) unless $calendar; + +# If parsing failed, give up :-( +unless ( $calendar ) { + print "Unable to parse vcalendar: ", $calendar->error_message, "\n"; + print $body; + exit 1; +} + +foreach my $entry ( @{$calendar->{entries}} ) { + my $properties; + + foreach my $property ( keys %{$entry->properties} ) { + next unless defined $entry->property($property); + $properties->{$property} = join(', ', map { $_->decoded_value } @{$entry->property($property)}); + if ( $property eq 'description' ) { + $properties->{$property} = "$properties->{$property}"; + + $properties->{$property} = autoformat $properties->{$property}, { + all => 1, + left => 15, + }; + $properties->{$property} =~ s/^\s*// if defined $properties->{$property}; + } + elsif ( $property =~ m{ \A dt (?: start | end ) \z }xms ) { + if ( $properties->{$property} =~ m{ (\d\d\d\d)(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d) }xms ) { + $properties->{$property} = "$1-$2-$3 $4:$5"; + } + } + } + + if ( $entry->ical_entry_type eq 'VTIMEZONE' ) { + unless ( defined $properties->{tzid} and $properties->{tzid} =~ m{Pacific/Auckland} ) { + print "Timezone : ", $properties->{tzid}, "\n"; + print "\n"; + } + } + elsif ( $entry->ical_entry_type eq 'VEVENT' ) { + print '-' x 72, "\n"; + foreach my $key ( qw(summary BR description BR location organizer dtstart dtend) ) { + if ( $key eq 'BR' ) { + print "\n"; + next; + } + next unless defined $properties->{$key}; + printf "%-12s: %s\n", ucfirst $key, $properties->{$key}; + } + } + else { + print "WARNING: Unknown entry type: ", $entry->ical_entry_type, "\n"; + } +} diff --git a/lib/openfile b/lib/openfile index 0f60b10..b34c018 100755 --- a/lib/openfile +++ b/lib/openfile @@ -1,10 +1,81 @@ #!/bin/sh -# Helps open a file with xdg-open from mutt in a external program without weird side effects. -tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files" -file="$tempdir/${1##*/}" -[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open" -mkdir -p "$tempdir" -cp -f "$1" "$file" -$opener "$file" >/dev/null 2>&1 -find "${tempdir:?}" -mtime +1 -type f -delete +# DESCRIPTION +# Mutt invokes external attachment viewers by writing the +# attachment to a temporary file, executing the pipeline specified +# for that attachment type in the mailcap file, waiting for the +# pipeline to terminate, writing nulls over the temporary file, +# then deleting it. This causes problems when using graphical +# viewers such as qvpview and acroread to view attachments. +# +# If qvpview, for example, is executed in the foreground, the mutt +# user interface is hung until qvpview exits, so the user can't do +# anything else with mutt until he or she finishes reading the +# attachment and exits qvpview. This is especially annoying when +# a message contains several MS Office attachments--one would like +# to have them all open at once. +# +# If qvpview is executed in the background, it must be given +# enough time to completely read the file before returning control +# to mutt, since mutt will then obliterate the file. Qvpview is +# so slow that this time can exceed 20 seconds, and the bound is +# unknown. So this is again annoying. +# +# The solution provided here is to invoke the specified viewer +# from this script after first copying mutt's temporary file to +# another temporary file. This script can then quickly return +# control to mutt while the viewer can take as much time as it +# needs to read and render the attachment. +# +# EXAMPLE +# To use qvpview to view MS Office attachments from mutt, add the +# following lines to mutt's mailcap file. +# +# application/msword; mutt_bgrun qvpview %s +# application/vnd.ms-excel; mutt_bgrun qvpview %s +# application/vnd.ms-powerpoint; mutt_bgrun qvpview %s + +prog=${0##*/} + +# Check the arguments first. + +if [ "$#" -lt "2" ]; then + echo "usage: $prog viewer [viewer options] file" >&2 + exit 1 +fi + +# Separate the arguments. Assume the first is the viewer, the last is +# the file, and all in between are options to the viewer. + +viewer="$1" +shift + +while [ "$#" -gt "1" ]; do + options="$options $1" + shift +done + +file=$1 + +# Create a temporary directory for our copy of the temporary file. +# +# This is more secure than creating a temporary file in an existing +# directory. + +tmpdir=/tmp/$LOGNAME$$ +umask 077 +mkdir "$tmpdir" || exit 1 +tmpfile="$tmpdir/${file##*/}" + +# Copy mutt's temporary file to our temporary directory so that we can +# let mutt overwrite and delete it when we exit. + +cp "$file" "$tmpfile" + +# Run the viewer in the background and delete the temporary files when done. + +( + "$viewer" $options "$tmpfile" + rm -f "$tmpfile" + rmdir "$tmpdir" +) & 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 diff --git a/share/mutt-wizard.muttrc b/share/mutt-wizard.muttrc index c145614..bdbff7a 100644 --- a/share/mutt-wizard.muttrc +++ b/share/mutt-wizard.muttrc @@ -7,7 +7,7 @@ set send_charset="us-ascii:utf-8" set mailcap_path = $HOME/.config/mutt/mailcap:/usr/local/share/mutt-wizard/mailcap:$mailcap_path set mime_type_query_command = "file --mime-type -b %s" set date_format="%y/%m/%d %I:%M%p" -set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" +set index_format="%2C %<H?[%H]> %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" set sort = 'reverse-date' set smtp_authenticators = 'gssapi:login' set query_command = "abook --datafile ~/.config/abook/addressbook --mutt-query '%s'" @@ -25,11 +25,17 @@ set forward_quote # include message in forwards set reverse_name # reply as whomever it was to set include # include message in replies set mail_check = 60 # to avoid lags using IMAP with some email providers (yahoo for example) -auto_view text/html # automatically show html (mailcap uses lynx) auto_view application/pgp-encrypted +auto_view text/* application/* image/* audio/* + #set display_filter = "tac | sed '/\\\[-- Autoview/,+1d' | tac" # Suppress autoview messages. alternative_order text/plain text/enriched text/html +# spam +spam "X-Spam-Status: Yes" "90+/SA" +spam "X-Spam-Score: ([0-9\\.]+).*" "SA: %1" +set pager_format = "%C/%m %Z %[%H:%M] %.20v, %s%* %?H? [%H] ? (%P)" + bind index,pager i noop bind index,pager g noop bind index \Cf noop |
