Skip to content

Instantly share code, notes, and snippets.

@jzelner
Last active August 29, 2015 14:03
Show Gist options
  • Save jzelner/1132b70977d26a231164 to your computer and use it in GitHub Desktop.
Save jzelner/1132b70977d26a231164 to your computer and use it in GitHub Desktop.
#!/bin/bash
FILE="${1}"
if [[ $# != 1 ]]; then
echo "Usage: ./render_post.sh <file>"
exit
fi
if [[ ! -f "${FILE}" ]]; then
echo "Uh oh, it looks like the file you provided me doesn't exist: ${FILE}"
exit
fi
hash watchmedo 2> /dev/null || {
echo "Oh dear. I require Watchdog to work"
echo "Install it with:"
echo "\t$ pip install watchdog"
exit
}
PATTERN="*.Rmd"
KNITR="echo \"Rerunning Knitr...\"; Rscript render_post.R ${FILE}"
echo "Watching ${FILE}..."
watchmedo shell-command --patterns="${PATTERN}" --command="${KNITR}" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment