First install a utility called highlight. It is available through macports and homebrew.
sudo port install highlight
Now that highlight is installed, you can “apply” it to a file and pipe it to the clipboard:
highlight -O rtf MyCode.cpp | pbcopy
Now go to Kenote and simply paste from clipboard (or
command + v). Highlight also provides a ton of syntax highlighting styles. You can see those by typing:
You can apply a style with the
highlight -O rtf MyInput.yaml --style darkblue | pbcopy