Christoph Polcin

Getting Your Notes Done

I stumbled upon a great idea: store quick notes in a private mailbox. It's a very smart solution especially because the notes are searchable and available from anywhere. The concept is quite easy to implement therefore it's adjustable to various toolchains.

The origin author provides a command-line+mutt+GMail solution. I did a few mod­i­fi­ca­tions to accomplish a GMail free and 'offline-working' version. I replaced mutt by msmtpQ a wrapper for msmtp and GMail by a procmail filter. In addition I made the subject prefix optional and added a custom e-mail header to tag notes.

Add this shell script function to your .bashrc or .zshrc and adjust YOUR@EMAIL.COM.

function noteit() {
  # based on

  local message subject="$*" mail="YOUR@EMAIL.COM"

  [[ -z "$subject" ]] && { echo 'no subject.'; return 1; }

  echo -e "^D to save, ^C to cancel\nNote:\n"


  [[ -z "$message" ]] && { echo 'no message.'; return 1; }

  echo "From: $mail\nTo: $mail\nSubject: $subject\nX-Tag: note\n\n$message" \
       |/usr/local/bin/msmtpQ $mail &> /dev/null

  [[ $? -ne 0 ]] && { echo "failed."; return 1; }

And now create a procmail or what-ever-you use e-mail filter to move incoming notes to a separate mailbox.

#procmail filter
* ^From:.*@MY-DOMAIN\.COM
* (^X-Tag:.*note|^Subject:.*\[note\])