Skip to content

Instantly share code, notes, and snippets.

@mnot
Created March 12, 2011 01:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnot/866891 to your computer and use it in GitHub Desktop.
Save mnot/866891 to your computer and use it in GitHub Desktop.
Quick and dirty way to get Internet-Drafts onto your kindle
#!/bin/sh
# Kindle My RFC (or Internet-Draft)
#
# Sends an Internet Draft to your kindle
# Invocation:
# > kindle_my_rfc [path/to/rfc2629-xml-file]
# > kindle_my_rfc [draft-name-with-number-00]
#
# Requires:
# - xsltproc
# - rfc2629xslt
# - kindlegen
# - sed
# - mutt
# - $KINDLE_ADDR set to kindle e-mail address
rfc2629xslt=~/Downloads/rfc2629xslt
tmpfile=/tmp/kindle_my_rfc
xmlfile=$1
if [ ! -f $xmlfile ]; then
curl -f "http://www.ietf.org/id/${xmlfile}.xml" -o ${tmpfile}.xml || exit 1;
xmlfile=${tmpfile}.xml
fi
rm -f ${tmpfile}.html
xsltproc $rfc2629xslt/rfc2629.xslt $xmlfile > ${tmpfile}.html
sed -Ei '' '/^[ \t]*margin-left:/d' ${tmpfile}.html
kindlegen ${tmpfile}.html
rm -f ${tmpfile}.html
#uuencode ${tmpfile}.mobi ${tmpfile}.mobi | mail -s "RFC upload" $KINDLE_ADDR
mutt -s "RFC Upload" -a ${tmpfile}.mobi $KINDLE_ADDR < "."
rm ${tmpfile}.mobi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment