Calling Pandoc from BBEdit

While I was futzing with letterheads, I also wrote a very quick shell script to convert the current file in BBEdit (my text edtor of choice1) to a pdf. Here’s the entire script:

#!/bin/bash
pandoc -o "${BB_DOC_PATH%%.*}".pdf "$BB_DOC_PATH"  --pdf-engine=xelatex --template=/Your/Template/Path/Here/carlton-iisg-letterhead.template

BB_DOC_PATH%%.* is the path of the currently open document, which is a variable set by the BBEdit command-line tools. This script takes that path and executes a basic Pandoc conversion, keeping your old file and creating a .pdf with the same filename. If you put this in your Library > Application Support > BBEdit > Scripts folder, you can execute the script from BBEdit’s script menu:

Screen capture of the BBEdit Script Menu

You can even assign a keyboard shortcut if you’re the type who writes so many letters that a keyboard shortcut makes sense.

Anyway, this script is also on Github if you really want it. Go nuts!


  1. BBEdit is Mac-only, so you’ll have to adapt it if you’re using a different OS [return]