Skip to content

Instantly share code, notes, and snippets.

@ods94065
Created January 6, 2012 18:12
Show Gist options
  • Save ods94065/1571724 to your computer and use it in GitHub Desktop.
Save ods94065/1571724 to your computer and use it in GitHub Desktop.
Engrave document with LilyPond using BBEdit/TextWrangler on Mac OS X
#!/bin/bash
# This script runs LilyPond on the currently open document in BBEdit/TextWrangler.
# It assumes you have already saved your work.
# Change this path, and these options, to suit your installation and preferences.
LILYAPP=/Applications/LilyPond.app/Contents/Resources/bin/lilypond
LILYOPTIONS=
# BBEdit/TextWrangler pass the pathname to the currently open document
# through BB_DOC_PATH.
SRC_LY="$(basename "$BB_DOC_PATH")"
if [ -z "$SRC_LY" ]; then
echo "ERROR: there is no document on disk to engrave!"
echo "If you are working on a new document, save your document and rerun this script."
exit 1
fi
SRC_ROOT="${SRC_LY%.ly}"
SRC_PDF="${SRC_ROOT}.pdf"
SRC_DIR="$(dirname "$BB_DOC_PATH")"
cd "$SRC_DIR" && "$LILYAPP" $LILYOPTIONS -o "$SRC_ROOT" "$SRC_LY" && open "$SRC_PDF"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment