4

I'm wondering if there is a command line clipboard manipulation program for Linux like xsel or xclip that supports RTF formatted data? What I mean is, if I use xsel to put RTF data on the clipboard, when I paste I get ASCII RTF code—not formatted text. Xsel and xclip can only handle plain text.

On MacOS, the pbpaste and pbcopy commands will automatically set the content type of the clipboard to RTF if there is an RTF header in the data. I'm looking for a Linux program that will do just that.

I need to use it in scripts, so graphical clipboard managers will not work.

Matthew
  • 215

2 Answers2

1

More modern versions of xclip do support formatted data. For example, if you have a command that outputs RTF, the following should result in the formatted text being properly placed in your clipboard:

command_outputting_rtf | xclip -selection clipboard -t 'text/rtf' -i

Analogously, if you're dealing with html:

command_outputting_html | xclip -selection clipboard -t 'text/html' -i

Based on: https://unix.stackexchange.com/a/145134/176466

aplaice
  • 414
  • 4
  • 8
0

Correct me if I'm wrong, but I think that the application that you are pasting to support formatting. I have done some copy/paste handling in my day, and I had to format whatever data I get from the paste command.

As for the headers, what environment are you running, Gnome or KDE? AFAIK, the clipboard is not a feature of the kernel but of the environment you are running.

Here is a similar issue on StackOverflow:

https://stackoverflow.com/questions/4486376/does-the-gnome-clipboard-have-a-mime-type-associated-with-the-data

I don't know about any command-line utilities. Here are some things that I found:

beatgammit
  • 1,465