Getting access to rich-text data from the clipboard (on Linux)

I've recently noticed that i.e. on Slack, if I right click a channel and click "Copy name", and then paste that into a Slack message, I get the name of the channel, but if I paste it into GitHub or Google Docs, I get a rich text link, with the name of the channel, and a link to the channel.

This is really nice behaviour, but with the way my team does standups and my Neovim plugin for standup updates, I wanted to make sure that I'm able to get the same functionality myself.

Digging into this via StackOverflow, it looks like the xclip command has the --target flag:

% xclip -o --target text/html
<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://github.com/deepmap/oapi-codegen">oapi-codegen</a>%

This is returned as an alternative to the default plain-text output:

% xclip -o
oapi-codegen

You can also list the options available for outputs with -t TARGETS:

% xclip -o -t TARGETS
TIMESTAMP
TARGETS
MULTIPLE
text/html
text/_moz_htmlcontext
text/_moz_htmlinfo
UTF8_STRING
COMPOUND_TEXT
TEXT
STRING
text/plain;charset=utf-8
text/plain
text/x-moz-url-priv

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #linux #command-line.

This blog post is 100% human-written, and has nothing derived from LLMs (be it code, editorial support or prose).

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.