123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- #!/usr/bin/env bash
- set -eu
- set -o pipefail
- help_main()
- {
- echo "\
- Usage: mail COMMANDS ARGS...
- Run COMMANDS with ARGS
- COMMAND must be one of the sub-commands listed below:
- inbox
- neomutt
- pull
- Report bugs to: go.wigust@gmail.com."
- }
- help_neomutt()
- {
- echo "\
- Usage: mail neomutt [OPTION] MAIL_ADDRESS...
- Run neomutt with MAIL_ADDRESS configuration.
- -A list available mail addresses
- -h, --help display this help and exit
- Report bugs to: go.wigust@gmail.com."
- }
- help_inbox()
- {
- echo "\
- Usage: mail inbox [OPTION] MAIL_ADDRESS...
- Run curl with MAIL_ADDRESS configuration.
- -A list available mail addresses
- -h, --help display this help and exit
- Report bugs to: go.wigust@gmail.com."
- }
- mail_addresses=(pyhalov@majordomo.ru
- asfjsdf@mail.ru
- rxaetbed@mail.ru
- houdinihar@yandex.ru
- jenkins@majordomo.ru
- i18n.wugi@yandex.ru
- zabbix.guix@yandex.ru
- localhost)
- case "$1" in
- pull)
- mbsync -a
- notmuch new
- ;;
- --help)
- help_main
- ;;
- inbox)
- case "$2" in
- pyhalov@majordomo.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "pyhalov@majordomo.ru:$(pass show majordomo/private/newmail.majordomo.ru/pyhalov@majordomo.ru)" \
- imaps://imap.majordomo.ru:993
- ;;
- asfjsdf@mail.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "asfjsdf@mail.ru:$(pass show mail.ru/asfjsdf)" \
- imaps://imap.mail.ru:993
- ;;
- rxaetbed@mail.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "rxaetbed@mail.ru:$(pass show mail.ru/rxaetbed@mail.ru)" \
- imaps://imap.mail.ru:993
- ;;
- houdinihar@yandex.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "houdinihar:$(pass show email/yandex.ru/houdinihar)" \
- imaps://imap.yandex.ru:993
- ;;
- jenkins@majordomo.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "jenkins@majordomo.ru:$(pass show majordomo/public/jenkins.intr/admin)" \
- imaps://imap.majordomo.ru:993
- ;;
- i18n.wugi@yandex.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "i18n.wugi:$(pass show email/yandex.ru/i18n.wugi)" \
- imaps://imap.yandex.ru:993
- ;;
- zabbix.guix@yandex.ru)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "zabbix.guix:$(pass show email/yandex.ru/zabbix.guix)" \
- imaps://imap.yandex.ru:993
- ;;
- localhost)
- exec -a "$0" curl \
- --silent \
- --request "EXAMINE ${3:-INBOX}" \
- --user "oleg:$(pass localhost/imap/oleg)" \
- imap://localhost
- ;;
- -A)
- printf "%s\n" "${mail_addresses[@]}"
- ;;
- ll)
- mail inbox -A | while IFS= read -r address
- do
- echo "$address"
- mail inbox "$address"
- done
- ;;
- *)
- help_inbox
- ;;
- esac
- ;;
- neomutt)
- case "$2" in
- pyhalov@majordomo.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_pyhalov_majordomo"
- ;;
- asfjsdf@mail.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_asfjsdf_mail"
- ;;
- rxaetbed@mail.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_rxaetbed_mail"
- ;;
- houdinihar@yandex.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_houdinihar_yandex"
- ;;
- jenkins@majordomo.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_jenkins_majordomo"
- ;;
- i18n.wugi@yandex.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_i18n.wugi_yandex"
- ;;
- zabbix.guix@yandex.ru)
- exec -a "$0" neomutt -F "$HOME/.muttrc_zabbix.guix_yandex"
- ;;
- localhost)
- exec -a "$0" neomutt -F "$HOME/.muttrc_localhost"
- ;;
- -A)
- printf "%s\n" "${mail_addresses[@]}"
- ;;
- *)
- help_neomutt
- ;;
- esac
- ;;
- *)
- help_main
- ;;
- esac
|