Portable environments files and scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.8KB

  1. # mblaze.env
  2. # Written in 2020 by Lucas
  3. # CC0 1.0 Universal/Public domain - No rights reserved
  4. #
  5. # To the extent possible under law, the author(s) have dedicated all
  6. # copyright and related and neighboring rights to this software to the
  7. # public domain worldwide. This software is distributed without any
  8. # warranty. You should have received a copy of the CC0 Public Domain
  9. # Dedication along with this software. If not, see
  10. # <http://creativecommons.org/publicdomain/zero/1.0/>.
  11. if [ -z "$mblaze_account" ]; then
  12. printf "Usage: mblaze_account=example.com . ~/.mblaze/env\n" >&2
  13. return 1
  14. fi
  15. MBLAZE=~/.mblaze/$mblaze_account
  16. if [ ! -d "$MBLAZE" ]; then
  17. printf "Unknown account \"%s\"\n" "$mblaze_account" >&2
  18. return 1
  19. fi
  20. export MBLAZE
  21. if [ -d ~/.mblaze/bin ]; then
  22. PATH=~/.mblaze/bin:$PATH
  23. export PATH
  24. fi
  25. # account in prompt
  26. PS1='@$mblaze_account \$ '
  27. export PS1
  28. # mless colors
  29. MCOLOR_CUR=10
  30. MCOLOR_MISS=1
  31. export MCOLOR_CUR MCOLOR_MISS
  32. # mcolor colors
  33. MCOLOR_SEP=7
  34. MCOLOR_FROM=14
  35. MCOLOR_HEADER=6
  36. MCOLOR_FOOTER=7
  37. MCOLOR_SIG=5
  38. MCOLOR_QQQUOTE=3
  39. MCOLOR_QQUOTE=3
  40. MCOLOR_QUOTE=3
  41. export MCOLOR_SEP MCOLOR_FROM MCOLOR_HEADER MCOLOR_FOOTER MCOLOR_SIG
  42. export MCOLOR_QQQUOTE MCOLOR_QQUOTE MCOLOR_QUOTE
  43. if [ -f "$MBLAZE/private.env" ]; then
  44. . "$MBLAZE/private.env"
  45. fi
  46. mfetch()
  47. {
  48. command -v _account_mfetch >/dev/null 2>&1 &&
  49. _account_mfetch "$mblaze_account"
  50. lockfile=%h/mail/.fdm-$mblaze_account-lock
  51. fdm -qa "$mblaze_account" -D "\$lockfile=$lockfile" fetch || return 1
  52. mcount=$(mdirs ~/mail/"$mblaze_account" | xargs minc | wc -l)
  53. mcount=$(printf "%u\n" "$mcount")
  54. prefix="$(date "+%a %d %b %T") [$mblaze_account]"
  55. case $mcount in
  56. 0) printf "%s: no new emails.\n" "$prefix"
  57. ;;
  58. 1) printf "%s: 1 new email.\n" "$prefix"
  59. ;;
  60. *) printf "%s: %u new emails.\n" "$prefix" "$mcount"
  61. ;;
  62. esac
  63. }
  64. cd ~/mail/"$mblaze_account"