Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Last active December 20, 2015 23:59
Show Gist options
  • Save garybernhardt/6216527 to your computer and use it in GitHub Desktop.
Save garybernhardt/6216527 to your computer and use it in GitHub Desktop.
find ~/Downloads/Gmail -type f | grep -v '\.git' | ruby -rdate -e 'today = Date.today; STDIN.each { |path| content = File.read(path.strip); begin; from = content.grep(/^From:/).fetch(0); date = content.grep(/^Date:/).fetch(0); puts from if Date.parse(date) > today - 365; rescue IndexError; end }' | while read line; do echo "$line" | ~/.mutt/add-aliases.sh; done
#!/bin/sh
#
# From http://wcm1.web.rice.edu/mutt-tips.html
MESSAGE=$(cat)
NEWALIAS=$(echo "${MESSAGE}" | grep -m 1 ^"From: " | sed s/[\,\"\']//g | awk '{$1=""; if (NF == 3) {print "alias" $0;} else if (NF == 2) {print "alias" $0 $0;} else if (NF > 3) {print "alias", tolower($(NF-1))"-"tolower($2) $0;}}')
if grep -Fxq "$NEWALIAS" $HOME/.mutt/aliases; then
:
else
echo "$NEWALIAS" >> $HOME/.mutt/aliases
fi
echo "${MESSAGE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment