Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can rich text or HTML source code be obtained from the X clipboard? For example, if you copy some text from a web browser and paste it into kompozer, it pastes as HTML, with links etc. preserved. However, xclip -o for the same selection just outputs plain text. I'd like to pull the HTML out and into a text editor.

share|improve this question
It does appear to obtain the HTML source itself: things like the class properties of <div> elements are preserved. – intuited May 23 '10 at 3:08
improve the title of your question to match what you really want: the source code of the website / rich text... – akira Jul 6 '10 at 10:42
@akira: Thanks for your suggestion. It would have been more polite to phrase it as such. – intuited Jul 6 '10 at 15:12
not polite, just more to the point :) – akira Jul 6 '10 at 18:39
up vote 1 down vote accepted

With some help from the answer to the fork of this question, I built a ghetto command-line client to pull this info.


clipcli [-h] [-f FILE] [-d] [-l] [TARGET]

positional arguments:
  TARGET                display the contents of this target

optional arguments:
  -h, --help            show this help message and exit
  -d, --debug           enable debug tracing
  -f FILE, --file FILE  the file to which output will be directed
  -l, --list            list available targets


$ clipcli text/html
some text with <em>emphasis</em>

The way this works, even the availability of different targets, seems to depend a lot on the application which is providing the clipboard data. There's a bit more info at the stackoverflow question.

share|improve this answer

Does xclip -o -selection secondary or xclip -o -selection clipboard work for you?

These could be abbreviated to

xclip -o -se s 


xclip -o -se c
share|improve this answer
No, that still gives a textual rendering of the page rather than the HTML source. – intuited May 23 '10 at 2:27

You must log in to answer this question.

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