Skip to content

Instantly share code, notes, and snippets.

@lcolladotor
Created February 18, 2014 19:38
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 lcolladotor/9078333 to your computer and use it in GitHub Desktop.
Save lcolladotor/9078333 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
<string>#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &amp;&amp; . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
# Source some support functions we need.
. "${TM_SUPPORT_PATH}/lib/html.sh"
. "${TM_SUPPORT_PATH}/lib/webpreview.sh"
# Get the viewer program. Any program (that works with open -a &lt;name&gt;) can be used,
# except 'html' which is reserved to mean the internal HTML window. This is also the
# default option.
# V=${TM_LATEX_VIEWER:-html}
V="html"
M=${TM_LATEX_MASTER:-$TM_FILEPATH}
DIR=`dirname "$M"`
FILE=`basename "${M%.*}".Rmd`
PDF="${FILE%.*}.html"
echo $FILE
echo $DIR
echo $PDF
# Switch to the right directory.
cd "$TM_PROJECT_DIRECTORY"
cd "$DIR"
# Prepare output window.
html_header 'knit html result' "$FILE"
echo '&lt;h2&gt;Kniting…&lt;/h2&gt;'
SW=${TM_SWEAVE_WD:=${TM_DIRECTORY}}
echo -e "setwd('$SW');library(knitrBootstrap); knit_bootstrap('$FILE', code_style='Brown Paper', chooser=c('boot', 'code'), show_code=FALSE)" | R --vanilla --quiet | pre
# If there is output and it's newer than the current document, then we go directly to preview or link to it.
WEB_LOC="file://${DIR}/${PDF}"
WEB_LOC="${WEB_LOC//\\#/%23}"
redirect "${WEB_LOC}"
html_footer
</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>~t</string>
<key>name</key>
<string>knit to html</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>html</string>
<key>outputLocation</key>
<string>newWindow</string>
<key>uuid</key>
<string>C09640FD-CDA3-4471-B62F-2046C1F4852A</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment