dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

mailstatus (1139B)


      1 #!/bin/sh
      2 maildir=~/.mail
      3 if [ ! -d $maildir ]; then
      4     exit 0
      5 fi
      6 newmails=$(find $maildir/*/INBOX/new $maildir/*/git/new -type f)
      7 #newmails=$(find $maildir/*/INBOX/new -type f)
      8 numbernewmails=$(echo "$newmails" | wc -w | sed 's/ *//')
      9 mailboxes="$(echo "$newmails" | tr ' ' '\n' | \
     10     sed 's/.*\/mail\///;s/\/INBOX.*//;s/adamsgaard\/git.*/git/')"
     11 
     12 accounts=""
     13 
     14 contains() {
     15     string="$1"
     16     substring="$2"
     17     if test "${string#*$substring}" != "$string"
     18     then
     19         return 0    # $substring is in $string
     20     else
     21         return 1    # $substring is not in $string
     22     fi
     23 }
     24 
     25 contains "$mailboxes" "adamsgaard" && accounts="${accounts}a"
     26 contains "$mailboxes" "git" && accounts="${accounts}G"
     27 contains "$mailboxes" "princeton" && accounts="${accounts}p"
     28 contains "$mailboxes" "noaa" && accounts="${accounts}n"
     29 contains "$mailboxes" "gmail" && accounts="${accounts}g"
     30 contains "$mailboxes" "geomail" && accounts="${accounts}e"
     31 contains "$mailboxes" "ucsd" && accounts="${accounts}u"
     32 contains "$mailboxes" "riseup" && accounts="${accounts}r"
     33 
     34 if [ "$numbernewmails" -gt 0 ]; then
     35     echo "M: ${numbernewmails} (${accounts})"
     36 fi