commit badf508538e060289189e497cd20d4f1000533f3
parent cf773b4db50101dbdb568a171f270d470f4e5e62
Author: Luke <luke@lukesmith.xyz>
Date: Sat, 10 Feb 2018 16:00:14 -0700
mutt configuration now automatic
Diffstat:
5 files changed, 77 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
@@ -18,7 +18,7 @@ Or you can help monetarily via [Patreon](https://patreon.com/lukesmith) or [Payp
* 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.)
+ * Stat `~/.offlineimaprc` and the the mutt configs to see what accounts are currently available. (**Done**, currently in `removeaccount.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**)
@@ -27,6 +27,3 @@ Or you can help monetarily via [Patreon](https://patreon.com/lukesmith) or [Payp
* 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
-
diff --git a/makedefault.sh b/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"muttrc -e "^source .*accounts.*" >/dev/null && \
+ sed -i "s/^source .*accounts.*/source ${muttdirsed}accounts\/$title.muttrc/g" "$muttdir"muttrc
diff --git a/mutt_install.sh b/mutt_install.sh
@@ -63,7 +63,10 @@ replacement="
s/\$type/$type/g;
/$delet/d"
-
+# Gets the first unused shortcut number in the muttrc and puts it in $idnum.
+cat "$muttdir"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() {
# First, adding the encrypted password.
@@ -78,9 +81,18 @@ addAccount() {
# 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"muttrc
+
+ # Adding directory structure for cache.
+ mkdir -p "$muttdir"accounts/$title/cache/bodies "$muttdir"accounts/$title/cache/headers
+
+ # Add to offlineimaprc sync list.
+ sed -i "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =$/accounts = $title/g" ~/.offlineimaprc
- # Add on offlineimaprc sync list.
- sed -i "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =$/accounts = $title/g" ~/.offlineimaprc ;}
+ # Makes account default if there is no default account.
+ grep "$muttdir"muttrc -e "^source .*accounts.*" >/dev/null && echo there || \
+ echo "source ${muttdir}accounts/$title.muttrc" >> "$muttdir"muttrc ;}
addAccount
clear
diff --git a/muttrc b/muttrc
@@ -0,0 +1,49 @@
+# vim: filetype=muttrc
+# This is the general mutt config which has the settings that all accounts use.
+set sleep_time = 0
+set sort = 'reverse-date'
+set editor = vim
+#set copy = no
+set timeout = "5"
+set mail_check = "10"
+set mailcap_path = ~/.config/mutt/mailcap
+set date_format="%m/%d %I:%M"
+set index_format="%2C %Z %D %-15.15F %s (%-4.4c)"
+set markers = no
+set mark_old = no
+bind index,pager i noop
+bind index,pager g noop
+auto_view text/html
+auto_view application/pdf
+alternative_order text/plain text/enriched text/html
+
+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]+
+
+bind editor <space> noop
+bind index G last-entry
+bind index gg first-entry
+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 |urlview\n
+bind index \Cf noop
+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)"
+macro index,pager i1 '<sync-mailbox><enter-command>source /home/luke/.config/mutt/accounts/luke.muttrc<enter><change-folder>!<enter>'
+source /home/luke/.config/mutt/accounts/luke.muttrc
+macro index,pager i2 '<sync-mailbox><enter-command>source /home/luke/.config/mutt/accounts/gkulade.muttrc<enter><change-folder>!<enter>'
+macro index,pager i3 '<sync-mailbox><enter-command>source /home/luke/.config/mutt/accounts/gmail.muttrc<enter><change-folder>!<enter>'
diff --git a/removeaccount.sh b/removeaccount.sh
@@ -17,6 +17,7 @@ removeAccount() { sed -ie "
" ~/.offlineimaprc
rm "$muttdir"accounts/$1.muttrc
rm "$muttdir"credentials/$1.gpg
+ rm -rf "$muttdir"accounts/$1
echo $1 deleted. ;}
#/tmp/numbered
@@ -31,11 +32,8 @@ clear
if [ -z "$choices" ];
then
- echo no selection
+ clear
else
todelet=$(IFS="|"; keys="${choices[*]}"; keys="${keys//|/\\|}"; grep -w "${keys}" /tmp/numbered | awk '{print $2}')
for i in $todelet; do removeAccount $i; done
fi
-
-
-