Skip to content

Instantly share code, notes, and snippets.

@peio
Created January 2, 2012 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peio/1550675 to your computer and use it in GitHub Desktop.
Save peio/1550675 to your computer and use it in GitHub Desktop.
Convert and email a markdown file to my Kindle
#!/bin/bash
# Convert and email MarkDown file to Kindle
MD_FILE=$1
HTML_FILE=`basename "$MD_FILE" .md`
HTML_FILE='/tmp/'$HTML_FILE".html"
KINDLE_HEADER='/home/peio/bin/kindle.header'
# Create header
cat $KINDLE_HEADER > "$HTML_FILE"
# Markdown to content
/usr/bin/markdown -x toc -x def_list -x footnotes -e utf-8 "$MD_FILE" >> "$HTML_FILE"
# Footer
echo '</body></html>' >> "$HTML_FILE"
echo "Send file" | mailx -s "Reads" -a "$HTML_FILE" peio@kindle.com
echo $HTML_FILE" sent"
rm "$HTML_FILE"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment