From 914a1bf4d895a986adaa240e857b95c7f49fed4c Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 9 Feb 2018 23:47:29 -0700 Subject: [PATCH] initial commit --- README.md | 38 ++++++++++++ autoconf/domains.csv | 88 +++++++++++++++++++++++++++ autoconf/mutt_profile | 26 ++++++++ autoconf/offlineimap_header | 6 ++ autoconf/offlineimap_profile | 18 ++++++ credentials/getmuttpass | 4 ++ credentials/imappwd.py | 11 ++++ manual.sh | 17 ++++++ mutt_install.sh | 80 +++++++++++++++++++++++++ offlineimap | 111 +++++++++++++++++++++++++++++++++++ removeaccount.sh | 20 +++++++ stat.sh | 8 +++ 12 files changed, 427 insertions(+) create mode 100644 README.md create mode 100644 autoconf/domains.csv create mode 100644 autoconf/mutt_profile create mode 100644 autoconf/offlineimap_header create mode 100644 autoconf/offlineimap_profile create mode 100755 credentials/getmuttpass create mode 100755 credentials/imappwd.py create mode 100644 manual.sh create mode 100755 mutt_install.sh create mode 100644 offlineimap create mode 100755 removeaccount.sh create mode 100755 stat.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..b10f3e0 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# mutt Offline email setup + +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. + +## Progress + +The main scripts `mutt_install.sh` can create or add an account from a domain in `domain.csv` to `~/.offlineimaprc` without a problem. + +## 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)! + +## Todo + +* Expand the list of server information in `domains.csv`, including adding spoolfiles/records/postponed folders for each account. +* Write scripts that do the following: + * Stat `~/.offlineimaprc` and the the mutt configs to see what accounts are currently available. (**Done**, currently in `stat.sh`; needs integration.) + * Delete a profile from above if requested. (**Done**, currently in `removeaccount.sh`; needs integration.) + * Add a profile above if requested, including: + * An automatic search of `domains.csv` for server information. (**Done**) + * An ncurses menu for inputing server settings if not available in `domains.csv`. (Soon, see `manual.sh`) + * Differential actions for Gmail accounts since these are distinct in offlineIMAP. (**Done**) + * Configure notmuch with all accounts. + * A prompt for adding encypted passwords for each account available. + * Or directions for adding plain text passwords if desired. + +### Todo: Add settings for email accounts not unified by one domain + +-------- + +zoho,imap.zoho.com,993.00,smtp.zoho.com,465.00 +icloud,imap.mail.me.com,993.00,smtp.mail.me.com,587.00 +inbox.com,imap.inbox.com,993.00,smtp.inbox.com,465.00 +office365,outlook.office365.com,993.00,smtp.office365.com,587.00 +hostgator,gator4171.hostgator.com,993.00,gator4171.hostgator.com,587.00 +godaddy,imap.secureserver.net,993,smtpout.secureserver.net,465 diff --git a/autoconf/domains.csv b/autoconf/domains.csv new file mode 100644 index 0000000..2d9aeb1 --- /dev/null +++ b/autoconf/domains.csv @@ -0,0 +1,88 @@ +ADDRESS,IMAP,imap port,SMTP,smtp port,spoolfile,postponed,record +yahoo.com,imap.mail.yahoo.com,993.00,smtp.mail.yahoo.com,465/587,,, +mail.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +aol.com,imap.aol.com,993.00,smtp.aol.com,465.00,,, +email.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +usa.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +myself.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +consultant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +post.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +europe.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +asia.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +iname.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +writeme.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +dr.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +engineer.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +cheerful.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +accountant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +techie.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +linuxmail.org,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +uymail.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +contractor.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +accountant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +activist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +adexec.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +allergist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +alumni.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +alumnidirector.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +angelic.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +appraiser.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +archaeologist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +arcticmail.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +artlover.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +asia.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +auctioneer.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +bartender.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +bikerider.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +birdlover.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +brew-meister.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +cash4u.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +chef.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +chemist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +clerk.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +clubmember.org,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +collector.org,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +columnist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +comic.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +computer4u.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +consultant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +contractor.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +coolsite.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +counsellor.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +cyberservices.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +deliveryman.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +diplomats.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent +hostgator,gator4171.hostgator.com,993.00,gator4171.hostgator.com,587.00,INBOX,INBOX.Sent,INBOX.Drafts +teknik.io,mail.teknik.io,993.00,mail.teknik.io,587.00,,, +yandex.com,imap.yandex.com,993.00,smtp.yandex.com,465.00,,, +outlook.com,imap-mail.outlook.com,993.00,smtp-mail.outlook.com,587.00,,, +hotmail.com,imap-mail.outlook.com,993.00,smtp-mail.outlook.com,587.00,,, +gmail.com,imap.google.com,993.00,smtp.gmail.com,587.00,INBOX,[Gmail].Drafts,[Gmail].Sent Mail +cock.li,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +airmail.cc,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +8chan.co,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +redchan.it,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +420blaze.it,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +aaathats3as.com,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +cumallover.me,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +dicksinhisan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +loves.dicksinhisan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +wants.dicksinhisan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +dicksinmyan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +loves.dicksinmyan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +wants.dicksinmyan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +goat.si,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +horsefucker.org,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +national.shitposting.agency,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +nigge.rs,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +tfwno.gf,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +cock.lu,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +cock.email,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +firemail.cc,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +hitler.rocks,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +getbackinthe.kitchen,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +memeware.net,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +cocaine.ninja,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +waifu.club,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +rape.lol,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent +nuke.africa,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent diff --git a/autoconf/mutt_profile b/autoconf/mutt_profile new file mode 100644 index 0000000..224defa --- /dev/null +++ b/autoconf/mutt_profile @@ -0,0 +1,26 @@ +# vim: filetype=muttrc +# muttrc file for account $title +set realname = "$realname" +set from = "$fulladdr" +set smtp_url = "smtp://$fulladdr@$smtp:$sport/" +set sendmail = "/usr/bin/msmtp -a $title" +set folder = "~/.mail/$title" +set header_cache = ~/.config/mutt/$title/cache/headers +set message_cachedir = ~/.config/mutt/$title/cache/bodies +set certificate_file = ~/.config/mutt/$title/certificates +source "~/.config/mutt/credentials/getmuttpass $title |" + +set spoolfile = "+$spoolfile" +set record = "+$record" +set postponed = "+$postponed" + + +set mbox_type = Maildir +set ssl_starttls = yes +set ssl_force_tls = yes + +bind index,pager g noop +bind index gg first-entry +macro index,pager gi "=$spoolfile" "Go to inbox" +macro index,pager gs "=$record" "Go to sent" +macro index,pager gd "=$postponed" "Go to drafts" diff --git a/autoconf/offlineimap_header b/autoconf/offlineimap_header new file mode 100644 index 0000000..786f04b --- /dev/null +++ b/autoconf/offlineimap_header @@ -0,0 +1,6 @@ +[general] +accounts = +starttls = yes +ssl = yes +pythonfile = ~/.config/mutt/credentials/imappwd.py + diff --git a/autoconf/offlineimap_profile b/autoconf/offlineimap_profile new file mode 100644 index 0000000..8311e1c --- /dev/null +++ b/autoconf/offlineimap_profile @@ -0,0 +1,18 @@ +[Account $title] + +localrepository = $title-local +remoterepository = $title-remote + +[Repository $title-remote] +type = $type +remoteuser = $fulladdr +sslcacerfile = /etc/ssl/cets/ca-certificates.crt +remotepasseval = mailpasswd("$title") +remotehost = $imap +port = $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/credentials/getmuttpass b/credentials/getmuttpass new file mode 100755 index 0000000..c5ee8c2 --- /dev/null +++ b/credentials/getmuttpass @@ -0,0 +1,4 @@ +#!/bin/bash +pass=$(gpg -d -q ~/.config/mutt/credentials/$1.gpg) +echo set smtp_pass=\"$pass\" +echo set imap_pass=\"$pass\" diff --git a/credentials/imappwd.py b/credentials/imappwd.py new file mode 100755 index 0000000..8570a5f --- /dev/null +++ b/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 = ["gpg", "--use-agent", "--quiet", "--batch", "-d", path] + try: + return subprocess.check_output(args).strip() + except subprocess.CalledProcessError: + return "" diff --git a/manual.sh b/manual.sh new file mode 100644 index 0000000..0f7315a --- /dev/null +++ b/manual.sh @@ -0,0 +1,17 @@ +# The stuff for manually putting in server settings. +# Will be added to main script as option eventually. +remotehost=$(\ + dialog --inputbox "Insert the IMAP server for your email provider (excluding the port number)" 10 60 \ + 3>&1 1>&2 2>&3 3>&- \ + ) + +dialog --inputbox "What is your server's IMAP port number? (Usually 993)" 10 60 + +smtpserver=$(\ + dialog --inputbox "Insert the SMTP server for your email provider (excluding the port number)" 10 60 \ + 3>&1 1>&2 2>&3 3>&- \ + ) +smtpport=$(\ +dialog --inputbox "What is your server's SMTP port number? (Usually 587 or 465)" 10 60 + 3>&1 1>&2 2>&3 3>&- \ + ) diff --git a/mutt_install.sh b/mutt_install.sh new file mode 100755 index 0000000..5d51810 --- /dev/null +++ b/mutt_install.sh @@ -0,0 +1,80 @@ +#!/bin/bash +muttdir="$HOME/Repos/email-mutt-offline/" +mkdir -p ~/.config/mutt/credentials + +# Email for GPG +youremail=$(\ + dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your key pair. This is NOT necessarily the email you want to configure." 10 60 \ + 3>&1 1>&2 2>&3 3>&- \ + ) + +# Get email address +fulladdr=$(\ + dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Insert your full email address." 10 60 \ + 3>&1 1>&2 2>&3 3>&- \ + ) + +# Check to see if domain is in domain list +serverinfo=$(cat autoconf/domains.csv | grep -w ^${fulladdr##*@}) +if [ -z "$serverinfo" ]; then echo No suitable match. && exit; fi + +# Read in server data as variables +IFS=, read service imap iport smtp sport spoolfile postponed record <&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>&- \ + ) + + +# 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 + +# 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/\$spoolfile/$spoolfile/g; + s/\$postponed/$postponed/g; + s/\$record/$record/g; + s/\$type/$type/g; + /$delet/d" + + +addAccount() { +if [ ! -f ~/.offlineimaprc ]; then cp "$muttdir"autoconf/offlineimap_header ~/.offlineimaprc; fi +cat "$muttdir"autoconf/offlineimap_profile | sed -e "$replacement" >> ~/.offlineimaprc +# Add the mutt profile. +cat "$muttdir"autoconf/mutt_profile | sed -e "$replacement" > "$muttdir"accounts/$title.muttrc +# Add on offlineimaprc sync list. +sed -i "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =$/accounts = $title/g" ~/.offlineimaprc ;} + +addAccount + +dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the password for the \"$title\" account." 10 60 2> /tmp/$title +gpg -r $youremail --encrypt /tmp/$title +shred -u /tmp/$title && echo "Password encrypted and memory shredded." +mv /tmp/$title.gpg ~/.config/mutt/credentials/ + +echo Done lmao. +exit diff --git a/offlineimap b/offlineimap new file mode 100644 index 0000000..a8b277f --- /dev/null +++ b/offlineimap @@ -0,0 +1,111 @@ +[general] +accounts = luke, gmail +#accounts = luke, gmail, gkulade, kulade, evenor +starttls = yes +ssl = yes +autorefresh = 1 +pythonfile = ~/.config/mutt/credentials/imappwd.py + + +####### +[Account gmail] + +localrepository = gmail-local +remoterepository = gmail-remote + +[Repository gmail-remote] +type = Gmail +remoteuser = luxmyth@gmail.com +remotepasseval = mailpasswd("gmail") +folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', '[Gmail]/Chats', '[Gmail].Trash', 'Trump', 'ugaroml', 'SMS'] +#folderfilter = lambda foldername: foldername in ['INBOX', 'lingcircle', "[Gmail].Sent Mail", '[Gmail].Drafts'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt + +[Repository gmail-local] +type = Maildir +localfolders = ~/.Mail/Gmail + +####### + +[Account luke] + +localrepository = luke-local +remoterepository = luke-remote + +[Repository luke-remote] +type = IMAP +remoteuser = luke@lukesmith.xyz +remotepasseval = mailpasswd("luke") +remotehost = gator4171.hostgator.com +folderfilter = lambda foldername: foldername in ['INBOX', 'INBOX.Sent', 'INBOX.Drafts'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt + +[Repository luke-local] +type = Maildir +localfolders = ~/.Mail/Luke + +[Account kulade] +localrepository = kulade-local +remoterepository = kulade-remote + +[Repository kulade-remote] +type = IMAP +remoteuser = kulade@cock.li +remotepasseval = mailpasswd("kulade") +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +remotehost = mail.cock.li + +[Repository kulade-local] +type = Maildir +localfolders = ~/.Mail/kulade +####### +[Account gkulade] + +localrepository = gkulade-local +remoterepository = gkulade-remote + +[Repository gkulade-remote] +type = Gmail +remoteuser = kulade@gmail.com +remotepasseval = mailpasswd("gkulade") +folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', 'SMS', 'Call log'] +sslcacertfile = /etc/ssl/certs/ca-certificates.crt + +[Repository gkulade-local] +type = Maildir +localfolders = ~/.Mail/gkulade + +#[Account arizona] +# +#localrepository = arizona-local +#remoterepository = arizona-remote +# +#[Repository arizona-remote] +#type = IMAP +#remoteuser = lukesmith@email.arizona.edu +#remotehost = mail.catnet.arizona.edu +#port = 993 +##folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', '[Gmail]/Chats', '[Gmail].Trash', 'Trump', 'ugaroml', 'SMS'] +#folderfilter = lambda foldername: foldername in ['INBOX', 'lingcircle', '[Gmail].Sent Mail', '[Gmail].Drafts'] +#sslcacertfile = /etc/ssl/certs/ca-certificates.crt +# +#[Repository arizona-local] +#type = Maildir +#localfolders = ~/.Mail/Arizona + +[Account evenor] +localrepository = evenor-local +remoterepository = evenor-remote + +[Repository evenor-remote] + +type = IMAP +remoteuser = evenor@teknik.io +remotepasseval = mailpasswd("evenor") +remotehost = mail.teknik.io +port = 993 +sslcacertfile = /etc/ssl/certs/ca-certificates.crt + +[Repository evenor-local] +type = Maildir +localfolders = ~/.Mail/Evenor diff --git a/removeaccount.sh b/removeaccount.sh new file mode 100755 index 0000000..1d1cbcc --- /dev/null +++ b/removeaccount.sh @@ -0,0 +1,20 @@ +#!/bin/sh +muttdir="$HOME/Repos/email-mutt-offline/" + +# This script will remove an account from ~/.offlineimaprc and the +# designated location in ~/.config/mutt/accounts. + +# Feed the script the title of the account. + +title=$1 + +removeAccount() { sed -ie " + /Account $title]/,/Account/{//!d} + /Account $title]/d + s/ $title\(,\|$\)//g + s/=$title\(,\|$\)/=/g + s/,$//g + " ~/.offlineimaprc + rm "$muttdir"accounts/$title.muttrc + echo $title deleted. ;} +removeAccount $title diff --git a/stat.sh b/stat.sh new file mode 100755 index 0000000..fa0143f --- /dev/null +++ b/stat.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Gets all accounts used by offlineimaps. + +cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' +# Another option +# Get current accounts +#accountsline=$(cat ~/.offlineimaprc | grep ^accou | sed 's/,//g')