summaryrefslogtreecommitdiff
path: root/mutt_install.sh
diff options
context:
space:
mode:
authorLuke <luke@lukesmith.xyz>2018-02-10 16:00:14 -0700
committerLuke <luke@lukesmith.xyz>2018-02-10 16:00:14 -0700
commitbadf508538e060289189e497cd20d4f1000533f3 (patch)
treeda76291de29bcf23bb31fa2d56351df9937818cb /mutt_install.sh
parentcf773b4db50101dbdb568a171f270d470f4e5e62 (diff)
mutt configuration now automatic
Diffstat (limited to 'mutt_install.sh')
-rwxr-xr-xmutt_install.sh18
1 files changed, 15 insertions, 3 deletions
diff --git a/mutt_install.sh b/mutt_install.sh
index 53be42b..6b21889 100755
--- 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