Programmer. Hiker. Cook. Always looking for interesting problems to solve.
09 Jun 2014 |
I’ve been looking for an easy way to format code snippets for my Keynote presentation and everything seemed quite awkward to use (especially taking screenshots!). I could just add a link to the example and make it open a local webpage, but I’d rather not do that for very short snippets. After some quick research I’ve settled with highlight.
You can install it with
brew install highlight
I put my snippets into a file (snippets.clj in the example below), and then run this to copy the formatted snippet to clipboard:
pbpaste | highlight --syntax=clojure -O rtf snippets.clj | pbcopy
-O rtf specifies format of the output file (which is rtf for Keynote). Highlight supports lots of languages and customising possibilities are endless. The end effect looks like this: