Do you want to display some code in a Keynote presentation?

It's easy. All you need is Homebrew installed.

First you need to install the program highlight.

$ brew install highlight

So you have a piece of code. For example some Python code. The take that snippet of code and save it to a file like code.py. Now all you need to do is run this:

$ highlight -O rtf code.py | pbcopy

Then, switch back into Keynote and simply paste.

But if you don't want to create a file of the snippet, simply copy the snippet from within your editor and run this:

$ pbpaste | highlight -S py -O rtf | pbcopy

The -S py means "syntax is py (for python)".

You can use highlight for a bunch of other things like creating HTML. See man highlight for more tips.

Comments

Your email will never ever be published.

Previous:
How I back up all my photos on S3 via Dropbox August 28, 2014 Photos
Next:
set -ex - The most useful bash trick of the year August 31, 2014 Linux
Related by category:
fnm is much faster than nvm. December 28, 2023 macOS
Set up iTerm to delete whole words on Option-Backspace May 13, 2025 macOS
Be careful with Date.toLocaleDateString() in JavaScript May 8, 2023 macOS
Trying out (and liking!) MeetingBar for macOS July 25, 2024 macOS
Related by keyword:
Introducing hylite - a Node code-syntax-to-HTML highlighter written in Bun October 3, 2023 Node, JavaScript, Bun
How I performance test PostgreSQL locally on macOS December 10, 2018 Web development, PostgreSQL, macOS
How to log ALL PostgreSQL SQL happening July 20, 2015 PostgreSQL, macOS
Catching a carriage return in bash October 23, 2006 Linux