env/mblaze/env
2020-03-11 23:25:28 +00:00

73 lines
1.8 KiB
Plaintext

# mblaze.env
# Written in 2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any
# warranty. You should have received a copy of the CC0 Public Domain
# Dedication along with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
if [ -z "$mblaze_account" ]; then
printf "Usage: mblaze_account=example.com . ~/.mblaze/env\n" >&2
return 1
fi
MBLAZE=~/.mblaze/$mblaze_account
if [ ! -d "$MBLAZE" ]; then
printf "Unknown account \"%s\"\n" "$mblaze_account" >&2
return 1
fi
export MBLAZE
if [ -d ~/.mblaze/bin ]; then
PATH=~/.mblaze/bin:$PATH
export PATH
fi
# account in prompt
PS1='@$mblaze_account \$ '
export PS1
# mless colors
MCOLOR_CUR=10
MCOLOR_MISS=1
export MCOLOR_CUR MCOLOR_MISS
# mcolor colors
MCOLOR_SEP=7
MCOLOR_FROM=14
MCOLOR_HEADER=6
MCOLOR_FOOTER=7
MCOLOR_SIG=5
MCOLOR_QQQUOTE=3
MCOLOR_QQUOTE=3
MCOLOR_QUOTE=3
export MCOLOR_SEP MCOLOR_FROM MCOLOR_HEADER MCOLOR_FOOTER MCOLOR_SIG
export MCOLOR_QQQUOTE MCOLOR_QQUOTE MCOLOR_QUOTE
if [ -f "$MBLAZE/private.env" ]; then
. "$MBLAZE/private.env"
fi
mfetch()
{
command -v _account_mfetch >/dev/null 2>&1 &&
_account_mfetch "$mblaze_account"
lockfile=%h/mail/.fdm-$mblaze_account-lock
fdm -qa "$mblaze_account" -D "\$lockfile=$lockfile" fetch || return 1
mcount=$(mdirs ~/mail/"$mblaze_account" | xargs minc | wc -l)
mcount=$(printf "%u\n" "$mcount")
prefix="$(date "+%a %d %b %T") [$mblaze_account]"
case $mcount in
0) printf "%s: no new emails.\n" "$prefix"
;;
1) printf "%s: 1 new email.\n" "$prefix"
;;
*) printf "%s: %u new emails.\n" "$prefix" "$mcount"
;;
esac
}
cd ~/mail/"$mblaze_account"