So I have a script that outputs this

<pre style="background:#f1f1f1;color:#000;font-weight:bold;">echo 'Hello World';</pre>

What I would like to do it copy it to the clipboard as rich text and not plain text. Is this possible?

Right now I have this command:

create-codeblock | pbcopy

This obviously only copies the plain text html code to the clipboard. What I really want is the html formatted version copied to the clipboard. Any thoughts?

What I am trying to do in the end is paste rich formatted text into Evernote.


1 Answer 1


As aglasser commented, you can use textutil like so:

create-codeblock | textutil -stdin -format html -convert rtf -stdout | pbcopy

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .