Quantcast
Channel: How to send rich text to the clipboard from command line? - Super User
Viewing all articles
Browse latest Browse all 4

Answer by idbrii for How to send rich text to the clipboard from command line?

$
0
0

Linux

via this answer

cat text.html | xclip -t text/html

Mac

via this answer

cat text.html | textutil -stdin -format html -convert rtf -stdout | pbcopy

Windows

In older Windows, you can natively only copy plaintext (via this answer).

type text.html | clip

In PowerShell you can copy rich text:

type text.html | Set-Clipboard -AsHtml

If you create a C:\sandbox\pbcopy.ps1:

type $args[0] | Set-Clipboard -AsHtml

Then you can enable scripts and then run it from anywhere (cmd.exe, .bat files, etc):

powershell C:\sandbox\pbcopy.ps1 text.html

There are a few different Cygwin commands to copy to Windows clipboard and it looks like cygwin provides xclip, so you could probably use the Linux solution on Windows if you have cygwin.


Viewing all articles
Browse latest Browse all 4

Trending Articles