Skip to content

Instantly share code, notes, and snippets.

@hugooliveirad
Last active January 4, 2016 21:29
Show Gist options
  • Save hugooliveirad/8681093 to your computer and use it in GitHub Desktop.
Save hugooliveirad/8681093 to your computer and use it in GitHub Desktop.
Highlight copied code for keynote presentations

Highlight Clipboard

highlights clipboard code for Keynote presentations

Why?

If you are presenting code, you should do this as text, as people could copy it after you share your slides. There is no option for code in Keynote, so here is a simple way to do this.

Usage

First install hightlight on your Mac using Homebrew.

# be sure to update brew
sudo brew update

# when updated install highlight
sudo brew install highlight

This could take a while. Meanwhile, you can copy the function into your ~/.profile file.

Open another shell session on Terminal.app, copy the code you want to highlight and run:

# syntax [theme] [font-size]
hc js malokai 40

The RTF result of code highlighting is now copied to your clipboard. Paste it on Keynote and voilá, color was added to your code.

PROTIP: run highlight -w to see a list of available themes.

Credits for inspiration

  1. https://gist.github.com/jimbojsb/1630790
  2. https://gist.github.com/jimbojsb/1630790/#comment-837445
# highlight copied code for keynote presentations
function hc() {
# syntax name
syntax="$1";
# theme name. `hightlight -w` for available thems
style="${2-solarized-dark}";
# font size in pixels
fontSize="${3-24}";
pbpaste | highlight -O rtf --font-size "$fontSize" --style "$style" \
--syntax="$syntax" | pbcopy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment