Move mutt config to dotfiles role

This commit is contained in:
Eryn Wells 2024-10-02 20:19:48 -07:00
parent 398c6f2d18
commit 6c6c7937c6
5 changed files with 33 additions and 5 deletions

View file

@ -0,0 +1,6 @@
text/html; w3m -v -F -I %{charset} -T text/html -cols 120 -dump %s; edit=vim; compose=vim; nametemplate=%s.html; needsterminal; copiousoutput
image/jpeg; ~/.mutt/view_attachment.sh %s jpg
image/jpg; ~/.mutt/view_attachment.sh %s jpg
image/pjepg; ~/.mutt/view_attachment.sh %s jpg
image/gif; ~/.mutt/view_attachment.sh %s gif
image/png; ~/.mutt/view_attachment.sh %s png

View file

@ -0,0 +1,119 @@
# .muttrc
# Eryn Wells <eryn@erynwells.me>
# whoami
set realname="Eryn Wells"
# Clear out whatever crap the system sets.
unmailboxes *
unlists *
unsubscribe *
# Source my local mail settings
source ~/.dotfiles/private/mail/erynwells.me.rc
# IMAP settings
set imap_check_subscribed
set mail_check=120
set timeout=300
set imap_keepalive=300
# Caching
set header_cache="~/.local/state/mutt/cache/headers"
set message_cachedir="~/.local/state/mutt/cache/bodies"
set certificate_file="~/.local/state/mutt/certificates"
set use_from=yes
set envelope_from=yes
# Interface
set quit=ask-yes
set move=no
set mark_old=no
set charset=UTF8
set sort=threads
set sort_aux=last-date-received
set sort_browser=alpha
set tilde
set markers=no
set wrap=80
set smart_wrap
set reflow_wrap
# Sounds
set beep_new
unset beep
ignore *
unignore Date: From: To: Cc: Subject:
hdr_order Date: From: To: Cc: Subject:
# Aliases
set reverse_alias=yes
set alias_file="~/.config/mutt/aliases"
# Composing and Sending
set edit_headers=yes
set include=yes
# HTML email :(
set mailcap_path="~/.config/mutt/mailcap"
auto_view text/html
alternative_order text/html text/plain text/enriched
unmailboxes "$record" "$postponed" "$trash"
# Basically the default, but give a little more space to addresses since we are no longer in the 80s.
set index_format="%4C %Z %{%b %d} %-20.20L (%?l?%4l&%4c?) %s"
# Vim style first and last
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
# First syncs everything, second syncs only INBOX.
macro index O "<shell-escape>offlineimap<enter>"
macro index o "<shell-escape>offlineimap -qf INBOX<enter>"
macro pager \Cu "|urlview<enter>" "call urlview to open links"
# Some resources for colors:
# http://www.strcat.de/dotfiles/mutt.color
# https://github.com/altercation/mutt-colors-solarized/blob/master/mutt-colors-solarized-dark-256.muttrc
# https://www.sendmail.org/~ca/email/mutt/manual-4.html
# A sensible default
color index default default ~A
# Unread email
color index color33 default ~U
# Email to me. Not flagged or tagged. (Those have their own colors.)
color index color64 default "~p!~T!~F"
# Collapsed thread
color index color61 default ~v
# Deleted email
color index color236 default ~D
color index color236 default "~D!~F"
# Flagged email
color index brightred default ~F
# Tagged email
color index yellow default ~T
# Arrows under threaded messages in the index
color tree red default
# Tildes are visible but dark
color tilde black default
color header color136 default "^Date:"
color header color33 default "^From:"
color header color37 default "^(To|Cc):"
color header color254 default "^Subject:"
# Quoted email levels. Possible quotedN's go from 0-9.
color quoted color61 default
color quoted1 color37 default
color quoted2 color64 default
# Solarized (light theme) colors
#source ~/.mutt/mutt-colors-solarized/mutt-colors-solarized-dark-256.muttrc

View file

@ -0,0 +1,127 @@
#!/bin/bash
#
# Author: Eric Gebhart
#
# Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments.
#
# Function: Copy the given file to a temporary directory so mutt
# Won't delete it before it is read by the application.
#
# Along the way, discern the file type or use the type
# That is given.
#
# Finally use 'open' or 'open -a' if the third argument is
# given.
#
#
# Arguments:
#
# $1 is the file
# $2 is the type - for those times when file magic isn't enough.
# I frequently get html mail that has no extension
# and file can't figure out what it is.
#
# Set to '-' if you don't want the type to be discerned.
# Many applications can sniff out the type on their own.
# And they do a better job of it too.
#
# Open Office and MS Office for example.
#
# $3 is open with. as in open -a 'open with this .app' foo.xls
#
# Examples: These are typical .mailcap entries which use this program.
#
# Image/JPEG; /Users/vdanen/.mutt/view_attachment %s
# Image/PNG; /Users/vdanen/.mutt/view_attachment %s
# Image/GIF; /Users/vdanen/.mutt/view_attachment %s
#
# Application/PDF; /Users/vdanen/.mutt/view_attachment %s
#
# #This HTML example passes the type because file doesn't always work and
# #there aren't always extensions.
#
# text/html; /Users/vdanen/.mutt/view_attachment %s html
#
# # If your Start OpenOffice.org.app is spelled with a space like this one, <--
# # then you'll need to precede the space with a \ . I found that too painful
# # and renamed it with an _.
#
# Application/vnd.ms-excel; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app'
# Application/msword; /Users/vdanen/.mutt/view_attachment %s "-" '/Applications/OpenOffice.org1.1.2/Start_OpenOffice.org.app'
#
#
# Debugging: If you have problems set debug to 'yes'. That will cause a debug file
# be written to /tmp/mutt_attach/debug so you can see what is going on.
#
# See Also: The man pages for open, file, basename
#
# the tmp directory to use.
tmpdir="$HOME/.tmp/mutt_attach"
# the name of the debug file if debugging is turned on.
debug_file=$tmpdir/debug
# debug. yes or no.
#debug="no"
debug="yes"
type=$2
open_with=$3
# make sure the tmpdir exists.
mkdir -p $tmpdir
# clean it out. Remove this if you want the directory
# to accumulate attachment files.
rm -f $tmpdir/*
# Mutt puts everything in /tmp by default.
# This gets the basic filename from the full pathname.
filename=`basename $1`
# get rid of the extenson and save the name for later.
file=`echo $filename | cut -d"." -f1`
if [ $debug = "yes" ]; then
echo "1:" $1 " 2:" $2 " 3:" $3 > $debug_file
echo "Filename:"$filename >> $debug_file
echo "File:"$file >> $debug_file
echo "===========================" >> $debug_file
fi
# if the type is empty then try to figure it out.
if [ -z $type ]; then
file $1
type=`file -bi $1 | cut -d"/" -f2`
fi
# if the type is '-' then we don't want to mess with type.
# Otherwise we are rebuilding the name. Either from the
# type that was passed in or from the type we discerned.
if [ $type = "-" ]; then
newfile=$filename
else
newfile=$file.$type
fi
newfile=$tmpdir/$newfile
# Copy the file to our new spot so mutt can't delete it
# before the app has a chance to view it.
cp $1 $newfile
if [ $debug = "yes" ]; then
echo "File:" $file "TYPE:" $type >> $debug_file
echo "Newfile:" $newfile >> $debug_file
echo "Open With:" $open_with >> $debug_file
fi
# If there's no 'open with' then we can let preview do it's thing.
# Otherwise we've been told what to use. So do an open -a.
if [ -z $open_with ]; then
open $newfile
else
open -a "$open_with" $newfile
fi

View file

@ -11,5 +11,8 @@
ansible.builtin.include_tasks: git.yml
tags: dotfiles_git
- name: Mutt
ansible.builtin.include_tasks: mutt.yml
- name: Shell utilities
ansible.builtin.include_tasks: shell_utilities.yml

View file

@ -0,0 +1,25 @@
---
- name: (mutt) Link muttrc
ansible.builtin.file:
path: ~/.muttrc
src: "{{ role_path }}/files/mutt/muttrc"
state: link
force: true
- name: (mutt) Make mutt config directory
ansible.builtin.file:
path: ~/.config/mutt
state: directory
force: true
- name: (mutt) Link mailcap
ansible.builtin.file:
path: ~/.config/mutt/mailcap
src: "{{ role_path }}/files/mutt/mailcap"
state: link
force: true
- name: (mutt) Create local state directory
ansible.builtin.file:
path: ~/.local/state/mutt
state: directory