Copy text from command line as formatted text

command linehtml

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.

Best Answer

As aglasser commented, you can use textutil like so:

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