diff options
| author | Kumar Damani <damani.kumar@gmail.com> | 2019-04-26 18:25:11 +0000 |
|---|---|---|
| committer | Kumar Damani <damani.kumar@gmail.com> | 2019-04-26 18:25:11 +0000 |
| commit | a13339e0e99118870498ecfdea22292c7e267eb2 (patch) | |
| tree | 127c8a7b88ca6b5eddc7ec567122ec129c72799a /mutt | |
dotfiles with stow structure
Diffstat (limited to 'mutt')
25 files changed, 987 insertions, 0 deletions
diff --git a/mutt/.config/mutt/.gitignore b/mutt/.config/mutt/.gitignore new file mode 100644 index 0000000..4aec69b --- /dev/null +++ b/mutt/.config/mutt/.gitignore @@ -0,0 +1,6 @@ +*.swp +*.gpg +accounts/ +*.pyc +personal.muttrc +thunderbird/ diff --git a/mutt/.config/mutt/LICENSE.md b/mutt/.config/mutt/LICENSE.md new file mode 100644 index 0000000..f49c226 --- /dev/null +++ b/mutt/.config/mutt/LICENSE.md @@ -0,0 +1,3 @@ +# License + +GPLv3. diff --git a/mutt/.config/mutt/README.md b/mutt/.config/mutt/README.md new file mode 100644 index 0000000..4938f78 --- /dev/null +++ b/mutt/.config/mutt/README.md @@ -0,0 +1,69 @@ +# Luke's mutt Wizard for automatic Neomutt and OfflineIMAP configuration! + + + +Mutt is one of the most rewarding programs one can use, but can be a pain in the ass to configure. Since my job is making power-user tools available for the masses I want to create a tool that automates most of mutt configuration so that users can simply give their email address and get a /comfy/ setup. At that, I don't just want a mutt wizard, but an offlineIMAP wizard, so users can easily access their mail offline as well, and a wizard that makes it easy to store passwords securely using gpg. + +The mutt-wizard is all of this in a simple ncurses menu. It's really just a little bash script, but one that can save countless people thousands of combined manhours of frustratingly trying to get all the moving pieces working together. + +## User interface + +The system takes an email and autodetect its server settings, generating a muttrc and offlineimaprc profile automatically. If it can't do so, it simply prompts you for these (which you can easily look up) and will put them all in the right places. You get: + ++ Automatic configuration of mutt and offlineimap. ++ Automatic encryption and safe storage of passwords which are used by mutt and offlineimap when necessary. ++ Multiple account management in mutt: jump from account to account with the `i` prefix in mutt: `i1`: first email account, `i5`: fifth, etc. ++ Easy movement to mail folders in mutt: `gi`: go to inbox, `gs` to sent mail, `ga` to archive, `gS` to spam, `gd` to drafts, etc. ++ Some default controls and colors. This system is going to be integrated into my [public auto-rice script](https://larbs.xyz) so I want it to look pretty and be usable out the box. ++ An optional autosync script that will smartly run offlineimap when connected to the internet at what interval you want and will notify you with a ding when new mail arrives. + +### Will it work on my email? (95% yes) + +Yes! At this point, the only problems are the unexpected ones. Please try it, and if you do run into problems, email me at [luke@lukesmith.xyz](mailto:luke@lukesmith.xyz)! I've tried the system personally on Gmail, Teknik.io, cock.li and Yandex, while others have tried other providers. + +One email provider which I think will *not* work (and will never work) is Proton Mail, but that's only because they require encryption through their web client IIRC. + +Note also that Gmail and some providers require you to enable sign-ins from third-party (or as they call it "less secure") applications to be able to load mail with mutt and offlineimap. Be sure to enable that! + +## Installation and Dependencies + +`dialog`, `neomutt` and `offlineimap` should be installed. You also need to have a GPG public/private key pair for the wizard to automatically store your passwords. The whole repo should be cloned to `~/.config/mutt/`. (If you have a previous mutt folder, you'll want to back it up or delete it first.) + +``` +git clone https://github.com/LukeSmithxyz/mutt-wizard.git ~/.config/mutt +``` + +You will want to delete or rename your current `~/.offlineimaprc` as well, as although you can later modify the `~/.offlineimaprc` produced by the script, you must have no file there the first time you add your first account or the wizard will assume some settings are already set which aren't. + +Just run `mutt-wizard.sh` and choose to add an account. After you do so, you may run `offlineimap` to begin the mailsync, and you will be able to run neomutt and see your mail. +If mutt doesn't immediately work properly run the `Redetect mailboxes` option, then open mutt. This may be necessary for some accounts. + +### Non-essential dependencies + +The automatically deployed configs will look for certain programs for certain extra abilities. Consider installing the following for the extra functionality. + ++ `urlview` -- Detecting and following links with `ctrl-u` ++ `mupdf` -- for viewing attached pdfs (`v` to view attachments, then select .pdf) ++ `notmuch` -- for mail searching and indexing set to `ctrl-f`. Be sure to run `notmuch setup`. Remember your mail is in `~/.mail/` when you configure notmuch. ++ `w3m` and/or `w3mimg` -- for viewing images. Like .pdfs, view in the attachments menu. ++ A cron manager if you want the autosync feature. ++ `iproute2mac` for Mac users who want the autosync feature. ++ `mpv` if you want the autosync feature to notify you with a ding on new mail. + +### "Wait? The script asks for my passwords?" + +Look at the code. The script takes the passwords you give it, encrypts them immediately with your own GPG key, and shreds the leftovers. Nothing malicious; it's all there! If it makes you comfortable you can even run the script offline at first. + +## You can help! + +If you use mutt with a particular host or domain, put your server information in `domains.csv`! This will make everyone else who uses your email provider's life much easier! + +Or you can help monetarily via [Patreon](https://patreon.com/lukesmith) or [Paypal](https://paypal.me/LukeMSmith)! + +## Notes + +Mail is stored in `~/.mail`. mutt configs and caches for each account are in `~/.config/mutt/accounts/`. Encypted passwords are in `~/.config/mutt/credentials`. A "personal" muttrc, with the macros for switching accounts and the default config is in `~/.config/mutt/personal.muttrc`. + +## Todo + +* Expand the list of server information in `domains.csv`, possibly porting the Thunderbird autoconfigure settings. diff --git a/mutt/.config/mutt/autoconf/domains.csv b/mutt/.config/mutt/autoconf/domains.csv new file mode 100644 index 0000000..ac89878 --- /dev/null +++ b/mutt/.config/mutt/autoconf/domains.csv @@ -0,0 +1,122 @@ +ADDRESS,IMAP,imap port,SMTP,smtp port +420blaze.it,mail.cock.li,993,mail.cock.li,587 +8chan.co,mail.cock.li,993,mail.cock.li,587 +aaathats3as.com,mail.cock.li,993,mail.cock.li,587 +accountant.com,imap.mail.com,995,smtp.mail.com,587 +accountant.com,imap.mail.com,995,smtp.mail.com,587 +activist.com,imap.mail.com,995,smtp.mail.com,587 +adexec.com,imap.mail.com,995,smtp.mail.com,587 +airmail.cc,mail.cock.li,993,mail.cock.li,587 +allergist.com,imap.mail.com,995,smtp.mail.com,587 +alumni.com,imap.mail.com,995,smtp.mail.com,587 +alumnidirector.com,imap.mail.com,995,smtp.mail.com,587 +angelic.com,imap.mail.com,995,smtp.mail.com,587 +aol.com,imap.aol.com,993,smtp.aol.com,465 +appraiser.net,imap.mail.com,995,smtp.mail.com,587 +archaeologist.com,imap.mail.com,995,smtp.mail.com,587 +arcticmail.com,imap.mail.com,995,smtp.mail.com,587 +artlover.com,imap.mail.com,995,smtp.mail.com,587 +asia.com,imap.mail.com,995,smtp.mail.com,587 +asia.com,imap.mail.com,995,smtp.mail.com,587 +auctioneer.net,imap.mail.com,995,smtp.mail.com,587 +bartender.net,imap.mail.com,995,smtp.mail.com,587 +bguth.de,wp300.webpack.hosteurope.de,993,wp300.webpack.hosteurope.de,587 +bikerider.com,imap.mail.com,995,smtp.mail.com,587 +billycarlyle.uk,mail.muny.us,993,mail.muny.us,465 +birdlover.com,imap.mail.com,995,smtp.mail.com,587 +bjoernguthphotography.de,wp300.webpack.hosteurope.de,993,wp300.webpack.hosteurope.de,587 +brew-meister.com,imap.mail.com,995,smtp.mail.com,587 +cash4u.com,imap.mail.com,995,smtp.mail.com,587 +cheerful.com,imap.mail.com,995,smtp.mail.com,587 +chef.net,imap.mail.com,995,smtp.mail.com,587 +chemist.com,imap.mail.com,995,smtp.mail.com,587 +clerk.com,imap.mail.com,995,smtp.mail.com,587 +clubmember.org,imap.mail.com,995,smtp.mail.com,587 +cocaine.ninja,mail.cock.li,993,mail.cock.li,587 +cock.email,mail.cock.li,993,mail.cock.li,587 +cock.li,mail.cock.li,993,mail.cock.li,587 +cock.lu,mail.cock.li,993,mail.cock.li,587 +collector.org,imap.mail.com,995,smtp.mail.com,587 +columnist.com,imap.mail.com,995,smtp.mail.com,587 +comic.com,imap.mail.com,995,smtp.mail.com,587 +computer4u.com,imap.mail.com,995,smtp.mail.com,587 +consultant.com,imap.mail.com,995,smtp.mail.com,587 +consultant.com,imap.mail.com,995,smtp.mail.com,587 +contractor.net,imap.mail.com,995,smtp.mail.com,587 +contractor.net,imap.mail.com,995,smtp.mail.com,587 +coolsite.net,imap.mail.com,995,smtp.mail.com,587 +counsellor.com,imap.mail.com,995,smtp.mail.com,587 +cumallover.me,mail.cock.li,993,mail.cock.li,587 +cyberservices.com,imap.mail.com,995,smtp.mail.com,587 +deliveryman.com,imap.mail.com,995,smtp.mail.com,587 +dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 +dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 +diplomats.com,imap.mail.com,995,smtp.mail.com,587 +disroot.org,disroot.org,993,disroot.org,587 +dr.com,imap.mail.com,995,smtp.mail.com,587 +email.arizona.edu,mail.catnet.arizona.edu,993,smtpgate.email.arizona.edu,587 +email.com,imap.mail.com,995,smtp.mail.com,587 +engineer.com,imap.mail.com,995,smtp.mail.com,587 +europe.com,imap.mail.com,995,smtp.mail.com,587 +fastmail.com,imap.fastmail.com,993,smtp.fastmail.com,465 +firemail.cc,mail.cock.li,993,mail.cock.li,587 +fsmpi.rwth-aachen.de,mail.fsmpi.rwth-aachen.de,993,mail.fsmpi.rwth-aachen.de,465 +getbackinthe.kitchen,mail.cock.li,993,mail.cock.li,587 +gmail.com,imap.google.com,993,smtp.gmail.com,587 +gmx.com,imap.gmx.net,993,mail.gmx.net,587 +gmx.de,imap.gmx.net,993,mail.gmx.net,587 +gmx.eu,imap.gmx.net,993,mail.gmx.net,587 +gmx.info,imap.gmx.net,993,mail.gmx.net,587 +gmx.net,imap.gmx.net,993,mail.gmx.net,587 +gmx.org,imap.gmx.net,993,mail.gmx.net,587 +goat.si,mail.cock.li,993,mail.cock.li,587 +googlemail.com,imap.googlemail.com,993,smtp.googlemail.com,587 +hitler.rocks,mail.cock.li,993,mail.cock.li,587 +horsefucker.org,mail.cock.li,993,mail.cock.li,587 +hostgator,gator4171.hostgator.com,993,gator4171.hostgator.com,587 +hotmail.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 +iname.com,imap.mail.com,995,smtp.mail.com,587 +linuxmail.org,imap.mail.com,995,smtp.mail.com,587 +live.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 +loves.dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 +loves.dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 +lukesmith.xyz,mail.privateemail.com,993,mail.privateemail.com,587 +mail.com,imap.mail.com,995,smtp.mail.com,587 +mailbox.org,imap.mailbox.org,993,smtp.mailbox.org,465 +memeware.net,mail.cock.li,993,mail.cock.li,587 +msn.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 +muny.us,mail.muny.us,993,mail.muny.us,465 +myself.com,imap.mail.com,995,smtp.mail.com,587 +narod.ru,imap.yandex.com,993,smtp.yandex.com,465 +national.shitposting.agency,mail.cock.li,993,mail.cock.li,587 +nigge.rs,mail.cock.li,993,mail.cock.li,587 +nuke.africa,mail.cock.li,993,mail.cock.li,587 +outlook.com,imap-mail.outlook.com,993,smtp-mail.outlook.com,587 +post.com,imap.mail.com,995,smtp.mail.com,587 +posteo.de,posteo.de,993,posteo.de,587 +rape.lol,mail.cock.li,993,mail.cock.li,587 +redchan.it,mail.cock.li,993,mail.cock.li,587 +runbox.com,mail.runbox.com,993,mail.runbox.com,587 +rwth-aachen.de,mail.rwth-aachen.de,993,mail.rwth-aachen.de,587 +sapo.pt,imap.sapo.pt,993,smtp.sapo.pt,587 +techie.com,imap.mail.com,995,smtp.mail.com,587 +teknik.io,mail.teknik.io,993,mail.teknik.io,587 +tfwno.gf,mail.cock.li,993,mail.cock.li,587 +tu-harburg.de,mail.tu-harburg.de,993,mail.tu-harburg.de,587 +tuhh.de,mail.tu-harburg.de,993,mail.tu-harburg.de,587 +usa.com,imap.mail.com,995,smtp.mail.com,587 +uymail.com,imap.mail.com,995,smtp.mail.com,587 +waifu.club,mail.cock.li,993,mail.cock.li,587 +wants.dicksinhisan.us,mail.cock.li,993,mail.cock.li,587 +wants.dicksinmyan.us,mail.cock.li,993,mail.cock.li,587 +writeme.com,imap.mail.com,995,smtp.mail.com,587 +ya.ru,imap.yandex.com,993,smtp.yandex.com,465 +yahoo.com,imap.mail.yahoo.com,993,smtp.mail.yahoo.com,587 +yandex.by,imap.yandex.com,993,smtp.yandex.com,465 +yandex.com,imap.yandex.com,993,smtp.yandex.com,465 +yandex.com,imap.yandex.com,993,smtp.yandex.com,465 +yandex.kz,imap.yandex.com,993,smtp.yandex.com,465 +yandex.net,imap.yandex.com,993,smtp.yandex.com,465 +yandex.ru,imap.yandex.com,993,smtp.yandex.com,465 +yandex.ua,imap.yandex.com,993,smtp.yandex.com,465 +zoho.com,imap.zoho.com,993,smtp.zoho.com,465 diff --git a/mutt/.config/mutt/autoconf/makedefault.sh b/mutt/.config/mutt/autoconf/makedefault.sh new file mode 100644 index 0000000..e8b1536 --- /dev/null +++ b/mutt/.config/mutt/autoconf/makedefault.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Give this script the abstract name of an account and it will make it the default. + +title=$1 +muttdir="$HOME/.config/mutt/" +muttdirsed=$(echo $muttdir | sed -e 's/\//\\\//g') + +grep "$muttdir"personal.muttrc -e "^source .*accounts.*" >/dev/null && \ + sed -i "s/^source .*accounts.*/source ${muttdirsed}accounts\/$title.muttrc/g" "$muttdir"personal.muttrc diff --git a/mutt/.config/mutt/autoconf/mutt_profile b/mutt/.config/mutt/autoconf/mutt_profile new file mode 100644 index 0000000..b34b5f9 --- /dev/null +++ b/mutt/.config/mutt/autoconf/mutt_profile @@ -0,0 +1,20 @@ +# vim: filetype=neomuttrc +# muttrc file for account $title +set realname = "$realname" +set from = "$fulladdr" +set smtp_url = "smtp://$login@$smtp:$sport/" +set sendmail = "/usr/bin/msmtp -a $title" +set folder = "~/.mail/$title" +set header_cache = ~/.config/mutt/accounts/$title/cache/headers +set message_cachedir = ~/.config/mutt/accounts/$title/cache/bodies +set certificate_file = ~/.config/mutt/accounts/$title/certificates +source "~/.config/mutt/credentials/getmuttpass $title |" + +set mbox_type = Maildir +set ssl_starttls = yes +set ssl_force_tls = yes + +bind index,pager gg noop +bind index,pager g noop +bind index gg first-entry +unmailboxes * diff --git a/mutt/.config/mutt/autoconf/offlineimap_header b/mutt/.config/mutt/autoconf/offlineimap_header new file mode 100644 index 0000000..786f04b --- /dev/null +++ b/mutt/.config/mutt/autoconf/offlineimap_header @@ -0,0 +1,6 @@ +[general] +accounts = +starttls = yes +ssl = yes +pythonfile = ~/.config/mutt/credentials/imappwd.py + diff --git a/mutt/.config/mutt/autoconf/offlineimap_header.macos b/mutt/.config/mutt/autoconf/offlineimap_header.macos new file mode 100644 index 0000000..86d5678 --- /dev/null +++ b/mutt/.config/mutt/autoconf/offlineimap_header.macos @@ -0,0 +1,6 @@ +[general] +accounts = +starttls = yes +ssl = true +pythonfile = ~/.config/mutt/credentials/imappwd.py + diff --git a/mutt/.config/mutt/autoconf/offlineimap_profile b/mutt/.config/mutt/autoconf/offlineimap_profile new file mode 100644 index 0000000..2277d6b --- /dev/null +++ b/mutt/.config/mutt/autoconf/offlineimap_profile @@ -0,0 +1,18 @@ +[Account $title] + +localrepository = $title-local +remoterepository = $title-remote + +[Repository $title-remote] +auth_mechanisms = LOGIN +type = $type +remoteuser = $login +remotepasseval = mailpasswd("$title") +remotehost = $imap +remoteport = $iport +folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt + +[Repository $title-local] +type = Maildir +localfolders = ~/.mail/$title diff --git a/mutt/.config/mutt/autoconf/offlineimap_profile.macos b/mutt/.config/mutt/autoconf/offlineimap_profile.macos new file mode 100644 index 0000000..e985538 --- /dev/null +++ b/mutt/.config/mutt/autoconf/offlineimap_profile.macos @@ -0,0 +1,19 @@ +[Account $title] + +localrepository = $title-local +remoterepository = $title-remote + +[Repository $title-remote] +auth_mechanisms = LOGIN +type = $type +remoteuser = $login +sslcacertfile = /usr/local/etc/openssl/cert.pem +remotepasseval = mailpasswd("$title") +remotehost = $imap +remoteport = $iport +folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail'] +sslcacertfile = /usr/local/etc/openssl/cert.pem + +[Repository $title-local] +type = Maildir +localfolders = ~/.mail/$title diff --git a/mutt/.config/mutt/autoconf/services.csv b/mutt/.config/mutt/autoconf/services.csv new file mode 100644 index 0000000..152be38 --- /dev/null +++ b/mutt/.config/mutt/autoconf/services.csv @@ -0,0 +1,9 @@ +SERVICE,IMAP,imap port,SMTP,smtp port,spoolfile,postponed,record +"Zoho",imap.zoho.com,993,smtp.zoho.com,465,,, +"iCloud",imap.mail.me.com,993,smtp.mail.me.com,587,,, +"Inbox.com",imap.inbox.com,993,smtp.inbox.com,465,,, +"Office 365",outlook.office365.com,993,smtp.office365.com,587,INBOX,Drafts,Sent Items +"Host Gator",gator4171.hostgator.com,993,gator4171.hostgator.com,587,INBOX,INBOX.Drafts,INBOX.Sent +"GoDaddy",imap.secureserver.net,993,smtpout.secureserver.net,465,,, +"Yandex",imap.yandex.com,993.00,smtp.yandex.com,465.00,,, +"Muny Mail",mail.muny.us,993,mail.muny.us,465,,, diff --git a/mutt/.config/mutt/credentials/getmuttpass b/mutt/.config/mutt/credentials/getmuttpass new file mode 100644 index 0000000..ee25584 --- /dev/null +++ b/mutt/.config/mutt/credentials/getmuttpass @@ -0,0 +1,5 @@ +#!/bin/bash +pass=$(gpg2 --decrypt --quiet ~/.config/mutt/credentials/$1.gpg) +pass=$(printf '%q' $pass) +echo set smtp_pass=\"$pass\" +echo set imap_pass=\"$pass\" diff --git a/mutt/.config/mutt/credentials/imappwd.py b/mutt/.config/mutt/credentials/imappwd.py new file mode 100644 index 0000000..0a74804 --- /dev/null +++ b/mutt/.config/mutt/credentials/imappwd.py @@ -0,0 +1,11 @@ +import os.path +import subprocess +home = os.path.expanduser("~") +def mailpasswd(acct): + acct = os.path.basename(acct) + path = "%s/.config/mutt/credentials/%s.gpg" % (home,acct) + args = ["gpg2", "--use-agent", "--quiet", "--batch", "-d", path] + try: + return subprocess.check_output(args).strip() + except subprocess.CalledProcessError: + return "" diff --git a/mutt/.config/mutt/etc/aliases b/mutt/.config/mutt/etc/aliases new file mode 100644 index 0000000..d48d897 --- /dev/null +++ b/mutt/.config/mutt/etc/aliases @@ -0,0 +1,13 @@ +# vim: filetype=neomuttrc +# A file for aliases + +alias me_personal kumarcanada96@gmail.com +alias me_official damani.kumar@gmail.com +alias me_school kumar.damani@mail.utoronto.ca + +alias mike_personal mdamani@shaw.ca +alias mike_official mike@flightexpress.net +alias kj_personal kavita_d@hotmail.com +alias kj_official kavita@paylesstravelonline.com + + diff --git a/mutt/.config/mutt/etc/email.gif b/mutt/.config/mutt/etc/email.gif Binary files differnew file mode 100644 index 0000000..1ed63cf --- /dev/null +++ b/mutt/.config/mutt/etc/email.gif diff --git a/mutt/.config/mutt/etc/mailcap b/mutt/.config/mutt/etc/mailcap new file mode 100644 index 0000000..1e9a613 --- /dev/null +++ b/mutt/.config/mutt/etc/mailcap @@ -0,0 +1,13 @@ +#text/html; qutebrowser %s &; test=test -n "$DISPLAY"; needsterminal; + +#text/html; $BROWSER %s 2>/dev/null & disown; copiousoutput; +text/html; w3m -I %{charset} -T text/html; copiousoutput; + +application/pdf; mv %s %s.pdf && i3 exec mupdf %s.pdf > /dev/null; needsterminal; + +image/*; ~/.config/mutt/etc/muttimage.sh %s ; copiousoutput + +#application/pdf; pdftotext '%s' -; copiousoutput; description=PDF Document; +#nametemplate=%s.pdf +# +text/plain; vim %s ; diff --git a/mutt/.config/mutt/etc/mailsync.sh b/mutt/.config/mutt/etc/mailsync.sh new file mode 100644 index 0000000..2ac78d9 --- /dev/null +++ b/mutt/.config/mutt/etc/mailsync.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# This script will run offlineimap and check +# for new email if there is an internet connection. +# +# If it detects new mail, it uses mpv to play a +# notification sound: notify.opus +# +# I have this run as a cronjob every 5 minutes. + +export DISPLAY=:0.0 + +# Checks for internet connection and set notification script. +# Settings are different for MacOS (Darwin) systems. +if [ "$(uname)" == "Darwin" ] +then + ping -q -t 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit + notify() { osascript -e "display notification \"$2 in $1\" with title \"Youve got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} +else + ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` >/dev/null || exit + notify() { pgrep -x dunst && notify-send -i ~/.config/mutt/etc/email.gif "$2 new mail(s) in \`$1\` account." ;} +fi + +# Run offlineimap. You can feed this script different settings. +offlineimap -o "$@" + +# Check all accounts/mailboxes for new mail. Notify if there is new content. +for account in $(ls ~/.mail) +do + #List unread messages newer than last mailsync and count them + newcount=$(find ~/.mail/$account/INBOX/new/ -type f -newer ~/.config/mutt/etc/mailsynclastrun 2> /dev/null | wc -l) + if [ "$newcount" -gt "0" ] + then + notify "$account" "$newcount" & disown + mpv --quiet ~/.config/mutt/etc/notify.opus + pkill -RTMIN+12 i3blocks # For my i3blocks setup. Updates new mail counter. + fi +done + +#Create a touch file that indicates the time of the last run of mailsync +touch ~/.config/mutt/etc/mailsynclastrun diff --git a/mutt/.config/mutt/etc/muttcol b/mutt/.config/mutt/etc/muttcol new file mode 100644 index 0000000..8524157 --- /dev/null +++ b/mutt/.config/mutt/etc/muttcol @@ -0,0 +1,71 @@ +# vim: filetype=neomuttrc + +# Default index colors: +color index yellow default '.*' +color index_author red default '.*' +color index_number blue default +color index_subject cyan default '.*' + +# For new mail: +color index brightyellow black "~N" +color index_author brightred black "~N" +color index_subject brightcyan black "~N" + +# Header colors: +color header blue default ".*" +color header brightmagenta default "^(From)" +color header brightcyan default "^(Subject)" +color header brightwhite default "^(CC|BCC)" + +mono bold bold +mono underline underline +mono indicator reverse +mono error bold +color normal default default +color indicator brightblack white +color sidebar_highlight red default +color sidebar_divider color8 black +color sidebar_flagged red black +color sidebar_new green black +color normal brightyellow default +color error red default +color tilde black default +color message cyan default +color markers red white +color attachment white default +color search brightmagenta default +color status brightyellow black +color hdrdefault brightgreen default +color quoted green default +color quoted1 blue default +color quoted2 cyan default +color quoted3 yellow default +color quoted4 red default +color quoted5 brightred default +color signature brightgreen default +color bold black default +color underline black default +color normal default default + +color body brightred default "[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+" # Email addresses +color body brightblue default "(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+" # URL +color body green default "\`[^\`]*\`" # Green text between ` and ` +color body brightblue default "^# \.*" # Headings as bold blue +color body brightcyan default "^## \.*" # Subheadings as bold cyan +color body brightgreen default "^### \.*" # Subsubheadings as bold green +color body yellow default "^(\t| )*(-|\\*) \.*" # List items as yellow +color body brightcyan default "[;:][-o][)/(|]" # emoticons +color body brightcyan default "[;:][)(|]" # emoticons +color body brightcyan default "[*]?((N)?ACK|CU|LOL|SCNR|BRB|BTW|CWYL|\ + |FWIW|vbg|GD&R|HTH|HTHBE|IMHO|IMNSHO|\ + |IRL|RTFM|ROTFL|ROFL|YMMV)[*]?" +color body brightcyan default "[ ][*][^*]*[*][ ]?" # more emoticon? +color body brightcyan default "[ ]?[*][^*]*[*][ ]" # more emoticon? +color body red default "(BAD signature)" +color body cyan default "(Good signature)" +color body brightblack default "^gpg: Good signature .*" +color body brightyellow default "^gpg: " +color body brightyellow red "^gpg: BAD signature from.*" +mono body bold "^gpg: Good signature" +mono body bold "^gpg: BAD signature from.*" +color body red default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]" diff --git a/mutt/.config/mutt/etc/muttimage.sh b/mutt/.config/mutt/etc/muttimage.sh new file mode 100644 index 0000000..b67de83 --- /dev/null +++ b/mutt/.config/mutt/etc/muttimage.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +#### Determine size of Terminal +height=`stty size | awk 'BEGIN {FS = " "} {print $1;}'` +width=`stty size | awk 'BEGIN {FS = " "} {print $2;}'` + +### Display Image / offset with mutt bar +echo -e "2;3;\n0;1;210;20;$((width*7-250));$((height*14-100));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay & diff --git a/mutt/.config/mutt/etc/mw.png b/mutt/.config/mutt/etc/mw.png Binary files differnew file mode 100644 index 0000000..dd15ce8 --- /dev/null +++ b/mutt/.config/mutt/etc/mw.png diff --git a/mutt/.config/mutt/etc/notify.opus b/mutt/.config/mutt/etc/notify.opus Binary files differnew file mode 100644 index 0000000..a76ce32 --- /dev/null +++ b/mutt/.config/mutt/etc/notify.opus diff --git a/mutt/.config/mutt/etc/view_attachment.sh b/mutt/.config/mutt/etc/view_attachment.sh new file mode 100644 index 0000000..df8b9a1 --- /dev/null +++ b/mutt/.config/mutt/etc/view_attachment.sh @@ -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 diff --git a/mutt/.config/mutt/mutt-wizard.sh b/mutt/.config/mutt/mutt-wizard.sh new file mode 100755 index 0000000..23ae7ab --- /dev/null +++ b/mutt/.config/mutt/mutt-wizard.sh @@ -0,0 +1,264 @@ +#!/usr/bin/env bash + +if [[ "$(uname)" == "Darwin" ]] +then + os=".macos" +else + os="" +fi + +muttdir="$HOME/.config/mutt/" + +createMailboxes() { \ + tmpdir=$(mktemp -d) + offlineimap --info -a $1 2&> "$tmpdir"/log + sed -n '/^Folderlist/,/^Folderlist/p' "$tmpdir"/log | + grep "^ " | sed -e "s/\//./g;s/(.*//g;s/^ //g" > "$tmpdir"/lognew + while read box; do mkdir -p "$HOME/.mail/$1/$box"; done <"$tmpdir"/lognew ;} + +chooseSync() { (cat /var/run/crond.pid && testSync) || dialog --msgbox "No cronjob manager detected. Please install one and return to enable automatic mailsyncing" 10 60 ;} +testSync() { (crontab -l | grep .config/mutt/etc/mailsync && removeSync) || addSync ;} + +addSync() { min=$(dialog --inputbox "How many minutes should be between mail syncs?" 8 60 3>&1 1>&2 2>&3 3>&-) + (crontab -l; echo "*/$min * * * * $HOME/.config/mutt/etc/mailsync.sh") | crontab - && + dialog --msgbox "Cronjob successfully added. Remember you may need to restart or tell systemd/etc. to start your cron manager for this to take effect." 7 60 ;} + +removeSync() { ((crontab -l | sed -e '/.config\/mutt\/etc\/mailsync/d') | crontab - >/dev/null) && dialog --msgbox "Cronjob successfully removed. To reactivate, select this option again." 6 60 ;} + +changePassword() { \ + gpgemail=$( dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your GPG key pair. This is NOT necessarily the email you want to configure." 10 60 3>&1 1>&2 2>&3 3>&- ) + dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the new password for the \"$1\" account." 10 60 2> /tmp/$1 + gpg2 -r $gpgemail --encrypt /tmp/$1 || (dialog --title "GPG decryption failed." --msgbox "GPG decryption failed. This is either because you do not have a GPG key pair or because your distro uses GPG1 and you thus need to symlink /usr/bin/gpg2 to /usr/bin/gpg." 7 60 && break) + shred -u /tmp/$1 + mv /tmp/$1.gpg ~/.config/mutt/credentials/ + dialog --title "Finalizing your account." --infobox "The account \"$title\"'s password has been changed. Now attempting to configure mail directories... + + This may take several seconds..." 10 70 + createMailboxes $title || (clear && exit) + detectMailboxes $title + dialog --title "Password changed." --msgbox "Your "$fulladdr" password has been changed. To start the download of your mail, you can manually run \`offlineimap -a $title\` in a terminal. The first sync may take some time depending on the amount of your mail." 8 60 ;} + +chooseDetect() { for x in $(cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;'); do detectMailboxes $x; done && detectSuccess ;} + +detectWarning() { \ + dialog --title "Mailbox detect requirement" --yesno "In order for the mailbox detection system to work, you must have + +1) already have added the email account with this wizard, and +2) already have run offlineimap at least once to synchronize your mail. + +This detection system only works if you already have begun your first sync. If you have, press 'yes' to continue." 12 70 ;} + +detectSuccess() { dialog --title "Mailbox detect complete." --msgbox "The script has now smartly detected your different mailboxes and has enabled them in the sidebar and given you keyboard shortcuts as below: + +gi for move to the Inbox. +gs for move to Sent Mail. +gd for move to Drafts +gS for move to Spam +ga for move to the Archive. +gj for move to Junk +gt for move to Trash + +These shortcuts will only work if your email system does have that particular folder (i.e. if your email system has a Junk folder, but not a Trash folder, 'gt' will not work, etc." 20 60 ;} + +formatShortcut() { \ + while read data; do + echo "macro index,pager g$1 \"<change-folder>$data<enter>\" \"Go to $2.\"" >> "$muttdir"accounts/$3.muttrc + done ;} + +gen_delim() { \ + delim="=" + for i in `seq $(( $1 - 1 ))` + do + delim="$delim-" + done + echo $delim ;} + +detectMailboxes() { \ + find ~/.mail/$1 -maxdepth 1 -mindepth 1 -type d | sed -e "s/.*\///g;s/^/=/g" > /tmp/$1_boxes + sidebar_width=$(sed -n -e '/^set sidebar_width/p' "$muttdir"/muttrc | awk -F'=' '{print $2}') + delim=$(gen_delim $sidebar_width) + oneline=$(cat /tmp/$1_boxes | sed -e "s/^\|$/\"/g" | tr "\n" " ") + oneline="=$1 $delim $oneline" + sed -i "/^mailboxes\|^set spoolfile\|^set record\|^set postponed/d" "$muttdir"accounts/$1.muttrc + echo mailboxes $oneline >> "$muttdir"accounts/$1.muttrc + sed -i "/^macro index,pager g/d" "$muttdir"accounts/$1.muttrc + grep -vi /tmp/$1_boxes -e "trash\|drafts\|sent\|trash\|spam\|junk\|archive\|chat\|old\|new\|gmail\|sms\|call" | sort -n | sed 1q | formatShortcut i inbox $1 + grep -i /tmp/$1_boxes -e sent | sed 1q | formatShortcut s sent $1 + grep -i /tmp/$1_boxes -e draft | sed 1q | formatShortcut d drafts $1 + grep -i /tmp/$1_boxes -e trash | sed 1q | formatShortcut t trash $1 + grep -i /tmp/$1_boxes -e spam | sed 1q | formatShortcut S spam $1 + grep -i /tmp/$1_boxes -e archive | sed 1q | formatShortcut a archive $1 + spoolfile=$(grep -vi /tmp/$1_boxes -e "trash\|drafts\|sent\|trash\|spam\|ham\|junk\|archive\|chat\|old\|new\|gmail\|sms\|call" | sort -n | sed 1q | sed -e 's/=/+/g') + record=$(grep -i /tmp/$1_boxes -e sent | sed -e 's/=/+/g' | sed 1q) + postponed=$(grep -i /tmp/$1_boxes -e draft | sed -e 's/=/+/g' | sed 1q) + trash=$(grep -i /tmp/$1_boxes -e trash | sed -e 's/=/+/g' | sed 1q) + echo "set spoolfile = \"$spoolfile\"" >> "$muttdir"accounts/$1.muttrc + echo "set record = \"$record\"" >> "$muttdir"accounts/$1.muttrc + echo "set postponed = \"$postponed\"" >> "$muttdir"accounts/$1.muttrc + echo "set trash = \"$trash\"" >> "$muttdir"accounts/$1.muttrc ;} + +# Get all accounts in ~/.offlineimaprc and load into variable `accounts`. +getAccounts() { \ + cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' | nl --number-format=ln > /tmp/numbered + accounts=() + while read n s ; do + accounts+=($n "$s" off) + done < /tmp/numbered ;} + +# Yields a menu of available accounts. +inventory() { \ + getAccounts + choices=$(dialog --separate-output --checklist "Select all desired email accounts with <SPACE>." 15 40 16 "${accounts[@]}" 2>&1 >/dev/tty) + + if [ -z "$choices" ]; + then + clear + else + userchoices=$(IFS="|"; keys="${choices[*]}"; keys="${keys//|/\\|}"; grep -w "${keys}" /tmp/numbered | awk '{print $2}') + fi ;} + + +removeAccount() { sed -ie " + /Account $1]/,/Account/{//!d} + /Account $1]/d + s/ $1\(,\|$\)//g + s/=$1\(,\|$\)/=/g + s/,$//g + " ~/.offlineimaprc + rm "$muttdir"accounts/$1.muttrc + rm "$muttdir"credentials/$1.gpg + rm -rf "$muttdir"accounts/$1 + sed -i "/$1.muttrc/d" "$muttdir"personal.muttrc ;} + +manual() { \ + imap=$( dialog --inputbox "Insert the IMAP server for your email provider (excluding the port number)" 10 60 3>&1 1>&2 2>&3 3>&- ) + iport=$(dialog --inputbox "What is your server's IMAP port number? (Usually 993)" 10 60 3>&1 1>&2 2>&3 3>&-) + smtp=$( dialog --inputbox "Insert the SMTP server for your email provider (excluding the port number)" 10 60 3>&1 1>&2 2>&3 3>&- ) + sport=$( dialog --inputbox "What is your server's SMTP port number? (Usually 587 or 465)" 10 60 3>&1 1>&2 2>&3 3>&- ) ;} + + +addloop() { fulladdr=$( dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Insert the full email address for the account you want to configure." 10 60 3>&1 1>&2 2>&3 3>&- ) +# Check to see if domain is in domain list +serverinfo=$(cat "$muttdir"autoconf/domains.csv | grep -w ^${fulladdr##*@}) +if [ -z "$serverinfo" ]; + then + manual + else +# Read in server data as variables +IFS=, read service imap iport smtp sport <<EOF +$serverinfo +EOF +fi +realname=$( dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Enter the full name you'd like to be identified by on this email account." 10 60 3>&1 1>&2 2>&3 3>&- ) +title=$( dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Give a short, one-word name for this email account that will differentiate it from other email accounts." 10 60 3>&1 1>&2 2>&3 3>&- ) +login=$(dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "If you have a username for the \"$title\" account which is different from your email address, enter it here. Otherwise leave this prompt blank." 10 60 3>&1 1>&2 2>&3 3>&- ) +# Sets the repo type and other variables for the sed regex. +if [[ "$service" == "gmail.com" ]]; + then + type="Gmail" + delet="remotehost" + else + type="IMAP" + delet="Gmail]\/" +fi +if [[ -z "$login" ]]; + then + login=$fulladdr +fi +# The replacements +replacement=" + s/\$realname/$realname/g; + s/\$title/$title/g; + s/\$fulladdr/$fulladdr/g; + s/\$imap/$imap/g; + s/\$iport/$iport/g; + s/\$smtp/$smtp/g; + s/\$sport/$sport/g; + s/\$type/$type/g; + s/\$login/$login/g; + /$delet/d" +# Gets the first unused shortcut number in the muttrc and puts it in $idnum. +cat "$muttdir"personal.muttrc | grep i[0-9] | awk '{print $3}' | sed -e 's/i//g' > /tmp/mutt_used +echo -e "1\n2\n3\n4\n5\n6\n7\n8\n9" > /tmp/mutt_all_possible +idnum=$(diff /tmp/mutt_all_possible /tmp/mutt_used | sed -n 2p | awk '{print $2}') +addAccount \ +;} + +addAccount() { + # First, adding the encrypted password. + dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the password for the \"$title\" account." 10 60 2> /tmp/$title + gpg2 -r $gpgemail --encrypt /tmp/$title || (dialog --title "GPG decryption failed." --msgbox "GPG decryption failed. This is either because you do not have a GPG key pair or because your distro uses GPG1 and you thus need to symlink /usr/bin/gpg2 to /usr/bin/gpg." 7 60 && break) + shred -u /tmp/$title + mv /tmp/$title.gpg ~/.config/mutt/credentials/ + + # Adding directory structure for cache. + mkdir -p "$muttdir"accounts/$title/cache/bodies + + # Creating the offlineimaprc if it doesn't exist already. + if [ ! -f ~/.offlineimaprc ]; then cp "$muttdir"autoconf/offlineimap_header"$os" ~/.offlineimaprc; fi + cat "$muttdir"autoconf/offlineimap_profile"$os" | sed -e "$replacement" >> ~/.offlineimaprc + mkdir -p ~/.mail/$title + + # Add the mutt profile. + cat "$muttdir"autoconf/mutt_profile | sed -e "$replacement" > "$muttdir"accounts/$title.muttrc + # Add a numbered shortcut in the muttrc + echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source "$muttdir"accounts/$title.muttrc<enter><change-folder>!<enter>'" >> "$muttdir"personal.muttrc + + # Add to offlineimaprc sync list. + sed -i.bu "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =\s*$/accounts = $title/g" ~/.offlineimaprc && rm ~/.offlineimaprc.bu + + # Makes account default if there is no default account. + grep "$muttdir"personal.muttrc -e "^source .*accounts.*" >/dev/null && echo there || \ + echo "source ${muttdir}accounts/$title.muttrc" >> "$muttdir"personal.muttrc + + dialog --title "Finalizing your account." --infobox "The account \"$title\" has been added. Now attempting to configure mail directories... + + This may take several seconds..." 10 70 + createMailboxes $title || (clear && exit) + detectMailboxes $title + dialog --title "Account added." --msgbox "Your "$fulladdr" account has been added. To start the download of your mail, you can manually run \`offlineimap -a $title\` in a terminal. The first sync may take some time depending on the amount of your mail." 8 60 ;} + +# This is run when a user chooses to add an account. +chooseAdd() { \ + mkdir -p "$muttdir"credentials/ "$muttdir"accounts/ + gpgemail=$( dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your GPG key pair. This is NOT necessarily the email you want to configure." 10 60 3>&1 1>&2 2>&3 3>&- ) + addloop + while : ; + do + dialog --title "Luke's mutt/offlineIMAP password wizard" --yesno "Would you like to add another email account?" 5 60 || break + addloop + done ;} + +wipe () { rm $HOME/.offlineimaprc + rm -rf "$muttdir"/accounts + rm -f "$muttdir"credentials/*gpg + rm "$muttdir"personal.muttrc ;} + +while : ; + do +choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" --nocancel \ + --menu "What would you like to do?" 15 45 8 \ + 0 "List all email accounts configured." \ + 1 "Add an email account." \ + 2 "Enable/disable autosync." \ + 3 "Redetect mailboxes." \ + 4 "Change an account's password." \ + 5 "Remove an email account." \ + 6 "Remove all email accounts." \ + 7 "Exit this wizard." \ + 3>&1 1>&2 2>&3 3>&1 ) + +case $choice in +0) dialog --title "Accounts detected" --msgbox "The following accounts have been detected: +$(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g') +" 6 60;; +1) chooseAdd;; +2) chooseSync;; +3) detectWarning && chooseDetect;; +4) inventory && for i in $userchoices; do changePassword $i ; done;; +5) inventory && for i in $userchoices; do removeAccount $i ; done;; +6) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;; +7) clear && break ;; +*) echo "Unable to read response from dialog. Exiting." >&2; exit 2 +esac +done diff --git a/mutt/.config/mutt/muttrc b/mutt/.config/mutt/muttrc new file mode 100644 index 0000000..cf647ef --- /dev/null +++ b/mutt/.config/mutt/muttrc @@ -0,0 +1,85 @@ +# vim: filetype=neomuttrc +# This is the general mutt config which has the settings that all accounts use. +bind index,pager i noop +bind index,pager g noop +bind index \Cf noop +source etc/muttcol +source etc/aliases +set sleep_time = 0 +set sort = 'reverse-date' +set editor = $EDITOR +#set copy = no +set timeout = "5" +set mail_check = "10" +set mailcap_path = ~/.config/mutt/etc/mailcap +set date_format="%m/%d %I:%M" +set index_format="%2C %Z %?X?A& ? %D %-15.15F %s (%-4.4c)" +set markers = no +set mark_old = no +set mime_forward = yes +set smtp_authenticators = 'gssapi:login' +auto_view text/html +auto_view application/pdf +alternative_order text/plain text/enriched text/html +set rfc2047_parameters = yes + +# General remappings +bind editor <space> noop +bind index G last-entry +bind index gg first-entry +bind pager j next-line +bind pager k previous-line +bind pager gg top +bind pager G bottom +bind index d half-down +bind index u half-up +bind index D delete-message +bind index U undelete-message +bind index F search +bind index,pager R group-reply +macro index,pager S '<sync-mailbox> +macro index,pager \Cu |urlscan\n + +# View attachments properly. +bind attach <return> view-mailcap +set fast_reply # skip to compose when replying +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 forward_quote # include message in forwards +set reverse_name # reply as whomever it was to +set include # include message in replies + +#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" + +#sync email +macro index O "<shell-escape>offlineimap<enter>" "run offlineimap to sync all mail" +macro index o "<shell-escape>offlineimap -qf INBOX<enter>" "run offlineimap to sync inbox" + +#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" + +# Notmuch searching +macro index \Cf "<enter-command>unset wait_key<enter><shell-escape>read -p 'notmuch query: ' x; echo \$x >~/.cache/mutt_terms<enter><limit>~i \"\`notmuch search --output=messages \$(cat ~/.cache/mutt_terms) | head -n 600 | perl -le '@a=<>;chomp@a;s/\^id:// for@a;$,=\"|\";print@a'\`\"<enter>" "show only messages matching a notmuch pattern" +macro index A "<limit>all\n" "show all messages (undo limit)" + +# 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 <F3> sidebar-page-up +bind index,pager <F4> sidebar-page-down +bind index,pager \Cp sidebar-prev-new +bind index,pager \Cn sidebar-next-new +bind index,pager B sidebar-toggle-visible + +source personal.muttrc diff --git a/mutt/.offlineimaprc b/mutt/.offlineimaprc new file mode 100644 index 0000000..8331c3d --- /dev/null +++ b/mutt/.offlineimaprc @@ -0,0 +1,62 @@ +[general] +accounts = gmailPersonal, gmailOfficial, utmail +starttls = yes +ssl = yes +pythonfile = ~/.config/mutt/credentials/imappwd.py + +[Account gmailPersonal] + +localrepository = gmailPersonal-local +remoterepository = gmailPersonal-remote + +[Repository gmailPersonal-remote] +auth_mechanisms = LOGIN +type = Gmail +remoteuser = kumarcanada96@gmail.com +remotepasseval = mailpasswd("gmailPersonal") +remoteport = 993 +folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +ssl_version = tls1_2 + +[Repository gmailPersonal-local] +type = Maildir +localfolders = ~/.mail/gmailPersonal +[Account gmailOfficial] + +localrepository = gmailOfficial-local +remoterepository = gmailOfficial-remote + +[Repository gmailOfficial-remote] +auth_mechanisms = LOGIN +type = Gmail +remoteuser = damani.kumar@gmail.com +remotepasseval = mailpasswd("gmailOfficial") +remoteport = 993 +folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +ssl_version = tls1_2 + +[Repository gmailOfficial-local] +type = Maildir +localfolders = ~/.mail/gmailOfficial +[Account utmail] + +localrepository = utmail-local +remoterepository = utmail-remote + +[Repository utmail-remote] +auth_mechanisms = LOGIN +type = IMAP +remotehost = outlook.office365.com +remoteuser = kumar.damani@mail.utoronto.ca +sslcacerfile = /etc/ssl/cets/ca-certificates.crt +remotepasseval = mailpasswd("utmail") +port = 993 +folderfilter = lambda foldername: foldername not in ['Deleted Items', 'Contacts', 'Calendar', 'Trash'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +ssl_version = tls1_2 + +[Repository utmail-local] +type = Maildir +localfolders = ~/.mail/utmail |
