Here are a couple of nifty (I think) bash functions which probably won’t work for anyone else. The first one checks GMail1 and reports unread messages on the command line, the second one keeps a vigilant watch for new messages and streams the sender and subject lines using rsstail.
The part that’s probably most likely to fail is the automatic detection of the username and password. It uses Directory Service via the dscl
utility to locate the primary email address of the current user, and then locates the password for “accounts.google.com” in your keychain based on the result. This makes a lot of assumptions: your primary email is your GMail address, your current user has it assigned and you’ve stored your password for GMail in your keychain.
It’s easy to fix if it doesn’t work (hardcode your email and password), but it’s not at all secure. Your call, I just figured I’d share the trick…
-
From commandlinefu.com via Peteris Krumins. ↩