2

If I copy some text containing a hyperlink and then paste into another application that accepts it, then the text and its hyperlink is correctly copied over.

How can I access this hyperlink via the command line? Using pbpaste or pbpaste -Prefer rtf just results in the text being pasted without the hyperlink.

For example if I copy the following text: "Some text with a hyperlink in it." from this webpage and then use pbpaste -Prefer rtf I see "Some text with a hyperlink in it." in the terminal but the https://example.com hyperlink is not shown anywhere / it is lost. Is there a way to access this information from the clipboard in a terminal? The data is there because if I paste into another application like the Notes application, the hyperlink will be present in the text pasted.

** Edit **

I am not expecting the output from pbpaste or any other tool to give a clickable link in the terminal. I do not believe that is even possible for terminals to provide that. I do want the hyperlink to come out in some standard format though. To extend the example above, perhaps it is displayed as the following string of characters: Some text with a [hyperlink](https://example.com) in it. or whatever format can be parsed to extract the URL.

Alternatively just being able to access the raw string of bits/bytes on the clipboard and writing something to parse them myself would be fine too.

16
  • What do you mean with "text without the hyperlink"? Can you add an example?
    – nohillside
    Jul 21 at 18:32
  • 1
    @nohillside I think the OP means text (no hyperlink) vs. text (contains hyperlink). Jul 21 at 21:01
  • @DavidSupportsMonica Maybe. Let‘s wait for the edit.
    – nohillside
    Jul 21 at 21:44
  • @ DavidSupportsMonica yes that's what I meant, thank you. @nohillside I have edited the question, I hope that helps clarify it. Thank you.
    – AJP
    Jul 22 at 11:49
  • 1
    @nohillside but xclip gives you the “pure” RTF and you pipe it to grep to just get https ://www.* … or whatever. the OP wants to extract the URL from a RTF clipboard content, right? Jul 22 at 18:05

0

You must log in to answer this question.

Browse other questions tagged .