1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00

Updated mutt config

This commit is contained in:
Ryan Kes 2019-06-12 12:53:59 +02:00
parent 48add33912
commit e4ed3e9fb6
14 changed files with 417 additions and 181 deletions

26
mutt/.config/msmtp/config Normal file
View File

@ -0,0 +1,26 @@
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.config/msmtp/msmtp.log
account ryankes
host mail.higherlearning.eu
port 587
from ryan@ryankes.eu
user ryan@ryankes.eu
passwordeval "gpg2 -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk '/machine mail.higherlearning.eu login ryan@ryankes.eu/ {print $NF}'"
account gmail
host smtp.gmail.com
port 587
from alrayyes@gmail.com
user alrayyes@gmail.com
passwordeval "gpg2 -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk '/machine imap.gmail.com login alrayyes@gmail.com/ {print $NF}'"
account andthensome
host smtp.gmail.com
port 587
from ryan@andthensome.nl
user ryan@andthensome.nl
passwordeval "gpg2 -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk '/machine imap.gmail.com login ryan@andthensome.nl/ {print $NF}'"

View File

@ -1,9 +0,0 @@
set spoolfile = "+gmail/inbox"
set record = "+gmail/Sent\ Items"
set postponed = "+gmail/Drafts"
set from = "alrayyes@gmail.com"
set sendmail = "msmtp -a gmail"
set sendmail_wait = 0
unset record
set realname = "Ryan"

View File

@ -1,7 +0,0 @@
set spoolfile = +ryankes/INBOX
set record = +ryankes/Sent
set from = "ryan@ryankes.eu"
set sendmail = "msmtp -a ryankes"
set sendmail_wait = 0
set realname = "Ryan"

View File

@ -1,9 +0,0 @@
set spoolfile = "+andthensome/inbox"
set record = "+andthensome/Sent\ Items"
set postponed = "+andthensome/Drafts"
set from = "ryan@andthensome.nl"
set sendmail = "msmtp -a andthensome"
set sendmail_wait = 0
unset record
set realname = "Ryan Kes"

View File

@ -0,0 +1,7 @@
text/plain; $EDITOR %s ;
text/html; openfile %s ;
text/html; w3m -I %{charset} -T text/html; copiousoutput;
image/*; muttimage %s ; copiousoutput
video/*; setsid mpv --quiet %s &; copiousoutput
application/pdf; openfile %s ;
application/pgp-encrypted; gpg -d '%s'; copiousoutput;

View File

@ -1,151 +1,83 @@
# Paths
set folder = ~/mail
set header_cache = ~/.config/mutt/cache/headers
set message_cachedir = ~/.config/mutt/cache/bodies
set mailcap_path = ~/.mailcap
set tmpdir = ~/.config/mutt/temp
set signature = ~/.config/mutt/sig
# Basic options
set wait_key = no
set mbox_type = Maildir
set timeout = 3
set mail_check = 0
set move = no
set delete
set confirmappend = no
set quit
set beep_new
set pipe_decode
set thorough_search
# Index view options
set sort = threads
set sort_aux = reverse-last-date-received
set date_format="%d/%m %I:%M"
set index_format="[%Z] %D %-20.20F %s"
# vim: filetype=neomuttrc
set certificate_file = ~/.cache/mutt/certificates
set date_format="%y/%m/%d %H:%M"
set index_format="%2C [%Z] %?X?A& ? %D %-15.15F %s (%-4.4c)"
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set uncollapse_jump
# pgp stuff
set pgp_replyencrypt # now crypt_replyencrypt
set pgp_replysign # now crypt_replysign
set pgp_replysignencrypted # now crypt_replysignencrypted
set pgp_show_unusable=no
# Pager View Options ---------------------------------
set pager_index_lines = 10 # number of index lines to show
set pager_context = 3 # number of context lines to show
set pager_stop # don't go to next message automatically
set menu_scroll # scroll in menus
set tilde # show tildes like in vim
unset markers # no ugly plus signs
set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
alternative_order text/plain text/enriched text/html
# Sidebar
set sidebar_visible
set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S"
set mail_check_stats
set sidebar_short_path
set sidebar_delim_chars="/"
set sidebar_new_mail_only
set sidebar_width = 24
# Compose View Options -------------------------------
set envelope_from # which from?
set sig_dashes # dashes before sig
set edit_headers # show headers when composing
set smtp_authenticators = 'gssapi:login'
set query_command = "abook --mutt-query '%s'"
set rfc2047_parameters = yes
set sleep_time = 0 # Pause 0 seconds for informational messages
set markers = no # Disables the `+` displayed at line wraps
set mark_old = no # Unread mail stay unread until read
set mime_forward = yes # attachments are forwarded with mail
set wait_key = no # mutt won't ask "press key to continue"
set fast_reply # skip to compose when replying
set askcc # ask for CC:
set fcc_attach # save attachments with the body
unset mime_forward # forward attachments as part of body
set forward_format = "Fwd: %s" # format of subject when forwarding
set forward_decode # decode when forwarding
set attribution = "On %d, %n wrote:" # format of quoting header
set reply_to # reply to Reply to: field
set forward_quote # include message in forwards
set reverse_name # reply as whomever it was to
set include # include message in replies
set forward_quote # include message in forwards
set editor = nvim
auto_view text/html # automatically show html (mailcap uses w3m)
auto_view application/pgp-encrypted
alternative_order text/plain text/enriched text/html
bind index,pager i noop
bind index,pager g noop
bind index \Cf noop
# Index Key Bindings ---------------------------------
bind index g noop
bind index gg first-entry
bind index G last-entry
bind index R group-reply
bind index <tab> sync-mailbox
bind index <space> collapse-thread
# Pager bindings
bind pager g noop
bind pager k previous-line
bind pager j next-line
bind pager gg top
bind pager G bottom
bind pager R group-reply
# Sidebar Navigation ---------------------------------
bind index,pager <down> sidebar-next
bind index,pager <up> sidebar-prev
bind index,pager <right> sidebar-open
bind index,pager B sidebar-toggle-visible
# Attachments and editor
# General rebindings
bind attach <return> view-mailcap
bind attach l view-mailcap
bind editor <space> noop
# Ctrl-R to mark all as read
macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"
# Saner copy/move dialogs
macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"
# Switch between mailboxes
macro index <f1> '<sync-mailbox><enter-command>source ~/.config/mutt/account.com.gmail.alrayyes<enter><change-folder>!<enter>'
macro index <f2> '<sync-mailbox><enter-command>source ~/.config/mutt/account.nl.andthensome.ryan<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.config/mutt/account.eu.ryankes.ryan<enter><change-folder>!<enter>'
# Sync email
macro index O "<shell-escape>offlineimap -o <enter>" "run offlineimap to sync all mail"
macro index o "<shell-escape>offlineimap -o -qf INBOX<enter>" "run offlineimap to sync inbox"
# Open links with urlview
macro pager \Cu "|urlview<enter>"
# Header Options -------------------------------------
ignore * # ignore all headers
unignore from: to: cc: date: subject: # show only these
unhdr_order * # some distros order things by default
hdr_order from: to: cc: date: subject: # and in this order
# layout
mono bold bold
mono underline underline
mono indicator reverse
color index yellow default '.*'
color index_author red default '.*'
color index_number blue default
color index_subject cyan default '.s'
color index_size green default
color normal default default
color body brightred default [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+
color body brightblue default (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+
color sidebar_new color221 color233
# Goobook
set query_command="goobook query %s"
macro index,pager a "<pipe-message>goobook add<return>" "add sender to google contacts"
bind index G last-entry
bind index gg first-entry
bind pager,attach h exit
bind pager j next-line
bind pager k previous-line
bind pager l view-attachments
bind index D delete-message
bind index U undelete-message
bind index L limit
bind index h noop
bind index l display-message
bind browser h goto-parent
bind browser l select-entry
bind pager,browser gg top-page
bind pager,browser G bottom-page
bind index,pager,browser d half-down
bind index,pager,browser u half-up
bind index,pager S sync-mailbox
bind index,pager R group-reply
bind index \031 previous-undeleted # Mouse wheel
bind index \005 next-undeleted # Mouse wheel
bind pager \031 previous-line # Mouse wheel
bind pager \005 next-line # Mouse wheel
bind editor <Tab> complete-query
# Notmuch
#set virtual_spoolfile=yes
#source ~/.config/mutt/notmuchmailboxes
macro index,pager a "|abook --add-email\n" 'add sender to abook'
macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"
macro index O "<shell-escape>mailsync -Va<enter>" "run offlineimap to sync all mail"
macro index \Cf "<enter-command>unset wait_key<enter><shell-escape>read -p 'Enter a search term to find with notmuch: ' x; echo \$x >~/.cache/mutt_terms<enter><limit>~i \"\`notmuch search --output=messages \$(cat ~/.cache/mutt_terms) | head -n 600 | perl -le '@a=<>;s/\^id:// for@a;$,=\"|\";print@a' | perl -le '@a=<>; chomp@a; s/\\+/\\\\+/ for@a;print@a' \`\"<enter>" "show only messages matching a notmuch pattern"
macro index A "<limit>all\n" "show all messages (undo limit)"
source ~/.config/mutt/mailboxes
source ~/.config/mutt/account.com.gmail.alrayyes
source ~/.config/mutt/account.nl.andthensome.ryan
source ~/.config/mutt/account.eu.ryankes.ryan
source ~/.config/mutt/muttcol
source ~/.config/mutt/gpg.rc
# Sidebar mappings
set sidebar_visible = yes
set sidebar_width = 20
set sidebar_short_path = yes
set sidebar_next_new_wrap = yes
set mail_check_stats
set sidebar_format = '%B%?F? [%F]?%* %?N?%N/? %?S?%S?'
bind index,pager \Ck sidebar-prev
bind index,pager \Cj sidebar-next
bind index,pager \Co sidebar-open
bind index,pager \Cp sidebar-prev-new
bind index,pager \Cn sidebar-next-new
bind index,pager B sidebar-toggle-visible
source /home/alrayyes/.config/mutt/muttcol
source /home/alrayyes/.config/mutt/gpg.rc
source /home/alrayyes/.config/mutt/accounts/1-ryankes.muttrc
macro index,pager i1 '<sync-mailbox><enter-command>source /home/alrayyes/.config/mutt/accounts/1-ryankes.muttrc<enter><change-folder>!<enter>;<check-stats>' "switch to ryan@ryankes.eu" # mw-autogenerated
macro index,pager i2 '<sync-mailbox><enter-command>source /home/alrayyes/.config/mutt/accounts/2-gmail.muttrc<enter><change-folder>!<enter>;<check-stats>' "switch to alrayyes@gmail.com" # mw-autogenerated
macro index,pager i3 '<sync-mailbox><enter-command>source /home/alrayyes/.config/mutt/accounts/3-andthensome.muttrc<enter><change-folder>!<enter>;<check-stats>' "switch to ryan@andthensome.nl" # mw-autogenerated

View File

@ -0,0 +1,6 @@
[Unit]
Description=Mailbox synchronization service
[Service]
Type=oneshot
ExecStart=/home/alrayyes/.local/bin/mailsync

View File

@ -0,0 +1,10 @@
[Unit]
Description=Mailbox synchronization timer
[Timer]
OnBootSec=2m
OnUnitActiveSec=5m
Unit=mailsync.service
[Install]
WantedBy=timers.target

52
mutt/.local/bin/mailsync Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env sh
# Sync mail and give notification if there is new mail.
# Run only if user logged in (prevent cron errors)
pgrep -u "$USER" >/dev/null || exit
# Run only if not already running in other instance
pgrep -x mbsync >/dev/null && exit
# Checks for internet connection and set notification script.
ping -q -c 1 1.1.1.1 > /dev/null || exit
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."
export DISPLAY=:0.0
notify() { notify-send "mutt" "📬 $2 new mail(s) in \`$1\` account." ;}
# Check account for new mail. Notify if there is new content.
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
mbsync "$acc"
new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2> /dev/null)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
if [ "$newcount" -gt "0" ]; then
notify "$acc" "$newcount" &
for file in $new; do
# Extract subject and sender from mail.
from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n-1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
notify-send "📧$from:" "$subject" &
done
fi
}
# Sync accounts passed as argument or all.
if [ "$#" -eq "0" ]; then
accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")"
else
accounts=$*
fi
# Parallelize multiple accounts
for account in $accounts
do
syncandnotify &
done
wait
notmuch new 2>/dev/null
#Create a touch file that indicates the time of the last run of mailsync
touch "$HOME/.config/mutt/.mailsynclastrun"

12
mutt/.local/bin/muttimage Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
#get image resolution
resolution=$(identify $1 | awk '{print $3}')
IFS='x' # x is set as delimiter
read -ra ADDR <<< "$resolution"
width=${ADDR[0]}
height=${ADDR[1]}
### Display Image / offset with mutt bar
echo -e "2;3;\n0;1;0;42;$((width));$((height));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay &

View File

@ -1,13 +0,0 @@
#!/bin/zsh
notmuch new
notmuch tag +inbox +new -- tag:new
notmuch tag -new -inbox +sent -- from:alrayyes@gmail.com or from:ryan@andthensome.nl
ACCOUNTS=( "gmail" "andthensome")
for ACCOUNT in "${ACCOUNTS[@]}"
do
NEWDIRS=$(ls ~/mail/$ACCOUNT/inbox/new/ | wc -l)
if [ ! "$NEWDIRS" -eq "0" ]; then
notify-send "New Mails ${ACCOUNT}" "$NEWDIRS" -i mail-message-new
fi
done

8
mutt/.local/bin/openfile Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
# Helps open a file with xdg-open from mutt in a external program without weird side effects.
[ $(uname) = "Darwin" ] && opener="open" || opener="setsid xdg-open"
mkdir -p "/tmp/$USER-mutt-tmp"
file="/tmp/$USER-mutt-tmp/$(basename "$1")"
rm -f "$file"
cp "$1" "$file"
$opener "$file" >/dev/null 2>&1 &

121
mutt/.mbsyncrc Normal file
View File

@ -0,0 +1,121 @@
Create Both
Expunge Both
SyncState *
IMAPStore ryankes-remote
Host mail.higherlearning.eu
Port 993
User ryan@ryankes.eu
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk '/machine mail.higherlearning.eu login ryan@ryankes.eu/ {print $NF}'"
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt
MaildirStore ryankes-local
Subfolders Verbatim
Path ~/.local/share/mail/ryankes/
Inbox ~/.local/share/mail/ryankes/INBOX
Flatten .
Channel ryankes
Master :ryankes-remote:
Slave :ryankes-local:
Patterns INBOX* Trash Drafts Sent Archive Spam
# End profile
IMAPStore gmail-remote
Host imap.gmail.com
Port 993
User alrayyes@gmail.com
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk '/machine imap.gmail.com login alrayyes@gmail.com/ {print $NF}'"
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt
MaildirStore gmail-local
Subfolders Verbatim
Path ~/.local/share/mail/gmail/
Inbox ~/.local/share/mail/gmail/INBOX
Flatten .
Channel gmail-inbox
Master :gmail-remote:
Slave :gmail-local:
Patterns "INBOX"
Channel gmail-sent
Master :gmail-remote:"[Gmail]/Sent Mail"
Slave :gmail-local:Sent
Channel gmail-drafts
Master :gmail-remote:"[Gmail]/Drafts"
Slave :gmail-local:Drafts
Channel gmail-spam
Master :gmail-remote:"[Gmail]/Spam"
Slave :gmail-local:Spam
Channel gmail-trash
Master :gmail-remote:"[Gmail]/Trash"
Slave :gmail-local:Trash
Channel gmail-archive
Master :gmail-remote:"[Gmail]/All Mail"
Slave :gmail-local:Archive
# Get all the channels together into a group.
Group gmail
Channel gmail-inbox
Channel gmail-sent
Channel gmail-drafts
Channel gmail-spam
Channel gmail-trash
Channel gmail-archive
# End profile
IMAPStore andthensome-remote
Host imap.gmail.com
Port 993
User ryan@andthensome.nl
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk '/machine imap.gmail.com login ryan@andthensome.nl/ {print $NF}'"
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt
MaildirStore andthensome-local
Subfolders Verbatim
Path ~/.local/share/mail/andthensome/
Inbox ~/.local/share/mail/andthensome/INBOX
Flatten .
Channel andthensome-inbox
Master :andthensome-remote:
Slave :andthensome-local:
Patterns "INBOX"
Channel andthensome-sent
Master :andthensome-remote:"[Gmail]/Sent Mail"
Slave :andthensome-local:Sent
Channel andthensome-drafts
Master :andthensome-remote:"[Gmail]/Drafts"
Slave :andthensome-local:Drafts
Channel andthensome-spam
Master :andthensome-remote:"[Gmail]/Spam"
Slave :andthensome-local:Spam
Channel andthensome-trash
Master :andthensome-remote:"[Gmail]/Trash"
Slave :andthensome-local:Trash
Channel andthensome-archive
Master :andthensome-remote:"[Gmail]/All Mail"
Slave :andthensome-local:Archive
# Get all the channels together into a group.
Group andthensome
Channel andthensome-inbox
Channel andthensome-sent
Channel andthensome-drafts
Channel andthensome-spam
Channel andthensome-trash
Channel andthensome-archive
# End profile

100
mutt/.notmuch-config Normal file
View File

@ -0,0 +1,100 @@
# .notmuch-config - Configuration file for the notmuch mail system
#
# For more information about notmuch, see https://notmuchmail.org
# Database configuration
#
# The only value supported here is 'path' which should be the top-level
# directory where your mail currently exists and to where mail will be
# delivered in the future. Files should be individual email messages.
# Notmuch will store its database within a sub-directory of the path
# configured here named ".notmuch".
#
[database]
path=/home/alrayyes/.local/share/mail/
# User configuration
#
# Here is where you can let notmuch know how you would like to be
# addressed. Valid settings are
#
# name Your full name.
# primary_email Your primary email address.
# other_email A list (separated by ';') of other email addresses
# at which you receive email.
#
# Notmuch will use the various email addresses configured here when
# formatting replies. It will avoid including your own addresses in the
# recipient list of replies, and will set the From address based on the
# address to which the original email was addressed.
#
[user]
name=Ryan
primary_email=ryan@ryankes.eu
other_email=alrayyes@gmail.com;ryan@andthensome.nl;
# Configuration for "notmuch new"
#
# The following options are supported here:
#
# tags A list (separated by ';') of the tags that will be
# added to all messages incorporated by "notmuch new".
#
# ignore A list (separated by ';') of file and directory names
# that will not be searched for messages by "notmuch new".
#
# NOTE: *Every* file/directory that goes by one of those
# names will be ignored, independent of its depth/location
# in the mail store.
#
[new]
tags=unread;inbox;
ignore=
# Search configuration
#
# The following option is supported here:
#
# exclude_tags
# A ;-separated list of tags that will be excluded from
# search results by default. Using an excluded tag in a
# query will override that exclusion.
#
[search]
exclude_tags=trash;spam;
# Maildir compatibility configuration
#
# The following option is supported here:
#
# synchronize_flags Valid values are true and false.
#
# If true, then the following maildir flags (in message filenames)
# will be synchronized with the corresponding notmuch tags:
#
# Flag Tag
# ---- -------
# D draft
# F flagged
# P passed
# R replied
# S unread (added when 'S' flag is not present)
#
# The "notmuch new" command will notice flag changes in filenames
# and update tags, while the "notmuch tag" and "notmuch restore"
# commands will notice tag changes and update flags in filenames
#
[maildir]
synchronize_flags=true
# Cryptography related configuration
#
# The following *deprecated* option is currently supported:
#
# gpg_path
# binary name or full path to invoke gpg.
# NOTE: In a future build, this option will be ignored.
# Setting $PATH is a better approach.
#
[crypto]
gpg_path=gpg