Last active
December 20, 2015 23:59
-
-
Save garybernhardt/6216527 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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