aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-05-10 18:48:35 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-05-10 18:48:35 +0200
commit4d4c0e81a0caace3dc035ff9010ee01ac162ec86 (patch)
tree42d045bcd2d003ebd30caf7c7d642e03002de35c /bin
downloadneomutt-4d4c0e81a0caace3dc035ff9010ee01ac162ec86.tar.gz
neomutt-4d4c0e81a0caace3dc035ff9010ee01ac162ec86.tar.bz2
neomutt-4d4c0e81a0caace3dc035ff9010ee01ac162ec86.zip
update
Diffstat (limited to 'bin')
-rwxr-xr-xbin/add_to_calcurse25
-rwxr-xr-xbin/display_filter.sh53
-rwxr-xr-xbin/get-mailboxes.sh17
-rwxr-xr-xbin/mutt-trim171
-rwxr-xr-xbin/mutt_bgrun114
-rwxr-xr-xbin/mutt_version5
-rwxr-xr-xbin/print_unicode.sh37
7 files changed, 422 insertions, 0 deletions
diff --git a/bin/add_to_calcurse b/bin/add_to_calcurse
new file mode 100755
index 0000000..4807854
--- /dev/null
+++ b/bin/add_to_calcurse
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Import text/calendar files from mutt
+# to calcurse.
+#
+
+# Make sure calcurse is running
+if [ ! -f "$HOME/.calcurse/.calcurse.pid" ]; then
+ exit 1
+fi
+
+# Extract the attachments
+TEMPDIR=$(mktemp -d add-to-calcurse.XXXXXXXX)
+cat "$@" | uudeview -i -m -n -q -p $TEMPDIR - > /dev/null 2>&1
+
+# Add the calendar file (last attachment) to calcurse
+# bartimoonboots update
+FILE=$(file $TEMPDIR/* | grep vCalendar | cut -d: -f1 | head -1)
+calcurse -i $FILE > /dev/null 2>&1
+#FILE=$(ls $TEMPDIR | sort -r | head -1)
+#calcurse -i "$TEMPDIR/$FILE" > /dev/null 2>&1
+
+# Remove the temporary dir and trigger a reload in calcurse
+rm -rf $TEMPDIR > /dev/null 2>&1
+kill -USR1 `cat $HOME/.calcurse/.calcurse.pid` > /dev/null 2>&1
diff --git a/bin/display_filter.sh b/bin/display_filter.sh
new file mode 100755
index 0000000..e45bf02
--- /dev/null
+++ b/bin/display_filter.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+# lun. 29 mars 2021 09:05:05 CEST
+# Neomutt display_filter.sh
+# filter for pager display only
+
+sed -e '
+
+# clean up neomutt notifications
+/\[-- Visualisation.* --\]/d
+/\[-- Type: text.* --\]/d
+/\[-- Type.* --\]/d
+/\[-- Pièce jointe #[0-9] --\]/d
+s/Pièce jointe #[0-9]: //g
+/\[-- .* pas disponible .* --\]/d
+
+# url tidy
+# put each url on a new line
+s/http/\nhttp/g
+# replace last /blahblah with /...
+#s|\(http.*\)/.*|\1\/...|
+
+# hide messy inline pdf
+/^%PDF-1.4/,/^%%EOF/d
+
+# add newline after --]
+s/--\]/--\]\n/g
+
+# CID
+s/\[cid/\n\[cid/g
+
+# delete [img] tags
+s/\[img\]//g
+
+# change ugly lines
+s/━/-/g
+
+# remove last <
+s/<*$//
+
+# remove lone [
+s/^\[$//
+
+# delete single spaces at the beginning of lines
+s/^ //g
+
+# delete multiple spaces
+s/[[:space:]]\+/ /g
+
+# delete multiple blank lines
+
+' | awk '!NF {if (++n <= 1) print; next}; {n=0;print}'
+
+
diff --git a/bin/get-mailboxes.sh b/bin/get-mailboxes.sh
new file mode 100755
index 0000000..e1ff8ef
--- /dev/null
+++ b/bin/get-mailboxes.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+maildir=$1
+
+# Find these specific paths so they stick at the top of the list
+MAILBOXES='"+Inbox" "+Sent" "+Trash" "+Drafts" "+Junk" '
+
+#Find all other paths, excluding those from above
+MAILBOXES=$MAILBOXES`find "$maildir" -type d -name cur \
+ -a -not \( -ipath "*Inbox*" \
+ -o -ipath "*Sent*" \
+ -o -ipath "*Drafts*" \
+ -o -ipath "*Trash*" \
+ -o -ipath "*Junk*" \
+ \) | sed -e 's/${maildir}//g' -e 's/\/cur$/\"/g' -e "s#^${maildir}/# \"+#" | sort`
+
+echo $MAILBOXES
diff --git a/bin/mutt-trim b/bin/mutt-trim
new file mode 100755
index 0000000..2378ea6
--- /dev/null
+++ b/bin/mutt-trim
@@ -0,0 +1,171 @@
+#!/usr/bin/perl
+#
+# "Beautify" quoted message and make it "ready-to-reply". Originally by Michael Velten.
+
+use utf8;
+
+# keep quotes nested up to 3rd level
+my $ind_max = 3;
+# # put 1 empty line between first and following quote
+# my $gap = 1;
+
+my $name = '[[:alpha:]]+([\'`-][[:alpha:]]+|[.])*';
+my $fullname = '\b(' . $name . '[,]?\s+)*' . $name . '\b';
+
+# Possible reply greetings (regexes) (note that '> ' will be prefixed)
+my @greetings = (
+ 'Dear\s+' . $fullname . '([,.]|\s*!)?',
+ '[Hh](ello|i|ey)' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Sehr geehrter?\s+' . $fullname . '([,.]|\s*!)?',
+ 'Lieber?\s+' . $fullname . '([,.]|\s*!)?',
+ 'Guten Tag' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Hh]allo' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Mm]oin' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Mm]esdames(,| et) [Mm]essieurs([,.]|\s*!)?',
+ 'M(adame)\s+' . $fullname . '([,.]|\s*!)?',
+ 'M(onsieur)\s+' . $fullname . '([,.]|\s*!)?',
+ '[Cc]her\s+' . $fullname . '([,.]|\s*!)?',
+ '[Cc]hère\s+' . $fullname . '([,.]|\s*!)?',
+ '[Bb]onjour' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Ss]alut' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Senhor(ita|a)?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Sra?\.?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Car(íssim)?[ao]s?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Prezad(íssim)?[ao]s?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Estimad(íssim)?[ao]s?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Bb]om [Dd]ia' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Bb]oa ([Tt]arde|[Nn]oite)' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Oo](i|lá|la)' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Aa]l[ôo]' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ '[Hh]ola' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ 'Se[ñ]or(ita|a)?' . '(\s+' . $fullname . ')?' . '([,.]|\s*!)?',
+ );
+
+# Possible reply "greetouts" (regexes) (note that '> ' will be prefixed)
+my @greetouts = (
+ '([Ww]ith )?(([Kk]ind|[Bb]est|[Ww]arm) )?([Rr]egards|[Ww]ishes)([,.]|\s*!)?',
+ '[Bb]est([,.]|\s*!)?',
+ '[Cc]heers([,.]|\s*!)?',
+ '[Mm]it ([Vv]iel|[Bb]est|[Ll]ieb|[Ff]reundlich)en [Gg]r([ü]|ue)([ß]|ss)en([,.]|\s*!)?',
+ '(([Vv]iel|[Bb]est|[Ll]ieb|[Ff]reundlich)e )?[Gg]r([ü]|ue)([ß]|ss)e([,.]|\s*!)?',
+ '(([[Bb]est|[Ll]ieb|[Ff]reundlich)e[rn] )?[Gg]ru([ß]|ss)([,.]|\s*!)?',
+ '[Mm]it (([[Bb]est|[Ll]ieb|[Ff]reundlich)em )?[Gg]ru([ß]|ss)([,.]|\s*!)?',
+ '([LV]|MF)G([,.]|\s*!)?',
+ '(([Tt]rès|[Bb]ien) )?([Cc]ordi|[Aa]mic)alement([,.]|\s*!)?',
+ '[Aa]miti[é]s?([,.]|\s*!)?',
+ '[Aa]tenciosamente([,.]|\s*!)?',
+ '[Aa]tt([,.]|\s*!)?',
+ '[Aa]abraços?([,.]|\s*!)?',
+ '[Aa]tentamente([,.]|\s*!)?',
+ '[Cc]ordialmente([,.]|\s*!)?',
+ );
+
+my $word = '[[:alpha:]]+([\'`-][[:alpha:]]+)*';
+
+# my $saw_greeting = 0;
+# my $saw_leadin = 0;
+# my $saw_greetout = 0;
+my $saw_own_sig = 0;
+my $saw_blank_line = 0;
+my $inds_other_sig = 0;
+my $quote_header = 0;
+my $extra_pref = '';
+# my $prev_inds = 0;
+
+my (@mail, @purged_mail);
+
+my $msg = shift;
+die "Usage: $0 MAIL" unless $msg;
+open(MAIL, "+<:encoding(UTF-8)", $msg) or die "$0: Can't open $msg: $!";
+push(@mail, $_) while <MAIL>; # Read whole mail
+
+# Process whole mail
+LINE:
+foreach my $line (@mail) {
+
+# Treat non-quoted lines as is
+ if ($line !~ /^>/) {
+ push(@purged_mail, $line);
+ next LINE;
+ }
+
+# Keep all lines after my own signature unmodified
+ if ($line =~ /^--\s?$/ || $saw_own_sig) {
+ $saw_own_sig = 1;
+ push(@purged_mail, $line);
+ next LINE;
+ }
+
+ # $line =~ tr/\xA0/ /;
+# tighten "> > " to ">> "
+ my ($pref, $suff) = $line =~ /^([>[:space:]]+)(.*)$/;
+ $pref =~ s/(>\s*(?!$))/>/g;
+# reduce multiple pre- and post-blanks to one post-blank
+ $pref =~ s/^\s*(>+)\s*/$1 /;
+ $line = $pref . $suff . "\n";
+
+# prepend additional '>' for each Outlook quote header
+ if ($line =~ /^>+ [-_=]{3,}\s*$word(\s+$word)*\s*[-_=]{3,}$/) {
+ $quote_header = 1;
+ next LINE;
+ }
+# first line after Outlook quote header that does not start with ...:
+ if ($quote_header == 1 && $line !~ /^>+ ([-*]\s*)?$word(\s+$word)*\s*:\s+/) {
+ $extra_pref = '>' . $extra_pref;
+ $quote_header = 0;
+ }
+ $pref = $extra_pref . $pref;
+ $line = $pref . $suff . "\n";
+
+# skip line if number of '>'s is greater than $ind_max
+ my $inds = $pref =~ tr/>//;
+ next LINE if $inds > $ind_max;
+
+# Remove other signatures
+ if ($line =~ /^>+ --\s?$/) {
+ $inds_other_sig = $inds;
+ }
+ if ($inds == $inds_other_sig) {
+ next LINE;
+ } else {
+ $inds_other_sig = 0;
+ }
+
+# Remove quoted greeting
+ # unless ($saw_greeting) {
+ foreach my $greeting (@greetings) {
+ if ($line =~ /^>+ $greeting$/) {
+ # $saw_greeting = 1;
+ next LINE;
+ }
+ }
+ # }
+
+# Remove quoted "greetout"
+ # unless ($saw_greetout) {
+ foreach my $greetout (@greetouts) {
+ if ($line =~ /^>+ $greetout$/) {
+ # $saw_greetout = 1;
+ next LINE;
+ }
+ }
+ # }
+
+# Remove quoted filler lines
+ if ($line =~ /^>+ \s*(-*|_*|=*|\+*|#*|\**)$/) {
+ next LINE;
+ }
+
+# Insert $gap empty lines between different quote levels
+ # $line = "\n" x $gap . $line if $prev_inds < $inds;
+ # $prev_inds = $inds;
+
+# Save purged line
+ push(@purged_mail, $line);
+}
+
+# Overwrite original mail with purged mail
+truncate(MAIL, 0);
+seek(MAIL, 0, 0);
+print MAIL @purged_mail;
+close(MAIL);
diff --git a/bin/mutt_bgrun b/bin/mutt_bgrun
new file mode 100755
index 0000000..7f03b67
--- /dev/null
+++ b/bin/mutt_bgrun
@@ -0,0 +1,114 @@
+#!/bin/sh
+# @(#) mutt_bgrun $Revision: 1.4 $
+
+# mutt_bgrun - run an attachment viewer from mutt in the background
+# Copyright (C) 1999-2002 Gary A. Johnson
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# SYNOPSIS
+# mutt_bgrun viewer [viewer options] file
+#
+# 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
+#
+# AUTHOR
+# Gary A. Johnson
+# <garyjohn@spk.agilent.com>
+#
+# ACKNOWLEDGEMENTS
+# My thanks to the people who have commented on this script and
+# offered solutions to shortcomings and bugs, especially Edmund
+# GRIMLEY EVANS <edmundo@rano.org> and Andreas Somogyi
+# <aso@somogyi.nu>.
+
+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/bin/mutt_version b/bin/mutt_version
new file mode 100755
index 0000000..96a8a08
--- /dev/null
+++ b/bin/mutt_version
@@ -0,0 +1,5 @@
+#!/bin/sh
+mutt="`neomutt -v | head -1`"
+os="`uname -o -r`"
+
+echo "my_hdr \"User-Agent: $mutt - $os\""
diff --git a/bin/print_unicode.sh b/bin/print_unicode.sh
new file mode 100755
index 0000000..24815a0
--- /dev/null
+++ b/bin/print_unicode.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+## print_unicode.sh
+## By Amanda Hickman https://gist.github.com/amandabee/cf7faad0a6f2afc485ee
+## Using https://github.com/baruchel/txt2pdf to print emails to PDF with unicode support.
+
+pdir="$HOME/.neomutt/tmp"
+open_pdf=qpdfview
+scriptloc="python3 $HOME/.neomutt/bin/text2pdf.py"
+
+# check to make sure that we're looking for txt2pdf in the right place
+if ! command -v python3 $scriptloc >/dev/null; then
+ echo "Is $scriptloc installed?"
+ exit 1
+fi
+
+# create temp dir if it does not exist
+if [ ! -d "$pdir" ]; then
+ mkdir -p "$pdir" 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Unable to make directory '$pdir'" 1>&2
+ exit 2
+ fi
+fi
+
+# dump stdin to a tempfile
+tmptxt="`mktemp $pdir/mutt_XXXXXXX.txt`"
+cat >> $tmptxt
+
+tmpfile="`mktemp $pdir/mutt_XXXXXXXX.pdf`"
+
+# Actually write the text into a PDF.
+$scriptloc --quiet -o $tmpfile $tmptxt
+$open_pdf $tmpfile >/dev/null 2>&1 &
+sleep 1
+rm $tmpfile
+rm $tmptxt