Skip to content

Instantly share code, notes, and snippets.

@cormacrelf
Created April 2, 2012 09:57
Show Gist options
  • Save cormacrelf/2282280 to your computer and use it in GitHub Desktop.
Save cormacrelf/2282280 to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Usage: copy-rtf [file]
#
# Copies Pygmentize's RTF output of a source file to the clipboard after making it 36pt Monaco.
#
# Copy straight into an "Auto-Shrink" text box in Keynote for efficient code highlighting in a Coding presentation.
# Depends on [Pygments](http://pygments.org/) being installed in your $PATH...
# try `gem install pygmentize` for a standalone Ruby installation.
pygmentize -f rtf $1 |
# Replace the default Pygmentize font (Courier - ew) with Monaco.
sed "s/\\\\f0\\\\fmodern\\\\fprq1\\\\fcharset0/\\\\f0Monaco/g" |
# Set the font size to 36pt (that's the \fs72 - RTF font sizes work in doubles)
sed "s/\\\\f0/\\\\f0\\\\fs72/g" |
# And copy. Enjoy!
pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment