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
Be careful with Date.toLocaleDateString() in JavaScript May 8, 2023 macOS
Trying out (and liking!) MeetingBar for macOS July 25, 2024 macOS
Search hidden directories with ripgrep, by default December 30, 2023 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
To code or to pdb in Python December 20, 2010 Python