pygmentize -f rtf FILE | pbcopy
- Paste into TextEdit (in rich text mode: Format → Make Rich Text before pasting), and copy to clipboard again.
- In PowerPoint, Edit → Paste Special… → Styled Text.
(Pasting RTF directly into PowerPoint doesn't work correctly, at least with PowerPoint 2008 — it extends colour spans longer than it should, and sometimes removes line breaks. Going via TextEdit seems to solve the problem.)
Great tip! Seemingly obvious in hindsight, yet something I had not considered at all before.
For future readers, note that you can also read from the clipboard if you don't want to extract your snippets out to files:
pbpaste | pygmentize -l ruby -f rtf | pbcopy
. In this scenario the lexer (-l
) should be specified, since there will be no filename to guess from.